From 8bc63f4e5645dc626e502c3a5d2546dfd0286d61 Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Wed, 2 Dec 2020 13:27:08 -0800 Subject: [PATCH 1/3] fix: fix dep ordering in Bazel dedupe rules --- rules_java_gapic/java_gapic.bzl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rules_java_gapic/java_gapic.bzl b/rules_java_gapic/java_gapic.bzl index 96e482907c..d265f8c676 100644 --- a/rules_java_gapic/java_gapic.bzl +++ b/rules_java_gapic/java_gapic.bzl @@ -189,7 +189,7 @@ def java_gapic_library( ) # General additional deps. - actual_deps = resource_name_deps + [ + actual_deps = deps + resource_name_deps + [ "@com_google_googleapis//google/rpc:rpc_java_proto", "@com_google_googleapis//google/longrunning:longrunning_java_proto", "@com_google_protobuf//:protobuf_java", @@ -207,7 +207,6 @@ def java_gapic_library( "@com_google_http_client_google_http_client//jar", "@javax_annotation_javax_annotation_api//jar", ] - _append_dep_without_duplicates(actual_deps, deps) native.java_library( name = name, From d4eb18af1b537293d4d197759ba4278535578c56 Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Mon, 7 Dec 2020 12:01:12 -0800 Subject: [PATCH 2/3] fix: use lowerCamelCase param names in ServiceClient JavaDocs --- .../ServiceClientCommentComposer.java | 3 +- .../gapic/composer/goldens/EchoClient.golden | 2 +- .../composer/goldens/IdentityClient.golden | 8 ++--- .../goldens/asset/AssetServiceClient.java | 2 +- .../goldens/library/LibraryServiceClient.java | 16 ++++----- .../goldens/logging/ConfigClient.java | 36 +++++++++---------- .../goldens/logging/LoggingClient.java | 22 ++++++------ .../goldens/logging/MetricsClient.java | 12 +++---- .../goldens/redis/CloudRedisClient.java | 22 ++++++------ 9 files changed, 62 insertions(+), 61 deletions(-) diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java index 09507cd30f..c7f63ee1d9 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientCommentComposer.java @@ -20,6 +20,7 @@ import com.google.api.generator.gapic.model.Method; import com.google.api.generator.gapic.model.MethodArgument; import com.google.api.generator.gapic.model.Service; +import com.google.api.generator.gapic.utils.JavaStyle; import com.google.common.base.Strings; import java.util.ArrayList; import java.util.Arrays; @@ -181,7 +182,7 @@ static List createRpcMethodHeaderComment( // TODO(miraleung): Remove the newline replacement when we support CommonMark. String description = argument.field().hasDescription() ? argument.field().description() : EMPTY_STRING; - methodJavadocBuilder.addParam(argument.name(), description); + methodJavadocBuilder.addParam(JavaStyle.toLowerCamelCase(argument.name()), description); } } diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden index 45cfef387a..f6495514d6 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden @@ -331,7 +331,7 @@ public class EchoClient implements BackgroundResource { // AUTO-GENERATED DOCUMENTATION AND METHOD. /** - * @param end_time + * @param endTime * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final OperationFuture waitAsync(Timestamp endTime) { diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden index db54847763..323a5cdbb3 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden @@ -125,7 +125,7 @@ public class IdentityClient implements BackgroundResource { // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * @param parent - * @param display_name + * @param displayName * @param email * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -142,12 +142,12 @@ public class IdentityClient implements BackgroundResource { // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * @param parent - * @param display_name + * @param displayName * @param email * @param age * @param nickname - * @param enable_notifications - * @param height_feet + * @param enableNotifications + * @param heightFeet * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final User createUser( diff --git a/test/integration/goldens/asset/AssetServiceClient.java b/test/integration/goldens/asset/AssetServiceClient.java index 2ade6c30d5..cfce3edd87 100644 --- a/test/integration/goldens/asset/AssetServiceClient.java +++ b/test/integration/goldens/asset/AssetServiceClient.java @@ -497,7 +497,7 @@ public final UnaryCallable deleteFeedCallable() { * "us-west1" region or the "global" location. * * - * @param asset_types Optional. A list of asset types that this request searches for. If empty, it + * @param assetTypes Optional. A list of asset types that this request searches for. If empty, it * will search all the [searchable asset * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types#searchable_asset_types). * @throws com.google.api.gax.rpc.ApiException if the remote call fails diff --git a/test/integration/goldens/library/LibraryServiceClient.java b/test/integration/goldens/library/LibraryServiceClient.java index 033e0b3b3d..a8303d5fe3 100644 --- a/test/integration/goldens/library/LibraryServiceClient.java +++ b/test/integration/goldens/library/LibraryServiceClient.java @@ -336,7 +336,7 @@ public final UnaryCallable deleteShelfCallable() { * shelves are the same. * * @param name The name of the shelf we're adding books to. - * @param other_shelf_name The name of the shelf we're removing books from and deleting. + * @param otherShelfName The name of the shelf we're removing books from and deleting. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Shelf mergeShelves(ShelfName name, ShelfName otherShelfName) { @@ -358,7 +358,7 @@ public final Shelf mergeShelves(ShelfName name, ShelfName otherShelfName) { * shelves are the same. * * @param name The name of the shelf we're adding books to. - * @param other_shelf_name The name of the shelf we're removing books from and deleting. + * @param otherShelfName The name of the shelf we're removing books from and deleting. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Shelf mergeShelves(ShelfName name, String otherShelfName) { @@ -380,7 +380,7 @@ public final Shelf mergeShelves(ShelfName name, String otherShelfName) { * shelves are the same. * * @param name The name of the shelf we're adding books to. - * @param other_shelf_name The name of the shelf we're removing books from and deleting. + * @param otherShelfName The name of the shelf we're removing books from and deleting. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Shelf mergeShelves(String name, ShelfName otherShelfName) { @@ -402,7 +402,7 @@ public final Shelf mergeShelves(String name, ShelfName otherShelfName) { * shelves are the same. * * @param name The name of the shelf we're adding books to. - * @param other_shelf_name The name of the shelf we're removing books from and deleting. + * @param otherShelfName The name of the shelf we're removing books from and deleting. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Shelf mergeShelves(String name, String otherShelfName) { @@ -668,7 +668,7 @@ public final UnaryCallable updateBookCallable() { * the same as the original book. * * @param name The name of the book to move. - * @param other_shelf_name The name of the destination shelf. + * @param otherShelfName The name of the destination shelf. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Book moveBook(BookName name, ShelfName otherShelfName) { @@ -686,7 +686,7 @@ public final Book moveBook(BookName name, ShelfName otherShelfName) { * the same as the original book. * * @param name The name of the book to move. - * @param other_shelf_name The name of the destination shelf. + * @param otherShelfName The name of the destination shelf. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Book moveBook(BookName name, String otherShelfName) { @@ -704,7 +704,7 @@ public final Book moveBook(BookName name, String otherShelfName) { * the same as the original book. * * @param name The name of the book to move. - * @param other_shelf_name The name of the destination shelf. + * @param otherShelfName The name of the destination shelf. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Book moveBook(String name, ShelfName otherShelfName) { @@ -722,7 +722,7 @@ public final Book moveBook(String name, ShelfName otherShelfName) { * the same as the original book. * * @param name The name of the book to move. - * @param other_shelf_name The name of the destination shelf. + * @param otherShelfName The name of the destination shelf. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Book moveBook(String name, String otherShelfName) { diff --git a/test/integration/goldens/logging/ConfigClient.java b/test/integration/goldens/logging/ConfigClient.java index 507ea5ed4a..c328da1caf 100644 --- a/test/integration/goldens/logging/ConfigClient.java +++ b/test/integration/goldens/logging/ConfigClient.java @@ -475,7 +475,7 @@ public final UnaryCallable listSinksCallabl /** * Gets a sink. * - * @param sink_name Required. The resource name of the sink: + * @param sinkName Required. The resource name of the sink: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" @@ -495,7 +495,7 @@ public final LogSink getSink(LogSinkName sinkName) { /** * Gets a sink. * - * @param sink_name Required. The resource name of the sink: + * @param sinkName Required. The resource name of the sink: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" @@ -681,7 +681,7 @@ public final UnaryCallable createSinkCallable() { *

