From 14997230146495375cbe164d89a6a8213eca3924 Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Wed, 17 Apr 2019 10:16:16 -0700 Subject: [PATCH 1/6] Fix missing default retries --- .../codegen/config/GapicProductConfig.java | 1 - .../api/codegen/config/RetryCodesConfig.java | 40 +++++++++++-------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/google/api/codegen/config/GapicProductConfig.java b/src/main/java/com/google/api/codegen/config/GapicProductConfig.java index 1e2b399e15..641a40f735 100644 --- a/src/main/java/com/google/api/codegen/config/GapicProductConfig.java +++ b/src/main/java/com/google/api/codegen/config/GapicProductConfig.java @@ -47,7 +47,6 @@ import com.google.common.collect.Iterables; import com.google.protobuf.Api; import com.google.protobuf.DescriptorProtos; -import java.util.Collection; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; diff --git a/src/main/java/com/google/api/codegen/config/RetryCodesConfig.java b/src/main/java/com/google/api/codegen/config/RetryCodesConfig.java index 123a9e6935..fbaf2b7ada 100644 --- a/src/main/java/com/google/api/codegen/config/RetryCodesConfig.java +++ b/src/main/java/com/google/api/codegen/config/RetryCodesConfig.java @@ -31,9 +31,9 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -44,6 +44,8 @@ public class RetryCodesConfig { public static ImmutableList RETRY_CODES_FOR_HTTP_GET = DEFAULT_RETRY_CODES.get(RETRY_CODES_IDEMPOTENT_NAME); + public static ImmutableList RETRY_CODES_FOR_HTTP_NON_GET = + DEFAULT_RETRY_CODES.get(RETRY_CODES_NON_IDEMPOTENT_NAME); private Map> retryCodesDefinition = new HashMap<>(); private Map methodRetryNames = new HashMap<>(); @@ -81,12 +83,9 @@ public static RetryCodesConfig create( retryCodesConfig.populateRetryCodesDefinitionFromConfigProto( diagCollector, interfaceConfigProto); - if (retryCodesConfig.error) { + if (!retryCodesConfig.setFinalRetryProperties()) { return null; } - retryCodesConfig.finalMethodRetryNames = ImmutableMap.copyOf(retryCodesConfig.methodRetryNames); - retryCodesConfig.finalRetryCodesDefinition = - ImmutableMap.copyOf(retryCodesConfig.retryCodesDefinition); return retryCodesConfig; } @@ -98,12 +97,9 @@ public static RetryCodesConfig create( RetryCodesConfig retryCodesConfig = new RetryCodesConfig(); retryCodesConfig.populateRetryCodesDefinition( diagCollector, interfaceConfigProto, methodsToGenerate, protoParser); - if (retryCodesConfig.error) { + if (!retryCodesConfig.setFinalRetryProperties()) { return null; } - retryCodesConfig.finalMethodRetryNames = ImmutableMap.copyOf(retryCodesConfig.methodRetryNames); - retryCodesConfig.finalRetryCodesDefinition = - ImmutableMap.copyOf(retryCodesConfig.retryCodesDefinition); return retryCodesConfig; } @@ -148,6 +144,15 @@ private static ImmutableMap createMethodRetryNamesFromConfigProt return builder.build(); } + private boolean setFinalRetryProperties() { + if (error) { + return false; + } + finalMethodRetryNames = ImmutableMap.copyOf(methodRetryNames); + finalRetryCodesDefinition = ImmutableMap.copyOf(retryCodesDefinition); + return true; + } + /** * Returns a mapping of a retryCodeDef name to the list of retry codes it contains. Also populates * the @param methodNameToRetryCodeNames with a mapping of a Method name to its retry code @@ -205,6 +210,11 @@ private void populateRetryCodesDefinitionWithProtoFile( SymbolTable symbolTable = new SymbolTable(); + // Add retry codes for default cases (idempotent and non_idempotent) if they have not + // already be added previously (in the GAPIC config). + retryCodesDefinition.putIfAbsent(RETRY_CODES_IDEMPOTENT_NAME, RETRY_CODES_FOR_HTTP_GET); + retryCodesDefinition.putIfAbsent(RETRY_CODES_NON_IDEMPOTENT_NAME, RETRY_CODES_FOR_HTTP_NON_GET); + for (String retryCodesName : retryCodesDefinition.keySet()) { // Record all the preexisting retryCodeNames from configProto. symbolTable.getNewSymbol(retryCodesName); @@ -213,11 +223,8 @@ private void populateRetryCodesDefinitionWithProtoFile( // Unite all HTTP GET methods that have no additional retry codes under one retry code name to // reduce duplication. String httpGetRetryName; - Set defaultRetryCodesForHttpGet = new HashSet<>(RETRY_CODES_FOR_HTTP_GET); - Set existingIdempotentRetryCodes = - new HashSet<>( - retryCodesDefinition.getOrDefault(RETRY_CODES_IDEMPOTENT_NAME, ImmutableList.of())); - if (defaultRetryCodesForHttpGet.equals(existingIdempotentRetryCodes)) { + if (Sets.newHashSet(RETRY_CODES_FOR_HTTP_GET) + .containsAll(retryCodesDefinition.get(RETRY_CODES_IDEMPOTENT_NAME))) { // The GAPIC config defined RETRY_CODES_IDEMPOTENT_NAME to have the same retry codes as // this method would have, // so we can just reuse RETRY_CODES_IDEMPOTENT_NAME. @@ -228,9 +235,8 @@ private void populateRetryCodesDefinitionWithProtoFile( // Unite all methods that have no retry codes under one retry code name to reduce duplication. String noRetryName; - if (retryCodesDefinition - .getOrDefault(RETRY_CODES_NON_IDEMPOTENT_NAME, ImmutableList.of()) - .isEmpty()) { + if (Sets.newHashSet(RETRY_CODES_FOR_HTTP_NON_GET) + .containsAll(retryCodesDefinition.get(RETRY_CODES_NON_IDEMPOTENT_NAME))) { noRetryName = RETRY_CODES_NON_IDEMPOTENT_NAME; } else { noRetryName = symbolTable.getNewSymbol(RETRY_CODES_NON_IDEMPOTENT_NAME); From f2ff3bbf6e84ee62643534de4b6d32cb8b0fcabc Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Wed, 17 Apr 2019 10:39:38 -0700 Subject: [PATCH 2/6] Update baselines --- .../api/codegen/config/GapicProductConfig.java | 1 + .../java/java_multiple_services.baseline | 6 ++++++ .../java/java_no_path_templates.baseline | 3 +++ .../nodejs/nodejs_multiple_services.baseline | 8 ++++++++ .../nodejs/nodejs_no_path_templates.baseline | 4 ++++ .../testdata/php/php_no_path_templates.baseline | 4 ++++ .../py/python_multiple_services.baseline | 16 ++++++++++++---- .../py/python_no_path_templates.baseline | 12 ++++++++---- .../ruby/ruby_multiple_services.baseline | 10 +++++++++- .../java_library_no_gapic_config.baseline | 3 +++ .../ruby_library_no_gapic_config.baseline | 6 +++++- 11 files changed, 63 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/google/api/codegen/config/GapicProductConfig.java b/src/main/java/com/google/api/codegen/config/GapicProductConfig.java index 641a40f735..1e2b399e15 100644 --- a/src/main/java/com/google/api/codegen/config/GapicProductConfig.java +++ b/src/main/java/com/google/api/codegen/config/GapicProductConfig.java @@ -47,6 +47,7 @@ import com.google.common.collect.Iterables; import com.google.protobuf.Api; import com.google.protobuf.DescriptorProtos; +import java.util.Collection; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/java/java_multiple_services.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/java/java_multiple_services.baseline index b68c240baf..2aec187372 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/java/java_multiple_services.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/java/java_multiple_services.baseline @@ -1086,6 +1086,9 @@ public class DecrementerServiceStubSettings extends StubSettings> definitions = ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); definitions.put( "non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); @@ -1877,6 +1880,9 @@ public class IncrementerServiceStubSettings extends StubSettings> definitions = ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); definitions.put( "non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/java/java_no_path_templates.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/java/java_no_path_templates.baseline index 4382a05fae..f968cb3ae3 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/java/java_no_path_templates.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/java/java_no_path_templates.baseline @@ -959,6 +959,9 @@ public class NoTemplatesApiServiceStubSettings extends StubSettings> definitions = ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); definitions.put( "non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/nodejs/nodejs_multiple_services.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/nodejs/nodejs_multiple_services.baseline index 1133c0742b..3acea4211d 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/nodejs/nodejs_multiple_services.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/nodejs/nodejs_multiple_services.baseline @@ -392,6 +392,10 @@ module.exports = DecrementerServiceClient; "interfaces": { "google.cloud.example.v1.foo.DecrementerService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { @@ -710,6 +714,10 @@ module.exports = IncrementerServiceClient; "interfaces": { "google.cloud.example.v1.foo.IncrementerService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/nodejs/nodejs_no_path_templates.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/nodejs/nodejs_no_path_templates.baseline index b8db4d1f05..2362b4f669 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/nodejs/nodejs_no_path_templates.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/nodejs/nodejs_no_path_templates.baseline @@ -387,6 +387,10 @@ module.exports = NoTemplatesApiServiceClient; "interfaces": { "google.cloud.example.v1.NoTemplatesAPIService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/php/php_no_path_templates.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/php/php_no_path_templates.baseline index dd017c1dcb..027e0b0315 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/php/php_no_path_templates.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/php/php_no_path_templates.baseline @@ -282,6 +282,10 @@ class NoTemplatesApiServiceClient extends NoTemplatesApiServiceGapicClient "interfaces": { "google.cloud.example.v1.NoTemplatesAPIService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline index 2a20ce1d9b..9110a952a1 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline @@ -279,11 +279,11 @@ Next Steps API to see other available methods on the client. - Read the `Google Example API Product documentation`_ to learn more about the product and see How-to Guides. -- View this `repository’s main README`_ to see the full list of Cloud +- View this `repository?s main README`_ to see the full list of Cloud APIs that we cover. .. _Google Example API Product documentation: https://cloud.google.com/multiple_services -.. _repository’s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst +.. _repository?s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst ============== file: docs/conf.py ============== # -*- coding: utf-8 -*- # @@ -720,11 +720,11 @@ Next Steps API to see other available methods on the client. - Read the `Google Example API Product documentation`_ to learn more about the product and see How-to Guides. -- View this `repository’s main README`_ to see the full list of Cloud +- View this `repository?s main README`_ to see the full list of Cloud APIs that we cover. .. _Google Example API Product documentation: https://cloud.google.com/multiple_services -.. _repository’s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst +.. _repository?s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst Api Reference ------------- @@ -1073,6 +1073,10 @@ config = { "interfaces": { "google.cloud.example.v1.foo.DecrementerService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { @@ -1307,6 +1311,10 @@ config = { "interfaces": { "google.cloud.example.v1.foo.IncrementerService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline index 008fbb9424..7787696eee 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline @@ -279,11 +279,11 @@ Next Steps API to see other available methods on the client. - Read the `Google Fake API Product documentation`_ to learn more about the product and see How-to Guides. -- View this `repository’s main README`_ to see the full list of Cloud +- View this `repository?s main README`_ to see the full list of Cloud APIs that we cover. .. _Google Fake API Product documentation: https://cloud.google.com/library -.. _repository’s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst +.. _repository?s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst ============== file: docs/conf.py ============== # -*- coding: utf-8 -*- # @@ -720,11 +720,11 @@ Next Steps API to see other available methods on the client. - Read the `Google Fake API Product documentation`_ to learn more about the product and see How-to Guides. -- View this `repository’s main README`_ to see the full list of Cloud +- View this `repository?s main README`_ to see the full list of Cloud APIs that we cover. .. _Google Fake API Product documentation: https://cloud.google.com/library -.. _repository’s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst +.. _repository?s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst Api Reference ------------- @@ -1012,6 +1012,10 @@ config = { "interfaces": { "google.cloud.example.v1.NoTemplatesAPIService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline index 08e1c7674c..a822c24d0a 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline @@ -326,7 +326,7 @@ end This library is supported on Ruby 2.3+. Google provides official support for Ruby versions that are actively supported -by Ruby Core—that is, Ruby versions that are either in normal maintenance or +by Ruby Core?that is, Ruby versions that are either in normal maintenance or in security maintenance, and not end of life. Currently, this means Ruby 2.3 and later. Older versions of Ruby _may_ still work, but are unsupported and not recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details @@ -1146,6 +1146,10 @@ end "interfaces": { "google.cloud.example.v1.foo.DecrementerService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { @@ -1425,6 +1429,10 @@ end "interfaces": { "google.cloud.example.v1.foo.IncrementerService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { diff --git a/src/test/java/com/google/api/codegen/protoannotations/testdata/java_library_no_gapic_config.baseline b/src/test/java/com/google/api/codegen/protoannotations/testdata/java_library_no_gapic_config.baseline index 4759783c8d..2bb1234f42 100644 --- a/src/test/java/com/google/api/codegen/protoannotations/testdata/java_library_no_gapic_config.baseline +++ b/src/test/java/com/google/api/codegen/protoannotations/testdata/java_library_no_gapic_config.baseline @@ -8278,6 +8278,9 @@ public class MyProtoStubSettings extends StubSettings { static { ImmutableMap.Builder> definitions = ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); definitions.put( "non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); diff --git a/src/test/java/com/google/api/codegen/protoannotations/testdata/ruby_library_no_gapic_config.baseline b/src/test/java/com/google/api/codegen/protoannotations/testdata/ruby_library_no_gapic_config.baseline index e15646ddda..ad38de6206 100644 --- a/src/test/java/com/google/api/codegen/protoannotations/testdata/ruby_library_no_gapic_config.baseline +++ b/src/test/java/com/google/api/codegen/protoannotations/testdata/ruby_library_no_gapic_config.baseline @@ -325,7 +325,7 @@ end This library is supported on Ruby 2.3+. Google provides official support for Ruby versions that are actively supported -by Ruby Core—that is, Ruby versions that are either in normal maintenance or +by Ruby Core?that is, Ruby versions that are either in normal maintenance or in security maintenance, and not end of life. Currently, this means Ruby 2.3 and later. Older versions of Ruby _may_ still work, but are unsupported and not recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details @@ -5143,6 +5143,10 @@ end "interfaces": { "google.example.library.v1.MyProto": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { From 5620640f5e2fa1dccbfaa7c080cdc73a44b734fd Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Wed, 17 Apr 2019 11:12:06 -0700 Subject: [PATCH 3/6] Update baselines --- .../gapic/testdata/py/python_multiple_services.baseline | 8 ++++---- .../gapic/testdata/py/python_no_path_templates.baseline | 8 ++++---- .../gapic/testdata/ruby/ruby_multiple_services.baseline | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline index 9110a952a1..c788e116f0 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline @@ -279,11 +279,11 @@ Next Steps API to see other available methods on the client. - Read the `Google Example API Product documentation`_ to learn more about the product and see How-to Guides. -- View this `repository?s main README`_ to see the full list of Cloud +- View this `repository’s main README`_ to see the full list of Cloud APIs that we cover. .. _Google Example API Product documentation: https://cloud.google.com/multiple_services -.. _repository?s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst +.. _repository’s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst ============== file: docs/conf.py ============== # -*- coding: utf-8 -*- # @@ -720,11 +720,11 @@ Next Steps API to see other available methods on the client. - Read the `Google Example API Product documentation`_ to learn more about the product and see How-to Guides. -- View this `repository?s main README`_ to see the full list of Cloud +- View this `repository’s main README`_ to see the full list of Cloud APIs that we cover. .. _Google Example API Product documentation: https://cloud.google.com/multiple_services -.. _repository?s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst +.. _repository’s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst Api Reference ------------- diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline index 7787696eee..fffe8ee830 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline @@ -279,11 +279,11 @@ Next Steps API to see other available methods on the client. - Read the `Google Fake API Product documentation`_ to learn more about the product and see How-to Guides. -- View this `repository?s main README`_ to see the full list of Cloud +- View this `repository’s main README`_ to see the full list of Cloud APIs that we cover. .. _Google Fake API Product documentation: https://cloud.google.com/library -.. _repository?s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst +.. _repository’s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst ============== file: docs/conf.py ============== # -*- coding: utf-8 -*- # @@ -720,11 +720,11 @@ Next Steps API to see other available methods on the client. - Read the `Google Fake API Product documentation`_ to learn more about the product and see How-to Guides. -- View this `repository?s main README`_ to see the full list of Cloud +- View this `repository’s main README`_ to see the full list of Cloud APIs that we cover. .. _Google Fake API Product documentation: https://cloud.google.com/library -.. _repository?s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst +.. _repository’s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst Api Reference ------------- diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline index a822c24d0a..69fceee489 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline @@ -326,7 +326,7 @@ end This library is supported on Ruby 2.3+. Google provides official support for Ruby versions that are actively supported -by Ruby Core?that is, Ruby versions that are either in normal maintenance or +by Ruby Core—that is, Ruby versions that are either in normal maintenance or in security maintenance, and not end of life. Currently, this means Ruby 2.3 and later. Older versions of Ruby _may_ still work, but are unsupported and not recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details From 9fbc9dcffa162f04383de0c6e6a2b10af1d18b78 Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Wed, 17 Apr 2019 11:22:58 -0700 Subject: [PATCH 4/6] Revert python and ruby baselines --- .../gapic/testdata/py/python_multiple_services.baseline | 8 -------- .../gapic/testdata/py/python_no_path_templates.baseline | 4 ---- .../gapic/testdata/ruby/ruby_multiple_services.baseline | 8 -------- .../testdata/ruby_library_no_gapic_config.baseline | 6 +----- 4 files changed, 1 insertion(+), 25 deletions(-) diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline index c788e116f0..2a20ce1d9b 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline @@ -1073,10 +1073,6 @@ config = { "interfaces": { "google.cloud.example.v1.foo.DecrementerService": { "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], "non_idempotent": [] }, "retry_params": { @@ -1311,10 +1307,6 @@ config = { "interfaces": { "google.cloud.example.v1.foo.IncrementerService": { "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], "non_idempotent": [] }, "retry_params": { diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline index fffe8ee830..008fbb9424 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline @@ -1012,10 +1012,6 @@ config = { "interfaces": { "google.cloud.example.v1.NoTemplatesAPIService": { "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], "non_idempotent": [] }, "retry_params": { diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline index 69fceee489..08e1c7674c 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline @@ -1146,10 +1146,6 @@ end "interfaces": { "google.cloud.example.v1.foo.DecrementerService": { "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], "non_idempotent": [] }, "retry_params": { @@ -1429,10 +1425,6 @@ end "interfaces": { "google.cloud.example.v1.foo.IncrementerService": { "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], "non_idempotent": [] }, "retry_params": { diff --git a/src/test/java/com/google/api/codegen/protoannotations/testdata/ruby_library_no_gapic_config.baseline b/src/test/java/com/google/api/codegen/protoannotations/testdata/ruby_library_no_gapic_config.baseline index ad38de6206..e15646ddda 100644 --- a/src/test/java/com/google/api/codegen/protoannotations/testdata/ruby_library_no_gapic_config.baseline +++ b/src/test/java/com/google/api/codegen/protoannotations/testdata/ruby_library_no_gapic_config.baseline @@ -325,7 +325,7 @@ end This library is supported on Ruby 2.3+. Google provides official support for Ruby versions that are actively supported -by Ruby Core?that is, Ruby versions that are either in normal maintenance or +by Ruby Core—that is, Ruby versions that are either in normal maintenance or in security maintenance, and not end of life. Currently, this means Ruby 2.3 and later. Older versions of Ruby _may_ still work, but are unsupported and not recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details @@ -5143,10 +5143,6 @@ end "interfaces": { "google.example.library.v1.MyProto": { "retry_codes": { - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], "non_idempotent": [] }, "retry_params": { From 1760611d882e447f80f05c69d67ce265139e96df Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Wed, 17 Apr 2019 11:28:40 -0700 Subject: [PATCH 5/6] Manual update of py and ruby baselines --- .../gapic/testdata/py/python_multiple_services.baseline | 8 ++++++++ .../gapic/testdata/py/python_no_path_templates.baseline | 4 ++++ .../gapic/testdata/ruby/ruby_multiple_services.baseline | 8 ++++++++ .../testdata/ruby_library_no_gapic_config.baseline | 4 ++++ 4 files changed, 24 insertions(+) diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline index 2a20ce1d9b..c788e116f0 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_multiple_services.baseline @@ -1073,6 +1073,10 @@ config = { "interfaces": { "google.cloud.example.v1.foo.DecrementerService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { @@ -1307,6 +1311,10 @@ config = { "interfaces": { "google.cloud.example.v1.foo.IncrementerService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline index 008fbb9424..fffe8ee830 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/py/python_no_path_templates.baseline @@ -1012,6 +1012,10 @@ config = { "interfaces": { "google.cloud.example.v1.NoTemplatesAPIService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { diff --git a/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline b/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline index 08e1c7674c..69fceee489 100644 --- a/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline +++ b/src/test/java/com/google/api/codegen/gapic/testdata/ruby/ruby_multiple_services.baseline @@ -1146,6 +1146,10 @@ end "interfaces": { "google.cloud.example.v1.foo.DecrementerService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { @@ -1425,6 +1429,10 @@ end "interfaces": { "google.cloud.example.v1.foo.IncrementerService": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { diff --git a/src/test/java/com/google/api/codegen/protoannotations/testdata/ruby_library_no_gapic_config.baseline b/src/test/java/com/google/api/codegen/protoannotations/testdata/ruby_library_no_gapic_config.baseline index e15646ddda..ed1f5768e7 100644 --- a/src/test/java/com/google/api/codegen/protoannotations/testdata/ruby_library_no_gapic_config.baseline +++ b/src/test/java/com/google/api/codegen/protoannotations/testdata/ruby_library_no_gapic_config.baseline @@ -5143,6 +5143,10 @@ end "interfaces": { "google.example.library.v1.MyProto": { "retry_codes": { + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], "non_idempotent": [] }, "retry_params": { From d55996aebcff6b18a92a9eaf225429fcf9535974 Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Wed, 17 Apr 2019 13:57:43 -0700 Subject: [PATCH 6/6] Remove unneeded diag tracking --- .../config/DiscoGapicInterfaceConfig.java | 3 +- .../codegen/config/GapicInterfaceConfig.java | 1 - .../api/codegen/config/RetryCodesConfig.java | 57 ++++--------------- .../RetryDefinitionsTransformerTest.java | 8 +-- 4 files changed, 14 insertions(+), 55 deletions(-) diff --git a/src/main/java/com/google/api/codegen/config/DiscoGapicInterfaceConfig.java b/src/main/java/com/google/api/codegen/config/DiscoGapicInterfaceConfig.java index 16044f5167..3e4e5bb180 100644 --- a/src/main/java/com/google/api/codegen/config/DiscoGapicInterfaceConfig.java +++ b/src/main/java/com/google/api/codegen/config/DiscoGapicInterfaceConfig.java @@ -71,8 +71,7 @@ static DiscoGapicInterfaceConfig createInterfaceConfig( ResourceNameMessageConfigs messageConfigs, ImmutableMap resourceNameConfigs) { - RetryCodesConfig retryCodesConfig = - RetryCodesConfig.create(model.getDiagCollector(), interfaceConfigProto); + RetryCodesConfig retryCodesConfig = RetryCodesConfig.create(interfaceConfigProto); ImmutableMap retrySettingsDefinition = RetryDefinitionsTransformer.createRetrySettingsDefinition(interfaceConfigProto); diff --git a/src/main/java/com/google/api/codegen/config/GapicInterfaceConfig.java b/src/main/java/com/google/api/codegen/config/GapicInterfaceConfig.java index b418a00d3c..448fe1e4cd 100644 --- a/src/main/java/com/google/api/codegen/config/GapicInterfaceConfig.java +++ b/src/main/java/com/google/api/codegen/config/GapicInterfaceConfig.java @@ -119,7 +119,6 @@ static GapicInterfaceConfig createInterfaceConfig( RetryCodesConfig retryCodesConfig = RetryCodesConfig.create( - diagCollector, interfaceConfigProto, new ArrayList<>(interfaceInput.getMethodsToGenerate().keySet()), protoParser); diff --git a/src/main/java/com/google/api/codegen/config/RetryCodesConfig.java b/src/main/java/com/google/api/codegen/config/RetryCodesConfig.java index fbaf2b7ada..bb6620bbd2 100644 --- a/src/main/java/com/google/api/codegen/config/RetryCodesConfig.java +++ b/src/main/java/com/google/api/codegen/config/RetryCodesConfig.java @@ -23,10 +23,7 @@ import com.google.api.codegen.RetryCodesDefinitionProto; import com.google.api.codegen.util.ProtoParser; import com.google.api.codegen.util.SymbolTable; -import com.google.api.tools.framework.model.Diag; -import com.google.api.tools.framework.model.DiagCollector; import com.google.api.tools.framework.model.Method; -import com.google.api.tools.framework.model.SimpleLocation; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -53,7 +50,6 @@ public class RetryCodesConfig { private ImmutableSet retryCodeDefsFromGapicConfig; private ImmutableMap> finalRetryCodesDefinition; private ImmutableMap finalMethodRetryNames; - private boolean error = false; /** * A map of retry config names to the list of codes to retry on, e.g. { "idempotent" : @@ -77,29 +73,22 @@ public Set getRetryCodeDefsFromGapicConfig() { private RetryCodesConfig() {} - public static RetryCodesConfig create( - DiagCollector diagCollector, InterfaceConfigProto interfaceConfigProto) { + public static RetryCodesConfig create(InterfaceConfigProto interfaceConfigProto) { RetryCodesConfig retryCodesConfig = new RetryCodesConfig(); - retryCodesConfig.populateRetryCodesDefinitionFromConfigProto( - diagCollector, interfaceConfigProto); - if (!retryCodesConfig.setFinalRetryProperties()) { - return null; - } + retryCodesConfig.populateRetryCodesDefinitionFromConfigProto(interfaceConfigProto); + retryCodesConfig.setFinalRetryProperties(); return retryCodesConfig; } public static RetryCodesConfig create( - DiagCollector diagCollector, InterfaceConfigProto interfaceConfigProto, List methodsToGenerate, ProtoParser protoParser) { RetryCodesConfig retryCodesConfig = new RetryCodesConfig(); retryCodesConfig.populateRetryCodesDefinition( - diagCollector, interfaceConfigProto, methodsToGenerate, protoParser); - if (!retryCodesConfig.setFinalRetryProperties()) { - return null; - } + interfaceConfigProto, methodsToGenerate, protoParser); + retryCodesConfig.setFinalRetryProperties(); return retryCodesConfig; } @@ -118,39 +107,19 @@ private static ImmutableMap createMethodRetryNamesFromConfigProt @Nullable private static ImmutableMap> - createRetryCodesDefinitionFromConfigProto( - DiagCollector diagCollector, InterfaceConfigProto interfaceConfigProto) { + createRetryCodesDefinitionFromConfigProto(InterfaceConfigProto interfaceConfigProto) { ImmutableMap.Builder> builder = ImmutableMap.builder(); for (RetryCodesDefinitionProto retryDef : interfaceConfigProto.getRetryCodesDefList()) { // Enforce ordering on set for baseline test consistency. - Set codes = new TreeSet<>(); - for (String codeText : retryDef.getRetryCodesList()) { - try { - codes.add(String.valueOf(codeText)); - } catch (IllegalArgumentException e) { - diagCollector.addDiag( - Diag.error( - SimpleLocation.TOPLEVEL, - "status code not found: '%s' (in interface %s)", - codeText, - interfaceConfigProto.getName())); - } - } + Set codes = new TreeSet<>(retryDef.getRetryCodesList()); builder.put(retryDef.getName(), ImmutableList.copyOf(codes)); } - if (diagCollector.getErrorCount() > 0) { - return null; - } return builder.build(); } - private boolean setFinalRetryProperties() { - if (error) { - return false; - } + private void setFinalRetryProperties() { finalMethodRetryNames = ImmutableMap.copyOf(methodRetryNames); finalRetryCodesDefinition = ImmutableMap.copyOf(retryCodesDefinition); - return true; } /** @@ -159,15 +128,11 @@ private boolean setFinalRetryProperties() { * settings name. */ private void populateRetryCodesDefinition( - DiagCollector diagCollector, InterfaceConfigProto interfaceConfigProto, Collection methodsToGenerate, ProtoParser protoParser) { // First create the retry codes definitions from the GAPIC config. - populateRetryCodesDefinitionFromConfigProto(diagCollector, interfaceConfigProto); - if (error) { - return; - } + populateRetryCodesDefinitionFromConfigProto(interfaceConfigProto); // Then create the retry codes defs from the proto annotations, but don't overwrite // existing retry codes defs from the GAPIC config. @@ -180,10 +145,10 @@ private void populateRetryCodesDefinition( * settings name. */ private void populateRetryCodesDefinitionFromConfigProto( - DiagCollector diagCollector, InterfaceConfigProto interfaceConfigProto) { + InterfaceConfigProto interfaceConfigProto) { ImmutableMap> retryCodesDefFromConfigProto = - createRetryCodesDefinitionFromConfigProto(diagCollector, interfaceConfigProto); + createRetryCodesDefinitionFromConfigProto(interfaceConfigProto); if (retryCodesDefFromConfigProto == null) { return; } diff --git a/src/test/java/com/google/api/codegen/transformer/RetryDefinitionsTransformerTest.java b/src/test/java/com/google/api/codegen/transformer/RetryDefinitionsTransformerTest.java index 77b711f94d..162328b2d6 100644 --- a/src/test/java/com/google/api/codegen/transformer/RetryDefinitionsTransformerTest.java +++ b/src/test/java/com/google/api/codegen/transformer/RetryDefinitionsTransformerTest.java @@ -99,8 +99,7 @@ public void testWithConfigAndInterface() { DiagCollector diagCollector = new BoundedDiagCollector(); RetryCodesConfig retryCodesConfig = - RetryCodesConfig.create( - diagCollector, interfaceConfigProto, apiInterface.getMethods(), protoParser); + RetryCodesConfig.create(interfaceConfigProto, apiInterface.getMethods(), protoParser); Map> retryCodesDef = retryCodesConfig.getRetryCodesDefinition(); Map retryCodesMap = retryCodesConfig.getMethodRetryNames(); @@ -154,11 +153,8 @@ public void testWithInterfaceOnly() { .addMethods(MethodConfigProto.newBuilder().setName(PERMISSION_DENIED_METHOD_NAME)) .build(); - DiagCollector diagCollector = new BoundedDiagCollector(); - RetryCodesConfig retryCodesConfig = - RetryCodesConfig.create( - diagCollector, bareBonesConfigProto, apiInterface.getMethods(), protoParser); + RetryCodesConfig.create(bareBonesConfigProto, apiInterface.getMethods(), protoParser); Map> retryCodesDef = retryCodesConfig.getRetryCodesDefinition(); Map retryCodesMap = retryCodesConfig.getMethodRetryNames();