diff --git a/packages/google-cloud-storageinsights/CONTRIBUTING.rst b/packages/google-cloud-storageinsights/CONTRIBUTING.rst index d927e564e6cc..7b95cfb3f54e 100644 --- a/packages/google-cloud-storageinsights/CONTRIBUTING.rst +++ b/packages/google-cloud-storageinsights/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-storageinsights/google/cloud/storageinsights/gapic_version.py b/packages/google-cloud-storageinsights/google/cloud/storageinsights/gapic_version.py index 536d6648a6f0..360a0d13ebdd 100644 --- a/packages/google-cloud-storageinsights/google/cloud/storageinsights/gapic_version.py +++ b/packages/google-cloud-storageinsights/google/cloud/storageinsights/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.3" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/gapic_version.py b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/gapic_version.py index 536d6648a6f0..360a0d13ebdd 100644 --- a/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/gapic_version.py +++ b/packages/google-cloud-storageinsights/google/cloud/storageinsights_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.3" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-storageinsights/noxfile.py b/packages/google-cloud-storageinsights/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-storageinsights/noxfile.py +++ b/packages/google-cloud-storageinsights/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-storageinsights/samples/generated_samples/snippet_metadata_google.cloud.storageinsights.v1.json b/packages/google-cloud-storageinsights/samples/generated_samples/snippet_metadata_google.cloud.storageinsights.v1.json index a3799d250eb0..7411c6d3c4bf 100644 --- a/packages/google-cloud-storageinsights/samples/generated_samples/snippet_metadata_google.cloud.storageinsights.v1.json +++ b/packages/google-cloud-storageinsights/samples/generated_samples/snippet_metadata_google.cloud.storageinsights.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-storageinsights", - "version": "0.1.3" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-storageinsights/tests/unit/gapic/storageinsights_v1/test_storage_insights.py b/packages/google-cloud-storageinsights/tests/unit/gapic/storageinsights_v1/test_storage_insights.py index 3c1bca3287ff..148ad4014855 100644 --- a/packages/google-cloud-storageinsights/tests/unit/gapic/storageinsights_v1/test_storage_insights.py +++ b/packages/google-cloud-storageinsights/tests/unit/gapic/storageinsights_v1/test_storage_insights.py @@ -2920,8 +2920,9 @@ def test_list_report_configs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ListReportConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ListReportConfigsResponse.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 @@ -3006,8 +3007,9 @@ def test_list_report_configs_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ListReportConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ListReportConfigsResponse.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 @@ -3142,8 +3144,9 @@ def test_list_report_configs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ListReportConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ListReportConfigsResponse.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 @@ -3266,8 +3269,9 @@ def test_get_report_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ReportConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ReportConfig.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 @@ -3343,8 +3347,9 @@ def test_get_report_config_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ReportConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ReportConfig.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 @@ -3471,8 +3476,9 @@ def test_get_report_config_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ReportConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ReportConfig.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 @@ -3551,6 +3557,73 @@ def test_create_report_config_rest(request_type): "labels": {}, "display_name": "display_name_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = storageinsights.CreateReportConfigRequest.meta.fields["report_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["report_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["report_config"][field])): + del request_init["report_config"][field][i][subfield] + else: + del request_init["report_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -3564,8 +3637,9 @@ def test_create_report_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ReportConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ReportConfig.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 @@ -3644,8 +3718,9 @@ def test_create_report_config_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ReportConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ReportConfig.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 @@ -3741,32 +3816,6 @@ def test_create_report_config_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["report_config"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "frequency_options": { - "frequency": 1, - "start_date": {"year": 433, "month": 550, "day": 318}, - "end_date": {}, - }, - "csv_options": { - "record_separator": "record_separator_value", - "delimiter": "delimiter_value", - "header_required": True, - }, - "parquet_options": {}, - "object_metadata_report_options": { - "metadata_fields": ["metadata_fields_value1", "metadata_fields_value2"], - "storage_filters": {"bucket": "bucket_value"}, - "storage_destination_options": { - "bucket": "bucket_value", - "destination_path": "destination_path_value", - }, - }, - "labels": {}, - "display_name": "display_name_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -3805,8 +3854,9 @@ def test_create_report_config_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ReportConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ReportConfig.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 @@ -3890,6 +3940,73 @@ def test_update_report_config_rest(request_type): "labels": {}, "display_name": "display_name_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = storageinsights.UpdateReportConfigRequest.meta.fields["report_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["report_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["report_config"][field])): + del request_init["report_config"][field][i][subfield] + else: + del request_init["report_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -3903,8 +4020,9 @@ def test_update_report_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ReportConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ReportConfig.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 @@ -3983,8 +4101,9 @@ def test_update_report_config_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ReportConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ReportConfig.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 @@ -4089,32 +4208,6 @@ def test_update_report_config_rest_bad_request( "name": "projects/sample1/locations/sample2/reportConfigs/sample3" } } - request_init["report_config"] = { - "name": "projects/sample1/locations/sample2/reportConfigs/sample3", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "frequency_options": { - "frequency": 1, - "start_date": {"year": 433, "month": 550, "day": 318}, - "end_date": {}, - }, - "csv_options": { - "record_separator": "record_separator_value", - "delimiter": "delimiter_value", - "header_required": True, - }, - "parquet_options": {}, - "object_metadata_report_options": { - "metadata_fields": ["metadata_fields_value1", "metadata_fields_value2"], - "storage_filters": {"bucket": "bucket_value"}, - "storage_destination_options": { - "bucket": "bucket_value", - "destination_path": "destination_path_value", - }, - }, - "labels": {}, - "display_name": "display_name_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -4157,8 +4250,9 @@ def test_update_report_config_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ReportConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ReportConfig.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 @@ -4497,8 +4591,9 @@ def test_list_report_details_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ListReportDetailsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ListReportDetailsResponse.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 @@ -4583,8 +4678,9 @@ def test_list_report_details_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ListReportDetailsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ListReportDetailsResponse.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 @@ -4723,8 +4819,9 @@ def test_list_report_details_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ListReportDetailsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ListReportDetailsResponse.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 @@ -4852,8 +4949,9 @@ def test_get_report_detail_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ReportDetail.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ReportDetail.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 @@ -4930,8 +5028,9 @@ def test_get_report_detail_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ReportDetail.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ReportDetail.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 @@ -5060,8 +5159,9 @@ def test_get_report_detail_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = storageinsights.ReportDetail.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = storageinsights.ReportDetail.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 diff --git a/packages/google-cloud-support/CONTRIBUTING.rst b/packages/google-cloud-support/CONTRIBUTING.rst index 98db9f75b226..17fc0fd3027c 100644 --- a/packages/google-cloud-support/CONTRIBUTING.rst +++ b/packages/google-cloud-support/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-support/google/cloud/support/gapic_version.py b/packages/google-cloud-support/google/cloud/support/gapic_version.py index cf99f3acb1ee..360a0d13ebdd 100644 --- a/packages/google-cloud-support/google/cloud/support/gapic_version.py +++ b/packages/google-cloud-support/google/cloud/support/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-support/google/cloud/support_v2/gapic_version.py b/packages/google-cloud-support/google/cloud/support_v2/gapic_version.py index cf99f3acb1ee..360a0d13ebdd 100644 --- a/packages/google-cloud-support/google/cloud/support_v2/gapic_version.py +++ b/packages/google-cloud-support/google/cloud/support_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-support/noxfile.py b/packages/google-cloud-support/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-support/noxfile.py +++ b/packages/google-cloud-support/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-support/samples/generated_samples/snippet_metadata_google.cloud.support.v2.json b/packages/google-cloud-support/samples/generated_samples/snippet_metadata_google.cloud.support.v2.json index e66b68569a32..26f909a94299 100644 --- a/packages/google-cloud-support/samples/generated_samples/snippet_metadata_google.cloud.support.v2.json +++ b/packages/google-cloud-support/samples/generated_samples/snippet_metadata_google.cloud.support.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-support", - "version": "0.1.2" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_attachment_service.py b/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_attachment_service.py index 33926c36c0ec..0d7aecbf2e6a 100644 --- a/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_attachment_service.py +++ b/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_attachment_service.py @@ -1198,8 +1198,9 @@ def test_list_attachments_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = attachment_service.ListAttachmentsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = attachment_service.ListAttachmentsResponse.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 @@ -1281,10 +1282,9 @@ def test_list_attachments_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = attachment_service.ListAttachmentsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = attachment_service.ListAttachmentsResponse.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 @@ -1417,8 +1417,9 @@ def test_list_attachments_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = attachment_service.ListAttachmentsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = attachment_service.ListAttachmentsResponse.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 diff --git a/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_service.py b/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_service.py index da86af661c29..1bbda17e90e8 100644 --- a/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_service.py +++ b/packages/google-cloud-support/tests/unit/gapic/support_v2/test_case_service.py @@ -2974,8 +2974,9 @@ def test_get_case_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = case.Case.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 @@ -3058,8 +3059,9 @@ def test_get_case_rest_required_fields(request_type=case_service.GetCaseRequest) response_value = Response() response_value.status_code = 200 - pb_return_value = case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = case.Case.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 @@ -3180,8 +3182,9 @@ def test_get_case_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = case.Case.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 @@ -3244,8 +3247,9 @@ def test_list_cases_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = case_service.ListCasesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = case_service.ListCasesResponse.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 @@ -3326,8 +3330,9 @@ def test_list_cases_rest_required_fields(request_type=case_service.ListCasesRequ response_value = Response() response_value.status_code = 200 - pb_return_value = case_service.ListCasesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = case_service.ListCasesResponse.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 @@ -3459,8 +3464,9 @@ def test_list_cases_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = case_service.ListCasesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = case_service.ListCasesResponse.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 @@ -3578,8 +3584,9 @@ def test_search_cases_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = case_service.SearchCasesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = case_service.SearchCasesResponse.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 @@ -3771,6 +3778,73 @@ def test_create_case_rest(request_type): "language_code": "language_code_value", "priority": 1, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = case_service.CreateCaseRequest.meta.fields["case"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["case"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["case"][field])): + del request_init["case"][field][i][subfield] + else: + del request_init["case"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -3793,8 +3867,9 @@ def test_create_case_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcs_case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcs_case.Case.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 @@ -3878,8 +3953,9 @@ def test_create_case_rest_required_fields(request_type=case_service.CreateCaseRe response_value = Response() response_value.status_code = 200 - pb_return_value = gcs_case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcs_case.Case.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 @@ -3971,30 +4047,6 @@ def test_create_case_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1"} - request_init["case"] = { - "name": "name_value", - "display_name": "display_name_value", - "description": "description_value", - "classification": {"id": "id_value", "display_name": "display_name_value"}, - "time_zone": "time_zone_value", - "subscriber_email_addresses": [ - "subscriber_email_addresses_value1", - "subscriber_email_addresses_value2", - ], - "state": 1, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "creator": { - "display_name": "display_name_value", - "email": "email_value", - "google_support": True, - }, - "contact_email": "contact_email_value", - "escalated": True, - "test_case": True, - "language_code": "language_code_value", - "priority": 1, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -4033,8 +4085,9 @@ def test_create_case_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcs_case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcs_case.Case.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 @@ -4110,6 +4163,73 @@ def test_update_case_rest(request_type): "language_code": "language_code_value", "priority": 1, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = case_service.UpdateCaseRequest.meta.fields["case"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["case"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["case"][field])): + del request_init["case"][field][i][subfield] + else: + del request_init["case"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -4132,8 +4252,9 @@ def test_update_case_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcs_case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcs_case.Case.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 @@ -4214,8 +4335,9 @@ def test_update_case_rest_required_fields(request_type=case_service.UpdateCaseRe response_value = Response() response_value.status_code = 200 - pb_return_value = gcs_case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcs_case.Case.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 @@ -4299,30 +4421,6 @@ def test_update_case_rest_bad_request( # send a request that will satisfy transcoding request_init = {"case": {"name": "projects/sample1/cases/sample2"}} - request_init["case"] = { - "name": "projects/sample1/cases/sample2", - "display_name": "display_name_value", - "description": "description_value", - "classification": {"id": "id_value", "display_name": "display_name_value"}, - "time_zone": "time_zone_value", - "subscriber_email_addresses": [ - "subscriber_email_addresses_value1", - "subscriber_email_addresses_value2", - ], - "state": 1, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "creator": { - "display_name": "display_name_value", - "email": "email_value", - "google_support": True, - }, - "contact_email": "contact_email_value", - "escalated": True, - "test_case": True, - "language_code": "language_code_value", - "priority": 1, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -4361,8 +4459,9 @@ def test_update_case_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcs_case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcs_case.Case.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 @@ -4436,8 +4535,9 @@ def test_escalate_case_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = case.Case.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 @@ -4523,8 +4623,9 @@ def test_escalate_case_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = case.Case.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 @@ -4667,8 +4768,9 @@ def test_close_case_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = case.Case.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 @@ -4752,8 +4854,9 @@ def test_close_case_rest_required_fields(request_type=case_service.CloseCaseRequ response_value = Response() response_value.status_code = 200 - pb_return_value = case.Case.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = case.Case.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 @@ -4884,10 +4987,9 @@ def test_search_case_classifications_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = case_service.SearchCaseClassificationsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = case_service.SearchCaseClassificationsResponse.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 diff --git a/packages/google-cloud-support/tests/unit/gapic/support_v2/test_comment_service.py b/packages/google-cloud-support/tests/unit/gapic/support_v2/test_comment_service.py index 80e8aa484686..892e8cb94d40 100644 --- a/packages/google-cloud-support/tests/unit/gapic/support_v2/test_comment_service.py +++ b/packages/google-cloud-support/tests/unit/gapic/support_v2/test_comment_service.py @@ -1401,8 +1401,9 @@ def test_list_comments_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = comment_service.ListCommentsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = comment_service.ListCommentsResponse.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 @@ -1484,8 +1485,9 @@ def test_list_comments_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = comment_service.ListCommentsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = comment_service.ListCommentsResponse.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 @@ -1618,8 +1620,9 @@ def test_list_comments_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = comment_service.ListCommentsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = comment_service.ListCommentsResponse.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 @@ -1739,6 +1742,73 @@ def test_create_comment_rest(request_type): "body": "body_value", "plain_text_body": "plain_text_body_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = comment_service.CreateCommentRequest.meta.fields["comment"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["comment"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["comment"][field])): + del request_init["comment"][field][i][subfield] + else: + del request_init["comment"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -1753,8 +1823,9 @@ def test_create_comment_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcs_comment.Comment.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcs_comment.Comment.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 @@ -1832,8 +1903,9 @@ def test_create_comment_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gcs_comment.Comment.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcs_comment.Comment.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 @@ -1927,17 +1999,6 @@ def test_create_comment_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/cases/sample2"} - request_init["comment"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "creator": { - "display_name": "display_name_value", - "email": "email_value", - "google_support": True, - }, - "body": "body_value", - "plain_text_body": "plain_text_body_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -1976,8 +2037,9 @@ def test_create_comment_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcs_comment.Comment.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcs_comment.Comment.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 diff --git a/packages/google-cloud-talent/CONTRIBUTING.rst b/packages/google-cloud-talent/CONTRIBUTING.rst index 9bdbbb52d8d3..fa5b337f204a 100644 --- a/packages/google-cloud-talent/CONTRIBUTING.rst +++ b/packages/google-cloud-talent/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-talent/google/cloud/talent/gapic_version.py b/packages/google-cloud-talent/google/cloud/talent/gapic_version.py index c0b370d3a667..360a0d13ebdd 100644 --- a/packages/google-cloud-talent/google/cloud/talent/gapic_version.py +++ b/packages/google-cloud-talent/google/cloud/talent/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.11.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-talent/google/cloud/talent_v4/gapic_version.py b/packages/google-cloud-talent/google/cloud/talent_v4/gapic_version.py index c0b370d3a667..360a0d13ebdd 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4/gapic_version.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.11.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-talent/google/cloud/talent_v4beta1/gapic_version.py b/packages/google-cloud-talent/google/cloud/talent_v4beta1/gapic_version.py index c0b370d3a667..360a0d13ebdd 100644 --- a/packages/google-cloud-talent/google/cloud/talent_v4beta1/gapic_version.py +++ b/packages/google-cloud-talent/google/cloud/talent_v4beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.11.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-talent/noxfile.py b/packages/google-cloud-talent/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-talent/noxfile.py +++ b/packages/google-cloud-talent/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4.json b/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4.json index 0d63653a55de..055c070bd80b 100644 --- a/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4.json +++ b/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-talent", - "version": "2.11.2" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4beta1.json b/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4beta1.json index aa55265323c4..4ece637720f6 100644 --- a/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4beta1.json +++ b/packages/google-cloud-talent/samples/generated_samples/snippet_metadata_google.cloud.talent.v4beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-talent", - "version": "2.11.2" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_company_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_company_service.py index ed0613bfc813..21b1dfb50f4a 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_company_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_company_service.py @@ -2266,6 +2266,73 @@ def test_create_company_rest(request_type): }, "suspended": True, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = company_service.CreateCompanyRequest.meta.fields["company"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["company"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["company"][field])): + del request_init["company"][field][i][subfield] + else: + del request_init["company"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -2291,8 +2358,9 @@ def test_create_company_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_company.Company.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 @@ -2381,8 +2449,9 @@ def test_create_company_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gct_company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_company.Company.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 @@ -2476,43 +2545,6 @@ def test_create_company_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/tenants/sample2"} - request_init["company"] = { - "name": "name_value", - "display_name": "display_name_value", - "external_id": "external_id_value", - "size": 1, - "headquarters_address": "headquarters_address_value", - "hiring_agency": True, - "eeo_text": "eeo_text_value", - "website_uri": "website_uri_value", - "career_site_uri": "career_site_uri_value", - "image_uri": "image_uri_value", - "keyword_searchable_job_custom_attributes": [ - "keyword_searchable_job_custom_attributes_value1", - "keyword_searchable_job_custom_attributes_value2", - ], - "derived_info": { - "headquarters_location": { - "location_type": 1, - "postal_address": { - "revision": 879, - "region_code": "region_code_value", - "language_code": "language_code_value", - "postal_code": "postal_code_value", - "sorting_code": "sorting_code_value", - "administrative_area": "administrative_area_value", - "locality": "locality_value", - "sublocality": "sublocality_value", - "address_lines": ["address_lines_value1", "address_lines_value2"], - "recipients": ["recipients_value1", "recipients_value2"], - "organization": "organization_value", - }, - "lat_lng": {"latitude": 0.86, "longitude": 0.971}, - "radius_miles": 0.12810000000000002, - } - }, - "suspended": True, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -2551,8 +2583,9 @@ def test_create_company_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_company.Company.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 @@ -2630,8 +2663,9 @@ def test_get_company_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = company.Company.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 @@ -2719,8 +2753,9 @@ def test_get_company_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = company.Company.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 @@ -2843,8 +2878,9 @@ def test_get_company_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = company.Company.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 @@ -2935,6 +2971,73 @@ def test_update_company_rest(request_type): }, "suspended": True, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = company_service.UpdateCompanyRequest.meta.fields["company"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["company"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["company"][field])): + del request_init["company"][field][i][subfield] + else: + del request_init["company"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -2960,8 +3063,9 @@ def test_update_company_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_company.Company.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 @@ -3047,8 +3151,9 @@ def test_update_company_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gct_company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_company.Company.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 @@ -3136,43 +3241,6 @@ def test_update_company_rest_bad_request( request_init = { "company": {"name": "projects/sample1/tenants/sample2/companies/sample3"} } - request_init["company"] = { - "name": "projects/sample1/tenants/sample2/companies/sample3", - "display_name": "display_name_value", - "external_id": "external_id_value", - "size": 1, - "headquarters_address": "headquarters_address_value", - "hiring_agency": True, - "eeo_text": "eeo_text_value", - "website_uri": "website_uri_value", - "career_site_uri": "career_site_uri_value", - "image_uri": "image_uri_value", - "keyword_searchable_job_custom_attributes": [ - "keyword_searchable_job_custom_attributes_value1", - "keyword_searchable_job_custom_attributes_value2", - ], - "derived_info": { - "headquarters_location": { - "location_type": 1, - "postal_address": { - "revision": 879, - "region_code": "region_code_value", - "language_code": "language_code_value", - "postal_code": "postal_code_value", - "sorting_code": "sorting_code_value", - "administrative_area": "administrative_area_value", - "locality": "locality_value", - "sublocality": "sublocality_value", - "address_lines": ["address_lines_value1", "address_lines_value2"], - "recipients": ["recipients_value1", "recipients_value2"], - "organization": "organization_value", - }, - "lat_lng": {"latitude": 0.86, "longitude": 0.971}, - "radius_miles": 0.12810000000000002, - } - }, - "suspended": True, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -3213,8 +3281,9 @@ def test_update_company_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_company.Company.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 @@ -3532,8 +3601,9 @@ def test_list_companies_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = company_service.ListCompaniesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = company_service.ListCompaniesResponse.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 @@ -3616,8 +3686,9 @@ def test_list_companies_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = company_service.ListCompaniesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = company_service.ListCompaniesResponse.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 @@ -3751,8 +3822,9 @@ def test_list_companies_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = company_service.ListCompaniesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = company_service.ListCompaniesResponse.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 diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_completion.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_completion.py index 68119f0a9452..71ac0428e241 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_completion.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_completion.py @@ -852,8 +852,9 @@ def test_complete_query_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = completion_service.CompleteQueryResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = completion_service.CompleteQueryResponse.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 @@ -952,8 +953,9 @@ def test_complete_query_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = completion_service.CompleteQueryResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = completion_service.CompleteQueryResponse.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 diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_event_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_event_service.py index 7742c62d3507..3432d9b529b2 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_event_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_event_service.py @@ -975,6 +975,73 @@ def test_create_client_event_rest(request_type): "job_event": {"type_": 1, "jobs": ["jobs_value1", "jobs_value2"]}, "event_notes": "event_notes_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = event_service.CreateClientEventRequest.meta.fields["client_event"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["client_event"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["client_event"][field])): + del request_init["client_event"][field][i][subfield] + else: + del request_init["client_event"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -989,8 +1056,9 @@ def test_create_client_event_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = event.ClientEvent.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = event.ClientEvent.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 @@ -1068,8 +1136,9 @@ def test_create_client_event_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = event.ClientEvent.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = event.ClientEvent.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 @@ -1163,13 +1232,6 @@ def test_create_client_event_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/tenants/sample2"} - request_init["client_event"] = { - "request_id": "request_id_value", - "event_id": "event_id_value", - "create_time": {"seconds": 751, "nanos": 543}, - "job_event": {"type_": 1, "jobs": ["jobs_value1", "jobs_value2"]}, - "event_notes": "event_notes_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -1208,8 +1270,9 @@ def test_create_client_event_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = event.ClientEvent.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = event.ClientEvent.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 diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_job_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_job_service.py index 6fb38eb785bb..365f59c302d0 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_job_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_job_service.py @@ -3449,6 +3449,73 @@ def test_create_job_rest(request_type): "html_sanitization": 1, }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = job_service.CreateJobRequest.meta.fields["job"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["job"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["job"][field])): + del request_init["job"][field][i][subfield] + else: + del request_init["job"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -3479,8 +3546,9 @@ def test_create_job_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_job.Job.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 @@ -3572,8 +3640,9 @@ def test_create_job_rest_required_fields(request_type=job_service.CreateJobReque response_value = Response() response_value.status_code = 200 - pb_return_value = gct_job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_job.Job.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 @@ -3665,87 +3734,6 @@ def test_create_job_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/tenants/sample2"} - request_init["job"] = { - "name": "name_value", - "company": "company_value", - "requisition_id": "requisition_id_value", - "title": "title_value", - "description": "description_value", - "addresses": ["addresses_value1", "addresses_value2"], - "application_info": { - "emails": ["emails_value1", "emails_value2"], - "instruction": "instruction_value", - "uris": ["uris_value1", "uris_value2"], - }, - "job_benefits": [1], - "compensation_info": { - "entries": [ - { - "type_": 1, - "unit": 1, - "amount": { - "currency_code": "currency_code_value", - "units": 563, - "nanos": 543, - }, - "range_": {"max_compensation": {}, "min_compensation": {}}, - "description": "description_value", - "expected_units_per_year": {"value": 0.541}, - } - ], - "annualized_base_compensation_range": {}, - "annualized_total_compensation_range": {}, - }, - "custom_attributes": {}, - "degree_types": [1], - "department": "department_value", - "employment_types": [1], - "incentives": "incentives_value", - "language_code": "language_code_value", - "job_level": 1, - "promotion_value": 1635, - "qualifications": "qualifications_value", - "responsibilities": "responsibilities_value", - "posting_region": 1, - "visibility": 1, - "job_start_time": {"seconds": 751, "nanos": 543}, - "job_end_time": {}, - "posting_publish_time": {}, - "posting_expire_time": {}, - "posting_create_time": {}, - "posting_update_time": {}, - "company_display_name": "company_display_name_value", - "derived_info": { - "locations": [ - { - "location_type": 1, - "postal_address": { - "revision": 879, - "region_code": "region_code_value", - "language_code": "language_code_value", - "postal_code": "postal_code_value", - "sorting_code": "sorting_code_value", - "administrative_area": "administrative_area_value", - "locality": "locality_value", - "sublocality": "sublocality_value", - "address_lines": [ - "address_lines_value1", - "address_lines_value2", - ], - "recipients": ["recipients_value1", "recipients_value2"], - "organization": "organization_value", - }, - "lat_lng": {"latitude": 0.86, "longitude": 0.971}, - "radius_miles": 0.12810000000000002, - } - ], - "job_categories": [1], - }, - "processing_options": { - "disable_street_address_resolution": True, - "html_sanitization": 1, - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -3784,8 +3772,9 @@ def test_create_job_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_job.Job.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 @@ -4141,8 +4130,9 @@ def test_get_job_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job.Job.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 @@ -4233,8 +4223,9 @@ def test_get_job_rest_required_fields(request_type=job_service.GetJobRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job.Job.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 @@ -4355,8 +4346,9 @@ def test_get_job_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job.Job.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 @@ -4488,6 +4480,73 @@ def test_update_job_rest(request_type): "html_sanitization": 1, }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = job_service.UpdateJobRequest.meta.fields["job"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["job"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["job"][field])): + del request_init["job"][field][i][subfield] + else: + del request_init["job"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -4518,8 +4577,9 @@ def test_update_job_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_job.Job.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 @@ -4608,8 +4668,9 @@ def test_update_job_rest_required_fields(request_type=job_service.UpdateJobReque response_value = Response() response_value.status_code = 200 - pb_return_value = gct_job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_job.Job.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 @@ -4693,87 +4754,6 @@ def test_update_job_rest_bad_request( # send a request that will satisfy transcoding request_init = {"job": {"name": "projects/sample1/tenants/sample2/jobs/sample3"}} - request_init["job"] = { - "name": "projects/sample1/tenants/sample2/jobs/sample3", - "company": "company_value", - "requisition_id": "requisition_id_value", - "title": "title_value", - "description": "description_value", - "addresses": ["addresses_value1", "addresses_value2"], - "application_info": { - "emails": ["emails_value1", "emails_value2"], - "instruction": "instruction_value", - "uris": ["uris_value1", "uris_value2"], - }, - "job_benefits": [1], - "compensation_info": { - "entries": [ - { - "type_": 1, - "unit": 1, - "amount": { - "currency_code": "currency_code_value", - "units": 563, - "nanos": 543, - }, - "range_": {"max_compensation": {}, "min_compensation": {}}, - "description": "description_value", - "expected_units_per_year": {"value": 0.541}, - } - ], - "annualized_base_compensation_range": {}, - "annualized_total_compensation_range": {}, - }, - "custom_attributes": {}, - "degree_types": [1], - "department": "department_value", - "employment_types": [1], - "incentives": "incentives_value", - "language_code": "language_code_value", - "job_level": 1, - "promotion_value": 1635, - "qualifications": "qualifications_value", - "responsibilities": "responsibilities_value", - "posting_region": 1, - "visibility": 1, - "job_start_time": {"seconds": 751, "nanos": 543}, - "job_end_time": {}, - "posting_publish_time": {}, - "posting_expire_time": {}, - "posting_create_time": {}, - "posting_update_time": {}, - "company_display_name": "company_display_name_value", - "derived_info": { - "locations": [ - { - "location_type": 1, - "postal_address": { - "revision": 879, - "region_code": "region_code_value", - "language_code": "language_code_value", - "postal_code": "postal_code_value", - "sorting_code": "sorting_code_value", - "administrative_area": "administrative_area_value", - "locality": "locality_value", - "sublocality": "sublocality_value", - "address_lines": [ - "address_lines_value1", - "address_lines_value2", - ], - "recipients": ["recipients_value1", "recipients_value2"], - "organization": "organization_value", - }, - "lat_lng": {"latitude": 0.86, "longitude": 0.971}, - "radius_miles": 0.12810000000000002, - } - ], - "job_categories": [1], - }, - "processing_options": { - "disable_street_address_resolution": True, - "html_sanitization": 1, - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -4814,8 +4794,9 @@ def test_update_job_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_job.Job.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 @@ -5667,8 +5648,9 @@ def test_list_jobs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.ListJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.ListJobsResponse.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 @@ -5757,8 +5739,9 @@ def test_list_jobs_rest_required_fields(request_type=job_service.ListJobsRequest response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.ListJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.ListJobsResponse.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 @@ -5903,8 +5886,9 @@ def test_list_jobs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.ListJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.ListJobsResponse.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 @@ -6025,8 +6009,9 @@ def test_search_jobs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.SearchJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.SearchJobsResponse.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 @@ -6104,8 +6089,9 @@ def test_search_jobs_rest_required_fields(request_type=job_service.SearchJobsReq response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.SearchJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.SearchJobsResponse.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 @@ -6248,8 +6234,9 @@ def test_search_jobs_for_alert_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.SearchJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.SearchJobsResponse.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 @@ -6329,8 +6316,9 @@ def test_search_jobs_for_alert_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.SearchJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.SearchJobsResponse.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 diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_tenant_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_tenant_service.py index 1472af80550d..e0aa7af12978 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_tenant_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4/test_tenant_service.py @@ -2083,6 +2083,73 @@ def test_create_tenant_rest(request_type): # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1"} request_init["tenant"] = {"name": "name_value", "external_id": "external_id_value"} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = tenant_service.CreateTenantRequest.meta.fields["tenant"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["tenant"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["tenant"][field])): + del request_init["tenant"][field][i][subfield] + else: + del request_init["tenant"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -2096,8 +2163,9 @@ def test_create_tenant_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_tenant.Tenant.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 @@ -2174,8 +2242,9 @@ def test_create_tenant_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gct_tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_tenant.Tenant.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 @@ -2269,7 +2338,6 @@ def test_create_tenant_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1"} - request_init["tenant"] = {"name": "name_value", "external_id": "external_id_value"} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -2308,8 +2376,9 @@ def test_create_tenant_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_tenant.Tenant.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 @@ -2374,8 +2443,9 @@ def test_get_tenant_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tenant.Tenant.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 @@ -2449,8 +2519,9 @@ def test_get_tenant_rest_required_fields(request_type=tenant_service.GetTenantRe response_value = Response() response_value.status_code = 200 - pb_return_value = tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tenant.Tenant.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 @@ -2573,8 +2644,9 @@ def test_get_tenant_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tenant.Tenant.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 @@ -2629,6 +2701,73 @@ def test_update_tenant_rest(request_type): "name": "projects/sample1/tenants/sample2", "external_id": "external_id_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = tenant_service.UpdateTenantRequest.meta.fields["tenant"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["tenant"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["tenant"][field])): + del request_init["tenant"][field][i][subfield] + else: + del request_init["tenant"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -2642,8 +2781,9 @@ def test_update_tenant_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_tenant.Tenant.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 @@ -2717,8 +2857,9 @@ def test_update_tenant_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gct_tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_tenant.Tenant.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 @@ -2804,10 +2945,6 @@ def test_update_tenant_rest_bad_request( # send a request that will satisfy transcoding request_init = {"tenant": {"name": "projects/sample1/tenants/sample2"}} - request_init["tenant"] = { - "name": "projects/sample1/tenants/sample2", - "external_id": "external_id_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -2846,8 +2983,9 @@ def test_update_tenant_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_tenant.Tenant.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 @@ -3162,8 +3300,9 @@ def test_list_tenants_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tenant_service.ListTenantsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tenant_service.ListTenantsResponse.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 @@ -3245,8 +3384,9 @@ def test_list_tenants_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = tenant_service.ListTenantsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tenant_service.ListTenantsResponse.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 @@ -3379,8 +3519,9 @@ def test_list_tenants_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tenant_service.ListTenantsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tenant_service.ListTenantsResponse.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 diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_company_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_company_service.py index a5354ce6e7a7..edd206fa16f9 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_company_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_company_service.py @@ -2244,8 +2244,9 @@ def test_create_company_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_company.Company.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 @@ -2334,8 +2335,9 @@ def test_create_company_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gct_company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_company.Company.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 @@ -2467,8 +2469,9 @@ def test_create_company_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_company.Company.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 @@ -2547,8 +2550,9 @@ def test_get_company_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = company.Company.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 @@ -2636,8 +2640,9 @@ def test_get_company_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = company.Company.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 @@ -2760,8 +2765,9 @@ def test_get_company_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = company.Company.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 @@ -2841,8 +2847,9 @@ def test_update_company_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_company.Company.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 @@ -2926,8 +2933,9 @@ def test_update_company_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gct_company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_company.Company.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 @@ -3054,8 +3062,9 @@ def test_update_company_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_company.Company.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_company.Company.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 @@ -3373,8 +3382,9 @@ def test_list_companies_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = company_service.ListCompaniesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = company_service.ListCompaniesResponse.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 @@ -3457,8 +3467,9 @@ def test_list_companies_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = company_service.ListCompaniesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = company_service.ListCompaniesResponse.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 @@ -3592,8 +3603,9 @@ def test_list_companies_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = company_service.ListCompaniesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = company_service.ListCompaniesResponse.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 diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_completion.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_completion.py index 34a546fab189..09c0fc89c678 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_completion.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_completion.py @@ -852,8 +852,9 @@ def test_complete_query_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = completion_service.CompleteQueryResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = completion_service.CompleteQueryResponse.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 @@ -952,8 +953,9 @@ def test_complete_query_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = completion_service.CompleteQueryResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = completion_service.CompleteQueryResponse.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 diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_event_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_event_service.py index f44203c10e08..ee72c0c2c062 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_event_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_event_service.py @@ -982,8 +982,9 @@ def test_create_client_event_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = event.ClientEvent.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = event.ClientEvent.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 @@ -1061,8 +1062,9 @@ def test_create_client_event_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = event.ClientEvent.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = event.ClientEvent.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 @@ -1194,8 +1196,9 @@ def test_create_client_event_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = event.ClientEvent.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = event.ClientEvent.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 diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_job_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_job_service.py index 556e53a99bb9..2a3190d3a791 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_job_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_job_service.py @@ -3784,8 +3784,9 @@ def test_create_job_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_job.Job.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 @@ -3877,8 +3878,9 @@ def test_create_job_rest_required_fields(request_type=job_service.CreateJobReque response_value = Response() response_value.status_code = 200 - pb_return_value = gct_job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_job.Job.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 @@ -4008,8 +4010,9 @@ def test_create_job_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_job.Job.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 @@ -4366,8 +4369,9 @@ def test_get_job_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job.Job.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 @@ -4458,8 +4462,9 @@ def test_get_job_rest_required_fields(request_type=job_service.GetJobRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job.Job.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 @@ -4580,8 +4585,9 @@ def test_get_job_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job.Job.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 @@ -4663,8 +4669,9 @@ def test_update_job_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_job.Job.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 @@ -4751,8 +4758,9 @@ def test_update_job_rest_required_fields(request_type=job_service.UpdateJobReque response_value = Response() response_value.status_code = 200 - pb_return_value = gct_job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_job.Job.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 @@ -4875,8 +4883,9 @@ def test_update_job_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_job.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_job.Job.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 @@ -5731,8 +5740,9 @@ def test_list_jobs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.ListJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.ListJobsResponse.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 @@ -5821,8 +5831,9 @@ def test_list_jobs_rest_required_fields(request_type=job_service.ListJobsRequest response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.ListJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.ListJobsResponse.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 @@ -5967,8 +5978,9 @@ def test_list_jobs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.ListJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.ListJobsResponse.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 @@ -6091,8 +6103,9 @@ def test_search_jobs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.SearchJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.SearchJobsResponse.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 @@ -6169,8 +6182,9 @@ def test_search_jobs_rest_required_fields(request_type=job_service.SearchJobsReq response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.SearchJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.SearchJobsResponse.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 @@ -6371,8 +6385,9 @@ def test_search_jobs_for_alert_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.SearchJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.SearchJobsResponse.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 @@ -6451,8 +6466,9 @@ def test_search_jobs_for_alert_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = job_service.SearchJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = job_service.SearchJobsResponse.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 diff --git a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_tenant_service.py b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_tenant_service.py index 681a6b7169d1..7752839c9a79 100644 --- a/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_tenant_service.py +++ b/packages/google-cloud-talent/tests/unit/gapic/talent_v4beta1/test_tenant_service.py @@ -2137,8 +2137,9 @@ def test_create_tenant_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_tenant.Tenant.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 @@ -2219,8 +2220,9 @@ def test_create_tenant_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gct_tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_tenant.Tenant.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 @@ -2352,8 +2354,9 @@ def test_create_tenant_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_tenant.Tenant.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 @@ -2422,8 +2425,9 @@ def test_get_tenant_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tenant.Tenant.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 @@ -2501,8 +2505,9 @@ def test_get_tenant_rest_required_fields(request_type=tenant_service.GetTenantRe response_value = Response() response_value.status_code = 200 - pb_return_value = tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tenant.Tenant.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 @@ -2625,8 +2630,9 @@ def test_get_tenant_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tenant.Tenant.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 @@ -2694,8 +2700,9 @@ def test_update_tenant_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_tenant.Tenant.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 @@ -2771,8 +2778,9 @@ def test_update_tenant_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gct_tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_tenant.Tenant.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 @@ -2895,8 +2903,9 @@ def test_update_tenant_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_tenant.Tenant.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_tenant.Tenant.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 @@ -3211,8 +3220,9 @@ def test_list_tenants_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tenant_service.ListTenantsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tenant_service.ListTenantsResponse.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 @@ -3294,8 +3304,9 @@ def test_list_tenants_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = tenant_service.ListTenantsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tenant_service.ListTenantsResponse.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 @@ -3428,8 +3439,9 @@ def test_list_tenants_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tenant_service.ListTenantsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tenant_service.ListTenantsResponse.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 diff --git a/packages/google-cloud-tasks/google/cloud/tasks/gapic_version.py b/packages/google-cloud-tasks/google/cloud/tasks/gapic_version.py index 3344051a673d..360a0d13ebdd 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks/gapic_version.py +++ b/packages/google-cloud-tasks/google/cloud/tasks/gapic_version.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2022 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2/gapic_version.py b/packages/google-cloud-tasks/google/cloud/tasks_v2/gapic_version.py index 3344051a673d..360a0d13ebdd 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2/gapic_version.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2/gapic_version.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2022 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/gapic_version.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/gapic_version.py index 3344051a673d..360a0d13ebdd 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/gapic_version.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta2/gapic_version.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2022 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/gapic_version.py b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/gapic_version.py index 3344051a673d..360a0d13ebdd 100644 --- a/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/gapic_version.py +++ b/packages/google-cloud-tasks/google/cloud/tasks_v2beta3/gapic_version.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2022 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "2.14.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_create_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_create_queue_async.py new file mode 100644 index 000000000000..7c84c9a91f2a --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_create_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_CreateQueue_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 tasks_v2 + + +async def sample_create_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_CreateQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_create_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_create_queue_sync.py new file mode 100644 index 000000000000..42477d565e49 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_create_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_CreateQueue_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 tasks_v2 + + +def sample_create_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_CreateQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_create_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_create_task_async.py new file mode 100644 index 000000000000..a410908e0f65 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_create_task_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateTask +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_CreateTask_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 tasks_v2 + + +async def sample_create_task(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_CreateTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_create_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_create_task_sync.py new file mode 100644 index 000000000000..b0be5c3d4bd5 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_create_task_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateTask +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_CreateTask_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 tasks_v2 + + +def sample_create_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_CreateTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_delete_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_delete_queue_async.py new file mode 100644 index 000000000000..74636a5b14b1 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_delete_queue_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_DeleteQueue_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 tasks_v2 + + +async def sample_delete_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + await client.delete_queue(request=request) + + +# [END cloudtasks_v2_generated_CloudTasks_DeleteQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_delete_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_delete_queue_sync.py new file mode 100644 index 000000000000..9034e3fbead3 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_delete_queue_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_DeleteQueue_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 tasks_v2 + + +def sample_delete_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + client.delete_queue(request=request) + + +# [END cloudtasks_v2_generated_CloudTasks_DeleteQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_delete_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_delete_task_async.py new file mode 100644 index 000000000000..655d6fb1f262 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_delete_task_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteTask +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_DeleteTask_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 tasks_v2 + + +async def sample_delete_task(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + await client.delete_task(request=request) + + +# [END cloudtasks_v2_generated_CloudTasks_DeleteTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_delete_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_delete_task_sync.py new file mode 100644 index 000000000000..b997b846f9b3 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_delete_task_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteTask +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_DeleteTask_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 tasks_v2 + + +def sample_delete_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + client.delete_task(request=request) + + +# [END cloudtasks_v2_generated_CloudTasks_DeleteTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_async.py new file mode 100644 index 000000000000..496744961bc5 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetIamPolicy +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_GetIamPolicy_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 tasks_v2 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +async def sample_get_iam_policy(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_GetIamPolicy_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_sync.py new file mode 100644 index 000000000000..3afe6117ab46 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetIamPolicy +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_GetIamPolicy_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 tasks_v2 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +def sample_get_iam_policy(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_GetIamPolicy_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_queue_async.py new file mode 100644 index 000000000000..feee4f291cb4 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_GetQueue_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 tasks_v2 + + +async def sample_get_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.get_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_GetQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_queue_sync.py new file mode 100644 index 000000000000..44b0fa1667f7 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_GetQueue_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 tasks_v2 + + +def sample_get_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = client.get_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_GetQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_task_async.py new file mode 100644 index 000000000000..7548ad9c9d6c --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_task_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetTask +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_GetTask_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 tasks_v2 + + +async def sample_get_task(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = await client.get_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_GetTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_task_sync.py new file mode 100644 index 000000000000..ac3385c3e7d9 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_task_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetTask +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_GetTask_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 tasks_v2 + + +def sample_get_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = client.get_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_GetTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_list_queues_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_list_queues_async.py new file mode 100644 index 000000000000..6bb53c7d66ab --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_list_queues_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListQueues +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_ListQueues_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 tasks_v2 + + +async def sample_list_queues(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_ListQueues_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_list_queues_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_list_queues_sync.py new file mode 100644 index 000000000000..305204b8c1f3 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_list_queues_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListQueues +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_ListQueues_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 tasks_v2 + + +def sample_list_queues(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_ListQueues_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_list_tasks_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_list_tasks_async.py new file mode 100644 index 000000000000..89fb882c7d77 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_list_tasks_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListTasks +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_ListTasks_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 tasks_v2 + + +async def sample_list_tasks(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_ListTasks_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_list_tasks_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_list_tasks_sync.py new file mode 100644 index 000000000000..b88a70a153bc --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_list_tasks_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListTasks +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_ListTasks_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 tasks_v2 + + +def sample_list_tasks(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_ListTasks_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_pause_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_pause_queue_async.py new file mode 100644 index 000000000000..797d3ced9720 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_pause_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 PauseQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_PauseQueue_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 tasks_v2 + + +async def sample_pause_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.pause_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_PauseQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_pause_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_pause_queue_sync.py new file mode 100644 index 000000000000..a2388ad7d72c --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_pause_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 PauseQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_PauseQueue_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 tasks_v2 + + +def sample_pause_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = client.pause_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_PauseQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_purge_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_purge_queue_async.py new file mode 100644 index 000000000000..77e4001ad4f8 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_purge_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 PurgeQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_PurgeQueue_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 tasks_v2 + + +async def sample_purge_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.purge_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_PurgeQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_purge_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_purge_queue_sync.py new file mode 100644 index 000000000000..beab81a196d0 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_purge_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 PurgeQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_PurgeQueue_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 tasks_v2 + + +def sample_purge_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.purge_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_PurgeQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_resume_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_resume_queue_async.py new file mode 100644 index 000000000000..9009b863c79f --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_resume_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ResumeQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_ResumeQueue_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 tasks_v2 + + +async def sample_resume_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.resume_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_ResumeQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_resume_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_resume_queue_sync.py new file mode 100644 index 000000000000..3dfd286a1278 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_resume_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ResumeQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_ResumeQueue_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 tasks_v2 + + +def sample_resume_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.resume_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_ResumeQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_run_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_run_task_async.py new file mode 100644 index 000000000000..f25ee615a590 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_run_task_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 RunTask +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_RunTask_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 tasks_v2 + + +async def sample_run_task(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = await client.run_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_RunTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_run_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_run_task_sync.py new file mode 100644 index 000000000000..cc3034929d01 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_run_task_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 RunTask +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_RunTask_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 tasks_v2 + + +def sample_run_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = client.run_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_RunTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_async.py new file mode 100644 index 000000000000..e2f9cf4b1aca --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 SetIamPolicy +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_SetIamPolicy_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 tasks_v2 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +async def sample_set_iam_policy(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_SetIamPolicy_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_sync.py new file mode 100644 index 000000000000..475824379678 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 SetIamPolicy +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_SetIamPolicy_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 tasks_v2 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +def sample_set_iam_policy(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_SetIamPolicy_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_async.py new file mode 100644 index 000000000000..b2e3097794ee --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_async.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 TestIamPermissions +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_TestIamPermissions_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 tasks_v2 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +async def sample_test_iam_permissions(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = await client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_TestIamPermissions_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_sync.py new file mode 100644 index 000000000000..02059d1f6202 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 TestIamPermissions +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_TestIamPermissions_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 tasks_v2 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +def sample_test_iam_permissions(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_TestIamPermissions_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_update_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_update_queue_async.py new file mode 100644 index 000000000000..4e225223bc2f --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_update_queue_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UpdateQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_UpdateQueue_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 tasks_v2 + + +async def sample_update_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.UpdateQueueRequest( + ) + + # Make the request + response = await client.update_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_UpdateQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_update_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_update_queue_sync.py new file mode 100644 index 000000000000..b19cd75504c8 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_update_queue_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UpdateQueue +# 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-tasks + + +# [START cloudtasks_v2_generated_CloudTasks_UpdateQueue_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 tasks_v2 + + +def sample_update_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.UpdateQueueRequest( + ) + + # Make the request + response = client.update_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2_generated_CloudTasks_UpdateQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_async.py new file mode 100644 index 000000000000..84894a5e8eb4 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 AcknowledgeTask +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_AcknowledgeTask_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 tasks_v2beta2 + + +async def sample_acknowledge_task(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.AcknowledgeTaskRequest( + name="name_value", + ) + + # Make the request + await client.acknowledge_task(request=request) + + +# [END cloudtasks_v2beta2_generated_CloudTasks_AcknowledgeTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_sync.py new file mode 100644 index 000000000000..bc16e06b8bbb --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 AcknowledgeTask +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_AcknowledgeTask_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 tasks_v2beta2 + + +def sample_acknowledge_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.AcknowledgeTaskRequest( + name="name_value", + ) + + # Make the request + client.acknowledge_task(request=request) + + +# [END cloudtasks_v2beta2_generated_CloudTasks_AcknowledgeTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_buffer_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_buffer_task_async.py new file mode 100644 index 000000000000..1c86ed30f6a2 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_buffer_task_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 BufferTask +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_BufferTask_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 tasks_v2beta2 + + +async def sample_buffer_task(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.BufferTaskRequest( + queue="queue_value", + ) + + # Make the request + response = await client.buffer_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_BufferTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_buffer_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_buffer_task_sync.py new file mode 100644 index 000000000000..c6e104349b38 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_buffer_task_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 BufferTask +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_BufferTask_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 tasks_v2beta2 + + +def sample_buffer_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.BufferTaskRequest( + queue="queue_value", + ) + + # Make the request + response = client.buffer_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_BufferTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_async.py new file mode 100644 index 000000000000..333c71db16bf --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CancelLease +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_CancelLease_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 tasks_v2beta2 + + +async def sample_cancel_lease(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CancelLeaseRequest( + name="name_value", + ) + + # Make the request + response = await client.cancel_lease(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_CancelLease_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_sync.py new file mode 100644 index 000000000000..4aed223e9caf --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CancelLease +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_CancelLease_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 tasks_v2beta2 + + +def sample_cancel_lease(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CancelLeaseRequest( + name="name_value", + ) + + # Make the request + response = client.cancel_lease(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_CancelLease_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_create_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_create_queue_async.py new file mode 100644 index 000000000000..b3237492ba40 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_create_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_CreateQueue_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 tasks_v2beta2 + + +async def sample_create_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_CreateQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_create_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_create_queue_sync.py new file mode 100644 index 000000000000..90b56431828d --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_create_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_CreateQueue_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 tasks_v2beta2 + + +def sample_create_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_CreateQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_create_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_create_task_async.py new file mode 100644 index 000000000000..593de42476a1 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_create_task_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateTask +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_CreateTask_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 tasks_v2beta2 + + +async def sample_create_task(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_CreateTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_create_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_create_task_sync.py new file mode 100644 index 000000000000..026133d78464 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_create_task_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateTask +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_CreateTask_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 tasks_v2beta2 + + +def sample_create_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_CreateTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_async.py new file mode 100644 index 000000000000..6cf454aac548 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_DeleteQueue_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 tasks_v2beta2 + + +async def sample_delete_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + await client.delete_queue(request=request) + + +# [END cloudtasks_v2beta2_generated_CloudTasks_DeleteQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_sync.py new file mode 100644 index 000000000000..97223c56759a --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_DeleteQueue_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 tasks_v2beta2 + + +def sample_delete_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + client.delete_queue(request=request) + + +# [END cloudtasks_v2beta2_generated_CloudTasks_DeleteQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_delete_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_delete_task_async.py new file mode 100644 index 000000000000..6df73037465d --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_delete_task_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteTask +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_DeleteTask_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 tasks_v2beta2 + + +async def sample_delete_task(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + await client.delete_task(request=request) + + +# [END cloudtasks_v2beta2_generated_CloudTasks_DeleteTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_delete_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_delete_task_sync.py new file mode 100644 index 000000000000..e319674d37d4 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_delete_task_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteTask +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_DeleteTask_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 tasks_v2beta2 + + +def sample_delete_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + client.delete_task(request=request) + + +# [END cloudtasks_v2beta2_generated_CloudTasks_DeleteTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_async.py new file mode 100644 index 000000000000..cef5a7334177 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetIamPolicy +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_GetIamPolicy_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 tasks_v2beta2 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +async def sample_get_iam_policy(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_GetIamPolicy_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_sync.py new file mode 100644 index 000000000000..4a51042bb76a --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetIamPolicy +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_GetIamPolicy_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 tasks_v2beta2 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +def sample_get_iam_policy(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_GetIamPolicy_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_queue_async.py new file mode 100644 index 000000000000..d2e167126aaa --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_GetQueue_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 tasks_v2beta2 + + +async def sample_get_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.get_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_GetQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_queue_sync.py new file mode 100644 index 000000000000..a2b4b4c03c74 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_GetQueue_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 tasks_v2beta2 + + +def sample_get_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = client.get_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_GetQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_task_async.py new file mode 100644 index 000000000000..a79211d68b90 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_task_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetTask +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_GetTask_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 tasks_v2beta2 + + +async def sample_get_task(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = await client.get_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_GetTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_task_sync.py new file mode 100644 index 000000000000..b3090f2d2b87 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_task_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetTask +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_GetTask_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 tasks_v2beta2 + + +def sample_get_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = client.get_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_GetTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_async.py new file mode 100644 index 000000000000..7b33ba071663 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 LeaseTasks +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_LeaseTasks_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 tasks_v2beta2 + + +async def sample_lease_tasks(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.LeaseTasksRequest( + parent="parent_value", + ) + + # Make the request + response = await client.lease_tasks(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_LeaseTasks_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_sync.py new file mode 100644 index 000000000000..2afa46c046d9 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 LeaseTasks +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_LeaseTasks_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 tasks_v2beta2 + + +def sample_lease_tasks(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.LeaseTasksRequest( + parent="parent_value", + ) + + # Make the request + response = client.lease_tasks(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_LeaseTasks_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_list_queues_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_list_queues_async.py new file mode 100644 index 000000000000..872dac9cf0ba --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_list_queues_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListQueues +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_ListQueues_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 tasks_v2beta2 + + +async def sample_list_queues(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_ListQueues_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_list_queues_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_list_queues_sync.py new file mode 100644 index 000000000000..7cd6d0525a06 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_list_queues_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListQueues +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_ListQueues_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 tasks_v2beta2 + + +def sample_list_queues(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_ListQueues_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_async.py new file mode 100644 index 000000000000..6f15de6363a8 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListTasks +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_ListTasks_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 tasks_v2beta2 + + +async def sample_list_tasks(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_ListTasks_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_sync.py new file mode 100644 index 000000000000..2aad89d5f287 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListTasks +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_ListTasks_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 tasks_v2beta2 + + +def sample_list_tasks(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_ListTasks_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_async.py new file mode 100644 index 000000000000..13536bb5d081 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 PauseQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_PauseQueue_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 tasks_v2beta2 + + +async def sample_pause_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.pause_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_PauseQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_sync.py new file mode 100644 index 000000000000..2f32a5ba0729 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 PauseQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_PauseQueue_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 tasks_v2beta2 + + +def sample_pause_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = client.pause_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_PauseQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_async.py new file mode 100644 index 000000000000..b8bec558d77b --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 PurgeQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_PurgeQueue_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 tasks_v2beta2 + + +async def sample_purge_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.purge_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_PurgeQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_sync.py new file mode 100644 index 000000000000..6afd0fc4d21e --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 PurgeQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_PurgeQueue_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 tasks_v2beta2 + + +def sample_purge_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.purge_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_PurgeQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_async.py new file mode 100644 index 000000000000..5103238ee64e --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 RenewLease +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_RenewLease_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 tasks_v2beta2 + + +async def sample_renew_lease(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.RenewLeaseRequest( + name="name_value", + ) + + # Make the request + response = await client.renew_lease(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_RenewLease_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_sync.py new file mode 100644 index 000000000000..92249e57cff8 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 RenewLease +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_RenewLease_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 tasks_v2beta2 + + +def sample_renew_lease(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.RenewLeaseRequest( + name="name_value", + ) + + # Make the request + response = client.renew_lease(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_RenewLease_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_async.py new file mode 100644 index 000000000000..dc9a39092a2a --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ResumeQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_ResumeQueue_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 tasks_v2beta2 + + +async def sample_resume_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.resume_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_ResumeQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_sync.py new file mode 100644 index 000000000000..b9978af9d5e6 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ResumeQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_ResumeQueue_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 tasks_v2beta2 + + +def sample_resume_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.resume_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_ResumeQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_run_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_run_task_async.py new file mode 100644 index 000000000000..291f66ebe54d --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_run_task_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 RunTask +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_RunTask_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 tasks_v2beta2 + + +async def sample_run_task(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = await client.run_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_RunTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_run_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_run_task_sync.py new file mode 100644 index 000000000000..6ef84d064df8 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_run_task_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 RunTask +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_RunTask_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 tasks_v2beta2 + + +def sample_run_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = client.run_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_RunTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_async.py new file mode 100644 index 000000000000..ac45abb8159c --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 SetIamPolicy +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_SetIamPolicy_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 tasks_v2beta2 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +async def sample_set_iam_policy(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_SetIamPolicy_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_sync.py new file mode 100644 index 000000000000..7d382476a719 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 SetIamPolicy +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_SetIamPolicy_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 tasks_v2beta2 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +def sample_set_iam_policy(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_SetIamPolicy_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_async.py new file mode 100644 index 000000000000..1aa830508771 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_async.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 TestIamPermissions +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_TestIamPermissions_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 tasks_v2beta2 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +async def sample_test_iam_permissions(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = await client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_TestIamPermissions_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_sync.py new file mode 100644 index 000000000000..d5fd97a5d713 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 TestIamPermissions +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_TestIamPermissions_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 tasks_v2beta2 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +def sample_test_iam_permissions(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_TestIamPermissions_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_update_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_update_queue_async.py new file mode 100644 index 000000000000..5e55852ab7de --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_update_queue_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UpdateQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_UpdateQueue_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 tasks_v2beta2 + + +async def sample_update_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.UpdateQueueRequest( + ) + + # Make the request + response = await client.update_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_UpdateQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_update_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_update_queue_sync.py new file mode 100644 index 000000000000..83f70e61b5d2 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_update_queue_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UpdateQueue +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_UpdateQueue_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 tasks_v2beta2 + + +def sample_update_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.UpdateQueueRequest( + ) + + # Make the request + response = client.update_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta2_generated_CloudTasks_UpdateQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_upload_queue_yaml_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_upload_queue_yaml_async.py new file mode 100644 index 000000000000..d7f96503a680 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_upload_queue_yaml_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UploadQueueYaml +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_UploadQueueYaml_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 tasks_v2beta2 + + +async def sample_upload_queue_yaml(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.UploadQueueYamlRequest( + app_id="app_id_value", + ) + + # Make the request + await client.upload_queue_yaml(request=request) + + +# [END cloudtasks_v2beta2_generated_CloudTasks_UploadQueueYaml_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_upload_queue_yaml_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_upload_queue_yaml_sync.py new file mode 100644 index 000000000000..1e7e4a3fdf92 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_upload_queue_yaml_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UploadQueueYaml +# 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-tasks + + +# [START cloudtasks_v2beta2_generated_CloudTasks_UploadQueueYaml_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 tasks_v2beta2 + + +def sample_upload_queue_yaml(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.UploadQueueYamlRequest( + app_id="app_id_value", + ) + + # Make the request + client.upload_queue_yaml(request=request) + + +# [END cloudtasks_v2beta2_generated_CloudTasks_UploadQueueYaml_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_buffer_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_buffer_task_async.py new file mode 100644 index 000000000000..2b57ea3be08f --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_buffer_task_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 BufferTask +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_BufferTask_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 tasks_v2beta3 + + +async def sample_buffer_task(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.BufferTaskRequest( + queue="queue_value", + ) + + # Make the request + response = await client.buffer_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_BufferTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_buffer_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_buffer_task_sync.py new file mode 100644 index 000000000000..246b167a25a5 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_buffer_task_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 BufferTask +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_BufferTask_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 tasks_v2beta3 + + +def sample_buffer_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.BufferTaskRequest( + queue="queue_value", + ) + + # Make the request + response = client.buffer_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_BufferTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_create_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_create_queue_async.py new file mode 100644 index 000000000000..eb20648927d3 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_create_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_CreateQueue_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 tasks_v2beta3 + + +async def sample_create_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_CreateQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_create_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_create_queue_sync.py new file mode 100644 index 000000000000..b562deecf6f2 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_create_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_CreateQueue_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 tasks_v2beta3 + + +def sample_create_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_CreateQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_create_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_create_task_async.py new file mode 100644 index 000000000000..872ce8522d4f --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_create_task_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateTask +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_CreateTask_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 tasks_v2beta3 + + +async def sample_create_task(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_CreateTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_create_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_create_task_sync.py new file mode 100644 index 000000000000..ef06554eef5f --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_create_task_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateTask +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_CreateTask_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 tasks_v2beta3 + + +def sample_create_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_CreateTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_async.py new file mode 100644 index 000000000000..6890770d1200 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_DeleteQueue_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 tasks_v2beta3 + + +async def sample_delete_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + await client.delete_queue(request=request) + + +# [END cloudtasks_v2beta3_generated_CloudTasks_DeleteQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_sync.py new file mode 100644 index 000000000000..2a54aaf8ba9c --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_DeleteQueue_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 tasks_v2beta3 + + +def sample_delete_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + client.delete_queue(request=request) + + +# [END cloudtasks_v2beta3_generated_CloudTasks_DeleteQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_delete_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_delete_task_async.py new file mode 100644 index 000000000000..129e7a48dd7d --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_delete_task_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteTask +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_DeleteTask_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 tasks_v2beta3 + + +async def sample_delete_task(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + await client.delete_task(request=request) + + +# [END cloudtasks_v2beta3_generated_CloudTasks_DeleteTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_delete_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_delete_task_sync.py new file mode 100644 index 000000000000..30a9e42754cb --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_delete_task_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteTask +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_DeleteTask_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 tasks_v2beta3 + + +def sample_delete_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + client.delete_task(request=request) + + +# [END cloudtasks_v2beta3_generated_CloudTasks_DeleteTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_async.py new file mode 100644 index 000000000000..dd6d2bfc7be6 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetIamPolicy +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_GetIamPolicy_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 tasks_v2beta3 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +async def sample_get_iam_policy(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_GetIamPolicy_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_sync.py new file mode 100644 index 000000000000..c2d72a310718 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetIamPolicy +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_GetIamPolicy_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 tasks_v2beta3 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +def sample_get_iam_policy(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = iam_policy_pb2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_GetIamPolicy_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_queue_async.py new file mode 100644 index 000000000000..225826721b90 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_GetQueue_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 tasks_v2beta3 + + +async def sample_get_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.get_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_GetQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_queue_sync.py new file mode 100644 index 000000000000..26d5bcc21a0e --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_GetQueue_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 tasks_v2beta3 + + +def sample_get_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = client.get_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_GetQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_task_async.py new file mode 100644 index 000000000000..ac839cd63aec --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_task_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetTask +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_GetTask_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 tasks_v2beta3 + + +async def sample_get_task(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = await client.get_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_GetTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_task_sync.py new file mode 100644 index 000000000000..aa89c1560c4c --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_task_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetTask +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_GetTask_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 tasks_v2beta3 + + +def sample_get_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = client.get_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_GetTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_list_queues_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_list_queues_async.py new file mode 100644 index 000000000000..92bc09912e1b --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_list_queues_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListQueues +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_ListQueues_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 tasks_v2beta3 + + +async def sample_list_queues(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_ListQueues_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_list_queues_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_list_queues_sync.py new file mode 100644 index 000000000000..16c75c4720bd --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_list_queues_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListQueues +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_ListQueues_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 tasks_v2beta3 + + +def sample_list_queues(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_ListQueues_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_async.py new file mode 100644 index 000000000000..dc80689d1c30 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListTasks +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_ListTasks_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 tasks_v2beta3 + + +async def sample_list_tasks(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_ListTasks_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_sync.py new file mode 100644 index 000000000000..d65fb760cb31 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListTasks +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_ListTasks_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 tasks_v2beta3 + + +def sample_list_tasks(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_ListTasks_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_async.py new file mode 100644 index 000000000000..ae58babda7b7 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 PauseQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_PauseQueue_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 tasks_v2beta3 + + +async def sample_pause_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.pause_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_PauseQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_sync.py new file mode 100644 index 000000000000..442c83509e71 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 PauseQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_PauseQueue_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 tasks_v2beta3 + + +def sample_pause_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = client.pause_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_PauseQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_async.py new file mode 100644 index 000000000000..a08033fe1fdc --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 PurgeQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_PurgeQueue_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 tasks_v2beta3 + + +async def sample_purge_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.purge_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_PurgeQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_sync.py new file mode 100644 index 000000000000..36e26a7c0af4 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 PurgeQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_PurgeQueue_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 tasks_v2beta3 + + +def sample_purge_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.purge_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_PurgeQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_async.py new file mode 100644 index 000000000000..9e05013b426a --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ResumeQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_ResumeQueue_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 tasks_v2beta3 + + +async def sample_resume_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.resume_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_ResumeQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_sync.py new file mode 100644 index 000000000000..415281420367 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ResumeQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_ResumeQueue_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 tasks_v2beta3 + + +def sample_resume_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.resume_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_ResumeQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_run_task_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_run_task_async.py new file mode 100644 index 000000000000..49a2580d1b20 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_run_task_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 RunTask +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_RunTask_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 tasks_v2beta3 + + +async def sample_run_task(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = await client.run_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_RunTask_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_run_task_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_run_task_sync.py new file mode 100644 index 000000000000..8aabaa152843 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_run_task_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 RunTask +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_RunTask_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 tasks_v2beta3 + + +def sample_run_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = client.run_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_RunTask_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_async.py new file mode 100644 index 000000000000..bf92c32efd40 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 SetIamPolicy +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_SetIamPolicy_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 tasks_v2beta3 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +async def sample_set_iam_policy(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_SetIamPolicy_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_sync.py new file mode 100644 index 000000000000..f0cebbc6793a --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 SetIamPolicy +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_SetIamPolicy_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 tasks_v2beta3 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +def sample_set_iam_policy(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = iam_policy_pb2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_SetIamPolicy_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_async.py new file mode 100644 index 000000000000..e8e1ee7dcfd7 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_async.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 TestIamPermissions +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_TestIamPermissions_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 tasks_v2beta3 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +async def sample_test_iam_permissions(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = await client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_TestIamPermissions_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_sync.py new file mode 100644 index 000000000000..706589dda5d9 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 TestIamPermissions +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_TestIamPermissions_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 tasks_v2beta3 +from google.iam.v1 import iam_policy_pb2 # type: ignore + + +def sample_test_iam_permissions(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = iam_policy_pb2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value1', 'permissions_value2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_TestIamPermissions_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_update_queue_async.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_update_queue_async.py new file mode 100644 index 000000000000..c1a6341da8bd --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_update_queue_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UpdateQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_UpdateQueue_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 tasks_v2beta3 + + +async def sample_update_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.UpdateQueueRequest( + ) + + # Make the request + response = await client.update_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_UpdateQueue_async] diff --git a/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_update_queue_sync.py b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_update_queue_sync.py new file mode 100644 index 000000000000..621776e438f3 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_update_queue_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UpdateQueue +# 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-tasks + + +# [START cloudtasks_v2beta3_generated_CloudTasks_UpdateQueue_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 tasks_v2beta3 + + +def sample_update_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.UpdateQueueRequest( + ) + + # Make the request + response = client.update_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_v2beta3_generated_CloudTasks_UpdateQueue_sync] diff --git a/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2.json b/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2.json new file mode 100644 index 000000000000..164c51d1def9 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2.json @@ -0,0 +1,2611 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.tasks.v2", + "version": "v2" + } + ], + "language": "PYTHON", + "name": "google-cloud-tasks", + "version": "0.1.0" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.create_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.CreateQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CreateQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.CreateQueueRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2.types.Queue" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "create_queue" + }, + "description": "Sample for CreateQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_create_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_CreateQueue_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": "cloudtasks_v2_generated_cloud_tasks_create_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.create_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.CreateQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CreateQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.CreateQueueRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2.types.Queue" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "create_queue" + }, + "description": "Sample for CreateQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_create_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_CreateQueue_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": "cloudtasks_v2_generated_cloud_tasks_create_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.create_task", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.CreateTask", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CreateTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.CreateTaskRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "task", + "type": "google.cloud.tasks_v2.types.Task" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Task", + "shortName": "create_task" + }, + "description": "Sample for CreateTask", + "file": "cloudtasks_v2_generated_cloud_tasks_create_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_CreateTask_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": "cloudtasks_v2_generated_cloud_tasks_create_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.create_task", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.CreateTask", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CreateTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.CreateTaskRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "task", + "type": "google.cloud.tasks_v2.types.Task" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Task", + "shortName": "create_task" + }, + "description": "Sample for CreateTask", + "file": "cloudtasks_v2_generated_cloud_tasks_create_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_CreateTask_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": "cloudtasks_v2_generated_cloud_tasks_create_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.delete_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.DeleteQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "DeleteQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.DeleteQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_queue" + }, + "description": "Sample for DeleteQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_delete_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_DeleteQueue_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2_generated_cloud_tasks_delete_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.delete_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.DeleteQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "DeleteQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.DeleteQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_queue" + }, + "description": "Sample for DeleteQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_delete_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_DeleteQueue_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2_generated_cloud_tasks_delete_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.delete_task", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.DeleteTask", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "DeleteTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.DeleteTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_task" + }, + "description": "Sample for DeleteTask", + "file": "cloudtasks_v2_generated_cloud_tasks_delete_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_DeleteTask_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2_generated_cloud_tasks_delete_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.delete_task", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.DeleteTask", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "DeleteTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.DeleteTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_task" + }, + "description": "Sample for DeleteTask", + "file": "cloudtasks_v2_generated_cloud_tasks_delete_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_DeleteTask_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2_generated_cloud_tasks_delete_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.get_iam_policy", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.GetIamPolicy", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" + }, + "description": "Sample for GetIamPolicy", + "file": "cloudtasks_v2_generated_cloud_tasks_get_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_GetIamPolicy_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2_generated_cloud_tasks_get_iam_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.get_iam_policy", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.GetIamPolicy", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" + }, + "description": "Sample for GetIamPolicy", + "file": "cloudtasks_v2_generated_cloud_tasks_get_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_GetIamPolicy_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2_generated_cloud_tasks_get_iam_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.get_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.GetQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.GetQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "get_queue" + }, + "description": "Sample for GetQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_get_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_GetQueue_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": "cloudtasks_v2_generated_cloud_tasks_get_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.get_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.GetQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.GetQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "get_queue" + }, + "description": "Sample for GetQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_get_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_GetQueue_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": "cloudtasks_v2_generated_cloud_tasks_get_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.get_task", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.GetTask", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.GetTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Task", + "shortName": "get_task" + }, + "description": "Sample for GetTask", + "file": "cloudtasks_v2_generated_cloud_tasks_get_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_GetTask_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": "cloudtasks_v2_generated_cloud_tasks_get_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.get_task", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.GetTask", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.GetTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Task", + "shortName": "get_task" + }, + "description": "Sample for GetTask", + "file": "cloudtasks_v2_generated_cloud_tasks_get_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_GetTask_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": "cloudtasks_v2_generated_cloud_tasks_get_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.list_queues", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.ListQueues", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ListQueues" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.ListQueuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.services.cloud_tasks.pagers.ListQueuesAsyncPager", + "shortName": "list_queues" + }, + "description": "Sample for ListQueues", + "file": "cloudtasks_v2_generated_cloud_tasks_list_queues_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_ListQueues_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": "cloudtasks_v2_generated_cloud_tasks_list_queues_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.list_queues", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.ListQueues", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ListQueues" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.ListQueuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.services.cloud_tasks.pagers.ListQueuesPager", + "shortName": "list_queues" + }, + "description": "Sample for ListQueues", + "file": "cloudtasks_v2_generated_cloud_tasks_list_queues_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_ListQueues_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": "cloudtasks_v2_generated_cloud_tasks_list_queues_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.list_tasks", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.ListTasks", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ListTasks" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.ListTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.services.cloud_tasks.pagers.ListTasksAsyncPager", + "shortName": "list_tasks" + }, + "description": "Sample for ListTasks", + "file": "cloudtasks_v2_generated_cloud_tasks_list_tasks_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_ListTasks_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": "cloudtasks_v2_generated_cloud_tasks_list_tasks_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.list_tasks", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.ListTasks", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ListTasks" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.ListTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.services.cloud_tasks.pagers.ListTasksPager", + "shortName": "list_tasks" + }, + "description": "Sample for ListTasks", + "file": "cloudtasks_v2_generated_cloud_tasks_list_tasks_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_ListTasks_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": "cloudtasks_v2_generated_cloud_tasks_list_tasks_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.pause_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.PauseQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "PauseQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.PauseQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "pause_queue" + }, + "description": "Sample for PauseQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_pause_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_PauseQueue_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": "cloudtasks_v2_generated_cloud_tasks_pause_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.pause_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.PauseQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "PauseQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.PauseQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "pause_queue" + }, + "description": "Sample for PauseQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_pause_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_PauseQueue_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": "cloudtasks_v2_generated_cloud_tasks_pause_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.purge_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.PurgeQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "PurgeQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.PurgeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "purge_queue" + }, + "description": "Sample for PurgeQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_purge_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_PurgeQueue_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": "cloudtasks_v2_generated_cloud_tasks_purge_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.purge_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.PurgeQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "PurgeQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.PurgeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "purge_queue" + }, + "description": "Sample for PurgeQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_purge_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_PurgeQueue_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": "cloudtasks_v2_generated_cloud_tasks_purge_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.resume_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.ResumeQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ResumeQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.ResumeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "resume_queue" + }, + "description": "Sample for ResumeQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_resume_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_ResumeQueue_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": "cloudtasks_v2_generated_cloud_tasks_resume_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.resume_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.ResumeQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ResumeQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.ResumeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "resume_queue" + }, + "description": "Sample for ResumeQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_resume_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_ResumeQueue_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": "cloudtasks_v2_generated_cloud_tasks_resume_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.run_task", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.RunTask", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "RunTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.RunTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Task", + "shortName": "run_task" + }, + "description": "Sample for RunTask", + "file": "cloudtasks_v2_generated_cloud_tasks_run_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_RunTask_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": "cloudtasks_v2_generated_cloud_tasks_run_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.run_task", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.RunTask", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "RunTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.RunTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Task", + "shortName": "run_task" + }, + "description": "Sample for RunTask", + "file": "cloudtasks_v2_generated_cloud_tasks_run_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_RunTask_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": "cloudtasks_v2_generated_cloud_tasks_run_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.set_iam_policy", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.SetIamPolicy", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "SetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" + }, + "description": "Sample for SetIamPolicy", + "file": "cloudtasks_v2_generated_cloud_tasks_set_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_SetIamPolicy_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2_generated_cloud_tasks_set_iam_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.set_iam_policy", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.SetIamPolicy", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "SetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" + }, + "description": "Sample for SetIamPolicy", + "file": "cloudtasks_v2_generated_cloud_tasks_set_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_SetIamPolicy_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2_generated_cloud_tasks_set_iam_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.test_iam_permissions", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.TestIamPermissions", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "TestIamPermissions" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "MutableSequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" + }, + "description": "Sample for TestIamPermissions", + "file": "cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_TestIamPermissions_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.test_iam_permissions", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.TestIamPermissions", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "TestIamPermissions" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "MutableSequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" + }, + "description": "Sample for TestIamPermissions", + "file": "cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_TestIamPermissions_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.update_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.UpdateQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "UpdateQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.UpdateQueueRequest" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2.types.Queue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "update_queue" + }, + "description": "Sample for UpdateQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_update_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_UpdateQueue_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2_generated_cloud_tasks_update_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.update_queue", + "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.UpdateQueue", + "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "UpdateQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.UpdateQueueRequest" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2.types.Queue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "update_queue" + }, + "description": "Sample for UpdateQueue", + "file": "cloudtasks_v2_generated_cloud_tasks_update_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2_generated_CloudTasks_UpdateQueue_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2_generated_cloud_tasks_update_queue_sync.py" + } + ] +} diff --git a/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta2.json b/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta2.json new file mode 100644 index 000000000000..9f7299153227 --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta2.json @@ -0,0 +1,3613 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.tasks.v2beta2", + "version": "v2beta2" + } + ], + "language": "PYTHON", + "name": "google-cloud-tasks", + "version": "0.1.0" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.acknowledge_task", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "AcknowledgeTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.AcknowledgeTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "schedule_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "acknowledge_task" + }, + "description": "Sample for AcknowledgeTask", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_AcknowledgeTask_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.acknowledge_task", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "AcknowledgeTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.AcknowledgeTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "schedule_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "acknowledge_task" + }, + "description": "Sample for AcknowledgeTask", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_AcknowledgeTask_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.buffer_task", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.BufferTask", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "BufferTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.BufferTaskRequest" + }, + { + "name": "queue", + "type": "str" + }, + { + "name": "task_id", + "type": "str" + }, + { + "name": "body", + "type": "google.api.httpbody_pb2.HttpBody" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.BufferTaskResponse", + "shortName": "buffer_task" + }, + "description": "Sample for BufferTask", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_buffer_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_BufferTask_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": "cloudtasks_v2beta2_generated_cloud_tasks_buffer_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.buffer_task", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.BufferTask", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "BufferTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.BufferTaskRequest" + }, + { + "name": "queue", + "type": "str" + }, + { + "name": "task_id", + "type": "str" + }, + { + "name": "body", + "type": "google.api.httpbody_pb2.HttpBody" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.BufferTaskResponse", + "shortName": "buffer_task" + }, + "description": "Sample for BufferTask", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_buffer_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_BufferTask_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": "cloudtasks_v2beta2_generated_cloud_tasks_buffer_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.cancel_lease", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.CancelLease", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CancelLease" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.CancelLeaseRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "schedule_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "cancel_lease" + }, + "description": "Sample for CancelLease", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_CancelLease_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": "cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.cancel_lease", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.CancelLease", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CancelLease" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.CancelLeaseRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "schedule_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "cancel_lease" + }, + "description": "Sample for CancelLease", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_CancelLease_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": "cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.create_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.CreateQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CreateQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.CreateQueueRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta2.types.Queue" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "create_queue" + }, + "description": "Sample for CreateQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_create_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_CreateQueue_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": "cloudtasks_v2beta2_generated_cloud_tasks_create_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.create_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.CreateQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CreateQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.CreateQueueRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta2.types.Queue" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "create_queue" + }, + "description": "Sample for CreateQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_create_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_CreateQueue_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": "cloudtasks_v2beta2_generated_cloud_tasks_create_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.create_task", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.CreateTask", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CreateTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.CreateTaskRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "task", + "type": "google.cloud.tasks_v2beta2.types.Task" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "create_task" + }, + "description": "Sample for CreateTask", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_create_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_CreateTask_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": "cloudtasks_v2beta2_generated_cloud_tasks_create_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.create_task", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.CreateTask", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CreateTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.CreateTaskRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "task", + "type": "google.cloud.tasks_v2beta2.types.Task" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "create_task" + }, + "description": "Sample for CreateTask", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_create_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_CreateTask_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": "cloudtasks_v2beta2_generated_cloud_tasks_create_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.delete_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.DeleteQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "DeleteQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.DeleteQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_queue" + }, + "description": "Sample for DeleteQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_DeleteQueue_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.delete_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.DeleteQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "DeleteQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.DeleteQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_queue" + }, + "description": "Sample for DeleteQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_DeleteQueue_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.delete_task", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.DeleteTask", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "DeleteTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.DeleteTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_task" + }, + "description": "Sample for DeleteTask", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_delete_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_DeleteTask_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_delete_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.delete_task", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.DeleteTask", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "DeleteTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.DeleteTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_task" + }, + "description": "Sample for DeleteTask", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_delete_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_DeleteTask_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_delete_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.get_iam_policy", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.GetIamPolicy", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" + }, + "description": "Sample for GetIamPolicy", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_GetIamPolicy_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.get_iam_policy", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.GetIamPolicy", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" + }, + "description": "Sample for GetIamPolicy", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_GetIamPolicy_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.get_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.GetQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.GetQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "get_queue" + }, + "description": "Sample for GetQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_get_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_GetQueue_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": "cloudtasks_v2beta2_generated_cloud_tasks_get_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.get_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.GetQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.GetQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "get_queue" + }, + "description": "Sample for GetQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_get_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_GetQueue_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": "cloudtasks_v2beta2_generated_cloud_tasks_get_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.get_task", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.GetTask", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.GetTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "get_task" + }, + "description": "Sample for GetTask", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_get_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_GetTask_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": "cloudtasks_v2beta2_generated_cloud_tasks_get_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.get_task", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.GetTask", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.GetTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "get_task" + }, + "description": "Sample for GetTask", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_get_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_GetTask_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": "cloudtasks_v2beta2_generated_cloud_tasks_get_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.lease_tasks", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "LeaseTasks" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.LeaseTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "lease_duration", + "type": "google.protobuf.duration_pb2.Duration" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.LeaseTasksResponse", + "shortName": "lease_tasks" + }, + "description": "Sample for LeaseTasks", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_LeaseTasks_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": "cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.lease_tasks", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "LeaseTasks" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.LeaseTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "lease_duration", + "type": "google.protobuf.duration_pb2.Duration" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.LeaseTasksResponse", + "shortName": "lease_tasks" + }, + "description": "Sample for LeaseTasks", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_LeaseTasks_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": "cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.list_queues", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.ListQueues", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ListQueues" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.ListQueuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesAsyncPager", + "shortName": "list_queues" + }, + "description": "Sample for ListQueues", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_list_queues_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_ListQueues_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": "cloudtasks_v2beta2_generated_cloud_tasks_list_queues_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.list_queues", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.ListQueues", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ListQueues" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.ListQueuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesPager", + "shortName": "list_queues" + }, + "description": "Sample for ListQueues", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_list_queues_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_ListQueues_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": "cloudtasks_v2beta2_generated_cloud_tasks_list_queues_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.list_tasks", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.ListTasks", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ListTasks" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.ListTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksAsyncPager", + "shortName": "list_tasks" + }, + "description": "Sample for ListTasks", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_ListTasks_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": "cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.list_tasks", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.ListTasks", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ListTasks" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.ListTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksPager", + "shortName": "list_tasks" + }, + "description": "Sample for ListTasks", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_ListTasks_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": "cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.pause_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.PauseQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "PauseQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.PauseQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "pause_queue" + }, + "description": "Sample for PauseQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_PauseQueue_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": "cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.pause_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.PauseQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "PauseQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.PauseQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "pause_queue" + }, + "description": "Sample for PauseQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_PauseQueue_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": "cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.purge_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.PurgeQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "PurgeQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.PurgeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "purge_queue" + }, + "description": "Sample for PurgeQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_PurgeQueue_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": "cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.purge_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.PurgeQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "PurgeQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.PurgeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "purge_queue" + }, + "description": "Sample for PurgeQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_PurgeQueue_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": "cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.renew_lease", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.RenewLease", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "RenewLease" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.RenewLeaseRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "schedule_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "lease_duration", + "type": "google.protobuf.duration_pb2.Duration" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "renew_lease" + }, + "description": "Sample for RenewLease", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_RenewLease_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": "cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.renew_lease", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.RenewLease", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "RenewLease" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.RenewLeaseRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "schedule_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "lease_duration", + "type": "google.protobuf.duration_pb2.Duration" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "renew_lease" + }, + "description": "Sample for RenewLease", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_RenewLease_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": "cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.resume_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.ResumeQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ResumeQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.ResumeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "resume_queue" + }, + "description": "Sample for ResumeQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_ResumeQueue_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": "cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.resume_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.ResumeQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ResumeQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.ResumeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "resume_queue" + }, + "description": "Sample for ResumeQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_ResumeQueue_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": "cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.run_task", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.RunTask", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "RunTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.RunTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "run_task" + }, + "description": "Sample for RunTask", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_run_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_RunTask_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": "cloudtasks_v2beta2_generated_cloud_tasks_run_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.run_task", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.RunTask", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "RunTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.RunTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "run_task" + }, + "description": "Sample for RunTask", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_run_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_RunTask_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": "cloudtasks_v2beta2_generated_cloud_tasks_run_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.set_iam_policy", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.SetIamPolicy", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "SetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" + }, + "description": "Sample for SetIamPolicy", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_SetIamPolicy_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.set_iam_policy", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.SetIamPolicy", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "SetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" + }, + "description": "Sample for SetIamPolicy", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_SetIamPolicy_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.test_iam_permissions", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.TestIamPermissions", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "TestIamPermissions" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "MutableSequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" + }, + "description": "Sample for TestIamPermissions", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_TestIamPermissions_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.test_iam_permissions", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.TestIamPermissions", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "TestIamPermissions" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "MutableSequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" + }, + "description": "Sample for TestIamPermissions", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_TestIamPermissions_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.update_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.UpdateQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "UpdateQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.UpdateQueueRequest" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta2.types.Queue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "update_queue" + }, + "description": "Sample for UpdateQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_update_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_UpdateQueue_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_update_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.update_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.UpdateQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "UpdateQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.UpdateQueueRequest" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta2.types.Queue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "update_queue" + }, + "description": "Sample for UpdateQueue", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_update_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_UpdateQueue_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_update_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.upload_queue_yaml", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.UploadQueueYaml", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "UploadQueueYaml" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.UploadQueueYamlRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "upload_queue_yaml" + }, + "description": "Sample for UploadQueueYaml", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_upload_queue_yaml_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_UploadQueueYaml_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_upload_queue_yaml_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.upload_queue_yaml", + "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.UploadQueueYaml", + "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "UploadQueueYaml" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.UploadQueueYamlRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "upload_queue_yaml" + }, + "description": "Sample for UploadQueueYaml", + "file": "cloudtasks_v2beta2_generated_cloud_tasks_upload_queue_yaml_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_UploadQueueYaml_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_upload_queue_yaml_sync.py" + } + ] +} diff --git a/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta3.json b/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta3.json new file mode 100644 index 000000000000..c5d7f811d5da --- /dev/null +++ b/packages/google-cloud-tasks/samples/generated_samples/snippet_metadata_google.cloud.tasks.v2beta3.json @@ -0,0 +1,2788 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.tasks.v2beta3", + "version": "v2beta3" + } + ], + "language": "PYTHON", + "name": "google-cloud-tasks", + "version": "0.1.0" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.buffer_task", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.BufferTask", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "BufferTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.BufferTaskRequest" + }, + { + "name": "queue", + "type": "str" + }, + { + "name": "task_id", + "type": "str" + }, + { + "name": "body", + "type": "google.api.httpbody_pb2.HttpBody" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.BufferTaskResponse", + "shortName": "buffer_task" + }, + "description": "Sample for BufferTask", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_buffer_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_BufferTask_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": "cloudtasks_v2beta3_generated_cloud_tasks_buffer_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.buffer_task", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.BufferTask", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "BufferTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.BufferTaskRequest" + }, + { + "name": "queue", + "type": "str" + }, + { + "name": "task_id", + "type": "str" + }, + { + "name": "body", + "type": "google.api.httpbody_pb2.HttpBody" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.BufferTaskResponse", + "shortName": "buffer_task" + }, + "description": "Sample for BufferTask", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_buffer_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_BufferTask_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": "cloudtasks_v2beta3_generated_cloud_tasks_buffer_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.create_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.CreateQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CreateQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.CreateQueueRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta3.types.Queue" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "create_queue" + }, + "description": "Sample for CreateQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_create_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_CreateQueue_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": "cloudtasks_v2beta3_generated_cloud_tasks_create_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.create_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.CreateQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CreateQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.CreateQueueRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta3.types.Queue" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "create_queue" + }, + "description": "Sample for CreateQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_create_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_CreateQueue_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": "cloudtasks_v2beta3_generated_cloud_tasks_create_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.create_task", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.CreateTask", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CreateTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.CreateTaskRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "task", + "type": "google.cloud.tasks_v2beta3.types.Task" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Task", + "shortName": "create_task" + }, + "description": "Sample for CreateTask", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_create_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_CreateTask_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": "cloudtasks_v2beta3_generated_cloud_tasks_create_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.create_task", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.CreateTask", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "CreateTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.CreateTaskRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "task", + "type": "google.cloud.tasks_v2beta3.types.Task" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Task", + "shortName": "create_task" + }, + "description": "Sample for CreateTask", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_create_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_CreateTask_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": "cloudtasks_v2beta3_generated_cloud_tasks_create_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.delete_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.DeleteQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "DeleteQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.DeleteQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_queue" + }, + "description": "Sample for DeleteQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_DeleteQueue_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.delete_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.DeleteQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "DeleteQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.DeleteQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_queue" + }, + "description": "Sample for DeleteQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_DeleteQueue_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.delete_task", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.DeleteTask", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "DeleteTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.DeleteTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_task" + }, + "description": "Sample for DeleteTask", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_delete_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_DeleteTask_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_delete_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.delete_task", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.DeleteTask", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "DeleteTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.DeleteTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_task" + }, + "description": "Sample for DeleteTask", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_delete_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_DeleteTask_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_delete_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.get_iam_policy", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.GetIamPolicy", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" + }, + "description": "Sample for GetIamPolicy", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_GetIamPolicy_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.get_iam_policy", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.GetIamPolicy", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" + }, + "description": "Sample for GetIamPolicy", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_GetIamPolicy_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.get_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.GetQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.GetQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "get_queue" + }, + "description": "Sample for GetQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_get_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_GetQueue_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": "cloudtasks_v2beta3_generated_cloud_tasks_get_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.get_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.GetQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.GetQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "get_queue" + }, + "description": "Sample for GetQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_get_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_GetQueue_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": "cloudtasks_v2beta3_generated_cloud_tasks_get_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.get_task", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.GetTask", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.GetTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Task", + "shortName": "get_task" + }, + "description": "Sample for GetTask", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_get_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_GetTask_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": "cloudtasks_v2beta3_generated_cloud_tasks_get_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.get_task", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.GetTask", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "GetTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.GetTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Task", + "shortName": "get_task" + }, + "description": "Sample for GetTask", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_get_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_GetTask_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": "cloudtasks_v2beta3_generated_cloud_tasks_get_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.list_queues", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.ListQueues", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ListQueues" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.ListQueuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListQueuesAsyncPager", + "shortName": "list_queues" + }, + "description": "Sample for ListQueues", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_list_queues_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_ListQueues_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": "cloudtasks_v2beta3_generated_cloud_tasks_list_queues_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.list_queues", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.ListQueues", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ListQueues" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.ListQueuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListQueuesPager", + "shortName": "list_queues" + }, + "description": "Sample for ListQueues", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_list_queues_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_ListQueues_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": "cloudtasks_v2beta3_generated_cloud_tasks_list_queues_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.list_tasks", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.ListTasks", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ListTasks" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.ListTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListTasksAsyncPager", + "shortName": "list_tasks" + }, + "description": "Sample for ListTasks", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_ListTasks_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": "cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.list_tasks", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.ListTasks", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ListTasks" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.ListTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListTasksPager", + "shortName": "list_tasks" + }, + "description": "Sample for ListTasks", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_ListTasks_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": "cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.pause_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.PauseQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "PauseQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.PauseQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "pause_queue" + }, + "description": "Sample for PauseQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_PauseQueue_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": "cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.pause_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.PauseQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "PauseQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.PauseQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "pause_queue" + }, + "description": "Sample for PauseQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_PauseQueue_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": "cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.purge_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.PurgeQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "PurgeQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.PurgeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "purge_queue" + }, + "description": "Sample for PurgeQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_PurgeQueue_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": "cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.purge_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.PurgeQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "PurgeQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.PurgeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "purge_queue" + }, + "description": "Sample for PurgeQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_PurgeQueue_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": "cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.resume_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.ResumeQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ResumeQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.ResumeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "resume_queue" + }, + "description": "Sample for ResumeQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_ResumeQueue_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": "cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.resume_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.ResumeQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "ResumeQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.ResumeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "resume_queue" + }, + "description": "Sample for ResumeQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_ResumeQueue_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": "cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.run_task", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.RunTask", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "RunTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.RunTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Task", + "shortName": "run_task" + }, + "description": "Sample for RunTask", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_run_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_RunTask_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": "cloudtasks_v2beta3_generated_cloud_tasks_run_task_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.run_task", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.RunTask", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "RunTask" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.RunTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Task", + "shortName": "run_task" + }, + "description": "Sample for RunTask", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_run_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_RunTask_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": "cloudtasks_v2beta3_generated_cloud_tasks_run_task_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.set_iam_policy", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.SetIamPolicy", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "SetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" + }, + "description": "Sample for SetIamPolicy", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_SetIamPolicy_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.set_iam_policy", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.SetIamPolicy", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "SetIamPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" + }, + "description": "Sample for SetIamPolicy", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_SetIamPolicy_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.test_iam_permissions", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.TestIamPermissions", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "TestIamPermissions" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "MutableSequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" + }, + "description": "Sample for TestIamPermissions", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_TestIamPermissions_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.test_iam_permissions", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.TestIamPermissions", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "TestIamPermissions" + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "MutableSequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" + }, + "description": "Sample for TestIamPermissions", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_TestIamPermissions_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 41, + "start": 39, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 42, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.update_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.UpdateQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "UpdateQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.UpdateQueueRequest" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta3.types.Queue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "update_queue" + }, + "description": "Sample for UpdateQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_update_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_UpdateQueue_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_update_queue_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.update_queue", + "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.UpdateQueue", + "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", + "shortName": "CloudTasks" + }, + "shortName": "UpdateQueue" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.UpdateQueueRequest" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta3.types.Queue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "update_queue" + }, + "description": "Sample for UpdateQueue", + "file": "cloudtasks_v2beta3_generated_cloud_tasks_update_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_UpdateQueue_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_update_queue_sync.py" + } + ] +} diff --git a/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2/test_cloud_tasks.py b/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2/test_cloud_tasks.py index 1a7a193a9277..e0c6270a8d6a 100644 --- a/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2/test_cloud_tasks.py +++ b/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2/test_cloud_tasks.py @@ -4922,8 +4922,9 @@ def test_list_queues_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListQueuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListQueuesResponse.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 @@ -5004,8 +5005,9 @@ def test_list_queues_rest_required_fields(request_type=cloudtasks.ListQueuesRequ response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListQueuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListQueuesResponse.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 @@ -5137,8 +5139,9 @@ def test_list_queues_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListQueuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListQueuesResponse.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 @@ -5258,8 +5261,9 @@ def test_get_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -5333,8 +5337,9 @@ def test_get_queue_rest_required_fields(request_type=cloudtasks.GetQueueRequest) response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -5455,8 +5460,9 @@ def test_get_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -5532,6 +5538,73 @@ def test_create_queue_rest(request_type): "purge_time": {"seconds": 751, "nanos": 543}, "stackdriver_logging_config": {"sampling_ratio": 0.1497}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = cloudtasks.CreateQueueRequest.meta.fields["queue"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["queue"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["queue"][field])): + del request_init["queue"][field][i][subfield] + else: + del request_init["queue"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -5545,8 +5618,9 @@ def test_create_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -5621,8 +5695,9 @@ def test_create_queue_rest_required_fields(request_type=cloudtasks.CreateQueueRe response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -5714,30 +5789,6 @@ def test_create_queue_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["queue"] = { - "name": "name_value", - "app_engine_routing_override": { - "service": "service_value", - "version": "version_value", - "instance": "instance_value", - "host": "host_value", - }, - "rate_limits": { - "max_dispatches_per_second": 0.26380000000000003, - "max_burst_size": 1519, - "max_concurrent_dispatches": 2671, - }, - "retry_config": { - "max_attempts": 1303, - "max_retry_duration": {"seconds": 751, "nanos": 543}, - "min_backoff": {}, - "max_backoff": {}, - "max_doublings": 1388, - }, - "state": 1, - "purge_time": {"seconds": 751, "nanos": 543}, - "stackdriver_logging_config": {"sampling_ratio": 0.1497}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -5776,8 +5827,9 @@ def test_create_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -5856,6 +5908,73 @@ def test_update_queue_rest(request_type): "purge_time": {"seconds": 751, "nanos": 543}, "stackdriver_logging_config": {"sampling_ratio": 0.1497}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = cloudtasks.UpdateQueueRequest.meta.fields["queue"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["queue"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["queue"][field])): + del request_init["queue"][field][i][subfield] + else: + del request_init["queue"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -5869,8 +5988,9 @@ def test_update_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -5942,8 +6062,9 @@ def test_update_queue_rest_required_fields(request_type=cloudtasks.UpdateQueueRe response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -6029,30 +6150,6 @@ def test_update_queue_rest_bad_request( request_init = { "queue": {"name": "projects/sample1/locations/sample2/queues/sample3"} } - request_init["queue"] = { - "name": "projects/sample1/locations/sample2/queues/sample3", - "app_engine_routing_override": { - "service": "service_value", - "version": "version_value", - "instance": "instance_value", - "host": "host_value", - }, - "rate_limits": { - "max_dispatches_per_second": 0.26380000000000003, - "max_burst_size": 1519, - "max_concurrent_dispatches": 2671, - }, - "retry_config": { - "max_attempts": 1303, - "max_retry_duration": {"seconds": 751, "nanos": 543}, - "min_backoff": {}, - "max_backoff": {}, - "max_doublings": 1388, - }, - "state": 1, - "purge_time": {"seconds": 751, "nanos": 543}, - "stackdriver_logging_config": {"sampling_ratio": 0.1497}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -6093,8 +6190,9 @@ def test_update_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -6409,8 +6507,9 @@ def test_purge_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -6485,8 +6584,9 @@ def test_purge_queue_rest_required_fields(request_type=cloudtasks.PurgeQueueRequ response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -6607,8 +6707,9 @@ def test_purge_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -6674,8 +6775,9 @@ def test_pause_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -6750,8 +6852,9 @@ def test_pause_queue_rest_required_fields(request_type=cloudtasks.PauseQueueRequ response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -6872,8 +6975,9 @@ def test_pause_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -6939,8 +7043,9 @@ def test_resume_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -7015,8 +7120,9 @@ def test_resume_queue_rest_required_fields(request_type=cloudtasks.ResumeQueueRe response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -7137,8 +7243,9 @@ def test_resume_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -7204,8 +7311,7 @@ def test_get_iam_policy_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -7282,8 +7388,7 @@ def test_get_iam_policy_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -7406,8 +7511,7 @@ def test_get_iam_policy_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -7473,8 +7577,7 @@ def test_set_iam_policy_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -7551,8 +7654,7 @@ def test_set_iam_policy_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -7683,8 +7785,7 @@ def test_set_iam_policy_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -7749,8 +7850,7 @@ def test_test_iam_permissions_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -7830,8 +7930,7 @@ def test_test_iam_permissions_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -7965,8 +8064,7 @@ def test_test_iam_permissions_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -8032,8 +8130,9 @@ def test_list_tasks_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListTasksResponse.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 @@ -8114,8 +8213,9 @@ def test_list_tasks_rest_required_fields(request_type=cloudtasks.ListTasksReques response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListTasksResponse.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 @@ -8247,8 +8347,9 @@ def test_list_tasks_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListTasksResponse.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 @@ -8373,8 +8474,9 @@ def test_get_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -8452,8 +8554,9 @@ def test_get_task_rest_required_fields(request_type=cloudtasks.GetTaskRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -8578,8 +8681,9 @@ def test_get_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -8647,8 +8751,9 @@ def test_create_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_task.Task.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 @@ -8725,8 +8830,9 @@ def test_create_task_rest_required_fields(request_type=cloudtasks.CreateTaskRequ response_value = Response() response_value.status_code = 200 - pb_return_value = gct_task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_task.Task.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 @@ -8856,8 +8962,9 @@ def test_create_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_task.Task.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 @@ -9183,8 +9290,9 @@ def test_run_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -9261,8 +9369,9 @@ def test_run_task_rest_required_fields(request_type=cloudtasks.RunTaskRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -9387,8 +9496,9 @@ def test_run_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 diff --git a/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py b/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py index c6dbddda9e23..2e70341ecc80 100644 --- a/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py +++ b/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py @@ -6194,8 +6194,9 @@ def test_list_queues_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListQueuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListQueuesResponse.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 @@ -6277,8 +6278,9 @@ def test_list_queues_rest_required_fields(request_type=cloudtasks.ListQueuesRequ response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListQueuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListQueuesResponse.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 @@ -6411,8 +6413,9 @@ def test_list_queues_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListQueuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListQueuesResponse.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 @@ -6533,8 +6536,9 @@ def test_get_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -6610,8 +6614,9 @@ def test_get_queue_rest_required_fields(request_type=cloudtasks.GetQueueRequest) response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -6732,8 +6737,9 @@ def test_get_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -6844,6 +6850,73 @@ def test_create_queue_rest(request_type): "effective_execution_rate": 0.2543, }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = cloudtasks.CreateQueueRequest.meta.fields["queue"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["queue"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["queue"][field])): + del request_init["queue"][field][i][subfield] + else: + del request_init["queue"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -6857,8 +6930,9 @@ def test_create_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -6933,8 +7007,9 @@ def test_create_queue_rest_required_fields(request_type=cloudtasks.CreateQueueRe response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -7026,64 +7101,6 @@ def test_create_queue_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["queue"] = { - "name": "name_value", - "app_engine_http_target": { - "app_engine_routing_override": { - "service": "service_value", - "version": "version_value", - "instance": "instance_value", - "host": "host_value", - } - }, - "pull_target": {}, - "http_target": { - "uri_override": { - "scheme": 1, - "host": "host_value", - "port": 453, - "path_override": {"path": "path_value"}, - "query_override": {"query_params": "query_params_value"}, - "uri_override_enforce_mode": 1, - }, - "http_method": 1, - "header_overrides": [ - {"header": {"key": "key_value", "value": "value_value"}} - ], - "oauth_token": { - "service_account_email": "service_account_email_value", - "scope": "scope_value", - }, - "oidc_token": { - "service_account_email": "service_account_email_value", - "audience": "audience_value", - }, - }, - "rate_limits": { - "max_tasks_dispatched_per_second": 0.32680000000000003, - "max_burst_size": 1519, - "max_concurrent_tasks": 2157, - }, - "retry_config": { - "max_attempts": 1303, - "unlimited_attempts": True, - "max_retry_duration": {"seconds": 751, "nanos": 543}, - "min_backoff": {}, - "max_backoff": {}, - "max_doublings": 1388, - }, - "state": 1, - "purge_time": {"seconds": 751, "nanos": 543}, - "task_ttl": {}, - "tombstone_ttl": {}, - "stats": { - "tasks_count": 1198, - "oldest_estimated_arrival_time": {}, - "executed_last_minute_count": 2787, - "concurrent_dispatches_count": 2898, - "effective_execution_rate": 0.2543, - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -7122,8 +7139,9 @@ def test_create_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -7237,6 +7255,73 @@ def test_update_queue_rest(request_type): "effective_execution_rate": 0.2543, }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = cloudtasks.UpdateQueueRequest.meta.fields["queue"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["queue"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["queue"][field])): + del request_init["queue"][field][i][subfield] + else: + del request_init["queue"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -7250,8 +7335,9 @@ def test_update_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -7323,8 +7409,9 @@ def test_update_queue_rest_required_fields(request_type=cloudtasks.UpdateQueueRe response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -7410,64 +7497,6 @@ def test_update_queue_rest_bad_request( request_init = { "queue": {"name": "projects/sample1/locations/sample2/queues/sample3"} } - request_init["queue"] = { - "name": "projects/sample1/locations/sample2/queues/sample3", - "app_engine_http_target": { - "app_engine_routing_override": { - "service": "service_value", - "version": "version_value", - "instance": "instance_value", - "host": "host_value", - } - }, - "pull_target": {}, - "http_target": { - "uri_override": { - "scheme": 1, - "host": "host_value", - "port": 453, - "path_override": {"path": "path_value"}, - "query_override": {"query_params": "query_params_value"}, - "uri_override_enforce_mode": 1, - }, - "http_method": 1, - "header_overrides": [ - {"header": {"key": "key_value", "value": "value_value"}} - ], - "oauth_token": { - "service_account_email": "service_account_email_value", - "scope": "scope_value", - }, - "oidc_token": { - "service_account_email": "service_account_email_value", - "audience": "audience_value", - }, - }, - "rate_limits": { - "max_tasks_dispatched_per_second": 0.32680000000000003, - "max_burst_size": 1519, - "max_concurrent_tasks": 2157, - }, - "retry_config": { - "max_attempts": 1303, - "unlimited_attempts": True, - "max_retry_duration": {"seconds": 751, "nanos": 543}, - "min_backoff": {}, - "max_backoff": {}, - "max_doublings": 1388, - }, - "state": 1, - "purge_time": {"seconds": 751, "nanos": 543}, - "task_ttl": {}, - "tombstone_ttl": {}, - "stats": { - "tasks_count": 1198, - "oldest_estimated_arrival_time": {}, - "executed_last_minute_count": 2787, - "concurrent_dispatches_count": 2898, - "effective_execution_rate": 0.2543, - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -7508,8 +7537,9 @@ def test_update_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -7825,8 +7855,9 @@ def test_purge_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -7901,8 +7932,9 @@ def test_purge_queue_rest_required_fields(request_type=cloudtasks.PurgeQueueRequ response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -8023,8 +8055,9 @@ def test_purge_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -8090,8 +8123,9 @@ def test_pause_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -8166,8 +8200,9 @@ def test_pause_queue_rest_required_fields(request_type=cloudtasks.PauseQueueRequ response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -8288,8 +8323,9 @@ def test_pause_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -8355,8 +8391,9 @@ def test_resume_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -8431,8 +8468,9 @@ def test_resume_queue_rest_required_fields(request_type=cloudtasks.ResumeQueueRe response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -8553,8 +8591,9 @@ def test_resume_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -8630,8 +8669,7 @@ def test_get_iam_policy_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -8708,8 +8746,7 @@ def test_get_iam_policy_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -8832,8 +8869,7 @@ def test_get_iam_policy_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -8899,8 +8935,7 @@ def test_set_iam_policy_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -8977,8 +9012,7 @@ def test_set_iam_policy_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -9109,8 +9143,7 @@ def test_set_iam_policy_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -9175,8 +9208,7 @@ def test_test_iam_permissions_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -9256,8 +9288,7 @@ def test_test_iam_permissions_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -9391,8 +9422,7 @@ def test_test_iam_permissions_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -9458,8 +9488,9 @@ def test_list_tasks_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListTasksResponse.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 @@ -9540,8 +9571,9 @@ def test_list_tasks_rest_required_fields(request_type=cloudtasks.ListTasksReques response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListTasksResponse.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 @@ -9673,8 +9705,9 @@ def test_list_tasks_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListTasksResponse.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 @@ -9797,8 +9830,9 @@ def test_get_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -9874,8 +9908,9 @@ def test_get_task_rest_required_fields(request_type=cloudtasks.GetTaskRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -10000,8 +10035,9 @@ def test_get_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -10067,8 +10103,9 @@ def test_create_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_task.Task.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 @@ -10143,8 +10180,9 @@ def test_create_task_rest_required_fields(request_type=cloudtasks.CreateTaskRequ response_value = Response() response_value.status_code = 200 - pb_return_value = gct_task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_task.Task.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 @@ -10274,8 +10312,9 @@ def test_create_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_task.Task.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 @@ -10594,8 +10633,9 @@ def test_lease_tasks_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.LeaseTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.LeaseTasksResponse.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 @@ -10668,8 +10708,9 @@ def test_lease_tasks_rest_required_fields(request_type=cloudtasks.LeaseTasksRequ response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.LeaseTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.LeaseTasksResponse.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 @@ -10801,8 +10842,9 @@ def test_lease_tasks_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.LeaseTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.LeaseTasksResponse.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 @@ -11141,8 +11183,9 @@ def test_renew_lease_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -11217,8 +11260,9 @@ def test_renew_lease_rest_required_fields(request_type=cloudtasks.RenewLeaseRequ response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -11354,8 +11398,9 @@ def test_renew_lease_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -11425,8 +11470,9 @@ def test_cancel_lease_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -11501,8 +11547,9 @@ def test_cancel_lease_rest_required_fields(request_type=cloudtasks.CancelLeaseRe response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -11636,8 +11683,9 @@ def test_cancel_lease_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -11706,8 +11754,9 @@ def test_run_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -11782,8 +11831,9 @@ def test_run_task_rest_required_fields(request_type=cloudtasks.RunTaskRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -11908,8 +11958,9 @@ def test_run_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -11975,8 +12026,9 @@ def test_buffer_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.BufferTaskResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.BufferTaskResponse.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 @@ -12049,8 +12101,9 @@ def test_buffer_task_rest_required_fields(request_type=cloudtasks.BufferTaskRequ response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.BufferTaskResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.BufferTaskResponse.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 @@ -12181,8 +12234,9 @@ def test_buffer_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.BufferTaskResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.BufferTaskResponse.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 diff --git a/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py b/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py index f0aa7de98f4c..c9ecee3569ff 100644 --- a/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py +++ b/packages/google-cloud-tasks/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py @@ -5195,8 +5195,9 @@ def test_list_queues_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListQueuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListQueuesResponse.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 @@ -5278,8 +5279,9 @@ def test_list_queues_rest_required_fields(request_type=cloudtasks.ListQueuesRequ response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListQueuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListQueuesResponse.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 @@ -5412,8 +5414,9 @@ def test_list_queues_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListQueuesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListQueuesResponse.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 @@ -5535,8 +5538,9 @@ def test_get_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -5613,8 +5617,9 @@ def test_get_queue_rest_required_fields(request_type=cloudtasks.GetQueueRequest) response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -5735,8 +5740,9 @@ def test_get_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -5847,6 +5853,73 @@ def test_create_queue_rest(request_type): "effective_execution_rate": 0.2543, }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = cloudtasks.CreateQueueRequest.meta.fields["queue"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["queue"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["queue"][field])): + del request_init["queue"][field][i][subfield] + else: + del request_init["queue"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -5861,8 +5934,9 @@ def test_create_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -5938,8 +6012,9 @@ def test_create_queue_rest_required_fields(request_type=cloudtasks.CreateQueueRe response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -6031,64 +6106,6 @@ def test_create_queue_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["queue"] = { - "name": "name_value", - "app_engine_http_queue": { - "app_engine_routing_override": { - "service": "service_value", - "version": "version_value", - "instance": "instance_value", - "host": "host_value", - } - }, - "http_target": { - "uri_override": { - "scheme": 1, - "host": "host_value", - "port": 453, - "path_override": {"path": "path_value"}, - "query_override": {"query_params": "query_params_value"}, - "uri_override_enforce_mode": 1, - }, - "http_method": 1, - "header_overrides": [ - {"header": {"key": "key_value", "value": "value_value"}} - ], - "oauth_token": { - "service_account_email": "service_account_email_value", - "scope": "scope_value", - }, - "oidc_token": { - "service_account_email": "service_account_email_value", - "audience": "audience_value", - }, - }, - "rate_limits": { - "max_dispatches_per_second": 0.26380000000000003, - "max_burst_size": 1519, - "max_concurrent_dispatches": 2671, - }, - "retry_config": { - "max_attempts": 1303, - "max_retry_duration": {"seconds": 751, "nanos": 543}, - "min_backoff": {}, - "max_backoff": {}, - "max_doublings": 1388, - }, - "state": 1, - "purge_time": {"seconds": 751, "nanos": 543}, - "task_ttl": {}, - "tombstone_ttl": {}, - "stackdriver_logging_config": {"sampling_ratio": 0.1497}, - "type_": 1, - "stats": { - "tasks_count": 1198, - "oldest_estimated_arrival_time": {}, - "executed_last_minute_count": 2787, - "concurrent_dispatches_count": 2898, - "effective_execution_rate": 0.2543, - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -6127,8 +6144,9 @@ def test_create_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -6242,6 +6260,73 @@ def test_update_queue_rest(request_type): "effective_execution_rate": 0.2543, }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = cloudtasks.UpdateQueueRequest.meta.fields["queue"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["queue"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["queue"][field])): + del request_init["queue"][field][i][subfield] + else: + del request_init["queue"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -6256,8 +6341,9 @@ def test_update_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -6330,8 +6416,9 @@ def test_update_queue_rest_required_fields(request_type=cloudtasks.UpdateQueueRe response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -6417,64 +6504,6 @@ def test_update_queue_rest_bad_request( request_init = { "queue": {"name": "projects/sample1/locations/sample2/queues/sample3"} } - request_init["queue"] = { - "name": "projects/sample1/locations/sample2/queues/sample3", - "app_engine_http_queue": { - "app_engine_routing_override": { - "service": "service_value", - "version": "version_value", - "instance": "instance_value", - "host": "host_value", - } - }, - "http_target": { - "uri_override": { - "scheme": 1, - "host": "host_value", - "port": 453, - "path_override": {"path": "path_value"}, - "query_override": {"query_params": "query_params_value"}, - "uri_override_enforce_mode": 1, - }, - "http_method": 1, - "header_overrides": [ - {"header": {"key": "key_value", "value": "value_value"}} - ], - "oauth_token": { - "service_account_email": "service_account_email_value", - "scope": "scope_value", - }, - "oidc_token": { - "service_account_email": "service_account_email_value", - "audience": "audience_value", - }, - }, - "rate_limits": { - "max_dispatches_per_second": 0.26380000000000003, - "max_burst_size": 1519, - "max_concurrent_dispatches": 2671, - }, - "retry_config": { - "max_attempts": 1303, - "max_retry_duration": {"seconds": 751, "nanos": 543}, - "min_backoff": {}, - "max_backoff": {}, - "max_doublings": 1388, - }, - "state": 1, - "purge_time": {"seconds": 751, "nanos": 543}, - "task_ttl": {}, - "tombstone_ttl": {}, - "stackdriver_logging_config": {"sampling_ratio": 0.1497}, - "type_": 1, - "stats": { - "tasks_count": 1198, - "oldest_estimated_arrival_time": {}, - "executed_last_minute_count": 2787, - "concurrent_dispatches_count": 2898, - "effective_execution_rate": 0.2543, - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -6515,8 +6544,9 @@ def test_update_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_queue.Queue.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 @@ -6833,8 +6863,9 @@ def test_purge_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -6910,8 +6941,9 @@ def test_purge_queue_rest_required_fields(request_type=cloudtasks.PurgeQueueRequ response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -7032,8 +7064,9 @@ def test_purge_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -7100,8 +7133,9 @@ def test_pause_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -7177,8 +7211,9 @@ def test_pause_queue_rest_required_fields(request_type=cloudtasks.PauseQueueRequ response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -7299,8 +7334,9 @@ def test_pause_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -7367,8 +7403,9 @@ def test_resume_queue_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -7444,8 +7481,9 @@ def test_resume_queue_rest_required_fields(request_type=cloudtasks.ResumeQueueRe response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -7566,8 +7604,9 @@ def test_resume_queue_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = queue.Queue.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = queue.Queue.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 @@ -7633,8 +7672,7 @@ def test_get_iam_policy_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -7711,8 +7749,7 @@ def test_get_iam_policy_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -7835,8 +7872,7 @@ def test_get_iam_policy_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -7902,8 +7938,7 @@ def test_set_iam_policy_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -7980,8 +8015,7 @@ def test_set_iam_policy_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -8112,8 +8146,7 @@ def test_set_iam_policy_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -8178,8 +8211,7 @@ def test_test_iam_permissions_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -8259,8 +8291,7 @@ def test_test_iam_permissions_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -8394,8 +8425,7 @@ def test_test_iam_permissions_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = return_value - json_return_value = json_format.MessageToJson(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 @@ -8461,8 +8491,9 @@ def test_list_tasks_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListTasksResponse.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 @@ -8543,8 +8574,9 @@ def test_list_tasks_rest_required_fields(request_type=cloudtasks.ListTasksReques response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListTasksResponse.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 @@ -8676,8 +8708,9 @@ def test_list_tasks_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.ListTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.ListTasksResponse.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 @@ -8802,8 +8835,9 @@ def test_get_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -8881,8 +8915,9 @@ def test_get_task_rest_required_fields(request_type=cloudtasks.GetTaskRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -9007,8 +9042,9 @@ def test_get_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -9076,8 +9112,9 @@ def test_create_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_task.Task.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 @@ -9154,8 +9191,9 @@ def test_create_task_rest_required_fields(request_type=cloudtasks.CreateTaskRequ response_value = Response() response_value.status_code = 200 - pb_return_value = gct_task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_task.Task.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 @@ -9285,8 +9323,9 @@ def test_create_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gct_task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gct_task.Task.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 @@ -9612,8 +9651,9 @@ def test_run_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -9690,8 +9730,9 @@ def test_run_task_rest_required_fields(request_type=cloudtasks.RunTaskRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -9816,8 +9857,9 @@ def test_run_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task.Task.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 @@ -9883,8 +9925,9 @@ def test_buffer_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.BufferTaskResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.BufferTaskResponse.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 @@ -9957,8 +10000,9 @@ def test_buffer_task_rest_required_fields(request_type=cloudtasks.BufferTaskRequ response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.BufferTaskResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.BufferTaskResponse.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 @@ -10089,8 +10133,9 @@ def test_buffer_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloudtasks.BufferTaskResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloudtasks.BufferTaskResponse.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 diff --git a/packages/google-cloud-tpu/CONTRIBUTING.rst b/packages/google-cloud-tpu/CONTRIBUTING.rst index da5ce292c847..f68df1af98b0 100644 --- a/packages/google-cloud-tpu/CONTRIBUTING.rst +++ b/packages/google-cloud-tpu/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py index 725b83961de2..360a0d13ebdd 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py +++ b/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.16.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/gapic_version.py index 725b83961de2..360a0d13ebdd 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/gapic_version.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.16.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu_v2/gapic_version.py index 725b83961de2..360a0d13ebdd 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2/gapic_version.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.16.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/gapic_version.py index 725b83961de2..360a0d13ebdd 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/gapic_version.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.16.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/noxfile.py b/packages/google-cloud-tpu/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-tpu/noxfile.py +++ b/packages/google-cloud-tpu/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json index d41f7b6d4288..0a659a05f598 100644 --- a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json +++ b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tpu", - "version": "1.16.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json index 99d34ea37e91..1b6219f228fc 100644 --- a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json +++ b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tpu", - "version": "1.16.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json index 5044fb036444..2ee393567ba2 100644 --- a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json +++ b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tpu", - "version": "1.16.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-tpu/tests/unit/gapic/tpu_v2/test_tpu.py b/packages/google-cloud-tpu/tests/unit/gapic/tpu_v2/test_tpu.py index 873b4d848a5a..6342b4f2f6a9 100644 --- a/packages/google-cloud-tpu/tests/unit/gapic/tpu_v2/test_tpu.py +++ b/packages/google-cloud-tpu/tests/unit/gapic/tpu_v2/test_tpu.py @@ -4084,8 +4084,9 @@ def test_list_nodes_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.ListNodesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.ListNodesResponse.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 @@ -4166,8 +4167,9 @@ def test_list_nodes_rest_required_fields(request_type=cloud_tpu.ListNodesRequest response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.ListNodesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.ListNodesResponse.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 @@ -4296,8 +4298,9 @@ def test_list_nodes_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.ListNodesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.ListNodesResponse.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 @@ -4428,8 +4431,9 @@ def test_get_node_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.Node.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.Node.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 @@ -4514,8 +4518,9 @@ def test_get_node_rest_required_fields(request_type=cloud_tpu.GetNodeRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.Node.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.Node.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 @@ -4634,8 +4639,9 @@ def test_get_node_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.Node.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.Node.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 @@ -4734,6 +4740,73 @@ def test_create_node_rest(request_type): "queued_resource": "queued_resource_value", "multislice_node": True, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = cloud_tpu.CreateNodeRequest.meta.fields["node"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["node"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["node"][field])): + del request_init["node"][field][i][subfield] + else: + del request_init["node"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -4912,53 +4985,6 @@ def test_create_node_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["node"] = { - "name": "name_value", - "description": "description_value", - "accelerator_type": "accelerator_type_value", - "state": 1, - "health_description": "health_description_value", - "runtime_version": "runtime_version_value", - "network_config": { - "network": "network_value", - "subnetwork": "subnetwork_value", - "enable_external_ips": True, - "can_ip_forward": True, - }, - "cidr_block": "cidr_block_value", - "service_account": { - "email": "email_value", - "scope": ["scope_value1", "scope_value2"], - }, - "create_time": {"seconds": 751, "nanos": 543}, - "scheduling_config": {"preemptible": True, "reserved": True}, - "network_endpoints": [ - { - "ip_address": "ip_address_value", - "port": 453, - "access_config": {"external_ip": "external_ip_value"}, - } - ], - "health": 1, - "labels": {}, - "metadata": {}, - "tags": ["tags_value1", "tags_value2"], - "id": 205, - "data_disks": [{"source_disk": "source_disk_value", "mode": 1}], - "api_version": 1, - "symptoms": [ - { - "create_time": {}, - "symptom_type": 1, - "details": "details_value", - "worker_id": "worker_id_value", - } - ], - "shielded_instance_config": {"enable_secure_boot": True}, - "accelerator_config": {"type_": 2, "topology": "topology_value"}, - "queued_resource": "queued_resource_value", - "multislice_node": True, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -5763,6 +5789,73 @@ def test_update_node_rest(request_type): "queued_resource": "queued_resource_value", "multislice_node": True, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = cloud_tpu.UpdateNodeRequest.meta.fields["node"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["node"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["node"][field])): + del request_init["node"][field][i][subfield] + else: + del request_init["node"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -5938,53 +6031,6 @@ def test_update_node_rest_bad_request( request_init = { "node": {"name": "projects/sample1/locations/sample2/nodes/sample3"} } - request_init["node"] = { - "name": "projects/sample1/locations/sample2/nodes/sample3", - "description": "description_value", - "accelerator_type": "accelerator_type_value", - "state": 1, - "health_description": "health_description_value", - "runtime_version": "runtime_version_value", - "network_config": { - "network": "network_value", - "subnetwork": "subnetwork_value", - "enable_external_ips": True, - "can_ip_forward": True, - }, - "cidr_block": "cidr_block_value", - "service_account": { - "email": "email_value", - "scope": ["scope_value1", "scope_value2"], - }, - "create_time": {"seconds": 751, "nanos": 543}, - "scheduling_config": {"preemptible": True, "reserved": True}, - "network_endpoints": [ - { - "ip_address": "ip_address_value", - "port": 453, - "access_config": {"external_ip": "external_ip_value"}, - } - ], - "health": 1, - "labels": {}, - "metadata": {}, - "tags": ["tags_value1", "tags_value2"], - "id": 205, - "data_disks": [{"source_disk": "source_disk_value", "mode": 1}], - "api_version": 1, - "symptoms": [ - { - "create_time": {}, - "symptom_type": 1, - "details": "details_value", - "worker_id": "worker_id_value", - } - ], - "shielded_instance_config": {"enable_secure_boot": True}, - "accelerator_config": {"type_": 2, "topology": "topology_value"}, - "queued_resource": "queued_resource_value", - "multislice_node": True, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -6088,8 +6134,9 @@ def test_generate_service_identity_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.GenerateServiceIdentityResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.GenerateServiceIdentityResponse.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 @@ -6164,8 +6211,9 @@ def test_generate_service_identity_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.GenerateServiceIdentityResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.GenerateServiceIdentityResponse.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 @@ -6299,8 +6347,9 @@ def test_list_accelerator_types_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.ListAcceleratorTypesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.ListAcceleratorTypesResponse.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 @@ -6385,8 +6434,9 @@ def test_list_accelerator_types_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.ListAcceleratorTypesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.ListAcceleratorTypesResponse.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 @@ -6519,8 +6569,9 @@ def test_list_accelerator_types_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.ListAcceleratorTypesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.ListAcceleratorTypesResponse.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 @@ -6645,8 +6696,9 @@ def test_get_accelerator_type_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.AcceleratorType.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.AcceleratorType.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 @@ -6722,8 +6774,9 @@ def test_get_accelerator_type_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.AcceleratorType.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.AcceleratorType.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 @@ -6850,8 +6903,9 @@ def test_get_accelerator_type_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.AcceleratorType.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.AcceleratorType.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 @@ -6917,8 +6971,9 @@ def test_list_runtime_versions_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.ListRuntimeVersionsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.ListRuntimeVersionsResponse.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 @@ -7003,8 +7058,9 @@ def test_list_runtime_versions_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.ListRuntimeVersionsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.ListRuntimeVersionsResponse.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 @@ -7137,8 +7193,9 @@ def test_list_runtime_versions_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.ListRuntimeVersionsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.ListRuntimeVersionsResponse.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 @@ -7263,8 +7320,9 @@ def test_get_runtime_version_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.RuntimeVersion.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.RuntimeVersion.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 @@ -7340,8 +7398,9 @@ def test_get_runtime_version_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.RuntimeVersion.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.RuntimeVersion.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 @@ -7468,8 +7527,9 @@ def test_get_runtime_version_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.RuntimeVersion.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.RuntimeVersion.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 @@ -7532,8 +7592,9 @@ def test_get_guest_attributes_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.GetGuestAttributesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.GetGuestAttributesResponse.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 @@ -7608,8 +7669,9 @@ def test_get_guest_attributes_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = cloud_tpu.GetGuestAttributesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = cloud_tpu.GetGuestAttributesResponse.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 diff --git a/packages/google-cloud-video-live-stream/CONTRIBUTING.rst b/packages/google-cloud-video-live-stream/CONTRIBUTING.rst index c3de31ad8fbf..827f32bc2a2a 100644 --- a/packages/google-cloud-video-live-stream/CONTRIBUTING.rst +++ b/packages/google-cloud-video-live-stream/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream/gapic_version.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream/gapic_version.py index 9bb24ba52e7d..360a0d13ebdd 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream/gapic_version.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream/gapic_version.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2022 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.5.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/gapic_version.py b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/gapic_version.py index 9bb24ba52e7d..360a0d13ebdd 100644 --- a/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/gapic_version.py +++ b/packages/google-cloud-video-live-stream/google/cloud/video/live_stream_v1/gapic_version.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2022 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.5.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-live-stream/noxfile.py b/packages/google-cloud-video-live-stream/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-video-live-stream/noxfile.py +++ b/packages/google-cloud-video-live-stream/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_asset_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_asset_async.py new file mode 100644 index 000000000000..3287c377469f --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_asset_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateAsset +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_CreateAsset_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.video import live_stream_v1 + + +async def sample_create_asset(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.CreateAssetRequest( + parent="parent_value", + asset_id="asset_id_value", + ) + + # Make the request + operation = client.create_asset(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_CreateAsset_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_asset_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_asset_sync.py new file mode 100644 index 000000000000..8d5570e2e90b --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_asset_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateAsset +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_CreateAsset_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.video import live_stream_v1 + + +def sample_create_asset(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.CreateAssetRequest( + parent="parent_value", + asset_id="asset_id_value", + ) + + # Make the request + operation = client.create_asset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_CreateAsset_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_channel_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_channel_async.py new file mode 100644 index 000000000000..726fb7f8dd69 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_channel_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateChannel +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_CreateChannel_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.video import live_stream_v1 + + +async def sample_create_channel(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.CreateChannelRequest( + parent="parent_value", + channel_id="channel_id_value", + ) + + # Make the request + operation = client.create_channel(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_CreateChannel_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_channel_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_channel_sync.py new file mode 100644 index 000000000000..adaffbde6cc2 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_channel_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateChannel +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_CreateChannel_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.video import live_stream_v1 + + +def sample_create_channel(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.CreateChannelRequest( + parent="parent_value", + channel_id="channel_id_value", + ) + + # Make the request + operation = client.create_channel(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_CreateChannel_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_event_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_event_async.py new file mode 100644 index 000000000000..a10775c0fc6e --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_event_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateEvent +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_CreateEvent_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.video import live_stream_v1 + + +async def sample_create_event(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.CreateEventRequest( + parent="parent_value", + event_id="event_id_value", + ) + + # Make the request + response = await client.create_event(request=request) + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_CreateEvent_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_event_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_event_sync.py new file mode 100644 index 000000000000..5b6ac375e265 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_event_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateEvent +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_CreateEvent_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.video import live_stream_v1 + + +def sample_create_event(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.CreateEventRequest( + parent="parent_value", + event_id="event_id_value", + ) + + # Make the request + response = client.create_event(request=request) + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_CreateEvent_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_input_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_input_async.py new file mode 100644 index 000000000000..9217ba152c4b --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_input_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateInput +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_CreateInput_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.video import live_stream_v1 + + +async def sample_create_input(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.CreateInputRequest( + parent="parent_value", + input_id="input_id_value", + ) + + # Make the request + operation = client.create_input(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_CreateInput_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_input_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_input_sync.py new file mode 100644 index 000000000000..2fba224595f2 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_create_input_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateInput +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_CreateInput_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.video import live_stream_v1 + + +def sample_create_input(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.CreateInputRequest( + parent="parent_value", + input_id="input_id_value", + ) + + # Make the request + operation = client.create_input(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_CreateInput_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_asset_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_asset_async.py new file mode 100644 index 000000000000..5bd7c95183d4 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_asset_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteAsset +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_DeleteAsset_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.video import live_stream_v1 + + +async def sample_delete_asset(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.DeleteAssetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_asset(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_DeleteAsset_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_asset_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_asset_sync.py new file mode 100644 index 000000000000..a346c1a8fb6a --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_asset_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteAsset +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_DeleteAsset_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.video import live_stream_v1 + + +def sample_delete_asset(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.DeleteAssetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_asset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_DeleteAsset_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_channel_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_channel_async.py new file mode 100644 index 000000000000..d39c790ab797 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_channel_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteChannel +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_DeleteChannel_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.video import live_stream_v1 + + +async def sample_delete_channel(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.DeleteChannelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_channel(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_DeleteChannel_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_channel_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_channel_sync.py new file mode 100644 index 000000000000..4c5f8a16ff1c --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_channel_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteChannel +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_DeleteChannel_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.video import live_stream_v1 + + +def sample_delete_channel(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.DeleteChannelRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_channel(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_DeleteChannel_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_event_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_event_async.py new file mode 100644 index 000000000000..19fa084772ed --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_event_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteEvent +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_DeleteEvent_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.video import live_stream_v1 + + +async def sample_delete_event(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.DeleteEventRequest( + name="name_value", + ) + + # Make the request + await client.delete_event(request=request) + + +# [END livestream_v1_generated_LivestreamService_DeleteEvent_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_event_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_event_sync.py new file mode 100644 index 000000000000..970e674aa3b7 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_event_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteEvent +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_DeleteEvent_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.video import live_stream_v1 + + +def sample_delete_event(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.DeleteEventRequest( + name="name_value", + ) + + # Make the request + client.delete_event(request=request) + + +# [END livestream_v1_generated_LivestreamService_DeleteEvent_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_input_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_input_async.py new file mode 100644 index 000000000000..0e1164fa2ad2 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_input_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteInput +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_DeleteInput_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.video import live_stream_v1 + + +async def sample_delete_input(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.DeleteInputRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_input(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_DeleteInput_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_input_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_input_sync.py new file mode 100644 index 000000000000..ed260321af2d --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_delete_input_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteInput +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_DeleteInput_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.video import live_stream_v1 + + +def sample_delete_input(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.DeleteInputRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_input(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_DeleteInput_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_asset_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_asset_async.py new file mode 100644 index 000000000000..c0ed64960b1e --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_asset_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetAsset +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_GetAsset_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.video import live_stream_v1 + + +async def sample_get_asset(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.GetAssetRequest( + name="name_value", + ) + + # Make the request + response = await client.get_asset(request=request) + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_GetAsset_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_asset_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_asset_sync.py new file mode 100644 index 000000000000..68bd9940519b --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_asset_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetAsset +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_GetAsset_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.video import live_stream_v1 + + +def sample_get_asset(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.GetAssetRequest( + name="name_value", + ) + + # Make the request + response = client.get_asset(request=request) + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_GetAsset_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_channel_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_channel_async.py new file mode 100644 index 000000000000..b830dc916a65 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_channel_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetChannel +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_GetChannel_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.video import live_stream_v1 + + +async def sample_get_channel(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.GetChannelRequest( + name="name_value", + ) + + # Make the request + response = await client.get_channel(request=request) + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_GetChannel_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_channel_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_channel_sync.py new file mode 100644 index 000000000000..42c7e45105f4 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_channel_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetChannel +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_GetChannel_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.video import live_stream_v1 + + +def sample_get_channel(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.GetChannelRequest( + name="name_value", + ) + + # Make the request + response = client.get_channel(request=request) + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_GetChannel_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_event_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_event_async.py new file mode 100644 index 000000000000..3467532604b5 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_event_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetEvent +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_GetEvent_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.video import live_stream_v1 + + +async def sample_get_event(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.GetEventRequest( + name="name_value", + ) + + # Make the request + response = await client.get_event(request=request) + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_GetEvent_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_event_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_event_sync.py new file mode 100644 index 000000000000..daf35121bb00 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_event_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetEvent +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_GetEvent_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.video import live_stream_v1 + + +def sample_get_event(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.GetEventRequest( + name="name_value", + ) + + # Make the request + response = client.get_event(request=request) + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_GetEvent_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_input_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_input_async.py new file mode 100644 index 000000000000..bc66d55888e4 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_input_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetInput +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_GetInput_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.video import live_stream_v1 + + +async def sample_get_input(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.GetInputRequest( + name="name_value", + ) + + # Make the request + response = await client.get_input(request=request) + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_GetInput_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_input_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_input_sync.py new file mode 100644 index 000000000000..e44475e77d6c --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_input_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetInput +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_GetInput_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.video import live_stream_v1 + + +def sample_get_input(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.GetInputRequest( + name="name_value", + ) + + # Make the request + response = client.get_input(request=request) + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_GetInput_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_pool_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_pool_async.py new file mode 100644 index 000000000000..538412350a01 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_pool_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetPool +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_GetPool_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.video import live_stream_v1 + + +async def sample_get_pool(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.GetPoolRequest( + name="name_value", + ) + + # Make the request + response = await client.get_pool(request=request) + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_GetPool_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_pool_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_pool_sync.py new file mode 100644 index 000000000000..4910410f8204 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_get_pool_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetPool +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_GetPool_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.video import live_stream_v1 + + +def sample_get_pool(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.GetPoolRequest( + name="name_value", + ) + + # Make the request + response = client.get_pool(request=request) + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_GetPool_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_assets_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_assets_async.py new file mode 100644 index 000000000000..229ba7fe2566 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_assets_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListAssets +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_ListAssets_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.video import live_stream_v1 + + +async def sample_list_assets(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.ListAssetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_assets(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END livestream_v1_generated_LivestreamService_ListAssets_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_assets_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_assets_sync.py new file mode 100644 index 000000000000..afdb450f3822 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_assets_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListAssets +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_ListAssets_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.video import live_stream_v1 + + +def sample_list_assets(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.ListAssetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_assets(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END livestream_v1_generated_LivestreamService_ListAssets_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_channels_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_channels_async.py new file mode 100644 index 000000000000..066d9abfa3b0 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_channels_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListChannels +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_ListChannels_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.video import live_stream_v1 + + +async def sample_list_channels(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.ListChannelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_channels(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END livestream_v1_generated_LivestreamService_ListChannels_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_channels_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_channels_sync.py new file mode 100644 index 000000000000..dcc5d4652ae2 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_channels_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListChannels +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_ListChannels_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.video import live_stream_v1 + + +def sample_list_channels(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.ListChannelsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_channels(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END livestream_v1_generated_LivestreamService_ListChannels_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_events_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_events_async.py new file mode 100644 index 000000000000..73e41c1f664b --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_events_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListEvents +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_ListEvents_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.video import live_stream_v1 + + +async def sample_list_events(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.ListEventsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_events(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END livestream_v1_generated_LivestreamService_ListEvents_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_events_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_events_sync.py new file mode 100644 index 000000000000..04270dbea5c0 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_events_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListEvents +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_ListEvents_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.video import live_stream_v1 + + +def sample_list_events(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.ListEventsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_events(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END livestream_v1_generated_LivestreamService_ListEvents_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_inputs_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_inputs_async.py new file mode 100644 index 000000000000..0a356fad5216 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_inputs_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListInputs +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_ListInputs_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.video import live_stream_v1 + + +async def sample_list_inputs(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.ListInputsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_inputs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END livestream_v1_generated_LivestreamService_ListInputs_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_inputs_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_inputs_sync.py new file mode 100644 index 000000000000..4a07b3cda518 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_list_inputs_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListInputs +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_ListInputs_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.video import live_stream_v1 + + +def sample_list_inputs(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.ListInputsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_inputs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END livestream_v1_generated_LivestreamService_ListInputs_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_start_channel_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_start_channel_async.py new file mode 100644 index 000000000000..ff7639cfb763 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_start_channel_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 StartChannel +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_StartChannel_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.video import live_stream_v1 + + +async def sample_start_channel(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.StartChannelRequest( + name="name_value", + ) + + # Make the request + operation = client.start_channel(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_StartChannel_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_start_channel_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_start_channel_sync.py new file mode 100644 index 000000000000..bfecb4b57fb6 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_start_channel_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 StartChannel +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_StartChannel_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.video import live_stream_v1 + + +def sample_start_channel(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.StartChannelRequest( + name="name_value", + ) + + # Make the request + operation = client.start_channel(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_StartChannel_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_stop_channel_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_stop_channel_async.py new file mode 100644 index 000000000000..6342895a11bd --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_stop_channel_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 StopChannel +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_StopChannel_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.video import live_stream_v1 + + +async def sample_stop_channel(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.StopChannelRequest( + name="name_value", + ) + + # Make the request + operation = client.stop_channel(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_StopChannel_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_stop_channel_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_stop_channel_sync.py new file mode 100644 index 000000000000..f5045fd24fc1 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_stop_channel_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 StopChannel +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_StopChannel_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.video import live_stream_v1 + + +def sample_stop_channel(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.StopChannelRequest( + name="name_value", + ) + + # Make the request + operation = client.stop_channel(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_StopChannel_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_channel_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_channel_async.py new file mode 100644 index 000000000000..b2b3701ee796 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_channel_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UpdateChannel +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_UpdateChannel_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.video import live_stream_v1 + + +async def sample_update_channel(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.UpdateChannelRequest( + ) + + # Make the request + operation = client.update_channel(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_UpdateChannel_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_channel_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_channel_sync.py new file mode 100644 index 000000000000..bad720393b86 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_channel_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UpdateChannel +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_UpdateChannel_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.video import live_stream_v1 + + +def sample_update_channel(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.UpdateChannelRequest( + ) + + # Make the request + operation = client.update_channel(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_UpdateChannel_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_input_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_input_async.py new file mode 100644 index 000000000000..bed709d3994d --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_input_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UpdateInput +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_UpdateInput_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.video import live_stream_v1 + + +async def sample_update_input(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.UpdateInputRequest( + ) + + # Make the request + operation = client.update_input(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_UpdateInput_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_input_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_input_sync.py new file mode 100644 index 000000000000..79a1a9157342 --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_input_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UpdateInput +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_UpdateInput_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.video import live_stream_v1 + + +def sample_update_input(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.UpdateInputRequest( + ) + + # Make the request + operation = client.update_input(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_UpdateInput_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_pool_async.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_pool_async.py new file mode 100644 index 000000000000..db589776555e --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_pool_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UpdatePool +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_UpdatePool_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.video import live_stream_v1 + + +async def sample_update_pool(): + # Create a client + client = live_stream_v1.LivestreamServiceAsyncClient() + + # Initialize request argument(s) + request = live_stream_v1.UpdatePoolRequest( + ) + + # Make the request + operation = client.update_pool(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_UpdatePool_async] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_pool_sync.py b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_pool_sync.py new file mode 100644 index 000000000000..31a04126b64a --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/livestream_v1_generated_livestream_service_update_pool_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 UpdatePool +# 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-video-live-stream + + +# [START livestream_v1_generated_LivestreamService_UpdatePool_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.video import live_stream_v1 + + +def sample_update_pool(): + # Create a client + client = live_stream_v1.LivestreamServiceClient() + + # Initialize request argument(s) + request = live_stream_v1.UpdatePoolRequest( + ) + + # Make the request + operation = client.update_pool(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END livestream_v1_generated_LivestreamService_UpdatePool_sync] diff --git a/packages/google-cloud-video-live-stream/samples/generated_samples/snippet_metadata_google.cloud.video.livestream.v1.json b/packages/google-cloud-video-live-stream/samples/generated_samples/snippet_metadata_google.cloud.video.livestream.v1.json new file mode 100644 index 000000000000..b91fc2fe0c6f --- /dev/null +++ b/packages/google-cloud-video-live-stream/samples/generated_samples/snippet_metadata_google.cloud.video.livestream.v1.json @@ -0,0 +1,3639 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.video.livestream.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-video-live-stream", + "version": "0.1.0" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.create_asset", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.CreateAsset", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "CreateAsset" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.CreateAssetRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "asset", + "type": "google.cloud.video.live_stream_v1.types.Asset" + }, + { + "name": "asset_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_asset" + }, + "description": "Sample for CreateAsset", + "file": "livestream_v1_generated_livestream_service_create_asset_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_CreateAsset_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_create_asset_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.create_asset", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.CreateAsset", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "CreateAsset" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.CreateAssetRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "asset", + "type": "google.cloud.video.live_stream_v1.types.Asset" + }, + { + "name": "asset_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_asset" + }, + "description": "Sample for CreateAsset", + "file": "livestream_v1_generated_livestream_service_create_asset_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_CreateAsset_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_create_asset_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.create_channel", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.CreateChannel", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "CreateChannel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.CreateChannelRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "channel", + "type": "google.cloud.video.live_stream_v1.types.Channel" + }, + { + "name": "channel_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_channel" + }, + "description": "Sample for CreateChannel", + "file": "livestream_v1_generated_livestream_service_create_channel_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_CreateChannel_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_create_channel_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.create_channel", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.CreateChannel", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "CreateChannel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.CreateChannelRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "channel", + "type": "google.cloud.video.live_stream_v1.types.Channel" + }, + { + "name": "channel_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_channel" + }, + "description": "Sample for CreateChannel", + "file": "livestream_v1_generated_livestream_service_create_channel_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_CreateChannel_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_create_channel_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.create_event", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.CreateEvent", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "CreateEvent" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.CreateEventRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "event", + "type": "google.cloud.video.live_stream_v1.types.Event" + }, + { + "name": "event_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.types.Event", + "shortName": "create_event" + }, + "description": "Sample for CreateEvent", + "file": "livestream_v1_generated_livestream_service_create_event_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_CreateEvent_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_create_event_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.create_event", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.CreateEvent", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "CreateEvent" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.CreateEventRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "event", + "type": "google.cloud.video.live_stream_v1.types.Event" + }, + { + "name": "event_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.types.Event", + "shortName": "create_event" + }, + "description": "Sample for CreateEvent", + "file": "livestream_v1_generated_livestream_service_create_event_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_CreateEvent_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_create_event_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.create_input", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.CreateInput", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "CreateInput" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.CreateInputRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "input", + "type": "google.cloud.video.live_stream_v1.types.Input" + }, + { + "name": "input_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_input" + }, + "description": "Sample for CreateInput", + "file": "livestream_v1_generated_livestream_service_create_input_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_CreateInput_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_create_input_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.create_input", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.CreateInput", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "CreateInput" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.CreateInputRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "input", + "type": "google.cloud.video.live_stream_v1.types.Input" + }, + { + "name": "input_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_input" + }, + "description": "Sample for CreateInput", + "file": "livestream_v1_generated_livestream_service_create_input_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_CreateInput_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_create_input_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.delete_asset", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.DeleteAsset", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "DeleteAsset" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.DeleteAssetRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_asset" + }, + "description": "Sample for DeleteAsset", + "file": "livestream_v1_generated_livestream_service_delete_asset_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_DeleteAsset_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_delete_asset_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.delete_asset", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.DeleteAsset", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "DeleteAsset" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.DeleteAssetRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_asset" + }, + "description": "Sample for DeleteAsset", + "file": "livestream_v1_generated_livestream_service_delete_asset_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_DeleteAsset_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_delete_asset_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.delete_channel", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.DeleteChannel", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "DeleteChannel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.DeleteChannelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_channel" + }, + "description": "Sample for DeleteChannel", + "file": "livestream_v1_generated_livestream_service_delete_channel_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_DeleteChannel_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_delete_channel_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.delete_channel", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.DeleteChannel", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "DeleteChannel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.DeleteChannelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_channel" + }, + "description": "Sample for DeleteChannel", + "file": "livestream_v1_generated_livestream_service_delete_channel_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_DeleteChannel_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_delete_channel_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.delete_event", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.DeleteEvent", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "DeleteEvent" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.DeleteEventRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_event" + }, + "description": "Sample for DeleteEvent", + "file": "livestream_v1_generated_livestream_service_delete_event_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_DeleteEvent_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_delete_event_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.delete_event", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.DeleteEvent", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "DeleteEvent" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.DeleteEventRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_event" + }, + "description": "Sample for DeleteEvent", + "file": "livestream_v1_generated_livestream_service_delete_event_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_DeleteEvent_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_delete_event_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.delete_input", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.DeleteInput", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "DeleteInput" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.DeleteInputRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_input" + }, + "description": "Sample for DeleteInput", + "file": "livestream_v1_generated_livestream_service_delete_input_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_DeleteInput_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_delete_input_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.delete_input", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.DeleteInput", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "DeleteInput" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.DeleteInputRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_input" + }, + "description": "Sample for DeleteInput", + "file": "livestream_v1_generated_livestream_service_delete_input_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_DeleteInput_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_delete_input_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.get_asset", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.GetAsset", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "GetAsset" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.GetAssetRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.types.Asset", + "shortName": "get_asset" + }, + "description": "Sample for GetAsset", + "file": "livestream_v1_generated_livestream_service_get_asset_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_GetAsset_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": "livestream_v1_generated_livestream_service_get_asset_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.get_asset", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.GetAsset", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "GetAsset" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.GetAssetRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.types.Asset", + "shortName": "get_asset" + }, + "description": "Sample for GetAsset", + "file": "livestream_v1_generated_livestream_service_get_asset_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_GetAsset_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": "livestream_v1_generated_livestream_service_get_asset_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.get_channel", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.GetChannel", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "GetChannel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.GetChannelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.types.Channel", + "shortName": "get_channel" + }, + "description": "Sample for GetChannel", + "file": "livestream_v1_generated_livestream_service_get_channel_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_GetChannel_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": "livestream_v1_generated_livestream_service_get_channel_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.get_channel", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.GetChannel", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "GetChannel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.GetChannelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.types.Channel", + "shortName": "get_channel" + }, + "description": "Sample for GetChannel", + "file": "livestream_v1_generated_livestream_service_get_channel_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_GetChannel_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": "livestream_v1_generated_livestream_service_get_channel_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.get_event", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.GetEvent", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "GetEvent" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.GetEventRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.types.Event", + "shortName": "get_event" + }, + "description": "Sample for GetEvent", + "file": "livestream_v1_generated_livestream_service_get_event_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_GetEvent_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": "livestream_v1_generated_livestream_service_get_event_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.get_event", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.GetEvent", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "GetEvent" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.GetEventRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.types.Event", + "shortName": "get_event" + }, + "description": "Sample for GetEvent", + "file": "livestream_v1_generated_livestream_service_get_event_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_GetEvent_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": "livestream_v1_generated_livestream_service_get_event_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.get_input", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.GetInput", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "GetInput" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.GetInputRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.types.Input", + "shortName": "get_input" + }, + "description": "Sample for GetInput", + "file": "livestream_v1_generated_livestream_service_get_input_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_GetInput_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": "livestream_v1_generated_livestream_service_get_input_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.get_input", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.GetInput", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "GetInput" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.GetInputRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.types.Input", + "shortName": "get_input" + }, + "description": "Sample for GetInput", + "file": "livestream_v1_generated_livestream_service_get_input_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_GetInput_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": "livestream_v1_generated_livestream_service_get_input_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.get_pool", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.GetPool", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "GetPool" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.GetPoolRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.types.Pool", + "shortName": "get_pool" + }, + "description": "Sample for GetPool", + "file": "livestream_v1_generated_livestream_service_get_pool_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_GetPool_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": "livestream_v1_generated_livestream_service_get_pool_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.get_pool", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.GetPool", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "GetPool" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.GetPoolRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.types.Pool", + "shortName": "get_pool" + }, + "description": "Sample for GetPool", + "file": "livestream_v1_generated_livestream_service_get_pool_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_GetPool_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": "livestream_v1_generated_livestream_service_get_pool_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.list_assets", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.ListAssets", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "ListAssets" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.ListAssetsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListAssetsAsyncPager", + "shortName": "list_assets" + }, + "description": "Sample for ListAssets", + "file": "livestream_v1_generated_livestream_service_list_assets_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_ListAssets_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": "livestream_v1_generated_livestream_service_list_assets_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.list_assets", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.ListAssets", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "ListAssets" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.ListAssetsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListAssetsPager", + "shortName": "list_assets" + }, + "description": "Sample for ListAssets", + "file": "livestream_v1_generated_livestream_service_list_assets_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_ListAssets_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": "livestream_v1_generated_livestream_service_list_assets_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.list_channels", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.ListChannels", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "ListChannels" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.ListChannelsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListChannelsAsyncPager", + "shortName": "list_channels" + }, + "description": "Sample for ListChannels", + "file": "livestream_v1_generated_livestream_service_list_channels_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_ListChannels_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": "livestream_v1_generated_livestream_service_list_channels_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.list_channels", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.ListChannels", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "ListChannels" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.ListChannelsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListChannelsPager", + "shortName": "list_channels" + }, + "description": "Sample for ListChannels", + "file": "livestream_v1_generated_livestream_service_list_channels_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_ListChannels_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": "livestream_v1_generated_livestream_service_list_channels_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.list_events", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.ListEvents", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "ListEvents" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.ListEventsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListEventsAsyncPager", + "shortName": "list_events" + }, + "description": "Sample for ListEvents", + "file": "livestream_v1_generated_livestream_service_list_events_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_ListEvents_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": "livestream_v1_generated_livestream_service_list_events_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.list_events", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.ListEvents", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "ListEvents" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.ListEventsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListEventsPager", + "shortName": "list_events" + }, + "description": "Sample for ListEvents", + "file": "livestream_v1_generated_livestream_service_list_events_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_ListEvents_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": "livestream_v1_generated_livestream_service_list_events_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.list_inputs", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.ListInputs", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "ListInputs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.ListInputsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListInputsAsyncPager", + "shortName": "list_inputs" + }, + "description": "Sample for ListInputs", + "file": "livestream_v1_generated_livestream_service_list_inputs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_ListInputs_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": "livestream_v1_generated_livestream_service_list_inputs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.list_inputs", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.ListInputs", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "ListInputs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.ListInputsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.live_stream_v1.services.livestream_service.pagers.ListInputsPager", + "shortName": "list_inputs" + }, + "description": "Sample for ListInputs", + "file": "livestream_v1_generated_livestream_service_list_inputs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_ListInputs_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": "livestream_v1_generated_livestream_service_list_inputs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.start_channel", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.StartChannel", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "StartChannel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.StartChannelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "start_channel" + }, + "description": "Sample for StartChannel", + "file": "livestream_v1_generated_livestream_service_start_channel_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_StartChannel_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_start_channel_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.start_channel", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.StartChannel", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "StartChannel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.StartChannelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "start_channel" + }, + "description": "Sample for StartChannel", + "file": "livestream_v1_generated_livestream_service_start_channel_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_StartChannel_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_start_channel_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.stop_channel", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.StopChannel", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "StopChannel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.StopChannelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "stop_channel" + }, + "description": "Sample for StopChannel", + "file": "livestream_v1_generated_livestream_service_stop_channel_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_StopChannel_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_stop_channel_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.stop_channel", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.StopChannel", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "StopChannel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.StopChannelRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "stop_channel" + }, + "description": "Sample for StopChannel", + "file": "livestream_v1_generated_livestream_service_stop_channel_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_StopChannel_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_stop_channel_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.update_channel", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.UpdateChannel", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "UpdateChannel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.UpdateChannelRequest" + }, + { + "name": "channel", + "type": "google.cloud.video.live_stream_v1.types.Channel" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_channel" + }, + "description": "Sample for UpdateChannel", + "file": "livestream_v1_generated_livestream_service_update_channel_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_UpdateChannel_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_update_channel_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.update_channel", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.UpdateChannel", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "UpdateChannel" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.UpdateChannelRequest" + }, + { + "name": "channel", + "type": "google.cloud.video.live_stream_v1.types.Channel" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_channel" + }, + "description": "Sample for UpdateChannel", + "file": "livestream_v1_generated_livestream_service_update_channel_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_UpdateChannel_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_update_channel_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.update_input", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.UpdateInput", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "UpdateInput" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.UpdateInputRequest" + }, + { + "name": "input", + "type": "google.cloud.video.live_stream_v1.types.Input" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_input" + }, + "description": "Sample for UpdateInput", + "file": "livestream_v1_generated_livestream_service_update_input_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_UpdateInput_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_update_input_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.update_input", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.UpdateInput", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "UpdateInput" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.UpdateInputRequest" + }, + { + "name": "input", + "type": "google.cloud.video.live_stream_v1.types.Input" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_input" + }, + "description": "Sample for UpdateInput", + "file": "livestream_v1_generated_livestream_service_update_input_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_UpdateInput_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_update_input_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient", + "shortName": "LivestreamServiceAsyncClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceAsyncClient.update_pool", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.UpdatePool", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "UpdatePool" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.UpdatePoolRequest" + }, + { + "name": "pool", + "type": "google.cloud.video.live_stream_v1.types.Pool" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_pool" + }, + "description": "Sample for UpdatePool", + "file": "livestream_v1_generated_livestream_service_update_pool_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_UpdatePool_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_update_pool_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient", + "shortName": "LivestreamServiceClient" + }, + "fullName": "google.cloud.video.live_stream_v1.LivestreamServiceClient.update_pool", + "method": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService.UpdatePool", + "service": { + "fullName": "google.cloud.video.livestream.v1.LivestreamService", + "shortName": "LivestreamService" + }, + "shortName": "UpdatePool" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.live_stream_v1.types.UpdatePoolRequest" + }, + { + "name": "pool", + "type": "google.cloud.video.live_stream_v1.types.Pool" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_pool" + }, + "description": "Sample for UpdatePool", + "file": "livestream_v1_generated_livestream_service_update_pool_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "livestream_v1_generated_LivestreamService_UpdatePool_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "livestream_v1_generated_livestream_service_update_pool_sync.py" + } + ] +} diff --git a/packages/google-cloud-video-live-stream/tests/unit/gapic/live_stream_v1/test_livestream_service.py b/packages/google-cloud-video-live-stream/tests/unit/gapic/live_stream_v1/test_livestream_service.py index ed07cf7a89c1..cf7aca6a2115 100644 --- a/packages/google-cloud-video-live-stream/tests/unit/gapic/live_stream_v1/test_livestream_service.py +++ b/packages/google-cloud-video-live-stream/tests/unit/gapic/live_stream_v1/test_livestream_service.py @@ -6826,6 +6826,73 @@ def test_create_channel_rest(request_type): ], "input_config": {"input_switch_mode": 1}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = service.CreateChannelRequest.meta.fields["channel"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["channel"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["channel"][field])): + del request_init["channel"][field][i][subfield] + else: + del request_init["channel"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -7030,135 +7097,6 @@ def test_create_channel_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["channel"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "labels": {}, - "input_attachments": [ - { - "key": "key_value", - "input": "input_value", - "automatic_failover": { - "input_keys": ["input_keys_value1", "input_keys_value2"] - }, - } - ], - "active_input": "active_input_value", - "output": {"uri": "uri_value"}, - "elementary_streams": [ - { - "key": "key_value", - "video_stream": { - "h264": { - "width_pixels": 1300, - "height_pixels": 1389, - "frame_rate": 0.1046, - "bitrate_bps": 1167, - "allow_open_gop": True, - "gop_frame_count": 1592, - "gop_duration": {"seconds": 751, "nanos": 543}, - "vbv_size_bits": 1401, - "vbv_fullness_bits": 1834, - "entropy_coder": "entropy_coder_value", - "b_pyramid": True, - "b_frame_count": 1364, - "aq_strength": 0.1184, - "profile": "profile_value", - "tune": "tune_value", - } - }, - "audio_stream": { - "transmux": True, - "codec": "codec_value", - "bitrate_bps": 1167, - "channel_count": 1377, - "channel_layout": [ - "channel_layout_value1", - "channel_layout_value2", - ], - "mapping_": [ - { - "input_key": "input_key_value", - "input_track": 1188, - "input_channel": 1384, - "output_channel": 1513, - "gain_db": 0.708, - } - ], - "sample_rate_hertz": 1817, - }, - "text_stream": {"codec": "codec_value"}, - } - ], - "mux_streams": [ - { - "key": "key_value", - "container": "container_value", - "elementary_streams": [ - "elementary_streams_value1", - "elementary_streams_value2", - ], - "segment_settings": {"segment_duration": {}}, - "encryption_id": "encryption_id_value", - } - ], - "manifests": [ - { - "file_name": "file_name_value", - "type_": 1, - "mux_streams": ["mux_streams_value1", "mux_streams_value2"], - "max_segment_count": 1824, - "segment_keep_duration": {}, - "use_timecode_as_timeline": True, - } - ], - "sprite_sheets": [ - { - "format_": "format__value", - "file_prefix": "file_prefix_value", - "sprite_width_pixels": 2058, - "sprite_height_pixels": 2147, - "column_count": 1302, - "row_count": 992, - "interval": {}, - "quality": 777, - } - ], - "streaming_state": 1, - "streaming_error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - "log_config": {"log_severity": 1}, - "timecode_config": { - "source": 1, - "utc_offset": {}, - "time_zone": {"id": "id_value", "version": "version_value"}, - }, - "encryptions": [ - { - "id": "id_value", - "secret_manager_key_source": {"secret_version": "secret_version_value"}, - "drm_systems": { - "widevine": {}, - "fairplay": {}, - "playready": {}, - "clearkey": {}, - }, - "aes128": {}, - "sample_aes": {}, - "mpeg_cenc": {"scheme": "scheme_value"}, - } - ], - "input_config": {"input_switch_mode": 1}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -7265,8 +7203,9 @@ def test_list_channels_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = service.ListChannelsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = service.ListChannelsResponse.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 @@ -7349,8 +7288,9 @@ def test_list_channels_rest_required_fields(request_type=service.ListChannelsReq response_value = Response() response_value.status_code = 200 - pb_return_value = service.ListChannelsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = service.ListChannelsResponse.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 @@ -7483,8 +7423,9 @@ def test_list_channels_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = service.ListChannelsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = service.ListChannelsResponse.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 @@ -7605,8 +7546,9 @@ def test_get_channel_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Channel.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Channel.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 @@ -7681,8 +7623,9 @@ def test_get_channel_rest_required_fields(request_type=service.GetChannelRequest response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Channel.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Channel.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 @@ -7803,8 +7746,9 @@ def test_get_channel_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Channel.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Channel.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 @@ -8260,6 +8204,73 @@ def test_update_channel_rest(request_type): ], "input_config": {"input_switch_mode": 1}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = service.UpdateChannelRequest.meta.fields["channel"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["channel"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["channel"][field])): + del request_init["channel"][field][i][subfield] + else: + del request_init["channel"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -8442,135 +8453,6 @@ def test_update_channel_rest_bad_request( request_init = { "channel": {"name": "projects/sample1/locations/sample2/channels/sample3"} } - request_init["channel"] = { - "name": "projects/sample1/locations/sample2/channels/sample3", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "labels": {}, - "input_attachments": [ - { - "key": "key_value", - "input": "input_value", - "automatic_failover": { - "input_keys": ["input_keys_value1", "input_keys_value2"] - }, - } - ], - "active_input": "active_input_value", - "output": {"uri": "uri_value"}, - "elementary_streams": [ - { - "key": "key_value", - "video_stream": { - "h264": { - "width_pixels": 1300, - "height_pixels": 1389, - "frame_rate": 0.1046, - "bitrate_bps": 1167, - "allow_open_gop": True, - "gop_frame_count": 1592, - "gop_duration": {"seconds": 751, "nanos": 543}, - "vbv_size_bits": 1401, - "vbv_fullness_bits": 1834, - "entropy_coder": "entropy_coder_value", - "b_pyramid": True, - "b_frame_count": 1364, - "aq_strength": 0.1184, - "profile": "profile_value", - "tune": "tune_value", - } - }, - "audio_stream": { - "transmux": True, - "codec": "codec_value", - "bitrate_bps": 1167, - "channel_count": 1377, - "channel_layout": [ - "channel_layout_value1", - "channel_layout_value2", - ], - "mapping_": [ - { - "input_key": "input_key_value", - "input_track": 1188, - "input_channel": 1384, - "output_channel": 1513, - "gain_db": 0.708, - } - ], - "sample_rate_hertz": 1817, - }, - "text_stream": {"codec": "codec_value"}, - } - ], - "mux_streams": [ - { - "key": "key_value", - "container": "container_value", - "elementary_streams": [ - "elementary_streams_value1", - "elementary_streams_value2", - ], - "segment_settings": {"segment_duration": {}}, - "encryption_id": "encryption_id_value", - } - ], - "manifests": [ - { - "file_name": "file_name_value", - "type_": 1, - "mux_streams": ["mux_streams_value1", "mux_streams_value2"], - "max_segment_count": 1824, - "segment_keep_duration": {}, - "use_timecode_as_timeline": True, - } - ], - "sprite_sheets": [ - { - "format_": "format__value", - "file_prefix": "file_prefix_value", - "sprite_width_pixels": 2058, - "sprite_height_pixels": 2147, - "column_count": 1302, - "row_count": 992, - "interval": {}, - "quality": 777, - } - ], - "streaming_state": 1, - "streaming_error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - "log_config": {"log_severity": 1}, - "timecode_config": { - "source": 1, - "utc_offset": {}, - "time_zone": {"id": "id_value", "version": "version_value"}, - }, - "encryptions": [ - { - "id": "id_value", - "secret_manager_key_source": {"secret_version": "secret_version_value"}, - "drm_systems": { - "widevine": {}, - "fairplay": {}, - "playready": {}, - "clearkey": {}, - }, - "aes128": {}, - "sample_aes": {}, - "mpeg_cenc": {"scheme": "scheme_value"}, - } - ], - "input_config": {"input_switch_mode": 1}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -9237,6 +9119,73 @@ def test_create_input_rest(request_type): ], }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = service.CreateInputRequest.meta.fields["input"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["input"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["input"][field])): + del request_init["input"][field][i][subfield] + else: + del request_init["input"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -9441,58 +9390,6 @@ def test_create_input_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["input"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "labels": {}, - "type_": 1, - "tier": 1, - "uri": "uri_value", - "preprocessing_config": { - "audio": {"lufs": 0.442}, - "crop": { - "top_pixels": 1095, - "bottom_pixels": 1417, - "left_pixels": 1183, - "right_pixels": 1298, - }, - "pad": { - "top_pixels": 1095, - "bottom_pixels": 1417, - "left_pixels": 1183, - "right_pixels": 1298, - }, - }, - "security_rules": {"ip_ranges": ["ip_ranges_value1", "ip_ranges_value2"]}, - "input_stream_property": { - "last_establish_time": {}, - "video_streams": [ - { - "index": 536, - "video_format": { - "codec": "codec_value", - "width_pixels": 1300, - "height_pixels": 1389, - "frame_rate": 0.1046, - }, - } - ], - "audio_streams": [ - { - "index": 536, - "audio_format": { - "codec": "codec_value", - "channel_count": 1377, - "channel_layout": [ - "channel_layout_value1", - "channel_layout_value2", - ], - }, - } - ], - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -9599,8 +9496,9 @@ def test_list_inputs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = service.ListInputsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = service.ListInputsResponse.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 @@ -9683,8 +9581,9 @@ def test_list_inputs_rest_required_fields(request_type=service.ListInputsRequest response_value = Response() response_value.status_code = 200 - pb_return_value = service.ListInputsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = service.ListInputsResponse.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 @@ -9817,8 +9716,9 @@ def test_list_inputs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = service.ListInputsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = service.ListInputsResponse.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 @@ -9940,8 +9840,9 @@ def test_get_input_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Input.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Input.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 @@ -10017,8 +9918,9 @@ def test_get_input_rest_required_fields(request_type=service.GetInputRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Input.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Input.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 @@ -10139,8 +10041,9 @@ def test_get_input_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Input.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Input.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 @@ -10506,6 +10409,73 @@ def test_update_input_rest(request_type): ], }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = service.UpdateInputRequest.meta.fields["input"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["input"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["input"][field])): + del request_init["input"][field][i][subfield] + else: + del request_init["input"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -10688,58 +10658,6 @@ def test_update_input_rest_bad_request( request_init = { "input": {"name": "projects/sample1/locations/sample2/inputs/sample3"} } - request_init["input"] = { - "name": "projects/sample1/locations/sample2/inputs/sample3", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "labels": {}, - "type_": 1, - "tier": 1, - "uri": "uri_value", - "preprocessing_config": { - "audio": {"lufs": 0.442}, - "crop": { - "top_pixels": 1095, - "bottom_pixels": 1417, - "left_pixels": 1183, - "right_pixels": 1298, - }, - "pad": { - "top_pixels": 1095, - "bottom_pixels": 1417, - "left_pixels": 1183, - "right_pixels": 1298, - }, - }, - "security_rules": {"ip_ranges": ["ip_ranges_value1", "ip_ranges_value2"]}, - "input_stream_property": { - "last_establish_time": {}, - "video_streams": [ - { - "index": 536, - "video_format": { - "codec": "codec_value", - "width_pixels": 1300, - "height_pixels": 1389, - "frame_rate": 0.1046, - }, - } - ], - "audio_streams": [ - { - "index": 536, - "audio_format": { - "codec": "codec_value", - "channel_count": 1377, - "channel_layout": [ - "channel_layout_value1", - "channel_layout_value2", - ], - }, - } - ], - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -10859,6 +10777,73 @@ def test_create_event_rest(request_type): ], }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = service.CreateEventRequest.meta.fields["event"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["event"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["event"][field])): + del request_init["event"][field][i][subfield] + else: + del request_init["event"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -10873,8 +10858,9 @@ def test_create_event_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Event.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Event.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 @@ -10964,8 +10950,9 @@ def test_create_event_rest_required_fields(request_type=service.CreateEventReque response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Event.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Event.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 @@ -11069,31 +11056,6 @@ def test_create_event_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2/channels/sample3"} - request_init["event"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "labels": {}, - "input_switch": {"input_key": "input_key_value"}, - "ad_break": {"duration": {"seconds": 751, "nanos": 543}}, - "return_to_program": {}, - "slate": {"duration": {}, "asset": "asset_value"}, - "mute": {"duration": {}}, - "unmute": {}, - "execute_now": True, - "execution_time": {}, - "state": 1, - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -11135,8 +11097,9 @@ def test_create_event_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Event.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Event.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 @@ -11204,8 +11167,9 @@ def test_list_events_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = service.ListEventsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = service.ListEventsResponse.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 @@ -11288,8 +11252,9 @@ def test_list_events_rest_required_fields(request_type=service.ListEventsRequest response_value = Response() response_value.status_code = 200 - pb_return_value = service.ListEventsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = service.ListEventsResponse.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 @@ -11424,8 +11389,9 @@ def test_list_events_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = service.ListEventsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = service.ListEventsResponse.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 @@ -11551,8 +11517,9 @@ def test_get_event_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Event.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Event.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 @@ -11627,8 +11594,9 @@ def test_get_event_rest_required_fields(request_type=service.GetEventRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Event.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Event.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 @@ -11753,8 +11721,9 @@ def test_get_event_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Event.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Event.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 @@ -12084,6 +12053,73 @@ def test_create_asset_rest(request_type): ], }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = service.CreateAssetRequest.meta.fields["asset"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["asset"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["asset"][field])): + del request_init["asset"][field][i][subfield] + else: + del request_init["asset"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -12288,26 +12324,6 @@ def test_create_asset_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["asset"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "labels": {}, - "video": {"uri": "uri_value"}, - "image": {"uri": "uri_value"}, - "crc32c": "crc32c_value", - "state": 1, - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -12675,8 +12691,9 @@ def test_get_asset_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Asset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Asset.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 @@ -12751,8 +12768,9 @@ def test_get_asset_rest_required_fields(request_type=service.GetAssetRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Asset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Asset.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 @@ -12873,8 +12891,9 @@ def test_get_asset_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Asset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Asset.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 @@ -12939,8 +12958,9 @@ def test_list_assets_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = service.ListAssetsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = service.ListAssetsResponse.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 @@ -13023,8 +13043,9 @@ def test_list_assets_rest_required_fields(request_type=service.ListAssetsRequest response_value = Response() response_value.status_code = 200 - pb_return_value = service.ListAssetsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = service.ListAssetsResponse.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 @@ -13157,8 +13178,9 @@ def test_list_assets_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = service.ListAssetsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = service.ListAssetsResponse.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 @@ -13277,8 +13299,9 @@ def test_get_pool_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Pool.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Pool.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 @@ -13351,8 +13374,9 @@ def test_get_pool_rest_required_fields(request_type=service.GetPoolRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Pool.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Pool.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 @@ -13473,8 +13497,9 @@ def test_get_pool_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Pool.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Pool.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 @@ -13535,6 +13560,73 @@ def test_update_pool_rest(request_type): "labels": {}, "network_config": {"peered_network": "peered_network_value"}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = service.UpdatePoolRequest.meta.fields["pool"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["pool"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["pool"][field])): + del request_init["pool"][field][i][subfield] + else: + del request_init["pool"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -13717,13 +13809,6 @@ def test_update_pool_rest_bad_request( request_init = { "pool": {"name": "projects/sample1/locations/sample2/pools/sample3"} } - request_init["pool"] = { - "name": "projects/sample1/locations/sample2/pools/sample3", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "labels": {}, - "network_config": {"peered_network": "peered_network_value"}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. diff --git a/packages/google-cloud-video-transcoder/CONTRIBUTING.rst b/packages/google-cloud-video-transcoder/CONTRIBUTING.rst index e814034e03a9..bc2838d3c1f0 100644 --- a/packages/google-cloud-video-transcoder/CONTRIBUTING.rst +++ b/packages/google-cloud-video-transcoder/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder/gapic_version.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder/gapic_version.py index 6f9b28f95196..360a0d13ebdd 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder/gapic_version.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder/gapic_version.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2022 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.10.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/gapic_version.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/gapic_version.py index 6f9b28f95196..360a0d13ebdd 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/gapic_version.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/gapic_version.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2022 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.10.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-video-transcoder/noxfile.py b/packages/google-cloud-video-transcoder/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-video-transcoder/noxfile.py +++ b/packages/google-cloud-video-transcoder/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/snippet_metadata_google.cloud.video.transcoder.v1.json b/packages/google-cloud-video-transcoder/samples/generated_samples/snippet_metadata_google.cloud.video.transcoder.v1.json new file mode 100644 index 000000000000..2c7572e16c29 --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/snippet_metadata_google.cloud.video.transcoder.v1.json @@ -0,0 +1,1315 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.video.transcoder.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-video-transcoder", + "version": "0.1.0" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient", + "shortName": "TranscoderServiceAsyncClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient.create_job_template", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.CreateJobTemplate", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "CreateJobTemplate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.CreateJobTemplateRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "job_template", + "type": "google.cloud.video.transcoder_v1.types.JobTemplate" + }, + { + "name": "job_template_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.transcoder_v1.types.JobTemplate", + "shortName": "create_job_template" + }, + "description": "Sample for CreateJobTemplate", + "file": "transcoder_v1_generated_transcoder_service_create_job_template_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_CreateJobTemplate_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "transcoder_v1_generated_transcoder_service_create_job_template_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient", + "shortName": "TranscoderServiceClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient.create_job_template", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.CreateJobTemplate", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "CreateJobTemplate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.CreateJobTemplateRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "job_template", + "type": "google.cloud.video.transcoder_v1.types.JobTemplate" + }, + { + "name": "job_template_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.transcoder_v1.types.JobTemplate", + "shortName": "create_job_template" + }, + "description": "Sample for CreateJobTemplate", + "file": "transcoder_v1_generated_transcoder_service_create_job_template_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_CreateJobTemplate_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "transcoder_v1_generated_transcoder_service_create_job_template_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient", + "shortName": "TranscoderServiceAsyncClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient.create_job", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.CreateJob", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "CreateJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.CreateJobRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "job", + "type": "google.cloud.video.transcoder_v1.types.Job" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.transcoder_v1.types.Job", + "shortName": "create_job" + }, + "description": "Sample for CreateJob", + "file": "transcoder_v1_generated_transcoder_service_create_job_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_CreateJob_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "transcoder_v1_generated_transcoder_service_create_job_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient", + "shortName": "TranscoderServiceClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient.create_job", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.CreateJob", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "CreateJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.CreateJobRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "job", + "type": "google.cloud.video.transcoder_v1.types.Job" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.transcoder_v1.types.Job", + "shortName": "create_job" + }, + "description": "Sample for CreateJob", + "file": "transcoder_v1_generated_transcoder_service_create_job_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_CreateJob_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "transcoder_v1_generated_transcoder_service_create_job_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient", + "shortName": "TranscoderServiceAsyncClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient.delete_job_template", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.DeleteJobTemplate", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "DeleteJobTemplate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.DeleteJobTemplateRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_job_template" + }, + "description": "Sample for DeleteJobTemplate", + "file": "transcoder_v1_generated_transcoder_service_delete_job_template_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_DeleteJobTemplate_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "transcoder_v1_generated_transcoder_service_delete_job_template_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient", + "shortName": "TranscoderServiceClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient.delete_job_template", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.DeleteJobTemplate", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "DeleteJobTemplate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.DeleteJobTemplateRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_job_template" + }, + "description": "Sample for DeleteJobTemplate", + "file": "transcoder_v1_generated_transcoder_service_delete_job_template_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_DeleteJobTemplate_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "transcoder_v1_generated_transcoder_service_delete_job_template_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient", + "shortName": "TranscoderServiceAsyncClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient.delete_job", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.DeleteJob", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "DeleteJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.DeleteJobRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_job" + }, + "description": "Sample for DeleteJob", + "file": "transcoder_v1_generated_transcoder_service_delete_job_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_DeleteJob_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "transcoder_v1_generated_transcoder_service_delete_job_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient", + "shortName": "TranscoderServiceClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient.delete_job", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.DeleteJob", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "DeleteJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.DeleteJobRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_job" + }, + "description": "Sample for DeleteJob", + "file": "transcoder_v1_generated_transcoder_service_delete_job_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_DeleteJob_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "transcoder_v1_generated_transcoder_service_delete_job_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient", + "shortName": "TranscoderServiceAsyncClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient.get_job_template", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.GetJobTemplate", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "GetJobTemplate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.GetJobTemplateRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.transcoder_v1.types.JobTemplate", + "shortName": "get_job_template" + }, + "description": "Sample for GetJobTemplate", + "file": "transcoder_v1_generated_transcoder_service_get_job_template_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_GetJobTemplate_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": "transcoder_v1_generated_transcoder_service_get_job_template_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient", + "shortName": "TranscoderServiceClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient.get_job_template", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.GetJobTemplate", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "GetJobTemplate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.GetJobTemplateRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.transcoder_v1.types.JobTemplate", + "shortName": "get_job_template" + }, + "description": "Sample for GetJobTemplate", + "file": "transcoder_v1_generated_transcoder_service_get_job_template_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_GetJobTemplate_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": "transcoder_v1_generated_transcoder_service_get_job_template_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient", + "shortName": "TranscoderServiceAsyncClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient.get_job", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.GetJob", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "GetJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.GetJobRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.transcoder_v1.types.Job", + "shortName": "get_job" + }, + "description": "Sample for GetJob", + "file": "transcoder_v1_generated_transcoder_service_get_job_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_GetJob_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "transcoder_v1_generated_transcoder_service_get_job_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient", + "shortName": "TranscoderServiceClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient.get_job", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.GetJob", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "GetJob" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.GetJobRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.transcoder_v1.types.Job", + "shortName": "get_job" + }, + "description": "Sample for GetJob", + "file": "transcoder_v1_generated_transcoder_service_get_job_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_GetJob_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "transcoder_v1_generated_transcoder_service_get_job_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient", + "shortName": "TranscoderServiceAsyncClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient.list_job_templates", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.ListJobTemplates", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "ListJobTemplates" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.ListJobTemplatesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobTemplatesAsyncPager", + "shortName": "list_job_templates" + }, + "description": "Sample for ListJobTemplates", + "file": "transcoder_v1_generated_transcoder_service_list_job_templates_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_ListJobTemplates_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": "transcoder_v1_generated_transcoder_service_list_job_templates_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient", + "shortName": "TranscoderServiceClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient.list_job_templates", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.ListJobTemplates", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "ListJobTemplates" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.ListJobTemplatesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobTemplatesPager", + "shortName": "list_job_templates" + }, + "description": "Sample for ListJobTemplates", + "file": "transcoder_v1_generated_transcoder_service_list_job_templates_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_ListJobTemplates_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": "transcoder_v1_generated_transcoder_service_list_job_templates_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient", + "shortName": "TranscoderServiceAsyncClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceAsyncClient.list_jobs", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.ListJobs", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "ListJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.ListJobsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobsAsyncPager", + "shortName": "list_jobs" + }, + "description": "Sample for ListJobs", + "file": "transcoder_v1_generated_transcoder_service_list_jobs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_ListJobs_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": "transcoder_v1_generated_transcoder_service_list_jobs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient", + "shortName": "TranscoderServiceClient" + }, + "fullName": "google.cloud.video.transcoder_v1.TranscoderServiceClient.list_jobs", + "method": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService.ListJobs", + "service": { + "fullName": "google.cloud.video.transcoder.v1.TranscoderService", + "shortName": "TranscoderService" + }, + "shortName": "ListJobs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.transcoder_v1.types.ListJobsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobsPager", + "shortName": "list_jobs" + }, + "description": "Sample for ListJobs", + "file": "transcoder_v1_generated_transcoder_service_list_jobs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "transcoder_v1_generated_TranscoderService_ListJobs_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": "transcoder_v1_generated_transcoder_service_list_jobs_sync.py" + } + ] +} diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_create_job_async.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_create_job_async.py new file mode 100644 index 000000000000..5dbeced5c180 --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_create_job_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateJob +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_CreateJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import transcoder_v1 + + +async def sample_create_job(): + # Create a client + client = transcoder_v1.TranscoderServiceAsyncClient() + + # Initialize request argument(s) + job = transcoder_v1.Job() + job.template_id = "template_id_value" + + request = transcoder_v1.CreateJobRequest( + parent="parent_value", + job=job, + ) + + # Make the request + response = await client.create_job(request=request) + + # Handle the response + print(response) + +# [END transcoder_v1_generated_TranscoderService_CreateJob_async] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_create_job_sync.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_create_job_sync.py new file mode 100644 index 000000000000..16de42c4461d --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_create_job_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateJob +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_CreateJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import transcoder_v1 + + +def sample_create_job(): + # Create a client + client = transcoder_v1.TranscoderServiceClient() + + # Initialize request argument(s) + job = transcoder_v1.Job() + job.template_id = "template_id_value" + + request = transcoder_v1.CreateJobRequest( + parent="parent_value", + job=job, + ) + + # Make the request + response = client.create_job(request=request) + + # Handle the response + print(response) + +# [END transcoder_v1_generated_TranscoderService_CreateJob_sync] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_create_job_template_async.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_create_job_template_async.py new file mode 100644 index 000000000000..6f096160d438 --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_create_job_template_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateJobTemplate +# 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-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_CreateJobTemplate_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.video import transcoder_v1 + + +async def sample_create_job_template(): + # Create a client + client = transcoder_v1.TranscoderServiceAsyncClient() + + # Initialize request argument(s) + request = transcoder_v1.CreateJobTemplateRequest( + parent="parent_value", + job_template_id="job_template_id_value", + ) + + # Make the request + response = await client.create_job_template(request=request) + + # Handle the response + print(response) + +# [END transcoder_v1_generated_TranscoderService_CreateJobTemplate_async] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_create_job_template_sync.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_create_job_template_sync.py new file mode 100644 index 000000000000..615823d372f7 --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_create_job_template_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 CreateJobTemplate +# 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-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_CreateJobTemplate_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.video import transcoder_v1 + + +def sample_create_job_template(): + # Create a client + client = transcoder_v1.TranscoderServiceClient() + + # Initialize request argument(s) + request = transcoder_v1.CreateJobTemplateRequest( + parent="parent_value", + job_template_id="job_template_id_value", + ) + + # Make the request + response = client.create_job_template(request=request) + + # Handle the response + print(response) + +# [END transcoder_v1_generated_TranscoderService_CreateJobTemplate_sync] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_delete_job_async.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_delete_job_async.py new file mode 100644 index 000000000000..230b0a602253 --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_delete_job_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteJob +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_DeleteJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import transcoder_v1 + + +async def sample_delete_job(): + # Create a client + client = transcoder_v1.TranscoderServiceAsyncClient() + + # Initialize request argument(s) + request = transcoder_v1.DeleteJobRequest( + name="name_value", + ) + + # Make the request + await client.delete_job(request=request) + + +# [END transcoder_v1_generated_TranscoderService_DeleteJob_async] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_delete_job_sync.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_delete_job_sync.py new file mode 100644 index 000000000000..b8deaf9d9d04 --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_delete_job_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteJob +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_DeleteJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import transcoder_v1 + + +def sample_delete_job(): + # Create a client + client = transcoder_v1.TranscoderServiceClient() + + # Initialize request argument(s) + request = transcoder_v1.DeleteJobRequest( + name="name_value", + ) + + # Make the request + client.delete_job(request=request) + + +# [END transcoder_v1_generated_TranscoderService_DeleteJob_sync] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_delete_job_template_async.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_delete_job_template_async.py new file mode 100644 index 000000000000..b7f2b1c178c2 --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_delete_job_template_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteJobTemplate +# 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-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_DeleteJobTemplate_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.video import transcoder_v1 + + +async def sample_delete_job_template(): + # Create a client + client = transcoder_v1.TranscoderServiceAsyncClient() + + # Initialize request argument(s) + request = transcoder_v1.DeleteJobTemplateRequest( + name="name_value", + ) + + # Make the request + await client.delete_job_template(request=request) + + +# [END transcoder_v1_generated_TranscoderService_DeleteJobTemplate_async] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_delete_job_template_sync.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_delete_job_template_sync.py new file mode 100644 index 000000000000..15f2607c8587 --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_delete_job_template_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 DeleteJobTemplate +# 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-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_DeleteJobTemplate_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.video import transcoder_v1 + + +def sample_delete_job_template(): + # Create a client + client = transcoder_v1.TranscoderServiceClient() + + # Initialize request argument(s) + request = transcoder_v1.DeleteJobTemplateRequest( + name="name_value", + ) + + # Make the request + client.delete_job_template(request=request) + + +# [END transcoder_v1_generated_TranscoderService_DeleteJobTemplate_sync] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_get_job_async.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_get_job_async.py new file mode 100644 index 000000000000..c2706abc9514 --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_get_job_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetJob +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_GetJob_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import transcoder_v1 + + +async def sample_get_job(): + # Create a client + client = transcoder_v1.TranscoderServiceAsyncClient() + + # Initialize request argument(s) + request = transcoder_v1.GetJobRequest( + name="name_value", + ) + + # Make the request + response = await client.get_job(request=request) + + # Handle the response + print(response) + +# [END transcoder_v1_generated_TranscoderService_GetJob_async] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_get_job_sync.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_get_job_sync.py new file mode 100644 index 000000000000..c165f7dfaa4a --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_get_job_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetJob +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_GetJob_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import transcoder_v1 + + +def sample_get_job(): + # Create a client + client = transcoder_v1.TranscoderServiceClient() + + # Initialize request argument(s) + request = transcoder_v1.GetJobRequest( + name="name_value", + ) + + # Make the request + response = client.get_job(request=request) + + # Handle the response + print(response) + +# [END transcoder_v1_generated_TranscoderService_GetJob_sync] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_get_job_template_async.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_get_job_template_async.py new file mode 100644 index 000000000000..71b32ae2c8cf --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_get_job_template_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetJobTemplate +# 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-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_GetJobTemplate_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.video import transcoder_v1 + + +async def sample_get_job_template(): + # Create a client + client = transcoder_v1.TranscoderServiceAsyncClient() + + # Initialize request argument(s) + request = transcoder_v1.GetJobTemplateRequest( + name="name_value", + ) + + # Make the request + response = await client.get_job_template(request=request) + + # Handle the response + print(response) + +# [END transcoder_v1_generated_TranscoderService_GetJobTemplate_async] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_get_job_template_sync.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_get_job_template_sync.py new file mode 100644 index 000000000000..b345463a824e --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_get_job_template_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 GetJobTemplate +# 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-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_GetJobTemplate_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.video import transcoder_v1 + + +def sample_get_job_template(): + # Create a client + client = transcoder_v1.TranscoderServiceClient() + + # Initialize request argument(s) + request = transcoder_v1.GetJobTemplateRequest( + name="name_value", + ) + + # Make the request + response = client.get_job_template(request=request) + + # Handle the response + print(response) + +# [END transcoder_v1_generated_TranscoderService_GetJobTemplate_sync] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_list_job_templates_async.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_list_job_templates_async.py new file mode 100644 index 000000000000..f52c630ee5b4 --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_list_job_templates_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListJobTemplates +# 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-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_ListJobTemplates_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.video import transcoder_v1 + + +async def sample_list_job_templates(): + # Create a client + client = transcoder_v1.TranscoderServiceAsyncClient() + + # Initialize request argument(s) + request = transcoder_v1.ListJobTemplatesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_job_templates(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END transcoder_v1_generated_TranscoderService_ListJobTemplates_async] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_list_job_templates_sync.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_list_job_templates_sync.py new file mode 100644 index 000000000000..29976ae37e4d --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_list_job_templates_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 ListJobTemplates +# 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-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_ListJobTemplates_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.video import transcoder_v1 + + +def sample_list_job_templates(): + # Create a client + client = transcoder_v1.TranscoderServiceClient() + + # Initialize request argument(s) + request = transcoder_v1.ListJobTemplatesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_job_templates(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END transcoder_v1_generated_TranscoderService_ListJobTemplates_sync] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_list_jobs_async.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_list_jobs_async.py new file mode 100644 index 000000000000..48cffa53e03e --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_list_jobs_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListJobs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_ListJobs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import transcoder_v1 + + +async def sample_list_jobs(): + # Create a client + client = transcoder_v1.TranscoderServiceAsyncClient() + + # Initialize request argument(s) + request = transcoder_v1.ListJobsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_jobs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END transcoder_v1_generated_TranscoderService_ListJobs_async] diff --git a/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_list_jobs_sync.py b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_list_jobs_sync.py new file mode 100644 index 000000000000..e9719b9c3cc0 --- /dev/null +++ b/packages/google-cloud-video-transcoder/samples/generated_samples/transcoder_v1_generated_transcoder_service_list_jobs_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListJobs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-transcoder + + +# [START transcoder_v1_generated_TranscoderService_ListJobs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import transcoder_v1 + + +def sample_list_jobs(): + # Create a client + client = transcoder_v1.TranscoderServiceClient() + + # Initialize request argument(s) + request = transcoder_v1.ListJobsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_jobs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END transcoder_v1_generated_TranscoderService_ListJobs_sync] diff --git a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py index 907403be94b8..3fa2aba605e9 100644 --- a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py +++ b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py @@ -3353,6 +3353,73 @@ def test_create_job_rest(request_type): "batch_mode_priority": 2023, "optimization": 1, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = services.CreateJobRequest.meta.fields["job"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["job"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["job"][field])): + del request_init["job"][field][i][subfield] + else: + del request_init["job"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -3373,8 +3440,9 @@ def test_create_job_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Job.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 @@ -3455,8 +3523,9 @@ def test_create_job_rest_required_fields(request_type=services.CreateJobRequest) response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Job.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 @@ -3548,258 +3617,6 @@ def test_create_job_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["job"] = { - "name": "name_value", - "input_uri": "input_uri_value", - "output_uri": "output_uri_value", - "template_id": "template_id_value", - "config": { - "inputs": [ - { - "key": "key_value", - "uri": "uri_value", - "preprocessing_config": { - "color": { - "saturation": 0.10980000000000001, - "contrast": 0.878, - "brightness": 0.1081, - }, - "denoise": {"strength": 0.879, "tune": "tune_value"}, - "deblock": {"strength": 0.879, "enabled": True}, - "audio": {"lufs": 0.442, "high_boost": True, "low_boost": True}, - "crop": { - "top_pixels": 1095, - "bottom_pixels": 1417, - "left_pixels": 1183, - "right_pixels": 1298, - }, - "pad": { - "top_pixels": 1095, - "bottom_pixels": 1417, - "left_pixels": 1183, - "right_pixels": 1298, - }, - "deinterlace": { - "yadif": { - "mode": "mode_value", - "disable_spatial_interlacing": True, - "parity": "parity_value", - "deinterlace_all_frames": True, - }, - "bwdif": { - "mode": "mode_value", - "parity": "parity_value", - "deinterlace_all_frames": True, - }, - }, - }, - } - ], - "edit_list": [ - { - "key": "key_value", - "inputs": ["inputs_value1", "inputs_value2"], - "end_time_offset": {"seconds": 751, "nanos": 543}, - "start_time_offset": {}, - } - ], - "elementary_streams": [ - { - "key": "key_value", - "video_stream": { - "h264": { - "width_pixels": 1300, - "height_pixels": 1389, - "frame_rate": 0.1046, - "bitrate_bps": 1167, - "pixel_format": "pixel_format_value", - "rate_control_mode": "rate_control_mode_value", - "crf_level": 946, - "allow_open_gop": True, - "gop_frame_count": 1592, - "gop_duration": {}, - "enable_two_pass": True, - "vbv_size_bits": 1401, - "vbv_fullness_bits": 1834, - "entropy_coder": "entropy_coder_value", - "b_pyramid": True, - "b_frame_count": 1364, - "aq_strength": 0.1184, - "profile": "profile_value", - "tune": "tune_value", - "preset": "preset_value", - }, - "h265": { - "width_pixels": 1300, - "height_pixels": 1389, - "frame_rate": 0.1046, - "bitrate_bps": 1167, - "pixel_format": "pixel_format_value", - "rate_control_mode": "rate_control_mode_value", - "crf_level": 946, - "allow_open_gop": True, - "gop_frame_count": 1592, - "gop_duration": {}, - "enable_two_pass": True, - "vbv_size_bits": 1401, - "vbv_fullness_bits": 1834, - "b_pyramid": True, - "b_frame_count": 1364, - "aq_strength": 0.1184, - "profile": "profile_value", - "tune": "tune_value", - "preset": "preset_value", - }, - "vp9": { - "width_pixels": 1300, - "height_pixels": 1389, - "frame_rate": 0.1046, - "bitrate_bps": 1167, - "pixel_format": "pixel_format_value", - "rate_control_mode": "rate_control_mode_value", - "crf_level": 946, - "gop_frame_count": 1592, - "gop_duration": {}, - "profile": "profile_value", - }, - }, - "audio_stream": { - "codec": "codec_value", - "bitrate_bps": 1167, - "channel_count": 1377, - "channel_layout": [ - "channel_layout_value1", - "channel_layout_value2", - ], - "mapping_": [ - { - "atom_key": "atom_key_value", - "input_key": "input_key_value", - "input_track": 1188, - "input_channel": 1384, - "output_channel": 1513, - "gain_db": 0.708, - } - ], - "sample_rate_hertz": 1817, - "language_code": "language_code_value", - "display_name": "display_name_value", - }, - "text_stream": { - "codec": "codec_value", - "language_code": "language_code_value", - "mapping_": [ - { - "atom_key": "atom_key_value", - "input_key": "input_key_value", - "input_track": 1188, - } - ], - "display_name": "display_name_value", - }, - } - ], - "mux_streams": [ - { - "key": "key_value", - "file_name": "file_name_value", - "container": "container_value", - "elementary_streams": [ - "elementary_streams_value1", - "elementary_streams_value2", - ], - "segment_settings": { - "segment_duration": {}, - "individual_segments": True, - }, - "encryption_id": "encryption_id_value", - } - ], - "manifests": [ - { - "file_name": "file_name_value", - "type_": 1, - "mux_streams": ["mux_streams_value1", "mux_streams_value2"], - "dash": {"segment_reference_scheme": 1}, - } - ], - "output": {"uri": "uri_value"}, - "ad_breaks": [{"start_time_offset": {}}], - "pubsub_destination": {"topic": "topic_value"}, - "sprite_sheets": [ - { - "format_": "format__value", - "file_prefix": "file_prefix_value", - "sprite_width_pixels": 2058, - "sprite_height_pixels": 2147, - "column_count": 1302, - "row_count": 992, - "start_time_offset": {}, - "end_time_offset": {}, - "total_count": 1196, - "interval": {}, - "quality": 777, - } - ], - "overlays": [ - { - "image": { - "uri": "uri_value", - "resolution": {"x": 0.12, "y": 0.121}, - "alpha": 0.518, - }, - "animations": [ - { - "animation_static": {"xy": {}, "start_time_offset": {}}, - "animation_fade": { - "fade_type": 1, - "xy": {}, - "start_time_offset": {}, - "end_time_offset": {}, - }, - "animation_end": {"start_time_offset": {}}, - } - ], - } - ], - "encryptions": [ - { - "id": "id_value", - "aes_128": {}, - "sample_aes": {}, - "mpeg_cenc": {"scheme": "scheme_value"}, - "secret_manager_key_source": { - "secret_version": "secret_version_value" - }, - "drm_systems": { - "widevine": {}, - "fairplay": {}, - "playready": {}, - "clearkey": {}, - }, - } - ], - }, - "state": 1, - "create_time": {"seconds": 751, "nanos": 543}, - "start_time": {}, - "end_time": {}, - "ttl_after_completion_days": 2670, - "labels": {}, - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - "mode": 1, - "batch_mode_priority": 2023, - "optimization": 1, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -3838,8 +3655,9 @@ def test_create_job_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Job.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 @@ -3905,8 +3723,9 @@ def test_list_jobs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = services.ListJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = services.ListJobsResponse.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 @@ -3989,8 +3808,9 @@ def test_list_jobs_rest_required_fields(request_type=services.ListJobsRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = services.ListJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = services.ListJobsResponse.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 @@ -4123,8 +3943,9 @@ def test_list_jobs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = services.ListJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = services.ListJobsResponse.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 @@ -4251,8 +4072,9 @@ def test_get_job_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Job.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 @@ -4332,8 +4154,9 @@ def test_get_job_rest_required_fields(request_type=services.GetJobRequest): response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Job.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 @@ -4454,8 +4277,9 @@ def test_get_job_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.Job.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.Job.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 @@ -4988,6 +4812,73 @@ def test_create_job_template_rest(request_type): }, "labels": {}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = services.CreateJobTemplateRequest.meta.fields["job_template"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["job_template"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["job_template"][field])): + del request_init["job_template"][field][i][subfield] + else: + del request_init["job_template"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -5000,8 +4891,9 @@ def test_create_job_template_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.JobTemplate.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.JobTemplate.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 @@ -5086,8 +4978,9 @@ def test_create_job_template_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.JobTemplate.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.JobTemplate.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 @@ -5190,237 +5083,6 @@ def test_create_job_template_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["job_template"] = { - "name": "name_value", - "config": { - "inputs": [ - { - "key": "key_value", - "uri": "uri_value", - "preprocessing_config": { - "color": { - "saturation": 0.10980000000000001, - "contrast": 0.878, - "brightness": 0.1081, - }, - "denoise": {"strength": 0.879, "tune": "tune_value"}, - "deblock": {"strength": 0.879, "enabled": True}, - "audio": {"lufs": 0.442, "high_boost": True, "low_boost": True}, - "crop": { - "top_pixels": 1095, - "bottom_pixels": 1417, - "left_pixels": 1183, - "right_pixels": 1298, - }, - "pad": { - "top_pixels": 1095, - "bottom_pixels": 1417, - "left_pixels": 1183, - "right_pixels": 1298, - }, - "deinterlace": { - "yadif": { - "mode": "mode_value", - "disable_spatial_interlacing": True, - "parity": "parity_value", - "deinterlace_all_frames": True, - }, - "bwdif": { - "mode": "mode_value", - "parity": "parity_value", - "deinterlace_all_frames": True, - }, - }, - }, - } - ], - "edit_list": [ - { - "key": "key_value", - "inputs": ["inputs_value1", "inputs_value2"], - "end_time_offset": {"seconds": 751, "nanos": 543}, - "start_time_offset": {}, - } - ], - "elementary_streams": [ - { - "key": "key_value", - "video_stream": { - "h264": { - "width_pixels": 1300, - "height_pixels": 1389, - "frame_rate": 0.1046, - "bitrate_bps": 1167, - "pixel_format": "pixel_format_value", - "rate_control_mode": "rate_control_mode_value", - "crf_level": 946, - "allow_open_gop": True, - "gop_frame_count": 1592, - "gop_duration": {}, - "enable_two_pass": True, - "vbv_size_bits": 1401, - "vbv_fullness_bits": 1834, - "entropy_coder": "entropy_coder_value", - "b_pyramid": True, - "b_frame_count": 1364, - "aq_strength": 0.1184, - "profile": "profile_value", - "tune": "tune_value", - "preset": "preset_value", - }, - "h265": { - "width_pixels": 1300, - "height_pixels": 1389, - "frame_rate": 0.1046, - "bitrate_bps": 1167, - "pixel_format": "pixel_format_value", - "rate_control_mode": "rate_control_mode_value", - "crf_level": 946, - "allow_open_gop": True, - "gop_frame_count": 1592, - "gop_duration": {}, - "enable_two_pass": True, - "vbv_size_bits": 1401, - "vbv_fullness_bits": 1834, - "b_pyramid": True, - "b_frame_count": 1364, - "aq_strength": 0.1184, - "profile": "profile_value", - "tune": "tune_value", - "preset": "preset_value", - }, - "vp9": { - "width_pixels": 1300, - "height_pixels": 1389, - "frame_rate": 0.1046, - "bitrate_bps": 1167, - "pixel_format": "pixel_format_value", - "rate_control_mode": "rate_control_mode_value", - "crf_level": 946, - "gop_frame_count": 1592, - "gop_duration": {}, - "profile": "profile_value", - }, - }, - "audio_stream": { - "codec": "codec_value", - "bitrate_bps": 1167, - "channel_count": 1377, - "channel_layout": [ - "channel_layout_value1", - "channel_layout_value2", - ], - "mapping_": [ - { - "atom_key": "atom_key_value", - "input_key": "input_key_value", - "input_track": 1188, - "input_channel": 1384, - "output_channel": 1513, - "gain_db": 0.708, - } - ], - "sample_rate_hertz": 1817, - "language_code": "language_code_value", - "display_name": "display_name_value", - }, - "text_stream": { - "codec": "codec_value", - "language_code": "language_code_value", - "mapping_": [ - { - "atom_key": "atom_key_value", - "input_key": "input_key_value", - "input_track": 1188, - } - ], - "display_name": "display_name_value", - }, - } - ], - "mux_streams": [ - { - "key": "key_value", - "file_name": "file_name_value", - "container": "container_value", - "elementary_streams": [ - "elementary_streams_value1", - "elementary_streams_value2", - ], - "segment_settings": { - "segment_duration": {}, - "individual_segments": True, - }, - "encryption_id": "encryption_id_value", - } - ], - "manifests": [ - { - "file_name": "file_name_value", - "type_": 1, - "mux_streams": ["mux_streams_value1", "mux_streams_value2"], - "dash": {"segment_reference_scheme": 1}, - } - ], - "output": {"uri": "uri_value"}, - "ad_breaks": [{"start_time_offset": {}}], - "pubsub_destination": {"topic": "topic_value"}, - "sprite_sheets": [ - { - "format_": "format__value", - "file_prefix": "file_prefix_value", - "sprite_width_pixels": 2058, - "sprite_height_pixels": 2147, - "column_count": 1302, - "row_count": 992, - "start_time_offset": {}, - "end_time_offset": {}, - "total_count": 1196, - "interval": {}, - "quality": 777, - } - ], - "overlays": [ - { - "image": { - "uri": "uri_value", - "resolution": {"x": 0.12, "y": 0.121}, - "alpha": 0.518, - }, - "animations": [ - { - "animation_static": {"xy": {}, "start_time_offset": {}}, - "animation_fade": { - "fade_type": 1, - "xy": {}, - "start_time_offset": {}, - "end_time_offset": {}, - }, - "animation_end": {"start_time_offset": {}}, - } - ], - } - ], - "encryptions": [ - { - "id": "id_value", - "aes_128": {}, - "sample_aes": {}, - "mpeg_cenc": {"scheme": "scheme_value"}, - "secret_manager_key_source": { - "secret_version": "secret_version_value" - }, - "drm_systems": { - "widevine": {}, - "fairplay": {}, - "playready": {}, - "clearkey": {}, - }, - } - ], - }, - "labels": {}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -5460,8 +5122,9 @@ def test_create_job_template_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.JobTemplate.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.JobTemplate.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 @@ -5529,8 +5192,9 @@ def test_list_job_templates_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = services.ListJobTemplatesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = services.ListJobTemplatesResponse.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 @@ -5615,8 +5279,9 @@ def test_list_job_templates_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = services.ListJobTemplatesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = services.ListJobTemplatesResponse.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 @@ -5751,8 +5416,9 @@ def test_list_job_templates_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = services.ListJobTemplatesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = services.ListJobTemplatesResponse.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 @@ -5872,8 +5538,9 @@ def test_get_job_template_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.JobTemplate.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.JobTemplate.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 @@ -5948,8 +5615,9 @@ def test_get_job_template_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = resources.JobTemplate.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.JobTemplate.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 @@ -6074,8 +5742,9 @@ def test_get_job_template_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = resources.JobTemplate.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = resources.JobTemplate.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 diff --git a/packages/google-cloud-vm-migration/CONTRIBUTING.rst b/packages/google-cloud-vm-migration/CONTRIBUTING.rst index d070b13e3844..5545009298e7 100644 --- a/packages/google-cloud-vm-migration/CONTRIBUTING.rst +++ b/packages/google-cloud-vm-migration/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration/gapic_version.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration/gapic_version.py index fc429472f4c9..360a0d13ebdd 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration/gapic_version.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.6.3" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/gapic_version.py b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/gapic_version.py index fc429472f4c9..360a0d13ebdd 100644 --- a/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/gapic_version.py +++ b/packages/google-cloud-vm-migration/google/cloud/vmmigration_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.6.3" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vm-migration/noxfile.py b/packages/google-cloud-vm-migration/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-vm-migration/noxfile.py +++ b/packages/google-cloud-vm-migration/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-vm-migration/samples/generated_samples/snippet_metadata_google.cloud.vmmigration.v1.json b/packages/google-cloud-vm-migration/samples/generated_samples/snippet_metadata_google.cloud.vmmigration.v1.json index 72b17cb89a54..8437717ca276 100644 --- a/packages/google-cloud-vm-migration/samples/generated_samples/snippet_metadata_google.cloud.vmmigration.v1.json +++ b/packages/google-cloud-vm-migration/samples/generated_samples/snippet_metadata_google.cloud.vmmigration.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vm-migration", - "version": "1.6.3" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-vm-migration/tests/unit/gapic/vmmigration_v1/test_vm_migration.py b/packages/google-cloud-vm-migration/tests/unit/gapic/vmmigration_v1/test_vm_migration.py index 19f67555ec61..f4cefeead8f2 100644 --- a/packages/google-cloud-vm-migration/tests/unit/gapic/vmmigration_v1/test_vm_migration.py +++ b/packages/google-cloud-vm-migration/tests/unit/gapic/vmmigration_v1/test_vm_migration.py @@ -13591,8 +13591,9 @@ def test_list_sources_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListSourcesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListSourcesResponse.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 @@ -13682,8 +13683,9 @@ def test_list_sources_rest_required_fields(request_type=vmmigration.ListSourcesR response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListSourcesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListSourcesResponse.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 @@ -13827,8 +13829,9 @@ def test_list_sources_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListSourcesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListSourcesResponse.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 @@ -13948,8 +13951,9 @@ def test_get_source_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.Source.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.Source.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 @@ -14023,8 +14027,9 @@ def test_get_source_rest_required_fields(request_type=vmmigration.GetSourceReque response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.Source.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.Source.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 @@ -14145,8 +14150,9 @@ def test_get_source_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.Source.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.Source.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 @@ -14236,6 +14242,73 @@ def test_create_source_rest(request_type): "labels": {}, "description": "description_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmmigration.CreateSourceRequest.meta.fields["source"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["source"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["source"][field])): + del request_init["source"][field][i][subfield] + else: + del request_init["source"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -14444,44 +14517,6 @@ def test_create_source_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["source"] = { - "vmware": { - "username": "username_value", - "password": "password_value", - "vcenter_ip": "vcenter_ip_value", - "thumbprint": "thumbprint_value", - }, - "aws": { - "access_key_creds": { - "access_key_id": "access_key_id_value", - "secret_access_key": "secret_access_key_value", - }, - "aws_region": "aws_region_value", - "state": 1, - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - "inventory_tag_list": [{"key": "key_value", "value": "value_value"}], - "inventory_security_group_names": [ - "inventory_security_group_names_value1", - "inventory_security_group_names_value2", - ], - "migration_resources_user_tags": {}, - "public_ip": "public_ip_value", - }, - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "labels": {}, - "description": "description_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -14619,6 +14654,73 @@ def test_update_source_rest(request_type): "labels": {}, "description": "description_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmmigration.UpdateSourceRequest.meta.fields["source"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["source"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["source"][field])): + del request_init["source"][field][i][subfield] + else: + del request_init["source"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -14805,44 +14907,6 @@ def test_update_source_rest_bad_request( request_init = { "source": {"name": "projects/sample1/locations/sample2/sources/sample3"} } - request_init["source"] = { - "vmware": { - "username": "username_value", - "password": "password_value", - "vcenter_ip": "vcenter_ip_value", - "thumbprint": "thumbprint_value", - }, - "aws": { - "access_key_creds": { - "access_key_id": "access_key_id_value", - "secret_access_key": "secret_access_key_value", - }, - "aws_region": "aws_region_value", - "state": 1, - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - "inventory_tag_list": [{"key": "key_value", "value": "value_value"}], - "inventory_security_group_names": [ - "inventory_security_group_names_value1", - "inventory_security_group_names_value2", - ], - "migration_resources_user_tags": {}, - "public_ip": "public_ip_value", - }, - "name": "projects/sample1/locations/sample2/sources/sample3", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "labels": {}, - "description": "description_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -15215,8 +15279,9 @@ def test_fetch_inventory_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.FetchInventoryResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.FetchInventoryResponse.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 @@ -15292,8 +15357,9 @@ def test_fetch_inventory_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.FetchInventoryResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.FetchInventoryResponse.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 @@ -15420,8 +15486,9 @@ def test_fetch_inventory_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.FetchInventoryResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.FetchInventoryResponse.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 @@ -15487,8 +15554,9 @@ def test_list_utilization_reports_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListUtilizationReportsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListUtilizationReportsResponse.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 @@ -15581,10 +15649,9 @@ def test_list_utilization_reports_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListUtilizationReportsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListUtilizationReportsResponse.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 @@ -15733,8 +15800,9 @@ def test_list_utilization_reports_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListUtilizationReportsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListUtilizationReportsResponse.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 @@ -15864,8 +15932,9 @@ def test_get_utilization_report_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.UtilizationReport.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.UtilizationReport.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 @@ -15946,8 +16015,9 @@ def test_get_utilization_report_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.UtilizationReport.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.UtilizationReport.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 @@ -16076,8 +16146,9 @@ def test_get_utilization_report_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.UtilizationReport.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.UtilizationReport.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 @@ -16179,6 +16250,75 @@ def test_create_utilization_report_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmmigration.CreateUtilizationReportRequest.meta.fields[ + "utilization_report" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["utilization_report"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["utilization_report"][field])): + del request_init["utilization_report"][field][i][subfield] + else: + del request_init["utilization_report"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -16390,55 +16530,6 @@ def test_create_utilization_report_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2/sources/sample3"} - request_init["utilization_report"] = { - "name": "name_value", - "display_name": "display_name_value", - "state": 1, - "state_time": {"seconds": 751, "nanos": 543}, - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - "create_time": {}, - "time_frame": 1, - "frame_end_time": {}, - "vm_count": 875, - "vms": [ - { - "vmware_vm_details": { - "vm_id": "vm_id_value", - "datacenter_id": "datacenter_id_value", - "datacenter_description": "datacenter_description_value", - "uuid": "uuid_value", - "display_name": "display_name_value", - "power_state": 1, - "cpu_count": 976, - "memory_mb": 967, - "disk_count": 1075, - "committed_storage_mb": 2120, - "guest_description": "guest_description_value", - "boot_option": 1, - }, - "vm_id": "vm_id_value", - "utilization": { - "cpu_max_percent": 1597, - "cpu_average_percent": 2002, - "memory_max_percent": 1934, - "memory_average_percent": 2339, - "disk_io_rate_max_kbps": 2209, - "disk_io_rate_average_kbps": 2614, - "network_throughput_max_kbps": 2935, - "network_throughput_average_kbps": 3340, - }, - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -16819,8 +16910,9 @@ def test_list_datacenter_connectors_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListDatacenterConnectorsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListDatacenterConnectorsResponse.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 @@ -16912,10 +17004,9 @@ def test_list_datacenter_connectors_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListDatacenterConnectorsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListDatacenterConnectorsResponse.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 @@ -17065,8 +17156,9 @@ def test_list_datacenter_connectors_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListDatacenterConnectorsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListDatacenterConnectorsResponse.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 @@ -17199,8 +17291,9 @@ def test_get_datacenter_connector_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.DatacenterConnector.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.DatacenterConnector.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 @@ -17285,8 +17378,9 @@ def test_get_datacenter_connector_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.DatacenterConnector.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.DatacenterConnector.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 @@ -17415,8 +17509,9 @@ def test_get_datacenter_connector_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.DatacenterConnector.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.DatacenterConnector.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 @@ -17508,6 +17603,77 @@ def test_create_datacenter_connector_rest(request_type): "previous_version": "previous_version_value", }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmmigration.CreateDatacenterConnectorRequest.meta.fields[ + "datacenter_connector" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "datacenter_connector" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["datacenter_connector"][field])): + del request_init["datacenter_connector"][field][i][subfield] + else: + del request_init["datacenter_connector"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -17719,45 +17885,6 @@ def test_create_datacenter_connector_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2/sources/sample3"} - request_init["datacenter_connector"] = { - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "name": "name_value", - "registration_id": "registration_id_value", - "service_account": "service_account_value", - "version": "version_value", - "bucket": "bucket_value", - "state": 1, - "state_time": {}, - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - "appliance_infrastructure_version": "appliance_infrastructure_version_value", - "appliance_software_version": "appliance_software_version_value", - "available_versions": { - "new_deployable_appliance": { - "version": "version_value", - "uri": "uri_value", - "critical": True, - "release_notes_uri": "release_notes_uri_value", - }, - "in_place_update": {}, - }, - "upgrade_status": { - "version": "version_value", - "state": 1, - "error": {}, - "start_time": {}, - "previous_version": "previous_version_value", - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -18501,6 +18628,73 @@ def test_create_migrating_vm_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmmigration.CreateMigratingVmRequest.meta.fields["migrating_vm"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["migrating_vm"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["migrating_vm"][field])): + del request_init["migrating_vm"][field][i][subfield] + else: + del request_init["migrating_vm"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -18709,165 +18903,6 @@ def test_create_migrating_vm_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2/sources/sample3"} - request_init["migrating_vm"] = { - "compute_engine_target_defaults": { - "vm_name": "vm_name_value", - "target_project": "target_project_value", - "zone": "zone_value", - "machine_type_series": "machine_type_series_value", - "machine_type": "machine_type_value", - "network_tags": ["network_tags_value1", "network_tags_value2"], - "network_interfaces": [ - { - "network": "network_value", - "subnetwork": "subnetwork_value", - "internal_ip": "internal_ip_value", - "external_ip": "external_ip_value", - } - ], - "service_account": "service_account_value", - "disk_type": 1, - "labels": {}, - "license_type": 1, - "applied_license": {"type_": 1, "os_license": "os_license_value"}, - "compute_scheduling": { - "on_host_maintenance": 1, - "restart_type": 1, - "node_affinities": [ - { - "key": "key_value", - "operator": 1, - "values": ["values_value1", "values_value2"], - } - ], - "min_node_cpus": 1379, - }, - "secure_boot": True, - "boot_option": 1, - "metadata": {}, - "additional_licenses": [ - "additional_licenses_value1", - "additional_licenses_value2", - ], - "hostname": "hostname_value", - }, - "aws_source_vm_details": {"firmware": 1, "committed_storage_bytes": 2464}, - "name": "name_value", - "source_vm_id": "source_vm_id_value", - "display_name": "display_name_value", - "description": "description_value", - "policy": { - "idle_duration": {"seconds": 751, "nanos": 543}, - "skip_os_adaptation": True, - }, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "last_sync": {"last_sync_time": {}}, - "state": 1, - "state_time": {}, - "current_sync_info": { - "name": "name_value", - "cycle_number": 1272, - "start_time": {}, - "end_time": {}, - "total_pause_duration": {}, - "progress_percent": 1733, - "steps": [ - { - "initializing_replication": {}, - "replicating": { - "total_bytes": 1194, - "replicated_bytes": 1699, - "last_two_minutes_average_bytes_per_second": 4370, - "last_thirty_minutes_average_bytes_per_second": 4700, - }, - "post_processing": {}, - "start_time": {}, - "end_time": {}, - } - ], - "state": 1, - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - }, - "group": "group_value", - "labels": {}, - "recent_clone_jobs": [ - { - "compute_engine_target_details": { - "vm_name": "vm_name_value", - "project": "project_value", - "zone": "zone_value", - "machine_type_series": "machine_type_series_value", - "machine_type": "machine_type_value", - "network_tags": ["network_tags_value1", "network_tags_value2"], - "network_interfaces": {}, - "service_account": "service_account_value", - "disk_type": 1, - "labels": {}, - "license_type": 1, - "applied_license": {}, - "compute_scheduling": {}, - "secure_boot": True, - "boot_option": 1, - "metadata": {}, - "additional_licenses": [ - "additional_licenses_value1", - "additional_licenses_value2", - ], - "hostname": "hostname_value", - }, - "create_time": {}, - "end_time": {}, - "name": "name_value", - "state": 1, - "state_time": {}, - "error": {}, - "steps": [ - { - "adapting_os": {}, - "preparing_vm_disks": {}, - "instantiating_migrated_vm": {}, - "start_time": {}, - "end_time": {}, - } - ], - } - ], - "error": {}, - "recent_cutover_jobs": [ - { - "compute_engine_target_details": {}, - "create_time": {}, - "end_time": {}, - "name": "name_value", - "state": 1, - "state_time": {}, - "progress_percent": 1733, - "error": {}, - "state_message": "state_message_value", - "steps": [ - { - "previous_replication_cycle": {}, - "shutting_down_source_vm": {}, - "final_sync": {}, - "preparing_vm_disks": {}, - "instantiating_migrated_vm": {}, - "start_time": {}, - "end_time": {}, - } - ], - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -18985,8 +19020,9 @@ def test_list_migrating_vms_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListMigratingVmsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListMigratingVmsResponse.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 @@ -19079,8 +19115,9 @@ def test_list_migrating_vms_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListMigratingVmsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListMigratingVmsResponse.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 @@ -19229,8 +19266,9 @@ def test_list_migrating_vms_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListMigratingVmsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListMigratingVmsResponse.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 @@ -19361,8 +19399,9 @@ def test_get_migrating_vm_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.MigratingVm.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.MigratingVm.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 @@ -19444,8 +19483,9 @@ def test_get_migrating_vm_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.MigratingVm.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.MigratingVm.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 @@ -19574,8 +19614,9 @@ def test_get_migrating_vm_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.MigratingVm.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.MigratingVm.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 @@ -19791,6 +19832,73 @@ def test_update_migrating_vm_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmmigration.UpdateMigratingVmRequest.meta.fields["migrating_vm"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["migrating_vm"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["migrating_vm"][field])): + del request_init["migrating_vm"][field][i][subfield] + else: + del request_init["migrating_vm"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -19979,165 +20087,6 @@ def test_update_migrating_vm_rest_bad_request( "name": "projects/sample1/locations/sample2/sources/sample3/migratingVms/sample4" } } - request_init["migrating_vm"] = { - "compute_engine_target_defaults": { - "vm_name": "vm_name_value", - "target_project": "target_project_value", - "zone": "zone_value", - "machine_type_series": "machine_type_series_value", - "machine_type": "machine_type_value", - "network_tags": ["network_tags_value1", "network_tags_value2"], - "network_interfaces": [ - { - "network": "network_value", - "subnetwork": "subnetwork_value", - "internal_ip": "internal_ip_value", - "external_ip": "external_ip_value", - } - ], - "service_account": "service_account_value", - "disk_type": 1, - "labels": {}, - "license_type": 1, - "applied_license": {"type_": 1, "os_license": "os_license_value"}, - "compute_scheduling": { - "on_host_maintenance": 1, - "restart_type": 1, - "node_affinities": [ - { - "key": "key_value", - "operator": 1, - "values": ["values_value1", "values_value2"], - } - ], - "min_node_cpus": 1379, - }, - "secure_boot": True, - "boot_option": 1, - "metadata": {}, - "additional_licenses": [ - "additional_licenses_value1", - "additional_licenses_value2", - ], - "hostname": "hostname_value", - }, - "aws_source_vm_details": {"firmware": 1, "committed_storage_bytes": 2464}, - "name": "projects/sample1/locations/sample2/sources/sample3/migratingVms/sample4", - "source_vm_id": "source_vm_id_value", - "display_name": "display_name_value", - "description": "description_value", - "policy": { - "idle_duration": {"seconds": 751, "nanos": 543}, - "skip_os_adaptation": True, - }, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "last_sync": {"last_sync_time": {}}, - "state": 1, - "state_time": {}, - "current_sync_info": { - "name": "name_value", - "cycle_number": 1272, - "start_time": {}, - "end_time": {}, - "total_pause_duration": {}, - "progress_percent": 1733, - "steps": [ - { - "initializing_replication": {}, - "replicating": { - "total_bytes": 1194, - "replicated_bytes": 1699, - "last_two_minutes_average_bytes_per_second": 4370, - "last_thirty_minutes_average_bytes_per_second": 4700, - }, - "post_processing": {}, - "start_time": {}, - "end_time": {}, - } - ], - "state": 1, - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - }, - "group": "group_value", - "labels": {}, - "recent_clone_jobs": [ - { - "compute_engine_target_details": { - "vm_name": "vm_name_value", - "project": "project_value", - "zone": "zone_value", - "machine_type_series": "machine_type_series_value", - "machine_type": "machine_type_value", - "network_tags": ["network_tags_value1", "network_tags_value2"], - "network_interfaces": {}, - "service_account": "service_account_value", - "disk_type": 1, - "labels": {}, - "license_type": 1, - "applied_license": {}, - "compute_scheduling": {}, - "secure_boot": True, - "boot_option": 1, - "metadata": {}, - "additional_licenses": [ - "additional_licenses_value1", - "additional_licenses_value2", - ], - "hostname": "hostname_value", - }, - "create_time": {}, - "end_time": {}, - "name": "name_value", - "state": 1, - "state_time": {}, - "error": {}, - "steps": [ - { - "adapting_os": {}, - "preparing_vm_disks": {}, - "instantiating_migrated_vm": {}, - "start_time": {}, - "end_time": {}, - } - ], - } - ], - "error": {}, - "recent_cutover_jobs": [ - { - "compute_engine_target_details": {}, - "create_time": {}, - "end_time": {}, - "name": "name_value", - "state": 1, - "state_time": {}, - "progress_percent": 1733, - "error": {}, - "state_message": "state_message_value", - "steps": [ - { - "previous_replication_cycle": {}, - "shutting_down_source_vm": {}, - "final_sync": {}, - "preparing_vm_disks": {}, - "instantiating_migrated_vm": {}, - "start_time": {}, - "end_time": {}, - } - ], - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -21546,6 +21495,73 @@ def test_create_clone_job_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmmigration.CreateCloneJobRequest.meta.fields["clone_job"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["clone_job"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["clone_job"][field])): + del request_init["clone_job"][field][i][subfield] + else: + del request_init["clone_job"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -21756,73 +21772,6 @@ def test_create_clone_job_rest_bad_request( request_init = { "parent": "projects/sample1/locations/sample2/sources/sample3/migratingVms/sample4" } - request_init["clone_job"] = { - "compute_engine_target_details": { - "vm_name": "vm_name_value", - "project": "project_value", - "zone": "zone_value", - "machine_type_series": "machine_type_series_value", - "machine_type": "machine_type_value", - "network_tags": ["network_tags_value1", "network_tags_value2"], - "network_interfaces": [ - { - "network": "network_value", - "subnetwork": "subnetwork_value", - "internal_ip": "internal_ip_value", - "external_ip": "external_ip_value", - } - ], - "service_account": "service_account_value", - "disk_type": 1, - "labels": {}, - "license_type": 1, - "applied_license": {"type_": 1, "os_license": "os_license_value"}, - "compute_scheduling": { - "on_host_maintenance": 1, - "restart_type": 1, - "node_affinities": [ - { - "key": "key_value", - "operator": 1, - "values": ["values_value1", "values_value2"], - } - ], - "min_node_cpus": 1379, - }, - "secure_boot": True, - "boot_option": 1, - "metadata": {}, - "additional_licenses": [ - "additional_licenses_value1", - "additional_licenses_value2", - ], - "hostname": "hostname_value", - }, - "create_time": {"seconds": 751, "nanos": 543}, - "end_time": {}, - "name": "name_value", - "state": 1, - "state_time": {}, - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - "steps": [ - { - "adapting_os": {}, - "preparing_vm_disks": {}, - "instantiating_migrated_vm": {}, - "start_time": {}, - "end_time": {}, - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -22212,8 +22161,9 @@ def test_list_clone_jobs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListCloneJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListCloneJobsResponse.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 @@ -22305,8 +22255,9 @@ def test_list_clone_jobs_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListCloneJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListCloneJobsResponse.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 @@ -22456,8 +22407,9 @@ def test_list_clone_jobs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListCloneJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListCloneJobsResponse.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 @@ -22582,8 +22534,9 @@ def test_get_clone_job_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.CloneJob.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.CloneJob.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 @@ -22659,8 +22612,9 @@ def test_get_clone_job_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.CloneJob.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.CloneJob.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 @@ -22785,8 +22739,9 @@ def test_get_clone_job_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.CloneJob.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.CloneJob.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 @@ -22935,6 +22890,73 @@ def test_create_cutover_job_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmmigration.CreateCutoverJobRequest.meta.fields["cutover_job"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["cutover_job"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["cutover_job"][field])): + del request_init["cutover_job"][field][i][subfield] + else: + del request_init["cutover_job"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -23145,100 +23167,6 @@ def test_create_cutover_job_rest_bad_request( request_init = { "parent": "projects/sample1/locations/sample2/sources/sample3/migratingVms/sample4" } - request_init["cutover_job"] = { - "compute_engine_target_details": { - "vm_name": "vm_name_value", - "project": "project_value", - "zone": "zone_value", - "machine_type_series": "machine_type_series_value", - "machine_type": "machine_type_value", - "network_tags": ["network_tags_value1", "network_tags_value2"], - "network_interfaces": [ - { - "network": "network_value", - "subnetwork": "subnetwork_value", - "internal_ip": "internal_ip_value", - "external_ip": "external_ip_value", - } - ], - "service_account": "service_account_value", - "disk_type": 1, - "labels": {}, - "license_type": 1, - "applied_license": {"type_": 1, "os_license": "os_license_value"}, - "compute_scheduling": { - "on_host_maintenance": 1, - "restart_type": 1, - "node_affinities": [ - { - "key": "key_value", - "operator": 1, - "values": ["values_value1", "values_value2"], - } - ], - "min_node_cpus": 1379, - }, - "secure_boot": True, - "boot_option": 1, - "metadata": {}, - "additional_licenses": [ - "additional_licenses_value1", - "additional_licenses_value2", - ], - "hostname": "hostname_value", - }, - "create_time": {"seconds": 751, "nanos": 543}, - "end_time": {}, - "name": "name_value", - "state": 1, - "state_time": {}, - "progress_percent": 1733, - "error": { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - }, - "state_message": "state_message_value", - "steps": [ - { - "previous_replication_cycle": { - "name": "name_value", - "cycle_number": 1272, - "start_time": {}, - "end_time": {}, - "total_pause_duration": {"seconds": 751, "nanos": 543}, - "progress_percent": 1733, - "steps": [ - { - "initializing_replication": {}, - "replicating": { - "total_bytes": 1194, - "replicated_bytes": 1699, - "last_two_minutes_average_bytes_per_second": 4370, - "last_thirty_minutes_average_bytes_per_second": 4700, - }, - "post_processing": {}, - "start_time": {}, - "end_time": {}, - } - ], - "state": 1, - "error": {}, - }, - "shutting_down_source_vm": {}, - "final_sync": {}, - "preparing_vm_disks": {}, - "instantiating_migrated_vm": {}, - "start_time": {}, - "end_time": {}, - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -23628,8 +23556,9 @@ def test_list_cutover_jobs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListCutoverJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListCutoverJobsResponse.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 @@ -23721,8 +23650,9 @@ def test_list_cutover_jobs_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListCutoverJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListCutoverJobsResponse.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 @@ -23872,8 +23802,9 @@ def test_list_cutover_jobs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListCutoverJobsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListCutoverJobsResponse.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 @@ -24002,8 +23933,9 @@ def test_get_cutover_job_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.CutoverJob.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.CutoverJob.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 @@ -24081,8 +24013,9 @@ def test_get_cutover_job_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.CutoverJob.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.CutoverJob.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 @@ -24211,8 +24144,9 @@ def test_get_cutover_job_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.CutoverJob.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.CutoverJob.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 @@ -24278,8 +24212,9 @@ def test_list_groups_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListGroupsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListGroupsResponse.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 @@ -24369,8 +24304,9 @@ def test_list_groups_rest_required_fields(request_type=vmmigration.ListGroupsReq response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListGroupsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListGroupsResponse.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 @@ -24514,8 +24450,9 @@ def test_list_groups_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListGroupsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListGroupsResponse.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 @@ -24636,8 +24573,9 @@ def test_get_group_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.Group.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.Group.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 @@ -24712,8 +24650,9 @@ def test_get_group_rest_required_fields(request_type=vmmigration.GetGroupRequest response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.Group.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.Group.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 @@ -24834,8 +24773,9 @@ def test_get_group_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.Group.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.Group.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 @@ -24894,6 +24834,73 @@ def test_create_group_rest(request_type): "description": "description_value", "display_name": "display_name_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmmigration.CreateGroupRequest.meta.fields["group"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["group"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["group"][field])): + del request_init["group"][field][i][subfield] + else: + del request_init["group"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -25098,13 +25105,6 @@ def test_create_group_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["group"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "description": "description_value", - "display_name": "display_name_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -25207,6 +25207,73 @@ def test_update_group_rest(request_type): "description": "description_value", "display_name": "display_name_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmmigration.UpdateGroupRequest.meta.fields["group"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["group"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["group"][field])): + del request_init["group"][field][i][subfield] + else: + del request_init["group"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -25389,13 +25456,6 @@ def test_update_group_rest_bad_request( request_init = { "group": {"name": "projects/sample1/locations/sample2/groups/sample3"} } - request_init["group"] = { - "name": "projects/sample1/locations/sample2/groups/sample3", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "description": "description_value", - "display_name": "display_name_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -26291,8 +26351,9 @@ def test_list_target_projects_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListTargetProjectsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListTargetProjectsResponse.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 @@ -26384,8 +26445,9 @@ def test_list_target_projects_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListTargetProjectsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListTargetProjectsResponse.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 @@ -26531,8 +26593,9 @@ def test_list_target_projects_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListTargetProjectsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListTargetProjectsResponse.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 @@ -26656,8 +26719,9 @@ def test_get_target_project_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.TargetProject.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.TargetProject.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 @@ -26734,8 +26798,9 @@ def test_get_target_project_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.TargetProject.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.TargetProject.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 @@ -26862,8 +26927,9 @@ def test_get_target_project_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.TargetProject.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.TargetProject.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 @@ -26923,6 +26989,73 @@ def test_create_target_project_rest(request_type): "create_time": {"seconds": 751, "nanos": 543}, "update_time": {}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmmigration.CreateTargetProjectRequest.meta.fields["target_project"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["target_project"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["target_project"][field])): + del request_init["target_project"][field][i][subfield] + else: + del request_init["target_project"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -27131,13 +27264,6 @@ def test_create_target_project_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["target_project"] = { - "name": "name_value", - "project": "project_value", - "description": "description_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -27243,6 +27369,73 @@ def test_update_target_project_rest(request_type): "create_time": {"seconds": 751, "nanos": 543}, "update_time": {}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmmigration.UpdateTargetProjectRequest.meta.fields["target_project"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["target_project"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["target_project"][field])): + del request_init["target_project"][field][i][subfield] + else: + del request_init["target_project"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -27431,13 +27624,6 @@ def test_update_target_project_rest_bad_request( "name": "projects/sample1/locations/sample2/targetProjects/sample3" } } - request_init["target_project"] = { - "name": "projects/sample1/locations/sample2/targetProjects/sample3", - "project": "project_value", - "description": "description_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -27816,8 +28002,9 @@ def test_list_replication_cycles_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListReplicationCyclesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListReplicationCyclesResponse.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 @@ -27909,8 +28096,9 @@ def test_list_replication_cycles_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListReplicationCyclesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListReplicationCyclesResponse.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 @@ -28060,8 +28248,9 @@ def test_list_replication_cycles_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ListReplicationCyclesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ListReplicationCyclesResponse.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 @@ -28190,8 +28379,9 @@ def test_get_replication_cycle_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ReplicationCycle.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ReplicationCycle.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 @@ -28269,8 +28459,9 @@ def test_get_replication_cycle_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ReplicationCycle.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ReplicationCycle.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 @@ -28399,8 +28590,9 @@ def test_get_replication_cycle_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmmigration.ReplicationCycle.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmmigration.ReplicationCycle.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 diff --git a/packages/google-cloud-vmwareengine/CONTRIBUTING.rst b/packages/google-cloud-vmwareengine/CONTRIBUTING.rst index 4aeb328fc3b0..deae95a12596 100644 --- a/packages/google-cloud-vmwareengine/CONTRIBUTING.rst +++ b/packages/google-cloud-vmwareengine/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine/gapic_version.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine/gapic_version.py index 4b57afbef668..360a0d13ebdd 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine/gapic_version.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.1.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/gapic_version.py b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/gapic_version.py index 4b57afbef668..360a0d13ebdd 100644 --- a/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/gapic_version.py +++ b/packages/google-cloud-vmwareengine/google/cloud/vmwareengine_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.1.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vmwareengine/noxfile.py b/packages/google-cloud-vmwareengine/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-vmwareengine/noxfile.py +++ b/packages/google-cloud-vmwareengine/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-vmwareengine/samples/generated_samples/snippet_metadata_google.cloud.vmwareengine.v1.json b/packages/google-cloud-vmwareengine/samples/generated_samples/snippet_metadata_google.cloud.vmwareengine.v1.json index a780242fda98..90fe9c99a25b 100644 --- a/packages/google-cloud-vmwareengine/samples/generated_samples/snippet_metadata_google.cloud.vmwareengine.v1.json +++ b/packages/google-cloud-vmwareengine/samples/generated_samples/snippet_metadata_google.cloud.vmwareengine.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vmwareengine", - "version": "1.1.2" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-vmwareengine/tests/unit/gapic/vmwareengine_v1/test_vmware_engine.py b/packages/google-cloud-vmwareengine/tests/unit/gapic/vmwareengine_v1/test_vmware_engine.py index 634311b46782..655fac23cb4a 100644 --- a/packages/google-cloud-vmwareengine/tests/unit/gapic/vmwareengine_v1/test_vmware_engine.py +++ b/packages/google-cloud-vmwareengine/tests/unit/gapic/vmwareengine_v1/test_vmware_engine.py @@ -12320,8 +12320,9 @@ def test_list_private_clouds_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListPrivateCloudsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListPrivateCloudsResponse.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 @@ -12406,8 +12407,9 @@ def test_list_private_clouds_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListPrivateCloudsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListPrivateCloudsResponse.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 @@ -12542,8 +12544,9 @@ def test_list_private_clouds_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListPrivateCloudsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListPrivateCloudsResponse.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 @@ -12669,8 +12672,9 @@ def test_get_private_cloud_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.PrivateCloud.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.PrivateCloud.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 @@ -12749,8 +12753,9 @@ def test_get_private_cloud_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.PrivateCloud.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.PrivateCloud.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 @@ -12877,8 +12882,9 @@ def test_get_private_cloud_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.PrivateCloud.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.PrivateCloud.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 @@ -12970,6 +12976,73 @@ def test_create_private_cloud_rest(request_type): "uid": "uid_value", "type_": 1, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmwareengine.CreatePrivateCloudRequest.meta.fields["private_cloud"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["private_cloud"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["private_cloud"][field])): + del request_init["private_cloud"][field][i][subfield] + else: + del request_init["private_cloud"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -13180,45 +13253,6 @@ def test_create_private_cloud_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["private_cloud"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "delete_time": {}, - "expire_time": {}, - "state": 1, - "network_config": { - "management_cidr": "management_cidr_value", - "vmware_engine_network": "vmware_engine_network_value", - "vmware_engine_network_canonical": "vmware_engine_network_canonical_value", - "management_ip_address_layout_version": 3836, - }, - "management_cluster": { - "cluster_id": "cluster_id_value", - "node_type_configs": {}, - }, - "description": "description_value", - "hcx": { - "internal_ip": "internal_ip_value", - "version": "version_value", - "state": 1, - "fqdn": "fqdn_value", - }, - "nsx": { - "internal_ip": "internal_ip_value", - "version": "version_value", - "state": 1, - "fqdn": "fqdn_value", - }, - "vcenter": { - "internal_ip": "internal_ip_value", - "version": "version_value", - "state": 1, - "fqdn": "fqdn_value", - }, - "uid": "uid_value", - "type_": 1, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -13356,6 +13390,73 @@ def test_update_private_cloud_rest(request_type): "uid": "uid_value", "type_": 1, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmwareengine.UpdatePrivateCloudRequest.meta.fields["private_cloud"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["private_cloud"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["private_cloud"][field])): + del request_init["private_cloud"][field][i][subfield] + else: + del request_init["private_cloud"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -13549,45 +13650,6 @@ def test_update_private_cloud_rest_bad_request( "name": "projects/sample1/locations/sample2/privateClouds/sample3" } } - request_init["private_cloud"] = { - "name": "projects/sample1/locations/sample2/privateClouds/sample3", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "delete_time": {}, - "expire_time": {}, - "state": 1, - "network_config": { - "management_cidr": "management_cidr_value", - "vmware_engine_network": "vmware_engine_network_value", - "vmware_engine_network_canonical": "vmware_engine_network_canonical_value", - "management_ip_address_layout_version": 3836, - }, - "management_cluster": { - "cluster_id": "cluster_id_value", - "node_type_configs": {}, - }, - "description": "description_value", - "hcx": { - "internal_ip": "internal_ip_value", - "version": "version_value", - "state": 1, - "fqdn": "fqdn_value", - }, - "nsx": { - "internal_ip": "internal_ip_value", - "version": "version_value", - "state": 1, - "fqdn": "fqdn_value", - }, - "vcenter": { - "internal_ip": "internal_ip_value", - "version": "version_value", - "state": 1, - "fqdn": "fqdn_value", - }, - "uid": "uid_value", - "type_": 1, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -14247,8 +14309,9 @@ def test_list_clusters_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListClustersResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListClustersResponse.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 @@ -14333,8 +14396,9 @@ def test_list_clusters_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListClustersResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListClustersResponse.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 @@ -14473,8 +14537,9 @@ def test_list_clusters_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListClustersResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListClustersResponse.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 @@ -14601,8 +14666,9 @@ def test_get_cluster_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.Cluster.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.Cluster.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 @@ -14678,8 +14744,9 @@ def test_get_cluster_rest_required_fields(request_type=vmwareengine.GetClusterRe response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.Cluster.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.Cluster.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 @@ -14806,8 +14873,9 @@ def test_get_cluster_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.Cluster.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.Cluster.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 @@ -14871,6 +14939,73 @@ def test_create_cluster_rest(request_type): "uid": "uid_value", "node_type_configs": {}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmwareengine.CreateClusterRequest.meta.fields["cluster"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["cluster"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["cluster"][field])): + del request_init["cluster"][field][i][subfield] + else: + del request_init["cluster"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -15083,15 +15218,6 @@ def test_create_cluster_rest_bad_request( request_init = { "parent": "projects/sample1/locations/sample2/privateClouds/sample3" } - request_init["cluster"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "state": 1, - "management": True, - "uid": "uid_value", - "node_type_configs": {}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -15201,6 +15327,73 @@ def test_update_cluster_rest(request_type): "uid": "uid_value", "node_type_configs": {}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmwareengine.UpdateClusterRequest.meta.fields["cluster"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["cluster"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["cluster"][field])): + del request_init["cluster"][field][i][subfield] + else: + del request_init["cluster"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -15396,15 +15589,6 @@ def test_update_cluster_rest_bad_request( "name": "projects/sample1/locations/sample2/privateClouds/sample3/clusters/sample4" } } - request_init["cluster"] = { - "name": "projects/sample1/locations/sample2/privateClouds/sample3/clusters/sample4", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "state": 1, - "management": True, - "uid": "uid_value", - "node_type_configs": {}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -15787,8 +15971,9 @@ def test_list_subnets_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListSubnetsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListSubnetsResponse.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 @@ -15871,8 +16056,9 @@ def test_list_subnets_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListSubnetsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListSubnetsResponse.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 @@ -16009,8 +16195,9 @@ def test_list_subnets_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListSubnetsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListSubnetsResponse.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 @@ -16138,8 +16325,9 @@ def test_get_subnet_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.Subnet.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.Subnet.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 @@ -16216,8 +16404,9 @@ def test_get_subnet_rest_required_fields(request_type=vmwareengine.GetSubnetRequ response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.Subnet.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.Subnet.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 @@ -16344,8 +16533,9 @@ def test_get_subnet_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.Subnet.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.Subnet.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 @@ -16409,6 +16599,73 @@ def test_update_subnet_rest(request_type): "type_": "type__value", "state": 1, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmwareengine.UpdateSubnetRequest.meta.fields["subnet"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["subnet"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["subnet"][field])): + del request_init["subnet"][field][i][subfield] + else: + del request_init["subnet"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -16592,13 +16849,6 @@ def test_update_subnet_rest_bad_request( "name": "projects/sample1/locations/sample2/privateClouds/sample3/subnets/sample4" } } - request_init["subnet"] = { - "name": "projects/sample1/locations/sample2/privateClouds/sample3/subnets/sample4", - "ip_cidr_range": "ip_cidr_range_value", - "gateway_ip": "gateway_ip_value", - "type_": "type__value", - "state": 1, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -16708,8 +16958,9 @@ def test_list_node_types_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListNodeTypesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListNodeTypesResponse.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 @@ -16793,8 +17044,9 @@ def test_list_node_types_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListNodeTypesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListNodeTypesResponse.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 @@ -16928,8 +17180,9 @@ def test_list_node_types_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListNodeTypesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListNodeTypesResponse.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 @@ -17057,8 +17310,9 @@ def test_get_node_type_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.NodeType.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.NodeType.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 @@ -17140,8 +17394,9 @@ def test_get_node_type_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.NodeType.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.NodeType.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 @@ -17268,8 +17523,9 @@ def test_get_node_type_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.NodeType.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.NodeType.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 @@ -17336,8 +17592,9 @@ def test_show_nsx_credentials_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.Credentials.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.Credentials.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 @@ -17413,8 +17670,9 @@ def test_show_nsx_credentials_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.Credentials.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.Credentials.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 @@ -17543,8 +17801,9 @@ def test_show_nsx_credentials_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.Credentials.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.Credentials.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 @@ -17612,8 +17871,9 @@ def test_show_vcenter_credentials_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.Credentials.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.Credentials.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 @@ -17689,8 +17949,9 @@ def test_show_vcenter_credentials_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.Credentials.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.Credentials.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 @@ -17819,8 +18080,9 @@ def test_show_vcenter_credentials_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.Credentials.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.Credentials.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 @@ -18422,6 +18684,75 @@ def test_create_hcx_activation_key_rest(request_type): "activation_key": "activation_key_value", "uid": "uid_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmwareengine.CreateHcxActivationKeyRequest.meta.fields[ + "hcx_activation_key" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["hcx_activation_key"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["hcx_activation_key"][field])): + del request_init["hcx_activation_key"][field][i][subfield] + else: + del request_init["hcx_activation_key"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -18634,13 +18965,6 @@ def test_create_hcx_activation_key_rest_bad_request( request_init = { "parent": "projects/sample1/locations/sample2/privateClouds/sample3" } - request_init["hcx_activation_key"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "state": 1, - "activation_key": "activation_key_value", - "uid": "uid_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -18756,8 +19080,9 @@ def test_list_hcx_activation_keys_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListHcxActivationKeysResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListHcxActivationKeysResponse.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 @@ -18840,10 +19165,9 @@ def test_list_hcx_activation_keys_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListHcxActivationKeysResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListHcxActivationKeysResponse.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 @@ -18980,8 +19304,9 @@ def test_list_hcx_activation_keys_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListHcxActivationKeysResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListHcxActivationKeysResponse.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 @@ -19112,8 +19437,9 @@ def test_get_hcx_activation_key_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.HcxActivationKey.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.HcxActivationKey.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 @@ -19191,8 +19517,9 @@ def test_get_hcx_activation_key_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.HcxActivationKey.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.HcxActivationKey.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 @@ -19321,8 +19648,9 @@ def test_get_hcx_activation_key_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.HcxActivationKey.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.HcxActivationKey.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 @@ -19394,8 +19722,9 @@ def test_get_network_policy_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.NetworkPolicy.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.NetworkPolicy.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 @@ -19478,8 +19807,9 @@ def test_get_network_policy_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.NetworkPolicy.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.NetworkPolicy.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 @@ -19608,8 +19938,9 @@ def test_get_network_policy_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.NetworkPolicy.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.NetworkPolicy.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 @@ -19675,8 +20006,9 @@ def test_list_network_policies_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListNetworkPoliciesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListNetworkPoliciesResponse.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 @@ -19761,8 +20093,9 @@ def test_list_network_policies_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListNetworkPoliciesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListNetworkPoliciesResponse.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 @@ -19897,8 +20230,9 @@ def test_list_network_policies_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListNetworkPoliciesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListNetworkPoliciesResponse.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 @@ -20020,6 +20354,73 @@ def test_create_network_policy_rest(request_type): "description": "description_value", "vmware_engine_network_canonical": "vmware_engine_network_canonical_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmwareengine.CreateNetworkPolicyRequest.meta.fields["network_policy"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["network_policy"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["network_policy"][field])): + del request_init["network_policy"][field][i][subfield] + else: + del request_init["network_policy"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -20228,18 +20629,6 @@ def test_create_network_policy_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["network_policy"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "internet_access": {"enabled": True, "state": 1}, - "external_ip": {}, - "edge_services_cidr": "edge_services_cidr_value", - "uid": "uid_value", - "vmware_engine_network": "vmware_engine_network_value", - "description": "description_value", - "vmware_engine_network_canonical": "vmware_engine_network_canonical_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -20350,6 +20739,73 @@ def test_update_network_policy_rest(request_type): "description": "description_value", "vmware_engine_network_canonical": "vmware_engine_network_canonical_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmwareengine.UpdateNetworkPolicyRequest.meta.fields["network_policy"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["network_policy"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["network_policy"][field])): + del request_init["network_policy"][field][i][subfield] + else: + del request_init["network_policy"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -20543,18 +20999,6 @@ def test_update_network_policy_rest_bad_request( "name": "projects/sample1/locations/sample2/networkPolicies/sample3" } } - request_init["network_policy"] = { - "name": "projects/sample1/locations/sample2/networkPolicies/sample3", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "internet_access": {"enabled": True, "state": 1}, - "external_ip": {}, - "edge_services_cidr": "edge_services_cidr_value", - "uid": "uid_value", - "vmware_engine_network": "vmware_engine_network_value", - "description": "description_value", - "vmware_engine_network_canonical": "vmware_engine_network_canonical_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -20933,6 +21377,77 @@ def test_create_vmware_engine_network_rest(request_type): "uid": "uid_value", "etag": "etag_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmwareengine.CreateVmwareEngineNetworkRequest.meta.fields[ + "vmware_engine_network" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "vmware_engine_network" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["vmware_engine_network"][field])): + del request_init["vmware_engine_network"][field][i][subfield] + else: + del request_init["vmware_engine_network"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -21146,17 +21661,6 @@ def test_create_vmware_engine_network_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["vmware_engine_network"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "description": "description_value", - "vpc_networks": [{"type_": 1, "network": "network_value"}], - "state": 1, - "type_": 1, - "uid": "uid_value", - "etag": "etag_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -21270,6 +21774,77 @@ def test_update_vmware_engine_network_rest(request_type): "uid": "uid_value", "etag": "etag_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmwareengine.UpdateVmwareEngineNetworkRequest.meta.fields[ + "vmware_engine_network" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init[ + "vmware_engine_network" + ].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["vmware_engine_network"][field])): + del request_init["vmware_engine_network"][field][i][subfield] + else: + del request_init["vmware_engine_network"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -21463,17 +22038,6 @@ def test_update_vmware_engine_network_rest_bad_request( "name": "projects/sample1/locations/sample2/vmwareEngineNetworks/sample3" } } - request_init["vmware_engine_network"] = { - "name": "projects/sample1/locations/sample2/vmwareEngineNetworks/sample3", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "description": "description_value", - "vpc_networks": [{"type_": 1, "network": "network_value"}], - "state": 1, - "type_": 1, - "uid": "uid_value", - "etag": "etag_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -21877,8 +22441,9 @@ def test_get_vmware_engine_network_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.VmwareEngineNetwork.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.VmwareEngineNetwork.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 @@ -21958,10 +22523,9 @@ def test_get_vmware_engine_network_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.VmwareEngineNetwork.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.VmwareEngineNetwork.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 @@ -22090,8 +22654,9 @@ def test_get_vmware_engine_network_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.VmwareEngineNetwork.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.VmwareEngineNetwork.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 @@ -22157,8 +22722,9 @@ def test_list_vmware_engine_networks_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListVmwareEngineNetworksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListVmwareEngineNetworksResponse.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 @@ -22243,10 +22809,11 @@ def test_list_vmware_engine_networks_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListVmwareEngineNetworksResponse.pb( + # Convert return value to protobuf type + return_value = vmwareengine.ListVmwareEngineNetworksResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -22383,8 +22950,9 @@ def test_list_vmware_engine_networks_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListVmwareEngineNetworksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListVmwareEngineNetworksResponse.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 @@ -22511,6 +23079,75 @@ def test_create_private_connection_rest(request_type): "service_network": "service_network_value", "peering_state": 1, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmwareengine.CreatePrivateConnectionRequest.meta.fields[ + "private_connection" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["private_connection"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["private_connection"][field])): + del request_init["private_connection"][field][i][subfield] + else: + del request_init["private_connection"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -22722,21 +23359,6 @@ def test_create_private_connection_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["private_connection"] = { - "name": "name_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "description": "description_value", - "state": 1, - "vmware_engine_network": "vmware_engine_network_value", - "vmware_engine_network_canonical": "vmware_engine_network_canonical_value", - "type_": 1, - "peering_id": "peering_id_value", - "routing_mode": 1, - "uid": "uid_value", - "service_network": "service_network_value", - "peering_state": 1, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -22859,8 +23481,9 @@ def test_get_private_connection_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.PrivateConnection.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.PrivateConnection.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 @@ -22957,8 +23580,9 @@ def test_get_private_connection_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.PrivateConnection.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.PrivateConnection.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 @@ -23087,8 +23711,9 @@ def test_get_private_connection_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine_resources.PrivateConnection.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine_resources.PrivateConnection.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 @@ -23154,8 +23779,9 @@ def test_list_private_connections_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListPrivateConnectionsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListPrivateConnectionsResponse.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 @@ -23240,10 +23866,9 @@ def test_list_private_connections_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListPrivateConnectionsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListPrivateConnectionsResponse.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 @@ -23378,8 +24003,9 @@ def test_list_private_connections_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListPrivateConnectionsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListPrivateConnectionsResponse.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 @@ -23510,6 +24136,75 @@ def test_update_private_connection_rest(request_type): "service_network": "service_network_value", "peering_state": 1, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vmwareengine.UpdatePrivateConnectionRequest.meta.fields[ + "private_connection" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["private_connection"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["private_connection"][field])): + del request_init["private_connection"][field][i][subfield] + else: + del request_init["private_connection"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -23703,21 +24398,6 @@ def test_update_private_connection_rest_bad_request( "name": "projects/sample1/locations/sample2/privateConnections/sample3" } } - request_init["private_connection"] = { - "name": "projects/sample1/locations/sample2/privateConnections/sample3", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "description": "description_value", - "state": 1, - "vmware_engine_network": "vmware_engine_network_value", - "vmware_engine_network_canonical": "vmware_engine_network_canonical_value", - "type_": 1, - "peering_id": "peering_id_value", - "routing_mode": 1, - "uid": "uid_value", - "service_network": "service_network_value", - "peering_state": 1, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -24103,10 +24783,11 @@ def test_list_private_connection_peering_routes_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListPrivateConnectionPeeringRoutesResponse.pb( + # Convert return value to protobuf type + return_value = vmwareengine.ListPrivateConnectionPeeringRoutesResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -24192,10 +24873,11 @@ def test_list_private_connection_peering_routes_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = ( - vmwareengine.ListPrivateConnectionPeeringRoutesResponse.pb(return_value) + # Convert return value to protobuf type + return_value = vmwareengine.ListPrivateConnectionPeeringRoutesResponse.pb( + return_value ) - json_return_value = json_format.MessageToJson(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 @@ -24339,10 +25021,11 @@ def test_list_private_connection_peering_routes_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vmwareengine.ListPrivateConnectionPeeringRoutesResponse.pb( + # Convert return value to protobuf type + return_value = vmwareengine.ListPrivateConnectionPeeringRoutesResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 diff --git a/packages/google-cloud-vpc-access/CONTRIBUTING.rst b/packages/google-cloud-vpc-access/CONTRIBUTING.rst index 0ef64dd37bab..d421afd6c2eb 100644 --- a/packages/google-cloud-vpc-access/CONTRIBUTING.rst +++ b/packages/google-cloud-vpc-access/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess/gapic_version.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess/gapic_version.py index f9e85c87b4d6..360a0d13ebdd 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess/gapic_version.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.8.3" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/gapic_version.py b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/gapic_version.py index f9e85c87b4d6..360a0d13ebdd 100644 --- a/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/gapic_version.py +++ b/packages/google-cloud-vpc-access/google/cloud/vpcaccess_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.8.3" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-vpc-access/noxfile.py b/packages/google-cloud-vpc-access/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-vpc-access/noxfile.py +++ b/packages/google-cloud-vpc-access/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-vpc-access/samples/generated_samples/snippet_metadata_google.cloud.vpcaccess.v1.json b/packages/google-cloud-vpc-access/samples/generated_samples/snippet_metadata_google.cloud.vpcaccess.v1.json index ce2e792c9088..16be63e96c27 100644 --- a/packages/google-cloud-vpc-access/samples/generated_samples/snippet_metadata_google.cloud.vpcaccess.v1.json +++ b/packages/google-cloud-vpc-access/samples/generated_samples/snippet_metadata_google.cloud.vpcaccess.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-vpc-access", - "version": "1.8.3" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-vpc-access/tests/unit/gapic/vpcaccess_v1/test_vpc_access_service.py b/packages/google-cloud-vpc-access/tests/unit/gapic/vpcaccess_v1/test_vpc_access_service.py index 688730bd5bf8..8d34fe1fa89c 100644 --- a/packages/google-cloud-vpc-access/tests/unit/gapic/vpcaccess_v1/test_vpc_access_service.py +++ b/packages/google-cloud-vpc-access/tests/unit/gapic/vpcaccess_v1/test_vpc_access_service.py @@ -1937,6 +1937,73 @@ def test_create_connector_rest(request_type): "min_instances": 1387, "max_instances": 1389, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = vpc_access.CreateConnectorRequest.meta.fields["connector"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["connector"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["connector"][field])): + del request_init["connector"][field][i][subfield] + else: + del request_init["connector"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -2135,22 +2202,6 @@ def test_create_connector_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["connector"] = { - "name": "name_value", - "network": "network_value", - "ip_cidr_range": "ip_cidr_range_value", - "state": 1, - "min_throughput": 1533, - "max_throughput": 1535, - "connected_projects": [ - "connected_projects_value1", - "connected_projects_value2", - ], - "subnet": {"name": "name_value", "project_id": "project_id_value"}, - "machine_type": "machine_type_value", - "min_instances": 1387, - "max_instances": 1389, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -2265,8 +2316,9 @@ def test_get_connector_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vpc_access.Connector.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vpc_access.Connector.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 @@ -2350,8 +2402,9 @@ def test_get_connector_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vpc_access.Connector.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vpc_access.Connector.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 @@ -2474,8 +2527,9 @@ def test_get_connector_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vpc_access.Connector.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vpc_access.Connector.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 @@ -2539,8 +2593,9 @@ def test_list_connectors_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vpc_access.ListConnectorsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vpc_access.ListConnectorsResponse.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 @@ -2622,8 +2677,9 @@ def test_list_connectors_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = vpc_access.ListConnectorsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vpc_access.ListConnectorsResponse.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 @@ -2756,8 +2812,9 @@ def test_list_connectors_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = vpc_access.ListConnectorsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = vpc_access.ListConnectorsResponse.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 diff --git a/packages/google-cloud-webrisk/CONTRIBUTING.rst b/packages/google-cloud-webrisk/CONTRIBUTING.rst index 3409d07c2fde..104619995530 100644 --- a/packages/google-cloud-webrisk/CONTRIBUTING.rst +++ b/packages/google-cloud-webrisk/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk/gapic_version.py b/packages/google-cloud-webrisk/google/cloud/webrisk/gapic_version.py index 394a70bae1a3..360a0d13ebdd 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk/gapic_version.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/gapic_version.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/gapic_version.py index 394a70bae1a3..360a0d13ebdd 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1/gapic_version.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/gapic_version.py b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/gapic_version.py index 394a70bae1a3..360a0d13ebdd 100644 --- a/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/gapic_version.py +++ b/packages/google-cloud-webrisk/google/cloud/webrisk_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-webrisk/noxfile.py b/packages/google-cloud-webrisk/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-webrisk/noxfile.py +++ b/packages/google-cloud-webrisk/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1.json b/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1.json index 2b27c5c0ff9c..1a29be137849 100644 --- a/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1.json +++ b/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-webrisk", - "version": "1.12.2" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1beta1.json b/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1beta1.json index 4b8a80548d31..de1e97aff4a5 100644 --- a/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1beta1.json +++ b/packages/google-cloud-webrisk/samples/generated_samples/snippet_metadata_google.cloud.webrisk.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-webrisk", - "version": "1.12.2" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1/test_web_risk_service.py b/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1/test_web_risk_service.py index 278cf1074dc7..8ffd5cf5a40b 100644 --- a/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1/test_web_risk_service.py +++ b/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1/test_web_risk_service.py @@ -1717,8 +1717,9 @@ def test_compute_threat_list_diff_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.ComputeThreatListDiffResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.ComputeThreatListDiffResponse.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 @@ -1800,8 +1801,9 @@ def test_compute_threat_list_diff_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.ComputeThreatListDiffResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.ComputeThreatListDiffResponse.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 @@ -1944,8 +1946,9 @@ def test_compute_threat_list_diff_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.ComputeThreatListDiffResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.ComputeThreatListDiffResponse.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 @@ -2010,8 +2013,9 @@ def test_search_uris_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.SearchUrisResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.SearchUrisResponse.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 @@ -2093,8 +2097,9 @@ def test_search_uris_rest_required_fields(request_type=webrisk.SearchUrisRequest response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.SearchUrisResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.SearchUrisResponse.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 @@ -2237,8 +2242,9 @@ def test_search_uris_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.SearchUrisResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.SearchUrisResponse.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 @@ -2300,8 +2306,9 @@ def test_search_hashes_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.SearchHashesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.SearchHashesResponse.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 @@ -2375,8 +2382,9 @@ def test_search_hashes_rest_required_fields(request_type=webrisk.SearchHashesReq response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.SearchHashesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.SearchHashesResponse.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 @@ -2508,8 +2516,9 @@ def test_search_hashes_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.SearchHashesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.SearchHashesResponse.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 @@ -2562,6 +2571,73 @@ def test_create_submission_rest(request_type): # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1"} request_init["submission"] = {"uri": "uri_value", "threat_types": [1]} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = webrisk.CreateSubmissionRequest.meta.fields["submission"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["submission"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["submission"][field])): + del request_init["submission"][field][i][subfield] + else: + del request_init["submission"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -2575,8 +2651,9 @@ def test_create_submission_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.Submission.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.Submission.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 @@ -2653,8 +2730,9 @@ def test_create_submission_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.Submission.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.Submission.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 @@ -2748,7 +2826,6 @@ def test_create_submission_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1"} - request_init["submission"] = {"uri": "uri_value", "threat_types": [1]} request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -2787,8 +2864,9 @@ def test_create_submission_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.Submission.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.Submission.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 diff --git a/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1beta1/test_web_risk_service_v1_beta1.py b/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1beta1/test_web_risk_service_v1_beta1.py index b343474c70a4..7ce857696a7c 100644 --- a/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1beta1/test_web_risk_service_v1_beta1.py +++ b/packages/google-cloud-webrisk/tests/unit/gapic/webrisk_v1beta1/test_web_risk_service_v1_beta1.py @@ -1351,8 +1351,9 @@ def test_compute_threat_list_diff_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.ComputeThreatListDiffResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.ComputeThreatListDiffResponse.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 @@ -1434,8 +1435,9 @@ def test_compute_threat_list_diff_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.ComputeThreatListDiffResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.ComputeThreatListDiffResponse.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 @@ -1578,8 +1580,9 @@ def test_compute_threat_list_diff_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.ComputeThreatListDiffResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.ComputeThreatListDiffResponse.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 @@ -1644,8 +1647,9 @@ def test_search_uris_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.SearchUrisResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.SearchUrisResponse.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 @@ -1727,8 +1731,9 @@ def test_search_uris_rest_required_fields(request_type=webrisk.SearchUrisRequest response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.SearchUrisResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.SearchUrisResponse.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 @@ -1871,8 +1876,9 @@ def test_search_uris_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.SearchUrisResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.SearchUrisResponse.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 @@ -1934,8 +1940,9 @@ def test_search_hashes_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.SearchHashesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.SearchHashesResponse.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 @@ -2009,8 +2016,9 @@ def test_search_hashes_rest_required_fields(request_type=webrisk.SearchHashesReq response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.SearchHashesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.SearchHashesResponse.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 @@ -2142,8 +2150,9 @@ def test_search_hashes_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = webrisk.SearchHashesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = webrisk.SearchHashesResponse.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 diff --git a/packages/google-cloud-websecurityscanner/CONTRIBUTING.rst b/packages/google-cloud-websecurityscanner/CONTRIBUTING.rst index aa92e64b0e90..c4b771848f79 100644 --- a/packages/google-cloud-websecurityscanner/CONTRIBUTING.rst +++ b/packages/google-cloud-websecurityscanner/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner/gapic_version.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner/gapic_version.py index 12049b60eb6c..360a0d13ebdd 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner/gapic_version.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.3" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/gapic_version.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/gapic_version.py index 12049b60eb6c..360a0d13ebdd 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/gapic_version.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.3" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic_version.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic_version.py index 12049b60eb6c..360a0d13ebdd 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic_version.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.3" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/gapic_version.py b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/gapic_version.py index 12049b60eb6c..360a0d13ebdd 100644 --- a/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/gapic_version.py +++ b/packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.3" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-websecurityscanner/noxfile.py b/packages/google-cloud-websecurityscanner/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-websecurityscanner/noxfile.py +++ b/packages/google-cloud-websecurityscanner/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1.json b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1.json index dca904d53608..030ea8082797 100644 --- a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1.json +++ b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-websecurityscanner", - "version": "1.12.3" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1alpha.json b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1alpha.json index 85b1f269f273..c87e0efb514b 100644 --- a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1alpha.json +++ b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1alpha.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-websecurityscanner", - "version": "1.12.3" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1beta.json b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1beta.json index 43f36c41eba9..3896b1676525 100644 --- a/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1beta.json +++ b/packages/google-cloud-websecurityscanner/samples/generated_samples/snippet_metadata_google.cloud.websecurityscanner.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-websecurityscanner", - "version": "1.12.3" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py index 357a4b28ba1f..20a7e54c7d23 100644 --- a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py +++ b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py @@ -3818,6 +3818,73 @@ def test_create_scan_config_rest(request_type): "static_ip_scan": True, "ignore_http_status_errors": True, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = web_security_scanner.CreateScanConfigRequest.meta.fields["scan_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["scan_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["scan_config"][field])): + del request_init["scan_config"][field][i][subfield] + else: + del request_init["scan_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -3840,8 +3907,9 @@ def test_create_scan_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_config.ScanConfig.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 @@ -3932,42 +4000,6 @@ def test_create_scan_config_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1"} - request_init["scan_config"] = { - "name": "name_value", - "display_name": "display_name_value", - "max_qps": 761, - "starting_urls": ["starting_urls_value1", "starting_urls_value2"], - "authentication": { - "google_account": { - "username": "username_value", - "password": "password_value", - }, - "custom_account": { - "username": "username_value", - "password": "password_value", - "login_url": "login_url_value", - }, - "iap_credential": { - "iap_test_service_account_info": { - "target_audience_client_id": "target_audience_client_id_value" - } - }, - }, - "user_agent": 1, - "blacklist_patterns": [ - "blacklist_patterns_value1", - "blacklist_patterns_value2", - ], - "schedule": { - "schedule_time": {"seconds": 751, "nanos": 543}, - "interval_duration_days": 2362, - }, - "export_to_security_command_center": 1, - "risk_level": 1, - "managed_scan": True, - "static_ip_scan": True, - "ignore_http_status_errors": True, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -4139,8 +4171,9 @@ def test_get_scan_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_config.ScanConfig.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 @@ -4278,8 +4311,9 @@ def test_list_scan_configs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanConfigsResponse.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 @@ -4487,6 +4521,73 @@ def test_update_scan_config_rest(request_type): "static_ip_scan": True, "ignore_http_status_errors": True, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = web_security_scanner.UpdateScanConfigRequest.meta.fields["scan_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["scan_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["scan_config"][field])): + del request_init["scan_config"][field][i][subfield] + else: + del request_init["scan_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -4509,8 +4610,9 @@ def test_update_scan_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_config.ScanConfig.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 @@ -4601,42 +4703,6 @@ def test_update_scan_config_rest_bad_request( # send a request that will satisfy transcoding request_init = {"scan_config": {"name": "projects/sample1/scanConfigs/sample2"}} - request_init["scan_config"] = { - "name": "projects/sample1/scanConfigs/sample2", - "display_name": "display_name_value", - "max_qps": 761, - "starting_urls": ["starting_urls_value1", "starting_urls_value2"], - "authentication": { - "google_account": { - "username": "username_value", - "password": "password_value", - }, - "custom_account": { - "username": "username_value", - "password": "password_value", - "login_url": "login_url_value", - }, - "iap_credential": { - "iap_test_service_account_info": { - "target_audience_client_id": "target_audience_client_id_value" - } - }, - }, - "user_agent": 1, - "blacklist_patterns": [ - "blacklist_patterns_value1", - "blacklist_patterns_value2", - ], - "schedule": { - "schedule_time": {"seconds": 751, "nanos": 543}, - "interval_duration_days": 2362, - }, - "export_to_security_command_center": 1, - "risk_level": 1, - "managed_scan": True, - "static_ip_scan": True, - "ignore_http_status_errors": True, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -4690,8 +4756,9 @@ def test_start_scan_run_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -4826,8 +4893,9 @@ def test_get_scan_run_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -4956,8 +5024,9 @@ def test_list_scan_runs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanRunsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanRunsResponse.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 @@ -5145,8 +5214,9 @@ def test_stop_scan_run_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -5275,8 +5345,9 @@ def test_list_crawled_urls_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListCrawledUrlsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListCrawledUrlsResponse.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 @@ -5474,8 +5545,9 @@ def test_get_finding_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = finding.Finding.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = finding.Finding.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 @@ -5610,8 +5682,9 @@ def test_list_findings_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingsResponse.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 @@ -5793,10 +5866,11 @@ def test_list_finding_type_stats_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 diff --git a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py index 7d1577ecdc50..9b09746c3f40 100644 --- a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py +++ b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py @@ -4870,6 +4870,73 @@ def test_create_scan_config_rest(request_type): "progress_percent": 1733, }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = web_security_scanner.CreateScanConfigRequest.meta.fields["scan_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["scan_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["scan_config"][field])): + del request_init["scan_config"][field][i][subfield] + else: + del request_init["scan_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -4888,8 +4955,9 @@ def test_create_scan_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcw_scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcw_scan_config.ScanConfig.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 @@ -4973,8 +5041,9 @@ def test_create_scan_config_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gcw_scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcw_scan_config.ScanConfig.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 @@ -5070,44 +5139,6 @@ def test_create_scan_config_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1"} - request_init["scan_config"] = { - "name": "name_value", - "display_name": "display_name_value", - "max_qps": 761, - "starting_urls": ["starting_urls_value1", "starting_urls_value2"], - "authentication": { - "google_account": { - "username": "username_value", - "password": "password_value", - }, - "custom_account": { - "username": "username_value", - "password": "password_value", - "login_url": "login_url_value", - }, - }, - "user_agent": 1, - "blacklist_patterns": [ - "blacklist_patterns_value1", - "blacklist_patterns_value2", - ], - "schedule": { - "schedule_time": {"seconds": 751, "nanos": 543}, - "interval_duration_days": 2362, - }, - "target_platforms": [1], - "latest_run": { - "name": "name_value", - "execution_state": 1, - "result_state": 1, - "start_time": {}, - "end_time": {}, - "urls_crawled_count": 1935, - "urls_tested_count": 1846, - "has_vulnerabilities": True, - "progress_percent": 1733, - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -5146,8 +5177,9 @@ def test_create_scan_config_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcw_scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcw_scan_config.ScanConfig.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 @@ -5470,8 +5502,9 @@ def test_get_scan_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_config.ScanConfig.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 @@ -5554,8 +5587,9 @@ def test_get_scan_config_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_config.ScanConfig.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 @@ -5680,8 +5714,9 @@ def test_get_scan_config_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_config.ScanConfig.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 @@ -5745,8 +5780,9 @@ def test_list_scan_configs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanConfigsResponse.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 @@ -5828,10 +5864,9 @@ def test_list_scan_configs_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanConfigsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanConfigsResponse.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 @@ -5966,8 +6001,9 @@ def test_list_scan_configs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanConfigsResponse.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 @@ -6114,6 +6150,73 @@ def test_update_scan_config_rest(request_type): "progress_percent": 1733, }, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = web_security_scanner.UpdateScanConfigRequest.meta.fields["scan_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["scan_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["scan_config"][field])): + del request_init["scan_config"][field][i][subfield] + else: + del request_init["scan_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -6132,8 +6235,9 @@ def test_update_scan_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcw_scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcw_scan_config.ScanConfig.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 @@ -6214,8 +6318,9 @@ def test_update_scan_config_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gcw_scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcw_scan_config.ScanConfig.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 @@ -6311,44 +6416,6 @@ def test_update_scan_config_rest_bad_request( # send a request that will satisfy transcoding request_init = {"scan_config": {"name": "projects/sample1/scanConfigs/sample2"}} - request_init["scan_config"] = { - "name": "projects/sample1/scanConfigs/sample2", - "display_name": "display_name_value", - "max_qps": 761, - "starting_urls": ["starting_urls_value1", "starting_urls_value2"], - "authentication": { - "google_account": { - "username": "username_value", - "password": "password_value", - }, - "custom_account": { - "username": "username_value", - "password": "password_value", - "login_url": "login_url_value", - }, - }, - "user_agent": 1, - "blacklist_patterns": [ - "blacklist_patterns_value1", - "blacklist_patterns_value2", - ], - "schedule": { - "schedule_time": {"seconds": 751, "nanos": 543}, - "interval_duration_days": 2362, - }, - "target_platforms": [1], - "latest_run": { - "name": "name_value", - "execution_state": 1, - "result_state": 1, - "start_time": {}, - "end_time": {}, - "urls_crawled_count": 1935, - "urls_tested_count": 1846, - "has_vulnerabilities": True, - "progress_percent": 1733, - }, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -6389,8 +6456,9 @@ def test_update_scan_config_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcw_scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcw_scan_config.ScanConfig.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 @@ -6462,8 +6530,9 @@ def test_start_scan_run_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -6545,8 +6614,9 @@ def test_start_scan_run_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -6669,8 +6739,9 @@ def test_start_scan_run_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -6740,8 +6811,9 @@ def test_get_scan_run_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -6822,8 +6894,9 @@ def test_get_scan_run_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -6948,8 +7021,9 @@ def test_get_scan_run_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -7014,8 +7088,9 @@ def test_list_scan_runs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanRunsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanRunsResponse.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 @@ -7097,8 +7172,9 @@ def test_list_scan_runs_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanRunsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanRunsResponse.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 @@ -7231,8 +7307,9 @@ def test_list_scan_runs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanRunsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanRunsResponse.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 @@ -7360,8 +7437,9 @@ def test_stop_scan_run_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -7443,8 +7521,9 @@ def test_stop_scan_run_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -7569,8 +7648,9 @@ def test_stop_scan_run_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -7635,8 +7715,9 @@ def test_list_crawled_urls_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListCrawledUrlsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListCrawledUrlsResponse.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 @@ -7718,10 +7799,9 @@ def test_list_crawled_urls_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListCrawledUrlsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListCrawledUrlsResponse.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 @@ -7858,8 +7938,9 @@ def test_list_crawled_urls_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListCrawledUrlsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListCrawledUrlsResponse.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 @@ -7994,8 +8075,9 @@ def test_get_finding_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = finding.Finding.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = finding.Finding.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 @@ -8079,8 +8161,9 @@ def test_get_finding_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = finding.Finding.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = finding.Finding.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 @@ -8207,8 +8290,9 @@ def test_get_finding_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = finding.Finding.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = finding.Finding.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 @@ -8273,8 +8357,9 @@ def test_list_findings_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingsResponse.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 @@ -8364,8 +8449,9 @@ def test_list_findings_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingsResponse.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 @@ -8513,8 +8599,9 @@ def test_list_findings_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingsResponse.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 @@ -8637,10 +8724,11 @@ def test_list_finding_type_stats_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -8714,10 +8802,11 @@ def test_list_finding_type_stats_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -8847,10 +8936,11 @@ def test_list_finding_type_stats_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 diff --git a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py index 336e174c4ee0..d40e54a088eb 100644 --- a/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py +++ b/packages/google-cloud-websecurityscanner/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py @@ -4926,6 +4926,73 @@ def test_create_scan_config_rest(request_type): }, "risk_level": 1, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = web_security_scanner.CreateScanConfigRequest.meta.fields["scan_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["scan_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["scan_config"][field])): + del request_init["scan_config"][field][i][subfield] + else: + del request_init["scan_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -4946,8 +5013,9 @@ def test_create_scan_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcw_scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcw_scan_config.ScanConfig.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 @@ -5036,8 +5104,9 @@ def test_create_scan_config_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gcw_scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcw_scan_config.ScanConfig.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 @@ -5133,52 +5202,6 @@ def test_create_scan_config_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1"} - request_init["scan_config"] = { - "name": "name_value", - "display_name": "display_name_value", - "max_qps": 761, - "starting_urls": ["starting_urls_value1", "starting_urls_value2"], - "authentication": { - "google_account": { - "username": "username_value", - "password": "password_value", - }, - "custom_account": { - "username": "username_value", - "password": "password_value", - "login_url": "login_url_value", - }, - }, - "user_agent": 1, - "blacklist_patterns": [ - "blacklist_patterns_value1", - "blacklist_patterns_value2", - ], - "schedule": { - "schedule_time": {"seconds": 751, "nanos": 543}, - "interval_duration_days": 2362, - }, - "target_platforms": [1], - "export_to_security_command_center": 1, - "latest_run": { - "name": "name_value", - "execution_state": 1, - "result_state": 1, - "start_time": {}, - "end_time": {}, - "urls_crawled_count": 1935, - "urls_tested_count": 1846, - "has_vulnerabilities": True, - "progress_percent": 1733, - "error_trace": { - "code": 1, - "scan_config_error": {"code": 1, "field_name": "field_name_value"}, - "most_common_http_error_code": 2893, - }, - "warning_traces": [{"code": 1}], - }, - "risk_level": 1, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -5217,8 +5240,9 @@ def test_create_scan_config_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcw_scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcw_scan_config.ScanConfig.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 @@ -5543,8 +5567,9 @@ def test_get_scan_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_config.ScanConfig.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 @@ -5632,8 +5657,9 @@ def test_get_scan_config_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_config.ScanConfig.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 @@ -5758,8 +5784,9 @@ def test_get_scan_config_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_config.ScanConfig.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 @@ -5823,8 +5850,9 @@ def test_list_scan_configs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanConfigsResponse.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 @@ -5906,10 +5934,9 @@ def test_list_scan_configs_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanConfigsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanConfigsResponse.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 @@ -6044,8 +6071,9 @@ def test_list_scan_configs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanConfigsResponse.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 @@ -6200,6 +6228,73 @@ def test_update_scan_config_rest(request_type): }, "risk_level": 1, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = web_security_scanner.UpdateScanConfigRequest.meta.fields["scan_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["scan_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["scan_config"][field])): + del request_init["scan_config"][field][i][subfield] + else: + del request_init["scan_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -6220,8 +6315,9 @@ def test_update_scan_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcw_scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcw_scan_config.ScanConfig.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 @@ -6307,8 +6403,9 @@ def test_update_scan_config_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gcw_scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcw_scan_config.ScanConfig.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 @@ -6404,52 +6501,6 @@ def test_update_scan_config_rest_bad_request( # send a request that will satisfy transcoding request_init = {"scan_config": {"name": "projects/sample1/scanConfigs/sample2"}} - request_init["scan_config"] = { - "name": "projects/sample1/scanConfigs/sample2", - "display_name": "display_name_value", - "max_qps": 761, - "starting_urls": ["starting_urls_value1", "starting_urls_value2"], - "authentication": { - "google_account": { - "username": "username_value", - "password": "password_value", - }, - "custom_account": { - "username": "username_value", - "password": "password_value", - "login_url": "login_url_value", - }, - }, - "user_agent": 1, - "blacklist_patterns": [ - "blacklist_patterns_value1", - "blacklist_patterns_value2", - ], - "schedule": { - "schedule_time": {"seconds": 751, "nanos": 543}, - "interval_duration_days": 2362, - }, - "target_platforms": [1], - "export_to_security_command_center": 1, - "latest_run": { - "name": "name_value", - "execution_state": 1, - "result_state": 1, - "start_time": {}, - "end_time": {}, - "urls_crawled_count": 1935, - "urls_tested_count": 1846, - "has_vulnerabilities": True, - "progress_percent": 1733, - "error_trace": { - "code": 1, - "scan_config_error": {"code": 1, "field_name": "field_name_value"}, - "most_common_http_error_code": 2893, - }, - "warning_traces": [{"code": 1}], - }, - "risk_level": 1, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -6490,8 +6541,9 @@ def test_update_scan_config_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gcw_scan_config.ScanConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gcw_scan_config.ScanConfig.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 @@ -6563,8 +6615,9 @@ def test_start_scan_run_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -6646,8 +6699,9 @@ def test_start_scan_run_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -6770,8 +6824,9 @@ def test_start_scan_run_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -6841,8 +6896,9 @@ def test_get_scan_run_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -6923,8 +6979,9 @@ def test_get_scan_run_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -7049,8 +7106,9 @@ def test_get_scan_run_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -7115,8 +7173,9 @@ def test_list_scan_runs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanRunsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanRunsResponse.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 @@ -7198,8 +7257,9 @@ def test_list_scan_runs_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanRunsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanRunsResponse.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 @@ -7332,8 +7392,9 @@ def test_list_scan_runs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListScanRunsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListScanRunsResponse.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 @@ -7461,8 +7522,9 @@ def test_stop_scan_run_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -7544,8 +7606,9 @@ def test_stop_scan_run_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -7670,8 +7733,9 @@ def test_stop_scan_run_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = scan_run.ScanRun.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = scan_run.ScanRun.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 @@ -7736,8 +7800,9 @@ def test_list_crawled_urls_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListCrawledUrlsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListCrawledUrlsResponse.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 @@ -7819,10 +7884,9 @@ def test_list_crawled_urls_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListCrawledUrlsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListCrawledUrlsResponse.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 @@ -7959,8 +8023,9 @@ def test_list_crawled_urls_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListCrawledUrlsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListCrawledUrlsResponse.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 @@ -8095,8 +8160,9 @@ def test_get_finding_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = finding.Finding.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = finding.Finding.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 @@ -8180,8 +8246,9 @@ def test_get_finding_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = finding.Finding.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = finding.Finding.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 @@ -8308,8 +8375,9 @@ def test_get_finding_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = finding.Finding.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = finding.Finding.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 @@ -8374,8 +8442,9 @@ def test_list_findings_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingsResponse.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 @@ -8465,8 +8534,9 @@ def test_list_findings_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingsResponse.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 @@ -8614,8 +8684,9 @@ def test_list_findings_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingsResponse.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 @@ -8738,10 +8809,11 @@ def test_list_finding_type_stats_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -8815,10 +8887,11 @@ def test_list_finding_type_stats_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -8948,10 +9021,11 @@ def test_list_finding_type_stats_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( + # Convert return value to protobuf type + return_value = web_security_scanner.ListFindingTypeStatsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 diff --git a/packages/google-cloud-workflows/CONTRIBUTING.rst b/packages/google-cloud-workflows/CONTRIBUTING.rst index 4987a71b127a..d560762c75fa 100644 --- a/packages/google-cloud-workflows/CONTRIBUTING.rst +++ b/packages/google-cloud-workflows/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-workflows/docs/index.rst b/packages/google-cloud-workflows/docs/index.rst index 894134b4bd00..a65ce6053a96 100644 --- a/packages/google-cloud-workflows/docs/index.rst +++ b/packages/google-cloud-workflows/docs/index.rst @@ -12,9 +12,7 @@ API Reference :maxdepth: 2 workflows_v1/services - executions_v1/services workflows_v1/types - executions_v1/types API Reference ------------- @@ -22,8 +20,22 @@ API Reference :maxdepth: 2 workflows_v1beta/services - executions_v1beta/services workflows_v1beta/types + +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + executions_v1/services + executions_v1/types + +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + executions_v1beta/services executions_v1beta/types diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows/executions/gapic_version.py index ac3bc60c3fb3..360a0d13ebdd 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/gapic_version.py index ac3bc60c3fb3..360a0d13ebdd 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/gapic_version.py index ac3bc60c3fb3..360a0d13ebdd 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/executions_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workflows/google/cloud/workflows/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows/gapic_version.py index ac3bc60c3fb3..360a0d13ebdd 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows_v1/gapic_version.py index ac3bc60c3fb3..360a0d13ebdd 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/gapic_version.py b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/gapic_version.py index ac3bc60c3fb3..360a0d13ebdd 100644 --- a/packages/google-cloud-workflows/google/cloud/workflows_v1beta/gapic_version.py +++ b/packages/google-cloud-workflows/google/cloud/workflows_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workflows/noxfile.py b/packages/google-cloud-workflows/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-workflows/noxfile.py +++ b/packages/google-cloud-workflows/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1.json b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1.json index b4a635226be8..56d60ff5a803 100644 --- a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1.json +++ b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workflows-executions", - "version": "1.12.1" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1beta.json b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1beta.json index 18584a2b271f..c486937ea17a 100644 --- a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1beta.json +++ b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.executions.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workflows-executions", - "version": "1.12.1" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1.json b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1.json index 1f36a84c1652..5eeb3c21a076 100644 --- a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1.json +++ b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workflows", - "version": "1.12.1" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1beta.json b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1beta.json index 176826ca227c..e6e1022f77a9 100644 --- a/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1beta.json +++ b/packages/google-cloud-workflows/samples/generated_samples/snippet_metadata_google.cloud.workflows.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workflows", - "version": "1.12.1" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py index d91dec5177b7..512ee672ae64 100644 --- a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py +++ b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1/test_workflows.py @@ -2104,8 +2104,9 @@ def test_list_workflows_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workflows.ListWorkflowsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workflows.ListWorkflowsResponse.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 @@ -2190,8 +2191,9 @@ def test_list_workflows_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workflows.ListWorkflowsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workflows.ListWorkflowsResponse.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 @@ -2322,8 +2324,9 @@ def test_list_workflows_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workflows.ListWorkflowsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workflows.ListWorkflowsResponse.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 @@ -2449,8 +2452,9 @@ def test_get_workflow_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workflows.Workflow.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workflows.Workflow.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 @@ -2531,8 +2535,9 @@ def test_get_workflow_rest_required_fields(request_type=workflows.GetWorkflowReq response_value = Response() response_value.status_code = 200 - pb_return_value = workflows.Workflow.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workflows.Workflow.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 @@ -2653,8 +2658,9 @@ def test_get_workflow_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workflows.Workflow.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workflows.Workflow.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 @@ -2722,6 +2728,73 @@ def test_create_workflow_rest(request_type): "call_log_level": 1, "user_env_vars": {}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workflows.CreateWorkflowRequest.meta.fields["workflow"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workflow"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workflow"][field])): + del request_init["workflow"][field][i][subfield] + else: + del request_init["workflow"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -2918,22 +2991,6 @@ def test_create_workflow_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["workflow"] = { - "name": "name_value", - "description": "description_value", - "state": 1, - "revision_id": "revision_id_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "revision_create_time": {}, - "labels": {}, - "service_account": "service_account_value", - "source_contents": "source_contents_value", - "crypto_key_name": "crypto_key_name_value", - "state_error": {"details": "details_value", "type_": 1}, - "call_log_level": 1, - "user_env_vars": {}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -3307,6 +3364,73 @@ def test_update_workflow_rest(request_type): "call_log_level": 1, "user_env_vars": {}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workflows.UpdateWorkflowRequest.meta.fields["workflow"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workflow"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workflow"][field])): + del request_init["workflow"][field][i][subfield] + else: + del request_init["workflow"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -3478,22 +3602,6 @@ def test_update_workflow_rest_bad_request( request_init = { "workflow": {"name": "projects/sample1/locations/sample2/workflows/sample3"} } - request_init["workflow"] = { - "name": "projects/sample1/locations/sample2/workflows/sample3", - "description": "description_value", - "state": 1, - "revision_id": "revision_id_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "revision_create_time": {}, - "labels": {}, - "service_account": "service_account_value", - "source_contents": "source_contents_value", - "crypto_key_name": "crypto_key_name_value", - "state_error": {"details": "details_value", "type_": 1}, - "call_log_level": 1, - "user_env_vars": {}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. diff --git a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py index 864369824015..054c5d66c0a3 100644 --- a/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py +++ b/packages/google-cloud-workflows/tests/unit/gapic/workflows_v1beta/test_workflows.py @@ -2095,8 +2095,9 @@ def test_list_workflows_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workflows.ListWorkflowsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workflows.ListWorkflowsResponse.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 @@ -2181,8 +2182,9 @@ def test_list_workflows_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workflows.ListWorkflowsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workflows.ListWorkflowsResponse.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 @@ -2313,8 +2315,9 @@ def test_list_workflows_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workflows.ListWorkflowsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workflows.ListWorkflowsResponse.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 @@ -2439,8 +2442,9 @@ def test_get_workflow_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workflows.Workflow.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workflows.Workflow.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 @@ -2517,8 +2521,9 @@ def test_get_workflow_rest_required_fields(request_type=workflows.GetWorkflowReq response_value = Response() response_value.status_code = 200 - pb_return_value = workflows.Workflow.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workflows.Workflow.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 @@ -2639,8 +2644,9 @@ def test_get_workflow_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workflows.Workflow.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workflows.Workflow.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 @@ -2705,6 +2711,73 @@ def test_create_workflow_rest(request_type): "service_account": "service_account_value", "source_contents": "source_contents_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workflows.CreateWorkflowRequest.meta.fields["workflow"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workflow"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workflow"][field])): + del request_init["workflow"][field][i][subfield] + else: + del request_init["workflow"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -2901,18 +2974,6 @@ def test_create_workflow_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["workflow"] = { - "name": "name_value", - "description": "description_value", - "state": 1, - "revision_id": "revision_id_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "revision_create_time": {}, - "labels": {}, - "service_account": "service_account_value", - "source_contents": "source_contents_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -3284,6 +3345,73 @@ def test_update_workflow_rest(request_type): "service_account": "service_account_value", "source_contents": "source_contents_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workflows.UpdateWorkflowRequest.meta.fields["workflow"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workflow"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workflow"][field])): + del request_init["workflow"][field][i][subfield] + else: + del request_init["workflow"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -3455,18 +3583,6 @@ def test_update_workflow_rest_bad_request( request_init = { "workflow": {"name": "projects/sample1/locations/sample2/workflows/sample3"} } - request_init["workflow"] = { - "name": "projects/sample1/locations/sample2/workflows/sample3", - "description": "description_value", - "state": 1, - "revision_id": "revision_id_value", - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "revision_create_time": {}, - "labels": {}, - "service_account": "service_account_value", - "source_contents": "source_contents_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. diff --git a/packages/google-cloud-workstations/CONTRIBUTING.rst b/packages/google-cloud-workstations/CONTRIBUTING.rst index 197af73fc02e..5feb95f22aa6 100644 --- a/packages/google-cloud-workstations/CONTRIBUTING.rst +++ b/packages/google-cloud-workstations/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-workstations/google/cloud/workstations/gapic_version.py b/packages/google-cloud-workstations/google/cloud/workstations/gapic_version.py index 83f9aec37eab..360a0d13ebdd 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations/gapic_version.py +++ b/packages/google-cloud-workstations/google/cloud/workstations/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1/gapic_version.py b/packages/google-cloud-workstations/google/cloud/workstations_v1/gapic_version.py index 83f9aec37eab..360a0d13ebdd 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1/gapic_version.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/gapic_version.py b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/gapic_version.py index 83f9aec37eab..360a0d13ebdd 100644 --- a/packages/google-cloud-workstations/google/cloud/workstations_v1beta/gapic_version.py +++ b/packages/google-cloud-workstations/google/cloud/workstations_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-workstations/noxfile.py b/packages/google-cloud-workstations/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-workstations/noxfile.py +++ b/packages/google-cloud-workstations/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1.json b/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1.json index 4cb28ca095f2..8dabda2a933a 100644 --- a/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1.json +++ b/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workstations", - "version": "0.5.1" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1beta.json b/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1beta.json index 4ee41933e500..8afcd1793b5c 100644 --- a/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1beta.json +++ b/packages/google-cloud-workstations/samples/generated_samples/snippet_metadata_google.cloud.workstations.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-workstations", - "version": "0.5.1" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1/test_workstations.py b/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1/test_workstations.py index bea90114cf2c..930650c917d2 100644 --- a/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1/test_workstations.py +++ b/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1/test_workstations.py @@ -6764,8 +6764,9 @@ def test_get_workstation_cluster_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.WorkstationCluster.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.WorkstationCluster.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 @@ -6848,8 +6849,9 @@ def test_get_workstation_cluster_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.WorkstationCluster.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.WorkstationCluster.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 @@ -6978,8 +6980,9 @@ def test_get_workstation_cluster_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.WorkstationCluster.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.WorkstationCluster.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 @@ -7045,8 +7048,9 @@ def test_list_workstation_clusters_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationClustersResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationClustersResponse.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 @@ -7129,10 +7133,9 @@ def test_list_workstation_clusters_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationClustersResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationClustersResponse.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 @@ -7267,8 +7270,9 @@ def test_list_workstation_clusters_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationClustersResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationClustersResponse.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 @@ -7412,6 +7416,75 @@ def test_create_workstation_cluster_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workstations.CreateWorkstationClusterRequest.meta.fields[ + "workstation_cluster" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workstation_cluster"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workstation_cluster"][field])): + del request_init["workstation_cluster"][field][i][subfield] + else: + del request_init["workstation_cluster"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -7623,40 +7696,6 @@ def test_create_workstation_cluster_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["workstation_cluster"] = { - "name": "name_value", - "display_name": "display_name_value", - "uid": "uid_value", - "reconciling": True, - "annotations": {}, - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "delete_time": {}, - "etag": "etag_value", - "network": "network_value", - "subnetwork": "subnetwork_value", - "control_plane_ip": "control_plane_ip_value", - "private_cluster_config": { - "enable_private_endpoint": True, - "cluster_hostname": "cluster_hostname_value", - "service_attachment_uri": "service_attachment_uri_value", - "allowed_projects": ["allowed_projects_value1", "allowed_projects_value2"], - }, - "degraded": True, - "conditions": [ - { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -7789,6 +7828,75 @@ def test_update_workstation_cluster_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workstations.UpdateWorkstationClusterRequest.meta.fields[ + "workstation_cluster" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workstation_cluster"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workstation_cluster"][field])): + del request_init["workstation_cluster"][field][i][subfield] + else: + del request_init["workstation_cluster"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -7984,40 +8092,6 @@ def test_update_workstation_cluster_rest_bad_request( "name": "projects/sample1/locations/sample2/workstationClusters/sample3" } } - request_init["workstation_cluster"] = { - "name": "projects/sample1/locations/sample2/workstationClusters/sample3", - "display_name": "display_name_value", - "uid": "uid_value", - "reconciling": True, - "annotations": {}, - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "delete_time": {}, - "etag": "etag_value", - "network": "network_value", - "subnetwork": "subnetwork_value", - "control_plane_ip": "control_plane_ip_value", - "private_cluster_config": { - "enable_private_endpoint": True, - "cluster_hostname": "cluster_hostname_value", - "service_attachment_uri": "service_attachment_uri_value", - "allowed_projects": ["allowed_projects_value1", "allowed_projects_value2"], - }, - "degraded": True, - "conditions": [ - { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -8420,8 +8494,9 @@ def test_get_workstation_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.WorkstationConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.WorkstationConfig.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 @@ -8502,8 +8577,9 @@ def test_get_workstation_config_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.WorkstationConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.WorkstationConfig.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 @@ -8632,8 +8708,9 @@ def test_get_workstation_config_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.WorkstationConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.WorkstationConfig.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 @@ -8701,8 +8778,9 @@ def test_list_workstation_configs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationConfigsResponse.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 @@ -8785,10 +8863,9 @@ def test_list_workstation_configs_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationConfigsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationConfigsResponse.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 @@ -8925,8 +9002,9 @@ def test_list_workstation_configs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationConfigsResponse.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 @@ -9053,10 +9131,11 @@ def test_list_usable_workstation_configs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListUsableWorkstationConfigsResponse.pb( + # Convert return value to protobuf type + return_value = workstations.ListUsableWorkstationConfigsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -9139,10 +9218,11 @@ def test_list_usable_workstation_configs_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListUsableWorkstationConfigsResponse.pb( + # Convert return value to protobuf type + return_value = workstations.ListUsableWorkstationConfigsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -9284,10 +9364,11 @@ def test_list_usable_workstation_configs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListUsableWorkstationConfigsResponse.pb( + # Convert return value to protobuf type + return_value = workstations.ListUsableWorkstationConfigsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -9479,6 +9560,75 @@ def test_create_workstation_config_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workstations.CreateWorkstationConfigRequest.meta.fields[ + "workstation_config" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workstation_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workstation_config"][field])): + del request_init["workstation_config"][field][i][subfield] + else: + del request_init["workstation_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -9692,81 +9842,6 @@ def test_create_workstation_config_rest_bad_request( request_init = { "parent": "projects/sample1/locations/sample2/workstationClusters/sample3" } - request_init["workstation_config"] = { - "name": "name_value", - "display_name": "display_name_value", - "uid": "uid_value", - "reconciling": True, - "annotations": {}, - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "delete_time": {}, - "etag": "etag_value", - "idle_timeout": {"seconds": 751, "nanos": 543}, - "running_timeout": {}, - "host": { - "gce_instance": { - "machine_type": "machine_type_value", - "service_account": "service_account_value", - "service_account_scopes": [ - "service_account_scopes_value1", - "service_account_scopes_value2", - ], - "tags": ["tags_value1", "tags_value2"], - "pool_size": 980, - "pooled_instances": 1706, - "disable_public_ip_addresses": True, - "enable_nested_virtualization": True, - "shielded_instance_config": { - "enable_secure_boot": True, - "enable_vtpm": True, - "enable_integrity_monitoring": True, - }, - "confidential_instance_config": {"enable_confidential_compute": True}, - "boot_disk_size_gb": 1792, - } - }, - "persistent_directories": [ - { - "gce_pd": { - "size_gb": 739, - "fs_type": "fs_type_value", - "disk_type": "disk_type_value", - "source_snapshot": "source_snapshot_value", - "reclaim_policy": 1, - }, - "mount_path": "mount_path_value", - } - ], - "container": { - "image": "image_value", - "command": ["command_value1", "command_value2"], - "args": ["args_value1", "args_value2"], - "env": {}, - "working_dir": "working_dir_value", - "run_as_user": 1190, - }, - "encryption_key": { - "kms_key": "kms_key_value", - "kms_key_service_account": "kms_key_service_account_value", - }, - "readiness_checks": [{"path": "path_value", "port": 453}], - "replica_zones": ["replica_zones_value1", "replica_zones_value2"], - "degraded": True, - "conditions": [ - { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -9942,6 +10017,75 @@ def test_update_workstation_config_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workstations.UpdateWorkstationConfigRequest.meta.fields[ + "workstation_config" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workstation_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workstation_config"][field])): + del request_init["workstation_config"][field][i][subfield] + else: + del request_init["workstation_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -10137,81 +10281,6 @@ def test_update_workstation_config_rest_bad_request( "name": "projects/sample1/locations/sample2/workstationClusters/sample3/workstationConfigs/sample4" } } - request_init["workstation_config"] = { - "name": "projects/sample1/locations/sample2/workstationClusters/sample3/workstationConfigs/sample4", - "display_name": "display_name_value", - "uid": "uid_value", - "reconciling": True, - "annotations": {}, - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "delete_time": {}, - "etag": "etag_value", - "idle_timeout": {"seconds": 751, "nanos": 543}, - "running_timeout": {}, - "host": { - "gce_instance": { - "machine_type": "machine_type_value", - "service_account": "service_account_value", - "service_account_scopes": [ - "service_account_scopes_value1", - "service_account_scopes_value2", - ], - "tags": ["tags_value1", "tags_value2"], - "pool_size": 980, - "pooled_instances": 1706, - "disable_public_ip_addresses": True, - "enable_nested_virtualization": True, - "shielded_instance_config": { - "enable_secure_boot": True, - "enable_vtpm": True, - "enable_integrity_monitoring": True, - }, - "confidential_instance_config": {"enable_confidential_compute": True}, - "boot_disk_size_gb": 1792, - } - }, - "persistent_directories": [ - { - "gce_pd": { - "size_gb": 739, - "fs_type": "fs_type_value", - "disk_type": "disk_type_value", - "source_snapshot": "source_snapshot_value", - "reclaim_policy": 1, - }, - "mount_path": "mount_path_value", - } - ], - "container": { - "image": "image_value", - "command": ["command_value1", "command_value2"], - "args": ["args_value1", "args_value2"], - "env": {}, - "working_dir": "working_dir_value", - "run_as_user": 1190, - }, - "encryption_key": { - "kms_key": "kms_key_value", - "kms_key_service_account": "kms_key_service_account_value", - }, - "readiness_checks": [{"path": "path_value", "port": 453}], - "replica_zones": ["replica_zones_value1", "replica_zones_value2"], - "degraded": True, - "conditions": [ - { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -10614,8 +10683,9 @@ def test_get_workstation_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.Workstation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.Workstation.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 @@ -10696,8 +10766,9 @@ def test_get_workstation_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.Workstation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.Workstation.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 @@ -10826,8 +10897,9 @@ def test_get_workstation_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.Workstation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.Workstation.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 @@ -10895,8 +10967,9 @@ def test_list_workstations_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationsResponse.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 @@ -10979,8 +11052,9 @@ def test_list_workstations_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationsResponse.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 @@ -11117,8 +11191,9 @@ def test_list_workstations_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationsResponse.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 @@ -11245,8 +11320,9 @@ def test_list_usable_workstations_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListUsableWorkstationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListUsableWorkstationsResponse.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 @@ -11329,10 +11405,9 @@ def test_list_usable_workstations_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListUsableWorkstationsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListUsableWorkstationsResponse.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 @@ -11469,8 +11544,9 @@ def test_list_usable_workstations_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListUsableWorkstationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListUsableWorkstationsResponse.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 @@ -11599,6 +11675,73 @@ def test_create_workstation_rest(request_type): "state": 1, "host": "host_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workstations.CreateWorkstationRequest.meta.fields["workstation"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workstation"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workstation"][field])): + del request_init["workstation"][field][i][subfield] + else: + del request_init["workstation"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -11809,21 +11952,6 @@ def test_create_workstation_rest_bad_request( request_init = { "parent": "projects/sample1/locations/sample2/workstationClusters/sample3/workstationConfigs/sample4" } - request_init["workstation"] = { - "name": "name_value", - "display_name": "display_name_value", - "uid": "uid_value", - "reconciling": True, - "annotations": {}, - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "start_time": {}, - "delete_time": {}, - "etag": "etag_value", - "state": 1, - "host": "host_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -11939,6 +12067,73 @@ def test_update_workstation_rest(request_type): "state": 1, "host": "host_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workstations.UpdateWorkstationRequest.meta.fields["workstation"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workstation"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workstation"][field])): + del request_init["workstation"][field][i][subfield] + else: + del request_init["workstation"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -12134,21 +12329,6 @@ def test_update_workstation_rest_bad_request( "name": "projects/sample1/locations/sample2/workstationClusters/sample3/workstationConfigs/sample4/workstations/sample5" } } - request_init["workstation"] = { - "name": "projects/sample1/locations/sample2/workstationClusters/sample3/workstationConfigs/sample4/workstations/sample5", - "display_name": "display_name_value", - "uid": "uid_value", - "reconciling": True, - "annotations": {}, - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "start_time": {}, - "delete_time": {}, - "etag": "etag_value", - "state": 1, - "host": "host_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -13083,8 +13263,9 @@ def test_generate_access_token_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.GenerateAccessTokenResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.GenerateAccessTokenResponse.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 @@ -13160,8 +13341,9 @@ def test_generate_access_token_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.GenerateAccessTokenResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.GenerateAccessTokenResponse.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 @@ -13290,8 +13472,9 @@ def test_generate_access_token_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.GenerateAccessTokenResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.GenerateAccessTokenResponse.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 diff --git a/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1beta/test_workstations.py b/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1beta/test_workstations.py index 42f28194ffd5..b5c5b70130db 100644 --- a/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1beta/test_workstations.py +++ b/packages/google-cloud-workstations/tests/unit/gapic/workstations_v1beta/test_workstations.py @@ -6768,8 +6768,9 @@ def test_get_workstation_cluster_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.WorkstationCluster.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.WorkstationCluster.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 @@ -6852,8 +6853,9 @@ def test_get_workstation_cluster_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.WorkstationCluster.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.WorkstationCluster.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 @@ -6982,8 +6984,9 @@ def test_get_workstation_cluster_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.WorkstationCluster.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.WorkstationCluster.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 @@ -7049,8 +7052,9 @@ def test_list_workstation_clusters_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationClustersResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationClustersResponse.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 @@ -7133,10 +7137,9 @@ def test_list_workstation_clusters_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationClustersResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationClustersResponse.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 @@ -7271,8 +7274,9 @@ def test_list_workstation_clusters_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationClustersResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationClustersResponse.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 @@ -7416,6 +7420,75 @@ def test_create_workstation_cluster_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workstations.CreateWorkstationClusterRequest.meta.fields[ + "workstation_cluster" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workstation_cluster"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workstation_cluster"][field])): + del request_init["workstation_cluster"][field][i][subfield] + else: + del request_init["workstation_cluster"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -7627,40 +7700,6 @@ def test_create_workstation_cluster_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1/locations/sample2"} - request_init["workstation_cluster"] = { - "name": "name_value", - "display_name": "display_name_value", - "uid": "uid_value", - "reconciling": True, - "annotations": {}, - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "delete_time": {}, - "etag": "etag_value", - "network": "network_value", - "subnetwork": "subnetwork_value", - "control_plane_ip": "control_plane_ip_value", - "private_cluster_config": { - "enable_private_endpoint": True, - "cluster_hostname": "cluster_hostname_value", - "service_attachment_uri": "service_attachment_uri_value", - "allowed_projects": ["allowed_projects_value1", "allowed_projects_value2"], - }, - "degraded": True, - "conditions": [ - { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -7793,6 +7832,75 @@ def test_update_workstation_cluster_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workstations.UpdateWorkstationClusterRequest.meta.fields[ + "workstation_cluster" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workstation_cluster"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workstation_cluster"][field])): + del request_init["workstation_cluster"][field][i][subfield] + else: + del request_init["workstation_cluster"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -7988,40 +8096,6 @@ def test_update_workstation_cluster_rest_bad_request( "name": "projects/sample1/locations/sample2/workstationClusters/sample3" } } - request_init["workstation_cluster"] = { - "name": "projects/sample1/locations/sample2/workstationClusters/sample3", - "display_name": "display_name_value", - "uid": "uid_value", - "reconciling": True, - "annotations": {}, - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "delete_time": {}, - "etag": "etag_value", - "network": "network_value", - "subnetwork": "subnetwork_value", - "control_plane_ip": "control_plane_ip_value", - "private_cluster_config": { - "enable_private_endpoint": True, - "cluster_hostname": "cluster_hostname_value", - "service_attachment_uri": "service_attachment_uri_value", - "allowed_projects": ["allowed_projects_value1", "allowed_projects_value2"], - }, - "degraded": True, - "conditions": [ - { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -8425,8 +8499,9 @@ def test_get_workstation_config_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.WorkstationConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.WorkstationConfig.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 @@ -8508,8 +8583,9 @@ def test_get_workstation_config_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.WorkstationConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.WorkstationConfig.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 @@ -8638,8 +8714,9 @@ def test_get_workstation_config_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.WorkstationConfig.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.WorkstationConfig.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 @@ -8707,8 +8784,9 @@ def test_list_workstation_configs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationConfigsResponse.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 @@ -8791,10 +8869,9 @@ def test_list_workstation_configs_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationConfigsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationConfigsResponse.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 @@ -8931,8 +9008,9 @@ def test_list_workstation_configs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationConfigsResponse.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 @@ -9059,10 +9137,11 @@ def test_list_usable_workstation_configs_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListUsableWorkstationConfigsResponse.pb( + # Convert return value to protobuf type + return_value = workstations.ListUsableWorkstationConfigsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -9145,10 +9224,11 @@ def test_list_usable_workstation_configs_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListUsableWorkstationConfigsResponse.pb( + # Convert return value to protobuf type + return_value = workstations.ListUsableWorkstationConfigsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -9290,10 +9370,11 @@ def test_list_usable_workstation_configs_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListUsableWorkstationConfigsResponse.pb( + # Convert return value to protobuf type + return_value = workstations.ListUsableWorkstationConfigsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -9498,6 +9579,75 @@ def test_create_workstation_config_rest(request_type): ], "enable_audit_agent": True, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workstations.CreateWorkstationConfigRequest.meta.fields[ + "workstation_config" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workstation_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workstation_config"][field])): + del request_init["workstation_config"][field][i][subfield] + else: + del request_init["workstation_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -9711,94 +9861,6 @@ def test_create_workstation_config_rest_bad_request( request_init = { "parent": "projects/sample1/locations/sample2/workstationClusters/sample3" } - request_init["workstation_config"] = { - "name": "name_value", - "display_name": "display_name_value", - "uid": "uid_value", - "reconciling": True, - "annotations": {}, - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "delete_time": {}, - "etag": "etag_value", - "idle_timeout": {"seconds": 751, "nanos": 543}, - "running_timeout": {}, - "host": { - "gce_instance": { - "machine_type": "machine_type_value", - "service_account": "service_account_value", - "service_account_scopes": [ - "service_account_scopes_value1", - "service_account_scopes_value2", - ], - "tags": ["tags_value1", "tags_value2"], - "pool_size": 980, - "pooled_instances": 1706, - "disable_public_ip_addresses": True, - "enable_nested_virtualization": True, - "shielded_instance_config": { - "enable_secure_boot": True, - "enable_vtpm": True, - "enable_integrity_monitoring": True, - }, - "confidential_instance_config": {"enable_confidential_compute": True}, - "boot_disk_size_gb": 1792, - "accelerators": [{"type_": "type__value", "count": 553}], - } - }, - "persistent_directories": [ - { - "gce_pd": { - "size_gb": 739, - "fs_type": "fs_type_value", - "disk_type": "disk_type_value", - "source_snapshot": "source_snapshot_value", - "reclaim_policy": 1, - }, - "mount_path": "mount_path_value", - } - ], - "ephemeral_directories": [ - { - "gce_pd": { - "disk_type": "disk_type_value", - "source_snapshot": "source_snapshot_value", - "source_image": "source_image_value", - "read_only": True, - }, - "mount_path": "mount_path_value", - } - ], - "container": { - "image": "image_value", - "command": ["command_value1", "command_value2"], - "args": ["args_value1", "args_value2"], - "env": {}, - "working_dir": "working_dir_value", - "run_as_user": 1190, - }, - "encryption_key": { - "kms_key": "kms_key_value", - "kms_key_service_account": "kms_key_service_account_value", - }, - "readiness_checks": [{"path": "path_value", "port": 453}], - "replica_zones": ["replica_zones_value1", "replica_zones_value2"], - "degraded": True, - "conditions": [ - { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - } - ], - "enable_audit_agent": True, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -9987,6 +10049,75 @@ def test_update_workstation_config_rest(request_type): ], "enable_audit_agent": True, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workstations.UpdateWorkstationConfigRequest.meta.fields[ + "workstation_config" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workstation_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workstation_config"][field])): + del request_init["workstation_config"][field][i][subfield] + else: + del request_init["workstation_config"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -10182,94 +10313,6 @@ def test_update_workstation_config_rest_bad_request( "name": "projects/sample1/locations/sample2/workstationClusters/sample3/workstationConfigs/sample4" } } - request_init["workstation_config"] = { - "name": "projects/sample1/locations/sample2/workstationClusters/sample3/workstationConfigs/sample4", - "display_name": "display_name_value", - "uid": "uid_value", - "reconciling": True, - "annotations": {}, - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "delete_time": {}, - "etag": "etag_value", - "idle_timeout": {"seconds": 751, "nanos": 543}, - "running_timeout": {}, - "host": { - "gce_instance": { - "machine_type": "machine_type_value", - "service_account": "service_account_value", - "service_account_scopes": [ - "service_account_scopes_value1", - "service_account_scopes_value2", - ], - "tags": ["tags_value1", "tags_value2"], - "pool_size": 980, - "pooled_instances": 1706, - "disable_public_ip_addresses": True, - "enable_nested_virtualization": True, - "shielded_instance_config": { - "enable_secure_boot": True, - "enable_vtpm": True, - "enable_integrity_monitoring": True, - }, - "confidential_instance_config": {"enable_confidential_compute": True}, - "boot_disk_size_gb": 1792, - "accelerators": [{"type_": "type__value", "count": 553}], - } - }, - "persistent_directories": [ - { - "gce_pd": { - "size_gb": 739, - "fs_type": "fs_type_value", - "disk_type": "disk_type_value", - "source_snapshot": "source_snapshot_value", - "reclaim_policy": 1, - }, - "mount_path": "mount_path_value", - } - ], - "ephemeral_directories": [ - { - "gce_pd": { - "disk_type": "disk_type_value", - "source_snapshot": "source_snapshot_value", - "source_image": "source_image_value", - "read_only": True, - }, - "mount_path": "mount_path_value", - } - ], - "container": { - "image": "image_value", - "command": ["command_value1", "command_value2"], - "args": ["args_value1", "args_value2"], - "env": {}, - "working_dir": "working_dir_value", - "run_as_user": 1190, - }, - "encryption_key": { - "kms_key": "kms_key_value", - "kms_key_service_account": "kms_key_service_account_value", - }, - "readiness_checks": [{"path": "path_value", "port": 453}], - "replica_zones": ["replica_zones_value1", "replica_zones_value2"], - "degraded": True, - "conditions": [ - { - "code": 411, - "message": "message_value", - "details": [ - { - "type_url": "type.googleapis.com/google.protobuf.Duration", - "value": b"\x08\x0c\x10\xdb\x07", - } - ], - } - ], - "enable_audit_agent": True, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -10672,8 +10715,9 @@ def test_get_workstation_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.Workstation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.Workstation.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 @@ -10754,8 +10798,9 @@ def test_get_workstation_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.Workstation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.Workstation.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 @@ -10884,8 +10929,9 @@ def test_get_workstation_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.Workstation.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.Workstation.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 @@ -10953,8 +10999,9 @@ def test_list_workstations_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationsResponse.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 @@ -11037,8 +11084,9 @@ def test_list_workstations_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationsResponse.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 @@ -11175,8 +11223,9 @@ def test_list_workstations_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListWorkstationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListWorkstationsResponse.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 @@ -11303,8 +11352,9 @@ def test_list_usable_workstations_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListUsableWorkstationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListUsableWorkstationsResponse.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 @@ -11387,10 +11437,9 @@ def test_list_usable_workstations_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListUsableWorkstationsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListUsableWorkstationsResponse.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 @@ -11527,8 +11576,9 @@ def test_list_usable_workstations_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.ListUsableWorkstationsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.ListUsableWorkstationsResponse.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 @@ -11658,6 +11708,73 @@ def test_create_workstation_rest(request_type): "host": "host_value", "env": {}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workstations.CreateWorkstationRequest.meta.fields["workstation"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workstation"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workstation"][field])): + del request_init["workstation"][field][i][subfield] + else: + del request_init["workstation"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -11868,22 +11985,6 @@ def test_create_workstation_rest_bad_request( request_init = { "parent": "projects/sample1/locations/sample2/workstationClusters/sample3/workstationConfigs/sample4" } - request_init["workstation"] = { - "name": "name_value", - "display_name": "display_name_value", - "uid": "uid_value", - "reconciling": True, - "annotations": {}, - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "start_time": {}, - "delete_time": {}, - "etag": "etag_value", - "state": 1, - "host": "host_value", - "env": {}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -12000,6 +12101,73 @@ def test_update_workstation_rest(request_type): "host": "host_value", "env": {}, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = workstations.UpdateWorkstationRequest.meta.fields["workstation"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["workstation"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["workstation"][field])): + del request_init["workstation"][field][i][subfield] + else: + del request_init["workstation"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -12195,22 +12363,6 @@ def test_update_workstation_rest_bad_request( "name": "projects/sample1/locations/sample2/workstationClusters/sample3/workstationConfigs/sample4/workstations/sample5" } } - request_init["workstation"] = { - "name": "projects/sample1/locations/sample2/workstationClusters/sample3/workstationConfigs/sample4/workstations/sample5", - "display_name": "display_name_value", - "uid": "uid_value", - "reconciling": True, - "annotations": {}, - "labels": {}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "start_time": {}, - "delete_time": {}, - "etag": "etag_value", - "state": 1, - "host": "host_value", - "env": {}, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -13145,8 +13297,9 @@ def test_generate_access_token_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.GenerateAccessTokenResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.GenerateAccessTokenResponse.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 @@ -13222,8 +13375,9 @@ def test_generate_access_token_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.GenerateAccessTokenResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.GenerateAccessTokenResponse.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 @@ -13352,8 +13506,9 @@ def test_generate_access_token_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = workstations.GenerateAccessTokenResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = workstations.GenerateAccessTokenResponse.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 diff --git a/packages/google-maps-fleetengine-delivery/tests/unit/gapic/fleetengine_delivery_v1/test_delivery_service.py b/packages/google-maps-fleetengine-delivery/tests/unit/gapic/fleetengine_delivery_v1/test_delivery_service.py index 96bf00c43f49..d421bb52a6da 100644 --- a/packages/google-maps-fleetengine-delivery/tests/unit/gapic/fleetengine_delivery_v1/test_delivery_service.py +++ b/packages/google-maps-fleetengine-delivery/tests/unit/gapic/fleetengine_delivery_v1/test_delivery_service.py @@ -3736,6 +3736,75 @@ def test_create_delivery_vehicle_rest(request_type): ], "type_": 1, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = delivery_api.CreateDeliveryVehicleRequest.meta.fields[ + "delivery_vehicle" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["delivery_vehicle"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["delivery_vehicle"][field])): + del request_init["delivery_vehicle"][field][i][subfield] + else: + del request_init["delivery_vehicle"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -3751,8 +3820,9 @@ def test_create_delivery_vehicle_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_vehicles.DeliveryVehicle.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_vehicles.DeliveryVehicle.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 @@ -3847,8 +3917,9 @@ def test_create_delivery_vehicle_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_vehicles.DeliveryVehicle.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_vehicles.DeliveryVehicle.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 @@ -3956,72 +4027,6 @@ def test_create_delivery_vehicle_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "providers/sample1"} - request_init["delivery_vehicle"] = { - "name": "name_value", - "last_location": { - "location": {"latitude": 0.86, "longitude": 0.971}, - "horizontal_accuracy": {"value": 0.541}, - "latlng_accuracy": {}, - "heading": {"value": 541}, - "bearing_accuracy": {}, - "heading_accuracy": {}, - "altitude": {}, - "vertical_accuracy": {}, - "altitude_accuracy": {}, - "speed_kmph": {}, - "speed": {}, - "speed_accuracy": {}, - "update_time": {"seconds": 751, "nanos": 543}, - "server_time": {}, - "location_sensor": 1, - "is_road_snapped": {"value": True}, - "is_gps_sensor_enabled": {}, - "time_since_update": {}, - "num_stale_updates": {}, - "raw_location": {}, - "raw_location_time": {}, - "raw_location_sensor": 1, - "raw_location_accuracy": {}, - "supplemental_location": {}, - "supplemental_location_time": {}, - "supplemental_location_sensor": 1, - "supplemental_location_accuracy": {}, - "road_snapped": True, - }, - "navigation_status": 1, - "current_route_segment": b"current_route_segment_blob", - "current_route_segment_end_point": {}, - "remaining_distance_meters": {}, - "remaining_duration": {"seconds": 751, "nanos": 543}, - "remaining_vehicle_journey_segments": [ - { - "stop": { - "planned_location": {"point": {}}, - "tasks": [ - { - "task_id": "task_id_value", - "task_duration": {}, - "target_time_window": {"start_time": {}, "end_time": {}}, - } - ], - "state": 1, - }, - "driving_distance_meters": {}, - "driving_duration": {}, - "path": {}, - } - ], - "attributes": [ - { - "key": "key_value", - "value": "value_value", - "string_value": "string_value_value", - "bool_value": True, - "number_value": 0.1285, - } - ], - "type_": 1, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -4061,8 +4066,9 @@ def test_create_delivery_vehicle_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_vehicles.DeliveryVehicle.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_vehicles.DeliveryVehicle.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 @@ -4131,8 +4137,9 @@ def test_get_delivery_vehicle_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_vehicles.DeliveryVehicle.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_vehicles.DeliveryVehicle.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 @@ -4214,8 +4221,9 @@ def test_get_delivery_vehicle_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_vehicles.DeliveryVehicle.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_vehicles.DeliveryVehicle.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 @@ -4340,8 +4348,9 @@ def test_get_delivery_vehicle_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_vehicles.DeliveryVehicle.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_vehicles.DeliveryVehicle.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 @@ -4461,6 +4470,75 @@ def test_update_delivery_vehicle_rest(request_type): ], "type_": 1, } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = delivery_api.UpdateDeliveryVehicleRequest.meta.fields[ + "delivery_vehicle" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["delivery_vehicle"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["delivery_vehicle"][field])): + del request_init["delivery_vehicle"][field][i][subfield] + else: + del request_init["delivery_vehicle"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -4476,8 +4554,9 @@ def test_update_delivery_vehicle_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_vehicles.DeliveryVehicle.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_vehicles.DeliveryVehicle.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 @@ -4560,8 +4639,9 @@ def test_update_delivery_vehicle_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_vehicles.DeliveryVehicle.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_vehicles.DeliveryVehicle.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 @@ -4664,72 +4744,6 @@ def test_update_delivery_vehicle_rest_bad_request( request_init = { "delivery_vehicle": {"name": "providers/sample1/deliveryVehicles/sample2"} } - request_init["delivery_vehicle"] = { - "name": "providers/sample1/deliveryVehicles/sample2", - "last_location": { - "location": {"latitude": 0.86, "longitude": 0.971}, - "horizontal_accuracy": {"value": 0.541}, - "latlng_accuracy": {}, - "heading": {"value": 541}, - "bearing_accuracy": {}, - "heading_accuracy": {}, - "altitude": {}, - "vertical_accuracy": {}, - "altitude_accuracy": {}, - "speed_kmph": {}, - "speed": {}, - "speed_accuracy": {}, - "update_time": {"seconds": 751, "nanos": 543}, - "server_time": {}, - "location_sensor": 1, - "is_road_snapped": {"value": True}, - "is_gps_sensor_enabled": {}, - "time_since_update": {}, - "num_stale_updates": {}, - "raw_location": {}, - "raw_location_time": {}, - "raw_location_sensor": 1, - "raw_location_accuracy": {}, - "supplemental_location": {}, - "supplemental_location_time": {}, - "supplemental_location_sensor": 1, - "supplemental_location_accuracy": {}, - "road_snapped": True, - }, - "navigation_status": 1, - "current_route_segment": b"current_route_segment_blob", - "current_route_segment_end_point": {}, - "remaining_distance_meters": {}, - "remaining_duration": {"seconds": 751, "nanos": 543}, - "remaining_vehicle_journey_segments": [ - { - "stop": { - "planned_location": {"point": {}}, - "tasks": [ - { - "task_id": "task_id_value", - "task_duration": {}, - "target_time_window": {"start_time": {}, "end_time": {}}, - } - ], - "state": 1, - }, - "driving_distance_meters": {}, - "driving_duration": {}, - "path": {}, - } - ], - "attributes": [ - { - "key": "key_value", - "value": "value_value", - "string_value": "string_value_value", - "bool_value": True, - "number_value": 0.1285, - } - ], - "type_": 1, - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -4770,8 +4784,9 @@ def test_update_delivery_vehicle_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_vehicles.DeliveryVehicle.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_vehicles.DeliveryVehicle.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 @@ -4835,8 +4850,9 @@ def test_batch_create_tasks_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_api.BatchCreateTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_api.BatchCreateTasksResponse.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 @@ -4911,8 +4927,9 @@ def test_batch_create_tasks_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_api.BatchCreateTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_api.BatchCreateTasksResponse.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 @@ -5130,6 +5147,73 @@ def test_create_task_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = delivery_api.CreateTaskRequest.meta.fields["task"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["task"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["task"][field])): + del request_init["task"][field][i][subfield] + else: + del request_init["task"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -5148,8 +5232,9 @@ def test_create_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tasks.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tasks.Task.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 @@ -5246,8 +5331,9 @@ def test_create_task_rest_required_fields(request_type=delivery_api.CreateTaskRe response_value = Response() response_value.status_code = 200 - pb_return_value = tasks.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tasks.Task.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 @@ -5351,93 +5437,6 @@ def test_create_task_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "providers/sample1"} - request_init["task"] = { - "name": "name_value", - "type_": 1, - "state": 1, - "task_outcome": 1, - "task_outcome_time": {"seconds": 751, "nanos": 543}, - "task_outcome_location": {"point": {"latitude": 0.86, "longitude": 0.971}}, - "task_outcome_location_source": 2, - "tracking_id": "tracking_id_value", - "delivery_vehicle_id": "delivery_vehicle_id_value", - "planned_location": {}, - "task_duration": {"seconds": 751, "nanos": 543}, - "target_time_window": {"start_time": {}, "end_time": {}}, - "journey_sharing_info": { - "remaining_vehicle_journey_segments": [ - { - "stop": { - "planned_location": {}, - "tasks": [ - { - "task_id": "task_id_value", - "task_duration": {}, - "target_time_window": {}, - } - ], - "state": 1, - }, - "driving_distance_meters": {"value": 541}, - "driving_duration": {}, - "path": {}, - } - ], - "last_location": { - "location": {}, - "horizontal_accuracy": {"value": 0.541}, - "latlng_accuracy": {}, - "heading": {}, - "bearing_accuracy": {}, - "heading_accuracy": {}, - "altitude": {}, - "vertical_accuracy": {}, - "altitude_accuracy": {}, - "speed_kmph": {}, - "speed": {}, - "speed_accuracy": {}, - "update_time": {}, - "server_time": {}, - "location_sensor": 1, - "is_road_snapped": {"value": True}, - "is_gps_sensor_enabled": {}, - "time_since_update": {}, - "num_stale_updates": {}, - "raw_location": {}, - "raw_location_time": {}, - "raw_location_sensor": 1, - "raw_location_accuracy": {}, - "supplemental_location": {}, - "supplemental_location_time": {}, - "supplemental_location_sensor": 1, - "supplemental_location_accuracy": {}, - "road_snapped": True, - }, - "last_location_snappable": True, - }, - "task_tracking_view_config": { - "route_polyline_points_visibility": { - "remaining_stop_count_threshold": 3219, - "duration_until_estimated_arrival_time_threshold": {}, - "remaining_driving_distance_meters_threshold": 4561, - "always": True, - "never": True, - }, - "estimated_arrival_time_visibility": {}, - "estimated_task_completion_time_visibility": {}, - "remaining_driving_distance_visibility": {}, - "remaining_stop_count_visibility": {}, - "vehicle_location_visibility": {}, - }, - "attributes": [ - { - "key": "key_value", - "string_value": "string_value_value", - "bool_value": True, - "number_value": 0.1285, - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -5477,8 +5476,9 @@ def test_create_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tasks.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tasks.Task.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 @@ -5549,8 +5549,9 @@ def test_get_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tasks.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tasks.Task.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 @@ -5634,8 +5635,9 @@ def test_get_task_rest_required_fields(request_type=delivery_api.GetTaskRequest) response_value = Response() response_value.status_code = 200 - pb_return_value = tasks.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tasks.Task.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 @@ -5756,8 +5758,9 @@ def test_get_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tasks.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tasks.Task.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 @@ -5820,8 +5823,9 @@ def test_search_tasks_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_api.SearchTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_api.SearchTasksResponse.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 @@ -5912,8 +5916,9 @@ def test_search_tasks_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_api.SearchTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_api.SearchTasksResponse.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 @@ -6059,8 +6064,9 @@ def test_search_tasks_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_api.SearchTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_api.SearchTasksResponse.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 @@ -6253,6 +6259,73 @@ def test_update_task_rest(request_type): } ], } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = delivery_api.UpdateTaskRequest.meta.fields["task"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["task"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["task"][field])): + del request_init["task"][field][i][subfield] + else: + del request_init["task"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -6271,8 +6344,9 @@ def test_update_task_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tasks.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tasks.Task.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 @@ -6357,8 +6431,9 @@ def test_update_task_rest_required_fields(request_type=delivery_api.UpdateTaskRe response_value = Response() response_value.status_code = 200 - pb_return_value = tasks.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tasks.Task.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 @@ -6455,93 +6530,6 @@ def test_update_task_rest_bad_request( # send a request that will satisfy transcoding request_init = {"task": {"name": "providers/sample1/tasks/sample2"}} - request_init["task"] = { - "name": "providers/sample1/tasks/sample2", - "type_": 1, - "state": 1, - "task_outcome": 1, - "task_outcome_time": {"seconds": 751, "nanos": 543}, - "task_outcome_location": {"point": {"latitude": 0.86, "longitude": 0.971}}, - "task_outcome_location_source": 2, - "tracking_id": "tracking_id_value", - "delivery_vehicle_id": "delivery_vehicle_id_value", - "planned_location": {}, - "task_duration": {"seconds": 751, "nanos": 543}, - "target_time_window": {"start_time": {}, "end_time": {}}, - "journey_sharing_info": { - "remaining_vehicle_journey_segments": [ - { - "stop": { - "planned_location": {}, - "tasks": [ - { - "task_id": "task_id_value", - "task_duration": {}, - "target_time_window": {}, - } - ], - "state": 1, - }, - "driving_distance_meters": {"value": 541}, - "driving_duration": {}, - "path": {}, - } - ], - "last_location": { - "location": {}, - "horizontal_accuracy": {"value": 0.541}, - "latlng_accuracy": {}, - "heading": {}, - "bearing_accuracy": {}, - "heading_accuracy": {}, - "altitude": {}, - "vertical_accuracy": {}, - "altitude_accuracy": {}, - "speed_kmph": {}, - "speed": {}, - "speed_accuracy": {}, - "update_time": {}, - "server_time": {}, - "location_sensor": 1, - "is_road_snapped": {"value": True}, - "is_gps_sensor_enabled": {}, - "time_since_update": {}, - "num_stale_updates": {}, - "raw_location": {}, - "raw_location_time": {}, - "raw_location_sensor": 1, - "raw_location_accuracy": {}, - "supplemental_location": {}, - "supplemental_location_time": {}, - "supplemental_location_sensor": 1, - "supplemental_location_accuracy": {}, - "road_snapped": True, - }, - "last_location_snappable": True, - }, - "task_tracking_view_config": { - "route_polyline_points_visibility": { - "remaining_stop_count_threshold": 3219, - "duration_until_estimated_arrival_time_threshold": {}, - "remaining_driving_distance_meters_threshold": 4561, - "always": True, - "never": True, - }, - "estimated_arrival_time_visibility": {}, - "estimated_task_completion_time_visibility": {}, - "remaining_driving_distance_visibility": {}, - "remaining_stop_count_visibility": {}, - "vehicle_location_visibility": {}, - }, - "attributes": [ - { - "key": "key_value", - "string_value": "string_value_value", - "bool_value": True, - "number_value": 0.1285, - } - ], - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -6580,8 +6568,9 @@ def test_update_task_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = tasks.Task.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = tasks.Task.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 @@ -6646,8 +6635,9 @@ def test_list_tasks_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_api.ListTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_api.ListTasksResponse.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 @@ -6730,8 +6720,9 @@ def test_list_tasks_rest_required_fields(request_type=delivery_api.ListTasksRequ response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_api.ListTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_api.ListTasksResponse.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 @@ -6864,8 +6855,9 @@ def test_list_tasks_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_api.ListTasksResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_api.ListTasksResponse.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 @@ -6986,8 +6978,9 @@ def test_get_task_tracking_info_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task_tracking_info.TaskTrackingInfo.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task_tracking_info.TaskTrackingInfo.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 @@ -7067,8 +7060,9 @@ def test_get_task_tracking_info_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = task_tracking_info.TaskTrackingInfo.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task_tracking_info.TaskTrackingInfo.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 @@ -7193,8 +7187,9 @@ def test_get_task_tracking_info_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = task_tracking_info.TaskTrackingInfo.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = task_tracking_info.TaskTrackingInfo.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 @@ -7259,8 +7254,9 @@ def test_list_delivery_vehicles_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_api.ListDeliveryVehiclesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_api.ListDeliveryVehiclesResponse.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 @@ -7346,8 +7342,9 @@ def test_list_delivery_vehicles_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_api.ListDeliveryVehiclesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_api.ListDeliveryVehiclesResponse.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 @@ -7483,8 +7480,9 @@ def test_list_delivery_vehicles_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = delivery_api.ListDeliveryVehiclesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = delivery_api.ListDeliveryVehiclesResponse.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 diff --git a/packages/google-maps-mapsplatformdatasets/CONTRIBUTING.rst b/packages/google-maps-mapsplatformdatasets/CONTRIBUTING.rst index 095250a3bc85..bd78e0d68954 100644 --- a/packages/google-maps-mapsplatformdatasets/CONTRIBUTING.rst +++ b/packages/google-maps-mapsplatformdatasets/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-maps-mapsplatformdatasets/docs/index.rst b/packages/google-maps-mapsplatformdatasets/docs/index.rst index 0578e94816f3..c1d250c7c393 100644 --- a/packages/google-maps-mapsplatformdatasets/docs/index.rst +++ b/packages/google-maps-mapsplatformdatasets/docs/index.rst @@ -3,7 +3,7 @@ .. include:: multiprocessing.rst This package includes clients for multiple versions of Maps Platform Datasets API. -By default, you will get version ``mapsplatformdatasets_v1``. +By default, you will get version ``mapsplatformdatasets_v1alpha``. API Reference @@ -11,16 +11,16 @@ API Reference .. toctree:: :maxdepth: 2 - mapsplatformdatasets_v1/services - mapsplatformdatasets_v1/types + mapsplatformdatasets_v1alpha/services + mapsplatformdatasets_v1alpha/types API Reference ------------- .. toctree:: :maxdepth: 2 - mapsplatformdatasets_v1alpha/services - mapsplatformdatasets_v1alpha/types + mapsplatformdatasets_v1/services + mapsplatformdatasets_v1/types Changelog diff --git a/packages/google-maps-mapsplatformdatasets/google/maps/mapsplatformdatasets/gapic_version.py b/packages/google-maps-mapsplatformdatasets/google/maps/mapsplatformdatasets/gapic_version.py index 78e859312100..360a0d13ebdd 100644 --- a/packages/google-maps-mapsplatformdatasets/google/maps/mapsplatformdatasets/gapic_version.py +++ b/packages/google-maps-mapsplatformdatasets/google/maps/mapsplatformdatasets/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.3.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-maps-mapsplatformdatasets/google/maps/mapsplatformdatasets_v1/gapic_version.py b/packages/google-maps-mapsplatformdatasets/google/maps/mapsplatformdatasets_v1/gapic_version.py index 78e859312100..360a0d13ebdd 100644 --- a/packages/google-maps-mapsplatformdatasets/google/maps/mapsplatformdatasets_v1/gapic_version.py +++ b/packages/google-maps-mapsplatformdatasets/google/maps/mapsplatformdatasets_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.3.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-maps-mapsplatformdatasets/google/maps/mapsplatformdatasets_v1alpha/gapic_version.py b/packages/google-maps-mapsplatformdatasets/google/maps/mapsplatformdatasets_v1alpha/gapic_version.py index 78e859312100..360a0d13ebdd 100644 --- a/packages/google-maps-mapsplatformdatasets/google/maps/mapsplatformdatasets_v1alpha/gapic_version.py +++ b/packages/google-maps-mapsplatformdatasets/google/maps/mapsplatformdatasets_v1alpha/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.3.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-maps-mapsplatformdatasets/noxfile.py b/packages/google-maps-mapsplatformdatasets/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-maps-mapsplatformdatasets/noxfile.py +++ b/packages/google-maps-mapsplatformdatasets/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-maps-mapsplatformdatasets/samples/generated_samples/snippet_metadata_google.maps.mapsplatformdatasets.v1.json b/packages/google-maps-mapsplatformdatasets/samples/generated_samples/snippet_metadata_google.maps.mapsplatformdatasets.v1.json index d787a8415003..a64c4e935462 100644 --- a/packages/google-maps-mapsplatformdatasets/samples/generated_samples/snippet_metadata_google.maps.mapsplatformdatasets.v1.json +++ b/packages/google-maps-mapsplatformdatasets/samples/generated_samples/snippet_metadata_google.maps.mapsplatformdatasets.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-maps-mapsplatformdatasets", - "version": "0.3.2" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-maps-mapsplatformdatasets/samples/generated_samples/snippet_metadata_google.maps.mapsplatformdatasets.v1alpha.json b/packages/google-maps-mapsplatformdatasets/samples/generated_samples/snippet_metadata_google.maps.mapsplatformdatasets.v1alpha.json index fb54318018c6..55c8275889ff 100644 --- a/packages/google-maps-mapsplatformdatasets/samples/generated_samples/snippet_metadata_google.maps.mapsplatformdatasets.v1alpha.json +++ b/packages/google-maps-mapsplatformdatasets/samples/generated_samples/snippet_metadata_google.maps.mapsplatformdatasets.v1alpha.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-maps-mapsplatformdatasets", - "version": "0.3.2" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-maps-mapsplatformdatasets/tests/unit/gapic/mapsplatformdatasets_v1/test_maps_platform_datasets.py b/packages/google-maps-mapsplatformdatasets/tests/unit/gapic/mapsplatformdatasets_v1/test_maps_platform_datasets.py index 41d4f91afe78..89065d56d39e 100644 --- a/packages/google-maps-mapsplatformdatasets/tests/unit/gapic/mapsplatformdatasets_v1/test_maps_platform_datasets.py +++ b/packages/google-maps-mapsplatformdatasets/tests/unit/gapic/mapsplatformdatasets_v1/test_maps_platform_datasets.py @@ -2207,6 +2207,73 @@ def test_create_dataset_rest(request_type): "version_create_time": {}, "version_description": "version_description_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = maps_platform_datasets.CreateDatasetRequest.meta.fields["dataset"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["dataset"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["dataset"][field])): + del request_init["dataset"][field][i][subfield] + else: + del request_init["dataset"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -2224,8 +2291,9 @@ def test_create_dataset_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gmm_dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gmm_dataset.Dataset.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 @@ -2306,8 +2374,9 @@ def test_create_dataset_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gmm_dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gmm_dataset.Dataset.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 @@ -2401,20 +2470,6 @@ def test_create_dataset_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1"} - request_init["dataset"] = { - "name": "name_value", - "display_name": "display_name_value", - "description": "description_value", - "version_id": "version_id_value", - "usage": [1], - "local_file_source": {"filename": "filename_value", "file_format": 1}, - "gcs_source": {"input_uri": "input_uri_value", "file_format": 1}, - "status": {"state": 1, "error_message": "error_message_value"}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "version_create_time": {}, - "version_description": "version_description_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -2453,8 +2508,9 @@ def test_create_dataset_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gmm_dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gmm_dataset.Dataset.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 @@ -2520,6 +2576,75 @@ def test_update_dataset_metadata_rest(request_type): "version_create_time": {}, "version_description": "version_description_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = maps_platform_datasets.UpdateDatasetMetadataRequest.meta.fields[ + "dataset" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["dataset"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["dataset"][field])): + del request_init["dataset"][field][i][subfield] + else: + del request_init["dataset"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -2537,8 +2662,9 @@ def test_update_dataset_metadata_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gmm_dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gmm_dataset.Dataset.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 @@ -2616,8 +2742,9 @@ def test_update_dataset_metadata_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gmm_dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gmm_dataset.Dataset.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 @@ -2704,20 +2831,6 @@ def test_update_dataset_metadata_rest_bad_request( # send a request that will satisfy transcoding request_init = {"dataset": {"name": "projects/sample1/datasets/sample2"}} - request_init["dataset"] = { - "name": "projects/sample1/datasets/sample2", - "display_name": "display_name_value", - "description": "description_value", - "version_id": "version_id_value", - "usage": [1], - "local_file_source": {"filename": "filename_value", "file_format": 1}, - "gcs_source": {"input_uri": "input_uri_value", "file_format": 1}, - "status": {"state": 1, "error_message": "error_message_value"}, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "version_create_time": {}, - "version_description": "version_description_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -2756,8 +2869,9 @@ def test_update_dataset_metadata_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gmm_dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gmm_dataset.Dataset.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 @@ -2827,8 +2941,9 @@ def test_get_dataset_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = dataset.Dataset.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 @@ -2908,8 +3023,9 @@ def test_get_dataset_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = dataset.Dataset.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 @@ -3032,8 +3148,9 @@ def test_get_dataset_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = dataset.Dataset.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 @@ -3096,8 +3213,9 @@ def test_list_datasets_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = maps_platform_datasets.ListDatasetsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = maps_platform_datasets.ListDatasetsResponse.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 @@ -3179,10 +3297,9 @@ def test_list_datasets_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = maps_platform_datasets.ListDatasetsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = maps_platform_datasets.ListDatasetsResponse.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 @@ -3315,8 +3432,9 @@ def test_list_datasets_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = maps_platform_datasets.ListDatasetsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = maps_platform_datasets.ListDatasetsResponse.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 diff --git a/packages/google-maps-mapsplatformdatasets/tests/unit/gapic/mapsplatformdatasets_v1alpha/test_maps_platform_datasets_v1_alpha.py b/packages/google-maps-mapsplatformdatasets/tests/unit/gapic/mapsplatformdatasets_v1alpha/test_maps_platform_datasets_v1_alpha.py index eacabe51e4df..ed567940dc51 100644 --- a/packages/google-maps-mapsplatformdatasets/tests/unit/gapic/mapsplatformdatasets_v1alpha/test_maps_platform_datasets_v1_alpha.py +++ b/packages/google-maps-mapsplatformdatasets/tests/unit/gapic/mapsplatformdatasets_v1alpha/test_maps_platform_datasets_v1_alpha.py @@ -2908,6 +2908,73 @@ def test_create_dataset_rest(request_type): "version_create_time": {}, "version_description": "version_description_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = maps_platform_datasets.CreateDatasetRequest.meta.fields["dataset"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["dataset"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["dataset"][field])): + del request_init["dataset"][field][i][subfield] + else: + del request_init["dataset"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -2926,8 +2993,9 @@ def test_create_dataset_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gmm_dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gmm_dataset.Dataset.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 @@ -3009,8 +3077,9 @@ def test_create_dataset_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gmm_dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gmm_dataset.Dataset.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 @@ -3104,20 +3173,6 @@ def test_create_dataset_rest_bad_request( # send a request that will satisfy transcoding request_init = {"parent": "projects/sample1"} - request_init["dataset"] = { - "name": "name_value", - "display_name": "display_name_value", - "description": "description_value", - "version_id": "version_id_value", - "usage": [1], - "local_file_source": {"filename": "filename_value", "file_format": 1}, - "gcs_source": {"input_uri": "input_uri_value", "file_format": 1}, - "status": 1, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "version_create_time": {}, - "version_description": "version_description_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -3156,8 +3211,9 @@ def test_create_dataset_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gmm_dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gmm_dataset.Dataset.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 @@ -3223,6 +3279,75 @@ def test_update_dataset_metadata_rest(request_type): "version_create_time": {}, "version_description": "version_description_value", } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = maps_platform_datasets.UpdateDatasetMetadataRequest.meta.fields[ + "dataset" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["dataset"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["dataset"][field])): + del request_init["dataset"][field][i][subfield] + else: + del request_init["dataset"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -3241,8 +3366,9 @@ def test_update_dataset_metadata_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gmm_dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gmm_dataset.Dataset.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 @@ -3321,8 +3447,9 @@ def test_update_dataset_metadata_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = gmm_dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gmm_dataset.Dataset.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 @@ -3411,20 +3538,6 @@ def test_update_dataset_metadata_rest_bad_request( # send a request that will satisfy transcoding request_init = {"dataset": {"name": "projects/sample1/datasets/sample2"}} - request_init["dataset"] = { - "name": "projects/sample1/datasets/sample2", - "display_name": "display_name_value", - "description": "description_value", - "version_id": "version_id_value", - "usage": [1], - "local_file_source": {"filename": "filename_value", "file_format": 1}, - "gcs_source": {"input_uri": "input_uri_value", "file_format": 1}, - "status": 1, - "create_time": {"seconds": 751, "nanos": 543}, - "update_time": {}, - "version_create_time": {}, - "version_description": "version_description_value", - } request = request_type(**request_init) # Mock the http request call within the method and fake a BadRequest error. @@ -3463,8 +3576,9 @@ def test_update_dataset_metadata_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = gmm_dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = gmm_dataset.Dataset.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 @@ -3535,8 +3649,9 @@ def test_get_dataset_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = dataset.Dataset.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 @@ -3619,8 +3734,9 @@ def test_get_dataset_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = dataset.Dataset.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 @@ -3743,8 +3859,9 @@ def test_get_dataset_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = dataset.Dataset.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = dataset.Dataset.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 @@ -3807,10 +3924,11 @@ def test_list_dataset_versions_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = maps_platform_datasets.ListDatasetVersionsResponse.pb( + # Convert return value to protobuf type + return_value = maps_platform_datasets.ListDatasetVersionsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -3892,10 +4010,11 @@ def test_list_dataset_versions_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = maps_platform_datasets.ListDatasetVersionsResponse.pb( + # Convert return value to protobuf type + return_value = maps_platform_datasets.ListDatasetVersionsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -4033,10 +4152,11 @@ def test_list_dataset_versions_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = maps_platform_datasets.ListDatasetVersionsResponse.pb( + # Convert return value to protobuf type + return_value = maps_platform_datasets.ListDatasetVersionsResponse.pb( return_value ) - json_return_value = json_format.MessageToJson(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 @@ -4159,8 +4279,9 @@ def test_list_datasets_rest(request_type): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = maps_platform_datasets.ListDatasetsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = maps_platform_datasets.ListDatasetsResponse.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 @@ -4242,10 +4363,9 @@ def test_list_datasets_rest_required_fields( response_value = Response() response_value.status_code = 200 - pb_return_value = maps_platform_datasets.ListDatasetsResponse.pb( - return_value - ) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = maps_platform_datasets.ListDatasetsResponse.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 @@ -4378,8 +4498,9 @@ def test_list_datasets_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - pb_return_value = maps_platform_datasets.ListDatasetsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(pb_return_value) + # Convert return value to protobuf type + return_value = maps_platform_datasets.ListDatasetsResponse.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