The updated sink might also have a new `writer_identity`; see the `unique_writer_identity` * field. * - * @param sink_name Required. The full resource name of the sink to update, including the parent + * @param sinkName Required. The full resource name of the sink to update, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" @@ -709,7 +709,7 @@ public final LogSink updateSink(LogSinkName sinkName, LogSink sink) { *

The updated sink might also have a new `writer_identity`; see the `unique_writer_identity` * field. * - * @param sink_name Required. The full resource name of the sink to update, including the parent + * @param sinkName Required. The full resource name of the sink to update, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" @@ -734,7 +734,7 @@ public final LogSink updateSink(String sinkName, LogSink sink) { *

The updated sink might also have a new `writer_identity`; see the `unique_writer_identity` * field. * - * @param sink_name Required. The full resource name of the sink to update, including the parent + * @param sinkName Required. The full resource name of the sink to update, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" @@ -743,9 +743,9 @@ public final LogSink updateSink(String sinkName, LogSink sink) { *

Example: `"projects/my-project-id/sinks/my-sink-id"`. * @param sink Required. The updated sink, whose name is the same identifier that appears as part * of `sink_name`. - * @param update_mask Optional. Field mask that specifies the fields in `sink` that need an - * update. A sink field will be overwritten if, and only if, it is in the update mask. `name` - * and output only fields cannot be updated. + * @param updateMask Optional. Field mask that specifies the fields in `sink` that need an update. + * A sink field will be overwritten if, and only if, it is in the update mask. `name` and + * output only fields cannot be updated. *

