Skip to content

Commit

Permalink
chore: Enable requesting numeric enums in "transport=rest" responses …
Browse files Browse the repository at this point in the history
…for services supporting this (Java, Go, Python, PHP, TypeScript, C#, and Ruby), even if they do not yet turn on REST transport (#2140)

* chore: Set `rest_numeric_enums = False` for all gapic rules explicitly

PiperOrigin-RevId: 485623855

Source-Link: googleapis/googleapis@807125e

Source-Link: https://github.com/googleapis/googleapis-gen/commit/c4ddd6d651da69658a4762c5eafff5cd8f0e25c5
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzRkZGQ2ZDY1MWRhNjk2NThhNDc2MmM1ZWFmZmY1Y2Q4ZjBlMjVjNSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* chore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (Java, Go, Python, PHP, TypeScript, C#, and Ruby), even if they do not yet turn on REST transport

chore: disallow "transport=rest" for services where numeric enums are not confirmed to be supported (except in PHP and Java)
PiperOrigin-RevId: 493113566

Source-Link: googleapis/googleapis@758f0d1

Source-Link: https://github.com/googleapis/googleapis-gen/commit/78bd8f05e1276363eb14eae70e91fe4bc20703ab
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzhiZDhmMDVlMTI3NjM2M2ViMTRlYWU3MGU5MWZlNGJjMjA3MDNhYiJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Lawrence Qiu <[email protected]>
  • Loading branch information
3 people authored Dec 22, 2022
1 parent 15f7194 commit 02973d3
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* DatabaseAdminSettings databaseAdminSettings =
* DatabaseAdminSettings.newBuilder()
* .setTransportChannelProvider(
* DatabaseAdminSettings.defaultHttpJsonTransportProviderBuilder().build())
* .build();
* DatabaseAdminSettings.newHttpJsonBuilder().build();
* DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create(databaseAdminSettings);
* }</pre>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
serializer.putQueryParam(fields, "pageToken", request.getPageToken());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
Expand Down Expand Up @@ -160,12 +161,13 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<CreateDatabaseRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearParent().build(), false))
.toBody("*", request.toBuilder().clearParent().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Operation>newBuilder()
Expand Down Expand Up @@ -199,6 +201,7 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<GetDatabaseRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
Expand Down Expand Up @@ -232,12 +235,13 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<UpdateDatabaseDdlRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearDatabase().build(), false))
.toBody("*", request.toBuilder().clearDatabase().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Operation>newBuilder()
Expand Down Expand Up @@ -271,6 +275,7 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<DropDatabaseRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
Expand Down Expand Up @@ -304,6 +309,7 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<GetDatabaseDdlRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
Expand Down Expand Up @@ -339,12 +345,13 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<SetIamPolicyRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearResource().build(), false))
.toBody("*", request.toBuilder().clearResource().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Policy>newBuilder()
Expand Down Expand Up @@ -377,12 +384,13 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<GetIamPolicyRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearResource().build(), false))
.toBody("*", request.toBuilder().clearResource().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Policy>newBuilder()
Expand Down Expand Up @@ -417,12 +425,13 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<TestIamPermissionsRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearResource().build(), false))
.toBody("*", request.toBuilder().clearResource().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.<TestIamPermissionsResponse>newBuilder()
Expand Down Expand Up @@ -456,12 +465,13 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
serializer.putQueryParam(fields, "backupId", request.getBackupId());
serializer.putQueryParam(
fields, "encryptionConfig", request.getEncryptionConfig());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("backup", request.getBackup(), false))
.toBody("backup", request.getBackup(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Operation>newBuilder()
Expand Down Expand Up @@ -495,12 +505,13 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<CopyBackupRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearParent().build(), false))
.toBody("*", request.toBuilder().clearParent().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Operation>newBuilder()
Expand Down Expand Up @@ -533,6 +544,7 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<GetBackupRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
Expand Down Expand Up @@ -568,12 +580,13 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
ProtoRestSerializer<UpdateBackupRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "updateMask", request.getUpdateMask());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("backup", request.getBackup(), false))
.toBody("backup", request.getBackup(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Backup>newBuilder()
Expand Down Expand Up @@ -604,6 +617,7 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<DeleteBackupRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
Expand Down Expand Up @@ -640,6 +654,7 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
serializer.putQueryParam(fields, "filter", request.getFilter());
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
serializer.putQueryParam(fields, "pageToken", request.getPageToken());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
Expand Down Expand Up @@ -673,12 +688,13 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<RestoreDatabaseRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearParent().build(), false))
.toBody("*", request.toBuilder().clearParent().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Operation>newBuilder()
Expand Down Expand Up @@ -718,6 +734,7 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
serializer.putQueryParam(fields, "filter", request.getFilter());
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
serializer.putQueryParam(fields, "pageToken", request.getPageToken());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
Expand Down Expand Up @@ -757,6 +774,7 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
serializer.putQueryParam(fields, "filter", request.getFilter());
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
serializer.putQueryParam(fields, "pageToken", request.getPageToken());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
Expand Down Expand Up @@ -792,6 +810,7 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub {
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
serializer.putQueryParam(fields, "pageToken", request.getPageToken());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,7 @@
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* InstanceAdminSettings instanceAdminSettings =
* InstanceAdminSettings.newBuilder()
* .setTransportChannelProvider(
* InstanceAdminSettings.defaultHttpJsonTransportProviderBuilder().build())
* .build();
* InstanceAdminSettings.newHttpJsonBuilder().build();
* InstanceAdminClient instanceAdminClient = InstanceAdminClient.create(instanceAdminSettings);
* }</pre>
*
Expand Down
Loading

0 comments on commit 02973d3

Please sign in to comment.