An empty updateMask is temporarily treated as using the following mask for backwards * compatibility purposes: destination,filter,includeChildren At some point in the future, * behavior will be removed and specifying an empty updateMask will be an error. @@ -772,7 +772,7 @@ public final LogSink updateSink(LogSinkName sinkName, LogSink sink, FieldMask up *

The updated sink might also have a new `writer_identity`; see the `unique_writer_identity` * field. * - * @param sink_name Required. The full resource name of the sink to update, including the parent + * @param sinkName Required. The full resource name of the sink to update, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" @@ -781,9 +781,9 @@ public final LogSink updateSink(LogSinkName sinkName, LogSink sink, FieldMask up *

Example: `"projects/my-project-id/sinks/my-sink-id"`. * @param sink Required. The updated sink, whose name is the same identifier that appears as part * of `sink_name`. - * @param update_mask Optional. Field mask that specifies the fields in `sink` that need an - * update. A sink field will be overwritten if, and only if, it is in the update mask. `name` - * and output only fields cannot be updated. + * @param updateMask Optional. Field mask that specifies the fields in `sink` that need an update. + * A sink field will be overwritten if, and only if, it is in the update mask. `name` and + * output only fields cannot be updated. *

An empty updateMask is temporarily treated as using the following mask for backwards * compatibility purposes: destination,filter,includeChildren At some point in the future, * behavior will be removed and specifying an empty updateMask will be an error. @@ -836,7 +836,7 @@ public final UnaryCallable updateSinkCallable() { * Deletes a sink. If the sink has a unique `writer_identity`, then that service account is also * deleted. * - * @param sink_name Required. The full resource name of the sink to delete, including the parent + * @param sinkName Required. The full resource name of the sink to delete, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" @@ -858,7 +858,7 @@ public final void deleteSink(LogSinkName sinkName) { * Deletes a sink. If the sink has a unique `writer_identity`, then that service account is also * deleted. * - * @param sink_name Required. The full resource name of the sink to delete, including the parent + * @param sinkName Required. The full resource name of the sink to delete, including the parent * resource and the sink identifier: *

"projects/[PROJECT_ID]/sinks/[SINK_ID]" * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" @@ -1208,8 +1208,8 @@ public final UnaryCallable createExclusion *

Example: `"projects/my-project-id/exclusions/my-exclusion-id"`. * @param exclusion Required. New values for the existing exclusion. Only the fields specified in * `update_mask` are relevant. - * @param update_mask Required. A non-empty list of fields to change in the existing exclusion. - * New values for the fields are taken from the corresponding fields in the + * @param updateMask Required. A non-empty list of fields to change in the existing exclusion. New + * values for the fields are taken from the corresponding fields in the * [LogExclusion][google.logging.v2.LogExclusion] included in this request. Fields not * mentioned in `update_mask` are not changed and are ignored in the request. *

For example, to change the filter and description of an exclusion, specify an @@ -1239,8 +1239,8 @@ public final LogExclusion updateExclusion( *

Example: `"projects/my-project-id/exclusions/my-exclusion-id"`. * @param exclusion Required. New values for the existing exclusion. Only the fields specified in * `update_mask` are relevant. - * @param update_mask Required. A non-empty list of fields to change in the existing exclusion. - * New values for the fields are taken from the corresponding fields in the + * @param updateMask Required. A non-empty list of fields to change in the existing exclusion. New + * values for the fields are taken from the corresponding fields in the * [LogExclusion][google.logging.v2.LogExclusion] included in this request. Fields not * mentioned in `update_mask` are not changed and are ignored in the request. *

For example, to change the filter and description of an exclusion, specify an diff --git a/test/integration/goldens/logging/LoggingClient.java b/test/integration/goldens/logging/LoggingClient.java index 2b7cef1ad5..8b7fcd0f2b 100644 --- a/test/integration/goldens/logging/LoggingClient.java +++ b/test/integration/goldens/logging/LoggingClient.java @@ -163,7 +163,7 @@ public LoggingServiceV2Stub getStub() { * written shortly before the delete operation might not be deleted. Entries received after the * delete operation with a timestamp before the operation will be deleted. * - * @param log_name Required. The resource name of the log to delete: + * @param logName Required. The resource name of the log to delete: *

"projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" *

`[LOG_ID]` must be URL-encoded. For example, `"projects/my-project-id/logs/syslog"`, @@ -185,7 +185,7 @@ public final void deleteLog(LogName logName) { * written shortly before the delete operation might not be deleted. Entries received after the * delete operation with a timestamp before the operation will be deleted. * - * @param log_name Required. The resource name of the log to delete: + * @param logName Required. The resource name of the log to delete: *

"projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" *

`[LOG_ID]` must be URL-encoded. For example, `"projects/my-project-id/logs/syslog"`, @@ -230,7 +230,7 @@ public final UnaryCallable deleteLogCallable() { * libraries configured to use Logging. A single request may contain log entries for a maximum of * 1000 different resources (projects, organizations, billing accounts or folders) * - * @param log_name Optional. A default log resource name that is assigned to all log entries in + * @param logName Optional. A default log resource name that is assigned to all log entries in * `entries` that do not specify a value for `log_name`: *

"projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" @@ -292,7 +292,7 @@ public final WriteLogEntriesResponse writeLogEntries( * libraries configured to use Logging. A single request may contain log entries for a maximum of * 1000 different resources (projects, organizations, billing accounts or folders) * - * @param log_name Optional. A default log resource name that is assigned to all log entries in + * @param logName Optional. A default log resource name that is assigned to all log entries in * `entries` that do not specify a value for `log_name`: *

"projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" @@ -381,8 +381,8 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * project/folder/organization/billing account. For ways to export log entries, see [Exporting * Logs](https://cloud.google.com/logging/docs/export). * - * @param resource_names Required. Names of one or more parent resources from which to retrieve - * log entries: + * @param resourceNames Required. Names of one or more parent resources from which to retrieve log + * entries: *

"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" * "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" *

Projects listed in the `project_ids` field are added to this list. @@ -392,11 +392,11 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * resources listed in `resource_names`. Referencing a parent resource that is not listed in * `resource_names` will cause the filter to return no results. The maximum length of the * filter is 20000 characters. - * @param order_by Optional. How the results should be sorted. Presently, the only permitted - * values are `"timestamp asc"` (default) and `"timestamp desc"`. The first option returns - * entries in order of increasing values of `LogEntry.timestamp` (oldest first), and the - * second option returns entries in order of decreasing timestamps (newest first). Entries - * with equal timestamps are returned in order of their `insert_id` values. + * @param orderBy Optional. How the results should be sorted. Presently, the only permitted values + * are `"timestamp asc"` (default) and `"timestamp desc"`. The first option returns entries in + * order of increasing values of `LogEntry.timestamp` (oldest first), and the second option + * returns entries in order of decreasing timestamps (newest first). Entries with equal + * timestamps are returned in order of their `insert_id` values. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final ListLogEntriesPagedResponse listLogEntries( diff --git a/test/integration/goldens/logging/MetricsClient.java b/test/integration/goldens/logging/MetricsClient.java index a7a58f48b8..3d105de40d 100644 --- a/test/integration/goldens/logging/MetricsClient.java +++ b/test/integration/goldens/logging/MetricsClient.java @@ -214,7 +214,7 @@ public final ListLogMetricsPagedResponse listLogMetrics(ListLogMetricsRequest re /** * Gets a logs-based metric. * - * @param metric_name Required. The resource name of the desired metric: + * @param metricName Required. The resource name of the desired metric: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -230,7 +230,7 @@ public final LogMetric getLogMetric(LogMetricName metricName) { /** * Gets a logs-based metric. * - * @param metric_name Required. The resource name of the desired metric: + * @param metricName Required. The resource name of the desired metric: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -323,7 +323,7 @@ public final UnaryCallable createLogMetricCal /** * Creates or updates a logs-based metric. * - * @param metric_name Required. The resource name of the metric to update: + * @param metricName Required. The resource name of the metric to update: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" *

The updated metric must be provided in the request and it's `name` field must be the * same as `[METRIC_ID]` If the metric does not exist in `[PROJECT_ID]`, then a new metric is @@ -344,7 +344,7 @@ public final LogMetric updateLogMetric(LogMetricName metricName, LogMetric metri /** * Creates or updates a logs-based metric. * - * @param metric_name Required. The resource name of the metric to update: + * @param metricName Required. The resource name of the metric to update: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" *

The updated metric must be provided in the request and it's `name` field must be the * same as `[METRIC_ID]` If the metric does not exist in `[PROJECT_ID]`, then a new metric is @@ -383,7 +383,7 @@ public final UnaryCallable updateLogMetricCal /** * Deletes a logs-based metric. * - * @param metric_name Required. The resource name of the metric to delete: + * @param metricName Required. The resource name of the metric to delete: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -399,7 +399,7 @@ public final void deleteLogMetric(LogMetricName metricName) { /** * Deletes a logs-based metric. * - * @param metric_name Required. The resource name of the metric to delete: + * @param metricName Required. The resource name of the metric to delete: *

"projects/[PROJECT_ID]/metrics/[METRIC_ID]" * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ diff --git a/test/integration/goldens/redis/CloudRedisClient.java b/test/integration/goldens/redis/CloudRedisClient.java index d58b981828..ae14c03a63 100644 --- a/test/integration/goldens/redis/CloudRedisClient.java +++ b/test/integration/goldens/redis/CloudRedisClient.java @@ -353,8 +353,8 @@ public final UnaryCallable getInstanceCallable() { * * @param parent Required. The resource name of the instance location using the form: * `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region. - * @param instance_id Required. The logical name of the Redis instance in the customer project - * with the following restrictions: + * @param instanceId Required. The logical name of the Redis instance in the customer project with + * the following restrictions: *

    *
  • Must contain only lowercase letters, numbers, and hyphens. *
  • Must start with a letter. @@ -394,8 +394,8 @@ public final OperationFuture createInstanceAsync( * * @param parent Required. The resource name of the instance location using the form: * `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region. - * @param instance_id Required. The logical name of the Redis instance in the customer project - * with the following restrictions: + * @param instanceId Required. The logical name of the Redis instance in the customer project with + * the following restrictions: *
      *
    • Must contain only lowercase letters, numbers, and hyphens. *
    • Must start with a letter. @@ -492,7 +492,7 @@ public final UnaryCallable createInstanceCalla * The returned operation is automatically deleted after a few hours, so there is no need to call * DeleteOperation. * - * @param update_mask Required. Mask of fields to update. At least one path must be supplied in + * @param updateMask Required. Mask of fields to update. At least one path must be supplied in * this field. The elements of the repeated paths field may only include these fields from * [Instance][google.cloud.redis.v1.Instance]: *

      * `displayName` * `labels` * `memorySizeGb` * `redisConfig` @@ -558,7 +558,7 @@ public final UnaryCallable updateInstanceCalla * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. - * @param redis_version Required. Specifies the target version of Redis software to upgrade to. + * @param redisVersion Required. Specifies the target version of Redis software to upgrade to. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final OperationFuture upgradeInstanceAsync( @@ -578,7 +578,7 @@ public final OperationFuture upgradeInstanceAsync( * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. - * @param redis_version Required. Specifies the target version of Redis software to upgrade to. + * @param redisVersion Required. Specifies the target version of Redis software to upgrade to. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final OperationFuture upgradeInstanceAsync( @@ -634,7 +634,7 @@ public final UnaryCallable upgradeInstanceCal * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. - * @param input_config Required. Specify data to be imported. + * @param inputConfig Required. Specify data to be imported. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final OperationFuture importInstanceAsync( @@ -707,7 +707,7 @@ public final UnaryCallable importInstanceCalla * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. - * @param output_config Required. Specify data to be exported. + * @param outputConfig Required. Specify data to be exported. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final OperationFuture exportInstanceAsync( @@ -773,7 +773,7 @@ public final UnaryCallable exportInstanceCalla * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. - * @param data_protection_mode Optional. Available data protection modes that the user can choose. + * @param dataProtectionMode Optional. Available data protection modes that the user can choose. * If it's unspecified, data protection mode will be LIMITED_DATA_LOSS by default. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -795,7 +795,7 @@ public final OperationFuture failoverInstanceAsync( * @param name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id` * refers to a GCP region. - * @param data_protection_mode Optional. Available data protection modes that the user can choose. + * @param dataProtectionMode Optional. Available data protection modes that the user can choose. * If it's unspecified, data protection mode will be LIMITED_DATA_LOSS by default. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ From 775999ed354f4fe7bc5f7816530afd526ce04fad Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Mon, 7 Dec 2020 13:05:07 -0800 Subject: [PATCH 3/3] fix: add HTTP's additional_bindings to GrpcServiceStub call settings --- .../gapic/protoparser/HttpRuleParser.java | 22 +++++++++++----- .../composer/goldens/GrpcTestingStub.golden | 4 +++ .../composer/goldens/TestingClientTest.golden | 6 +++++ .../gapic/protoparser/HttpRuleParserTest.java | 25 ++++++++++++++++--- .../generator/gapic/testdata/testing.proto | 18 +++++++++++++ 5 files changed, 66 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/google/api/generator/gapic/protoparser/HttpRuleParser.java b/src/main/java/com/google/api/generator/gapic/protoparser/HttpRuleParser.java index 086eea4a2e..6998f3c26b 100644 --- a/src/main/java/com/google/api/generator/gapic/protoparser/HttpRuleParser.java +++ b/src/main/java/com/google/api/generator/gapic/protoparser/HttpRuleParser.java @@ -26,9 +26,11 @@ import com.google.protobuf.Descriptors.MethodDescriptor; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; public class HttpRuleParser { private static final String ASTERISK = "*"; @@ -48,11 +50,20 @@ public static Optional> parseHttpBindings( } // Get pattern. - List bindings = getPatternBindings(httpRule); - if (bindings.isEmpty()) { + Set uniqueBindings = getPatternBindings(httpRule); + if (uniqueBindings.isEmpty()) { return Optional.empty(); } + if (httpRule.getAdditionalBindingsCount() > 0) { + for (HttpRule additionalRule : httpRule.getAdditionalBindingsList()) { + uniqueBindings.addAll(getPatternBindings(additionalRule)); + } + } + + List bindings = new ArrayList<>(uniqueBindings); + Collections.sort(bindings); + // Binding validation. for (String binding : bindings) { // Handle foo.bar cases by descending into the subfields. @@ -77,7 +88,7 @@ public static Optional> parseHttpBindings( return Optional.of(bindings); } - private static List getPatternBindings(HttpRule httpRule) { + private static Set getPatternBindings(HttpRule httpRule) { String pattern = null; // Assign a temp variable to prevent the formatter from removing the import. PatternCase patternCase = httpRule.getPatternCase(); @@ -100,12 +111,11 @@ private static List getPatternBindings(HttpRule httpRule) { case CUSTOM: // Invalid pattern. // Fall through. default: - return Collections.emptyList(); + return Collections.emptySet(); } PathTemplate template = PathTemplate.create(pattern); - List bindings = new ArrayList(template.vars()); - Collections.sort(bindings); + Set bindings = new HashSet(template.vars()); return bindings; } diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcTestingStub.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcTestingStub.golden index 61ea7d1fa9..a178c51a33 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcTestingStub.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcTestingStub.golden @@ -262,7 +262,11 @@ public class GrpcTestingStub extends TestingStub { @Override public Map extract(VerifyTestRequest request) { ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("answer", String.valueOf(request.getAnswer())); + params.put("foo", String.valueOf(request.getFoo())); params.put("name", String.valueOf(request.getName())); + params.put( + "test_to_verify.name", String.valueOf(request.getTestToVerify().getName())); return params.build(); } }) diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/TestingClientTest.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/TestingClientTest.golden index bf955ecc31..f0dc05e18a 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/TestingClientTest.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/TestingClientTest.golden @@ -465,6 +465,8 @@ public class TestingClientTest { .setName(TestName.of("[SESSION]", "[SHARD_ID]", "[TEST_ID]").toString()) .setAnswer(ByteString.EMPTY) .addAllAnswers(new ArrayList()) + .setFoo("foo101574") + .setTestToVerify(com.google.showcase.v1beta1.Test.newBuilder().build()) .build(); VerifyTestResponse actualResponse = client.verifyTest(request); @@ -477,6 +479,8 @@ public class TestingClientTest { Assert.assertEquals(request.getName(), actualRequest.getName()); Assert.assertEquals(request.getAnswer(), actualRequest.getAnswer()); Assert.assertEquals(request.getAnswersList(), actualRequest.getAnswersList()); + Assert.assertEquals(request.getFoo(), actualRequest.getFoo()); + Assert.assertEquals(request.getTestToVerify(), actualRequest.getTestToVerify()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -494,6 +498,8 @@ public class TestingClientTest { .setName(TestName.of("[SESSION]", "[SHARD_ID]", "[TEST_ID]").toString()) .setAnswer(ByteString.EMPTY) .addAllAnswers(new ArrayList()) + .setFoo("foo101574") + .setTestToVerify(com.google.showcase.v1beta1.Test.newBuilder().build()) .build(); client.verifyTest(request); Assert.fail("No exception raised"); diff --git a/src/test/java/com/google/api/generator/gapic/protoparser/HttpRuleParserTest.java b/src/test/java/com/google/api/generator/gapic/protoparser/HttpRuleParserTest.java index 69a482d610..1aed7b9f92 100644 --- a/src/test/java/com/google/api/generator/gapic/protoparser/HttpRuleParserTest.java +++ b/src/test/java/com/google/api/generator/gapic/protoparser/HttpRuleParserTest.java @@ -46,14 +46,33 @@ public void parseHttpAnnotation_basic() { HttpRuleParser.parseHttpBindings(rpcMethod, inputMessage, messages); assertFalse(httpBindingsOpt.isPresent()); - // VerityTest method. - rpcMethod = testingService.getMethods().get(testingService.getMethods().size() - 1); - inputMessage = messages.get("VerifyTestRequest"); + // GetSession method. + rpcMethod = testingService.getMethods().get(1); + inputMessage = messages.get("GetSessionRequest"); httpBindingsOpt = HttpRuleParser.parseHttpBindings(rpcMethod, inputMessage, messages); assertTrue(httpBindingsOpt.isPresent()); assertThat(httpBindingsOpt.get()).containsExactly("name"); } + @Test + public void parseHttpAnnotation_multipleBindings() { + FileDescriptor testingFileDescriptor = TestingOuterClass.getDescriptor(); + ServiceDescriptor testingService = testingFileDescriptor.getServices().get(0); + assertEquals("Testing", testingService.getName()); + + Map messages = Parser.parseMessages(testingFileDescriptor); + + // VerityTest method. + MethodDescriptor rpcMethod = + testingService.getMethods().get(testingService.getMethods().size() - 1); + Message inputMessage = messages.get("VerifyTestRequest"); + Optional> httpBindingsOpt = + HttpRuleParser.parseHttpBindings(rpcMethod, inputMessage, messages); + assertTrue(httpBindingsOpt.isPresent()); + assertThat(httpBindingsOpt.get()) + .containsExactly("answer", "foo", "name", "test_to_verify.name"); + } + @Test public void parseHttpAnnotation_missingFieldFromMessage() { FileDescriptor testingFileDescriptor = TestingOuterClass.getDescriptor(); diff --git a/src/test/java/com/google/api/generator/gapic/testdata/testing.proto b/src/test/java/com/google/api/generator/gapic/testdata/testing.proto index 2fe4ad9f66..28432bffaa 100644 --- a/src/test/java/com/google/api/generator/gapic/testdata/testing.proto +++ b/src/test/java/com/google/api/generator/gapic/testdata/testing.proto @@ -107,6 +107,19 @@ service Testing { rpc VerifyTest(VerifyTestRequest) returns (VerifyTestResponse) { option (google.api.http) = { post: "/v1beta1/{name=sessions/*/tests/*}:check" + body: "*" + additional_bindings { + post: "/v1beta1/{foo=sessions/*/tests/*}:check" + body: "*" + } + additional_bindings { + post: "/v1beta1/{answer=sessions/*/tests/*}:check" + body: "*" + } + additional_bindings { + post: "/v1beta1/{test_to_verify.name=sessions/*/tests/*}:check" + body: "*" + } }; } } @@ -392,6 +405,11 @@ message VerifyTestRequest { // The answers from the test if multiple are to be checked repeated bytes answers = 3; + + // Test fields for HTTP annotations. + string foo = 4; + + Test test_to_verify = 5; } message VerifyTestResponse {