From 1810451e1ed01329c4af9ea0247672818ba7ac0f Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Thu, 2 May 2024 15:25:50 +0000 Subject: [PATCH 1/6] chore: skip library generation tests after merging a pull request (#2712) In this PR: - Skip running library generation test after merging a pull request. Related error: ``` Run set -ex set -ex git checkout "${base_ref}" git checkout "${head_ref}" changed_directories="$(git diff --name-only ${base_ref} ${head_ref})" if [[ ${changed_directories} =~ "library_generation/" ]]; then echo "should_run=true" >> $GITHUB_OUTPUT else echo "should_run=false" >> $GITHUB_OUTPUT fi shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0} env: base_ref: head_ref: + git checkout '' fatal: empty string is not a valid pathspec. please use . instead if you meant to match all paths ``` Full log: https://github.com/googleapis/sdk-platform-java/actions/runs/8913958564/job/24480528068 --- .github/workflows/verify_library_generation.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/verify_library_generation.yaml b/.github/workflows/verify_library_generation.yaml index 8feec8a9d66..8f2520c858d 100644 --- a/.github/workflows/verify_library_generation.yaml +++ b/.github/workflows/verify_library_generation.yaml @@ -3,7 +3,8 @@ on: branches: - main pull_request: - + # do not run this workflow when merging the pull request. + types: [opened, reopened, edited, synchronize] workflow_dispatch: name: verify_library_generation jobs: From 3ab0aa3313ae223d0dd16d1bdfffe51e137f5ac6 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Thu, 2 May 2024 16:16:08 +0000 Subject: [PATCH 2/6] chore: remove test output (#2713) In this PR: - Remove test output directory. --- library_generation/test/integration_tests.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library_generation/test/integration_tests.py b/library_generation/test/integration_tests.py index e3f950300ed..47ad22b6dc4 100644 --- a/library_generation/test/integration_tests.py +++ b/library_generation/test/integration_tests.py @@ -190,8 +190,7 @@ def __build_image(cls, docker_file: str, cwd: str): @classmethod def __remove_generated_files(cls): - # uncomment this line when the generated files don't owned by root. - # shutil.rmtree(f"{output_dir}", ignore_errors=True) + shutil.rmtree(f"{output_dir}", ignore_errors=True) if os.path.isdir(f"{golden_dir}"): shutil.rmtree(f"{golden_dir}") From 5d4567f883b1e29cd5f299d392c5a809b451aa18 Mon Sep 17 00:00:00 2001 From: Alice <65933803+alicejli@users.noreply.github.com> Date: Thu, 2 May 2024 13:14:28 -0400 Subject: [PATCH 3/6] chore: fix verify_library_generation.yaml for forks (#2716) PRs opened by renovate-bot are failing `verify_library_generation` because renovate-bot opens PRs from a fork rather than main. For instance https://github.com/googleapis/sdk-platform-java/pull/2657 is failing: ``` env: base_ref: main head_ref: renovate/markupsafe-2.x + git checkout main Previous HEAD position was d84e6072d Merge 645951c0497bf9cdb42e6323cd90a08d77a1926a into 766646a9e0bed6c8e804eb1e6ab4d[13](https://github.com/googleapis/sdk-platform-java/actions/runs/8914757209/job/24482995077?pr=2657#step:3:13)3d1465dca Switched to a new branch 'main' branch 'main' set up to track 'origin/main'. + git checkout renovate/markupsafe-2.x error: pathspec 'renovate/markupsafe-2.x' did not match any file(s) known to git ``` This updates the yaml file to explicitly fetch specific branches which should fix the issue. --------- Co-authored-by: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> --- .github/workflows/verify_library_generation.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verify_library_generation.yaml b/.github/workflows/verify_library_generation.yaml index 8f2520c858d..51c276504dc 100644 --- a/.github/workflows/verify_library_generation.yaml +++ b/.github/workflows/verify_library_generation.yaml @@ -21,8 +21,10 @@ jobs: shell: bash run: | set -ex - git checkout "${base_ref}" - git checkout "${head_ref}" + git checkout "${base_ref}" # Checkout a detached head, and then fetch the base ref to populate the detached head. + git fetch --no-tags --prune origin +${base_ref}:refs/remotes/origin/${base_ref} + git checkout "${head_ref}" # Checkout a detached head, and then fetch the head ref to populate the detached head. + git fetch --no-tags --prune origin +${head_ref}:refs/remotes/origin/${head_ref} changed_directories="$(git diff --name-only ${base_ref} ${head_ref})" if [[ ${changed_directories} =~ "library_generation/" ]]; then echo "should_run=true" >> $GITHUB_OUTPUT From 8f21be6c8e2eee11b4cea857c8ede4f44178c546 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Thu, 2 May 2024 18:05:00 +0000 Subject: [PATCH 4/6] chore: do not run workflow on push (#2718) In this PR: - Remove `on.push` trigger so that the workflow doesn't run against a specific branch. Official doc: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore --- .github/workflows/verify_library_generation.yaml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/verify_library_generation.yaml b/.github/workflows/verify_library_generation.yaml index 51c276504dc..768325f9f50 100644 --- a/.github/workflows/verify_library_generation.yaml +++ b/.github/workflows/verify_library_generation.yaml @@ -1,11 +1,6 @@ on: - push: - branches: - - main pull_request: - # do not run this workflow when merging the pull request. - types: [opened, reopened, edited, synchronize] - workflow_dispatch: + name: verify_library_generation jobs: should-run-library-generation-tests: @@ -21,9 +16,11 @@ jobs: shell: bash run: | set -ex - git checkout "${base_ref}" # Checkout a detached head, and then fetch the base ref to populate the detached head. + # Checkout a detached head, and then fetch the base ref to populate the detached head. + git checkout "${base_ref}" git fetch --no-tags --prune origin +${base_ref}:refs/remotes/origin/${base_ref} - git checkout "${head_ref}" # Checkout a detached head, and then fetch the head ref to populate the detached head. + # Checkout a detached head, and then fetch the head ref to populate the detached head. + git checkout "${head_ref}" git fetch --no-tags --prune origin +${head_ref}:refs/remotes/origin/${head_ref} changed_directories="$(git diff --name-only ${base_ref} ${head_ref})" if [[ ${changed_directories} =~ "library_generation/" ]]; then From 32c99953496fe3e0ab47c67aad4117c242d1c798 Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Thu, 2 May 2024 20:25:24 +0000 Subject: [PATCH 5/6] fix: Return resolved endpoint from StubSettings' Builder (#2715) --- .../google/api/gax/grpc/GrpcCallContext.java | 8 ++--- .../api/gax/httpjson/HttpJsonCallContext.java | 8 ++--- .../com/google/api/gax/rpc/ClientContext.java | 32 ++++++++----------- .../google/api/gax/rpc/EndpointContext.java | 16 ++++++++++ .../com/google/api/gax/rpc/StubSettings.java | 32 ++++++++++++++++--- .../api/gax/rpc/testing/FakeCallContext.java | 9 ++---- .../v1beta1/it/ITEndpointContext.java | 26 ++++++++++++--- 7 files changed, 85 insertions(+), 46 deletions(-) diff --git a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java index 3de00ec6719..94099dd96b7 100644 --- a/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java +++ b/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/GrpcCallContext.java @@ -154,12 +154,8 @@ private GrpcCallContext( this.retryableCodes = retryableCodes == null ? null : ImmutableSet.copyOf(retryableCodes); // Attempt to create an empty, non-functioning EndpointContext by default. The client will have // a valid EndpointContext with user configurations after the client has been initialized. - try { - this.endpointContext = - endpointContext == null ? EndpointContext.newBuilder().build() : endpointContext; - } catch (IOException ex) { - throw new RuntimeException(ex); - } + this.endpointContext = + endpointContext == null ? EndpointContext.getDefaultInstance() : endpointContext; } /** diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java index bb208110580..bde0c432a83 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java @@ -135,12 +135,8 @@ private HttpJsonCallContext( defaultRetryableCodes == null ? null : ImmutableSet.copyOf(defaultRetryableCodes); // Attempt to create an empty, non-functioning EndpointContext by default. The client will have // a valid EndpointContext with user configurations after the client has been initialized. - try { - this.endpointContext = - endpointContext == null ? EndpointContext.newBuilder().build() : endpointContext; - } catch (IOException ex) { - throw new RuntimeException(ex); - } + this.endpointContext = + endpointContext == null ? EndpointContext.getDefaultInstance() : endpointContext; } /** diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java index afe6ab0655d..26cf63eb850 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java @@ -126,24 +126,20 @@ public abstract class ClientContext { /** Create a new ClientContext with default values */ public static Builder newBuilder() { - try { - return new AutoValue_ClientContext.Builder() - .setBackgroundResources(Collections.emptyList()) - .setExecutor(Executors.newScheduledThreadPool(0)) - .setHeaders(Collections.emptyMap()) - .setInternalHeaders(Collections.emptyMap()) - .setClock(NanoClock.getDefaultClock()) - .setStreamWatchdog(null) - .setStreamWatchdogCheckInterval(Duration.ZERO) - .setTracerFactory(BaseApiTracerFactory.getInstance()) - .setQuotaProjectId(null) - .setGdchApiAudience(null) - // Attempt to create an empty, non-functioning EndpointContext by default. This is - // not exposed to the user via getters/setters. - .setEndpointContext(EndpointContext.newBuilder().build()); - } catch (IOException e) { - throw new RuntimeException(e); - } + return new AutoValue_ClientContext.Builder() + .setBackgroundResources(Collections.emptyList()) + .setExecutor(Executors.newScheduledThreadPool(0)) + .setHeaders(Collections.emptyMap()) + .setInternalHeaders(Collections.emptyMap()) + .setClock(NanoClock.getDefaultClock()) + .setStreamWatchdog(null) + .setStreamWatchdogCheckInterval(Duration.ZERO) + .setTracerFactory(BaseApiTracerFactory.getInstance()) + .setQuotaProjectId(null) + .setGdchApiAudience(null) + // Attempt to create an empty, non-functioning EndpointContext by default. This is + // not exposed to the user via getters/setters. + .setEndpointContext(EndpointContext.getDefaultInstance()); } public abstract Builder toBuilder(); diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java index de99b019959..efe0f517f50 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java @@ -47,12 +47,28 @@ @InternalApi @AutoValue public abstract class EndpointContext { + + private static final EndpointContext INSTANCE; + + // static block initialization for exception handling + static { + try { + INSTANCE = EndpointContext.newBuilder().setServiceName("").build(); + } catch (IOException e) { + throw new RuntimeException("Unable to create a default empty EndpointContext", e); + } + } + public static final String GOOGLE_CLOUD_UNIVERSE_DOMAIN = "GOOGLE_CLOUD_UNIVERSE_DOMAIN"; public static final String INVALID_UNIVERSE_DOMAIN_ERROR_TEMPLATE = "The configured universe domain (%s) does not match the universe domain found in the credentials (%s). If you haven't configured the universe domain explicitly, `googleapis.com` is the default."; public static final String UNABLE_TO_RETRIEVE_CREDENTIALS_ERROR_MESSAGE = "Unable to retrieve the Universe Domain from the Credentials."; + public static EndpointContext getDefaultInstance() { + return INSTANCE; + } + /** * ServiceName is host URI for Google Cloud Services. It follows the format of * `{ServiceName}.googleapis.com`. For example, speech.googleapis.com would have a ServiceName of diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/StubSettings.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/StubSettings.java index 0e37c12cadc..4dc67c9a2d8 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/StubSettings.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/StubSettings.java @@ -266,6 +266,7 @@ public abstract static class Builder< @Nonnull private ApiTracerFactory tracerFactory; private boolean deprecatedExecutorProviderSet; private String universeDomain; + private final EndpointContext endpointContext; /** * Indicate when creating transport whether it is allowed to use mTLS endpoint instead of the @@ -300,6 +301,9 @@ protected Builder(StubSettings settings) { this.switchToMtlsEndpointAllowed = settings.getEndpointContext().switchToMtlsEndpointAllowed(); this.universeDomain = settings.getEndpointContext().universeDomain(); + // Store the EndpointContext that was already created. This is used to return the state + // of the EndpointContext prior to any new modifications + this.endpointContext = settings.getEndpointContext(); } /** Get Quota Project ID from Client Context * */ @@ -327,16 +331,22 @@ protected Builder(ClientContext clientContext) { this.headerProvider = new NoHeaderProvider(); this.internalHeaderProvider = new NoHeaderProvider(); this.clock = NanoClock.getDefaultClock(); - this.clientSettingsEndpoint = null; - this.transportChannelProviderEndpoint = null; - this.mtlsEndpoint = null; this.quotaProjectId = null; this.streamWatchdogProvider = InstantiatingWatchdogProvider.create(); this.streamWatchdogCheckInterval = Duration.ofSeconds(10); this.tracerFactory = BaseApiTracerFactory.getInstance(); this.deprecatedExecutorProviderSet = false; this.gdchApiAudience = null; + + this.clientSettingsEndpoint = null; + this.transportChannelProviderEndpoint = null; + this.mtlsEndpoint = null; + this.switchToMtlsEndpointAllowed = false; this.universeDomain = null; + // Attempt to create an empty, non-functioning EndpointContext by default. The client will + // have + // a valid EndpointContext with user configurations after the client has been initialized. + this.endpointContext = EndpointContext.getDefaultInstance(); } else { ExecutorProvider fixedExecutorProvider = FixedExecutorProvider.create(clientContext.getExecutor()); @@ -365,6 +375,9 @@ protected Builder(ClientContext clientContext) { this.switchToMtlsEndpointAllowed = clientContext.getEndpointContext().switchToMtlsEndpointAllowed(); this.universeDomain = clientContext.getEndpointContext().universeDomain(); + // Store the EndpointContext that was already created. This is used to return the state + // of the EndpointContext prior to any new modifications + this.endpointContext = clientContext.getEndpointContext(); } } @@ -584,8 +597,19 @@ public ApiClock getClock() { return clock; } + /** + * @return the resolved endpoint when the Builder was created. If invoked after + * `StubSettings.newBuilder()` is called, it will return the clientSettingsEndpoint value. + * If other parameters are then set in the builder, the resolved endpoint is not + * automatically updated. The resolved endpoint will only be recomputed when the + * StubSettings is built again. + */ public String getEndpoint() { - return clientSettingsEndpoint; + // For the `StubSettings.newBuilder()` case + if (endpointContext.equals(EndpointContext.getDefaultInstance())) { + return clientSettingsEndpoint; + } + return endpointContext.resolvedEndpoint(); } public String getMtlsEndpoint() { diff --git a/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeCallContext.java b/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeCallContext.java index 77ae3d1fcad..a075e02cc1c 100644 --- a/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeCallContext.java +++ b/gax-java/gax/src/test/java/com/google/api/gax/rpc/testing/FakeCallContext.java @@ -44,7 +44,6 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import java.io.IOException; import java.util.List; import java.util.Map; import java.util.Set; @@ -88,12 +87,8 @@ private FakeCallContext( this.tracer = tracer; this.retrySettings = retrySettings; this.retryableCodes = retryableCodes == null ? null : ImmutableSet.copyOf(retryableCodes); - try { - this.endpointContext = - endpointContext == null ? EndpointContext.newBuilder().build() : endpointContext; - } catch (IOException e) { - throw new RuntimeException(e); - } + this.endpointContext = + endpointContext == null ? EndpointContext.getDefaultInstance() : endpointContext; } public static FakeCallContext createDefault() { diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITEndpointContext.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITEndpointContext.java index ad44622471f..812a52696b9 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITEndpointContext.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITEndpointContext.java @@ -416,17 +416,33 @@ public void universeDomainValidation_noCredentials_userSetUniverseDomain() throw @Test public void endpointResolution_defaultViaBuilder() { EchoSettings.Builder echoSettingsBuilder = EchoSettings.newBuilder(); - // The getter in the builder returns the user set value. No configuration - // means the getter will return null + // `StubSettings.newBuilder()` will return the clientSettingsEndpoint Truth.assertThat(echoSettingsBuilder.getEndpoint()).isEqualTo(null); } // User configuration in Builder @Test public void endpointResolution_userConfigurationViaBuilder() { - String customEndpoint = "test.com:123"; EchoSettings.Builder echoSettingsBuilder = - EchoSettings.newBuilder().setEndpoint(customEndpoint); - Truth.assertThat(echoSettingsBuilder.getEndpoint()).isEqualTo(customEndpoint); + EchoSettings.newBuilder().setEndpoint("test.com:123"); + // `StubSettings.newBuilder()` will return the clientSettingsEndpoint + Truth.assertThat(echoSettingsBuilder.getEndpoint()).isEqualTo("test.com:123"); + } + + @Test + public void endpointResolution_builderBuilderBackToBuilder() throws IOException { + String customEndpoint = "test.com:123"; + EchoStubSettings.Builder echoStubSettingsBuilder = + EchoStubSettings.newBuilder().setEndpoint(customEndpoint); + // `StubSettings.newBuilder()` will return the clientSettingsEndpoint + Truth.assertThat(echoStubSettingsBuilder.getEndpoint()).isEqualTo(customEndpoint); + + // EndpointContext is recomputed when the Builder is re-built + EchoStubSettings echoStubSettings = echoStubSettingsBuilder.build(); + Truth.assertThat(echoStubSettings.getEndpoint()).isEqualTo(customEndpoint); + + // Calling toBuilder on StubSettings keeps the configurations the same + echoStubSettingsBuilder = echoStubSettings.toBuilder(); + Truth.assertThat(echoStubSettingsBuilder.getEndpoint()).isEqualTo(customEndpoint); } } From 5bb97700ddcef1b0494808b1e7d8029d92c74d13 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 17:55:54 -0400 Subject: [PATCH 6/6] feat: [common-protos] add `Weight` to common types for Shopping APIs to be used for accounts bundle (#2699) - [ ] Regenerate this pull request now. docs: A comment for field `amount_micros` in message `.google.shopping.type.Price` is changed PiperOrigin-RevId: 629159171 Source-Link: https://github.com/googleapis/googleapis/commit/a3a2dc62816053b6e9dc2b67d52048133794b178 Source-Link: https://github.com/googleapis/googleapis-gen/commit/7a598761f9021328bc2dea46ec0c0852adc26d83 Copy-Tag: eyJwIjoiamF2YS1jb21tb24tcHJvdG9zLy5Pd2xCb3QueWFtbCIsImgiOiI3YTU5ODc2MWY5MDIxMzI4YmMyZGVhNDZlYzBjMDg1MmFkYzI2ZDgzIn0= --------- Co-authored-by: Owl Bot Co-authored-by: Alice <65933803+alicejli@users.noreply.github.com> --- java-common-protos/README.md | 6 +- .../java/com/google/shopping/type/Price.java | 12 - .../google/shopping/type/PriceOrBuilder.java | 4 - .../com/google/shopping/type/TypesProto.java | 81 +- .../java/com/google/shopping/type/Weight.java | 905 ++++++++++++++++++ .../google/shopping/type/WeightOrBuilder.java | 86 ++ .../proto/google/shopping/type/types.proto | 28 +- 7 files changed, 1069 insertions(+), 53 deletions(-) create mode 100644 java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/Weight.java create mode 100644 java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/WeightOrBuilder.java diff --git a/java-common-protos/README.md b/java-common-protos/README.md index a062c7dc574..e9d4a967279 100644 --- a/java-common-protos/README.md +++ b/java-common-protos/README.md @@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file: com.google.api.grpc proto-google-common-protos - 2.37.1 + 2.38.0 ``` If you are using Gradle without BOM, add this to your dependencies: ```Groovy -implementation 'com.google.api.grpc:proto-google-common-protos:2.37.1' +implementation 'com.google.api.grpc:proto-google-common-protos:2.38.0' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.api.grpc" % "proto-google-common-protos" % "2.37.1" +libraryDependencies += "com.google.api.grpc" % "proto-google-common-protos" % "2.38.0" ``` ## Authentication diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/Price.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/Price.java index 0e32d2884b3..54a67678ff7 100644 --- a/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/Price.java +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/Price.java @@ -72,8 +72,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * The price represented as a number in micros (1 million micros is an * equivalent to one's currency standard unit, for example, 1 USD = 1000000 * micros). - * This field can also be set as infinity by setting to -1. - * This field only support -1 and positive value. * * * optional int64 amount_micros = 1; @@ -91,8 +89,6 @@ public boolean hasAmountMicros() { * The price represented as a number in micros (1 million micros is an * equivalent to one's currency standard unit, for example, 1 USD = 1000000 * micros). - * This field can also be set as infinity by setting to -1. - * This field only support -1 and positive value. * * * optional int64 amount_micros = 1; @@ -554,8 +550,6 @@ public Builder mergeFrom( * The price represented as a number in micros (1 million micros is an * equivalent to one's currency standard unit, for example, 1 USD = 1000000 * micros). - * This field can also be set as infinity by setting to -1. - * This field only support -1 and positive value. * * * optional int64 amount_micros = 1; @@ -573,8 +567,6 @@ public boolean hasAmountMicros() { * The price represented as a number in micros (1 million micros is an * equivalent to one's currency standard unit, for example, 1 USD = 1000000 * micros). - * This field can also be set as infinity by setting to -1. - * This field only support -1 and positive value. * * * optional int64 amount_micros = 1; @@ -592,8 +584,6 @@ public long getAmountMicros() { * The price represented as a number in micros (1 million micros is an * equivalent to one's currency standard unit, for example, 1 USD = 1000000 * micros). - * This field can also be set as infinity by setting to -1. - * This field only support -1 and positive value. * * * optional int64 amount_micros = 1; @@ -615,8 +605,6 @@ public Builder setAmountMicros(long value) { * The price represented as a number in micros (1 million micros is an * equivalent to one's currency standard unit, for example, 1 USD = 1000000 * micros). - * This field can also be set as infinity by setting to -1. - * This field only support -1 and positive value. * * * optional int64 amount_micros = 1; diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/PriceOrBuilder.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/PriceOrBuilder.java index 738b7268d0f..bee4a652c52 100644 --- a/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/PriceOrBuilder.java +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/PriceOrBuilder.java @@ -31,8 +31,6 @@ public interface PriceOrBuilder * The price represented as a number in micros (1 million micros is an * equivalent to one's currency standard unit, for example, 1 USD = 1000000 * micros). - * This field can also be set as infinity by setting to -1. - * This field only support -1 and positive value. * * * optional int64 amount_micros = 1; @@ -47,8 +45,6 @@ public interface PriceOrBuilder * The price represented as a number in micros (1 million micros is an * equivalent to one's currency standard unit, for example, 1 USD = 1000000 * micros). - * This field can also be set as infinity by setting to -1. - * This field only support -1 and positive value. * * * optional int64 amount_micros = 1; diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/TypesProto.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/TypesProto.java index 9ae914ad08e..79c44df5175 100644 --- a/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/TypesProto.java +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/TypesProto.java @@ -28,6 +28,10 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_shopping_type_Weight_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_shopping_type_Weight_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_shopping_type_Price_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable @@ -58,39 +62,52 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { static { java.lang.String[] descriptorData = { "\n google/shopping/type/types.proto\022\024goog" - + "le.shopping.type\"c\n\005Price\022\032\n\ramount_micr" - + "os\030\001 \001(\003H\000\210\001\001\022\032\n\rcurrency_code\030\002 \001(\tH\001\210\001" - + "\001B\020\n\016_amount_microsB\020\n\016_currency_code\"\210\001" - + "\n\017CustomAttribute\022\021\n\004name\030\001 \001(\tH\000\210\001\001\022\022\n\005" - + "value\030\002 \001(\tH\001\210\001\001\022;\n\014group_values\030\003 \003(\0132%" - + ".google.shopping.type.CustomAttributeB\007\n" - + "\005_nameB\010\n\006_value\"\301\001\n\013Destination\"\261\001\n\017Des" - + "tinationEnum\022 \n\034DESTINATION_ENUM_UNSPECI" - + "FIED\020\000\022\020\n\014SHOPPING_ADS\020\001\022\017\n\013DISPLAY_ADS\020" - + "\002\022\027\n\023LOCAL_INVENTORY_ADS\020\003\022\021\n\rFREE_LISTI" - + "NGS\020\004\022\027\n\023FREE_LOCAL_LISTINGS\020\005\022\024\n\020YOUTUB" - + "E_SHOPPING\020\006\"\226\003\n\020ReportingContext\"\201\003\n\024Re" - + "portingContextEnum\022&\n\"REPORTING_CONTEXT_" - + "ENUM_UNSPECIFIED\020\000\022\020\n\014SHOPPING_ADS\020\001\022\025\n\r" - + "DISCOVERY_ADS\020\002\032\002\010\001\022\022\n\016DEMAND_GEN_ADS\020\r\022" - + "#\n\037DEMAND_GEN_ADS_DISCOVER_SURFACE\020\016\022\r\n\t" - + "VIDEO_ADS\020\003\022\017\n\013DISPLAY_ADS\020\004\022\027\n\023LOCAL_IN" - + "VENTORY_ADS\020\005\022\031\n\025VEHICLE_INVENTORY_ADS\020\006" - + "\022\021\n\rFREE_LISTINGS\020\007\022\027\n\023FREE_LOCAL_LISTIN" - + "GS\020\010\022\037\n\033FREE_LOCAL_VEHICLE_LISTINGS\020\t\022\024\n" - + "\020YOUTUBE_SHOPPING\020\n\022\020\n\014CLOUD_RETAIL\020\013\022\026\n" - + "\022LOCAL_CLOUD_RETAIL\020\014\"M\n\007Channel\"B\n\013Chan" - + "nelEnum\022\034\n\030CHANNEL_ENUM_UNSPECIFIED\020\000\022\n\n" - + "\006ONLINE\020\001\022\t\n\005LOCAL\020\002Bp\n\030com.google.shopp" - + "ing.typeB\nTypesProtoP\001Z/cloud.google.com" - + "/go/shopping/type/typepb;typepb\252\002\024Google" - + ".Shopping.Typeb\006proto3" + + "le.shopping.type\"\261\001\n\006Weight\022\032\n\ramount_mi" + + "cros\030\001 \001(\003H\000\210\001\001\0225\n\004unit\030\002 \001(\0162\'.google.s" + + "hopping.type.Weight.WeightUnit\"B\n\nWeight" + + "Unit\022\033\n\027WEIGHT_UNIT_UNSPECIFIED\020\000\022\t\n\005POU" + + "ND\020\001\022\014\n\010KILOGRAM\020\002B\020\n\016_amount_micros\"c\n\005" + + "Price\022\032\n\ramount_micros\030\001 \001(\003H\000\210\001\001\022\032\n\rcur" + + "rency_code\030\002 \001(\tH\001\210\001\001B\020\n\016_amount_microsB" + + "\020\n\016_currency_code\"\210\001\n\017CustomAttribute\022\021\n" + + "\004name\030\001 \001(\tH\000\210\001\001\022\022\n\005value\030\002 \001(\tH\001\210\001\001\022;\n\014" + + "group_values\030\003 \003(\0132%.google.shopping.typ" + + "e.CustomAttributeB\007\n\005_nameB\010\n\006_value\"\301\001\n" + + "\013Destination\"\261\001\n\017DestinationEnum\022 \n\034DEST" + + "INATION_ENUM_UNSPECIFIED\020\000\022\020\n\014SHOPPING_A" + + "DS\020\001\022\017\n\013DISPLAY_ADS\020\002\022\027\n\023LOCAL_INVENTORY" + + "_ADS\020\003\022\021\n\rFREE_LISTINGS\020\004\022\027\n\023FREE_LOCAL_" + + "LISTINGS\020\005\022\024\n\020YOUTUBE_SHOPPING\020\006\"\226\003\n\020Rep" + + "ortingContext\"\201\003\n\024ReportingContextEnum\022&" + + "\n\"REPORTING_CONTEXT_ENUM_UNSPECIFIED\020\000\022\020" + + "\n\014SHOPPING_ADS\020\001\022\025\n\rDISCOVERY_ADS\020\002\032\002\010\001\022" + + "\022\n\016DEMAND_GEN_ADS\020\r\022#\n\037DEMAND_GEN_ADS_DI" + + "SCOVER_SURFACE\020\016\022\r\n\tVIDEO_ADS\020\003\022\017\n\013DISPL" + + "AY_ADS\020\004\022\027\n\023LOCAL_INVENTORY_ADS\020\005\022\031\n\025VEH" + + "ICLE_INVENTORY_ADS\020\006\022\021\n\rFREE_LISTINGS\020\007\022" + + "\027\n\023FREE_LOCAL_LISTINGS\020\010\022\037\n\033FREE_LOCAL_V" + + "EHICLE_LISTINGS\020\t\022\024\n\020YOUTUBE_SHOPPING\020\n\022" + + "\020\n\014CLOUD_RETAIL\020\013\022\026\n\022LOCAL_CLOUD_RETAIL\020" + + "\014\"M\n\007Channel\"B\n\013ChannelEnum\022\034\n\030CHANNEL_E" + + "NUM_UNSPECIFIED\020\000\022\n\n\006ONLINE\020\001\022\t\n\005LOCAL\020\002" + + "Bp\n\030com.google.shopping.typeB\nTypesProto" + + "P\001Z/cloud.google.com/go/shopping/type/ty" + + "pepb;typepb\252\002\024Google.Shopping.Typeb\006prot" + + "o3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}); - internal_static_google_shopping_type_Price_descriptor = + internal_static_google_shopping_type_Weight_descriptor = getDescriptor().getMessageTypes().get(0); + internal_static_google_shopping_type_Weight_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_shopping_type_Weight_descriptor, + new java.lang.String[] { + "AmountMicros", "Unit", + }); + internal_static_google_shopping_type_Price_descriptor = + getDescriptor().getMessageTypes().get(1); internal_static_google_shopping_type_Price_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_shopping_type_Price_descriptor, @@ -98,7 +115,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "AmountMicros", "CurrencyCode", }); internal_static_google_shopping_type_CustomAttribute_descriptor = - getDescriptor().getMessageTypes().get(1); + getDescriptor().getMessageTypes().get(2); internal_static_google_shopping_type_CustomAttribute_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_shopping_type_CustomAttribute_descriptor, @@ -106,18 +123,18 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Name", "Value", "GroupValues", }); internal_static_google_shopping_type_Destination_descriptor = - getDescriptor().getMessageTypes().get(2); + getDescriptor().getMessageTypes().get(3); internal_static_google_shopping_type_Destination_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_shopping_type_Destination_descriptor, new java.lang.String[] {}); internal_static_google_shopping_type_ReportingContext_descriptor = - getDescriptor().getMessageTypes().get(3); + getDescriptor().getMessageTypes().get(4); internal_static_google_shopping_type_ReportingContext_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_shopping_type_ReportingContext_descriptor, new java.lang.String[] {}); internal_static_google_shopping_type_Channel_descriptor = - getDescriptor().getMessageTypes().get(4); + getDescriptor().getMessageTypes().get(5); internal_static_google_shopping_type_Channel_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_shopping_type_Channel_descriptor, new java.lang.String[] {}); diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/Weight.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/Weight.java new file mode 100644 index 00000000000..f66f829d578 --- /dev/null +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/Weight.java @@ -0,0 +1,905 @@ +/* + * Copyright 2020 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 + * + * https://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 by the protocol buffer compiler. DO NOT EDIT! +// source: google/shopping/type/types.proto + +// Protobuf Java Version: 3.25.3 +package com.google.shopping.type; + +/** + * + * + *
+ * The weight represented as the value in string and the unit.
+ * 
+ * + * Protobuf type {@code google.shopping.type.Weight} + */ +public final class Weight extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.shopping.type.Weight) + WeightOrBuilder { + private static final long serialVersionUID = 0L; + // Use Weight.newBuilder() to construct. + private Weight(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Weight() { + unit_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Weight(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.shopping.type.TypesProto + .internal_static_google_shopping_type_Weight_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.shopping.type.TypesProto + .internal_static_google_shopping_type_Weight_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.shopping.type.Weight.class, com.google.shopping.type.Weight.Builder.class); + } + + /** + * + * + *
+   * The weight unit.
+   * 
+ * + * Protobuf enum {@code google.shopping.type.Weight.WeightUnit} + */ + public enum WeightUnit implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * unit unspecified
+     * 
+ * + * WEIGHT_UNIT_UNSPECIFIED = 0; + */ + WEIGHT_UNIT_UNSPECIFIED(0), + /** + * + * + *
+     * lb unit.
+     * 
+ * + * POUND = 1; + */ + POUND(1), + /** + * + * + *
+     * kg unit.
+     * 
+ * + * KILOGRAM = 2; + */ + KILOGRAM(2), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * unit unspecified
+     * 
+ * + * WEIGHT_UNIT_UNSPECIFIED = 0; + */ + public static final int WEIGHT_UNIT_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+     * lb unit.
+     * 
+ * + * POUND = 1; + */ + public static final int POUND_VALUE = 1; + /** + * + * + *
+     * kg unit.
+     * 
+ * + * KILOGRAM = 2; + */ + public static final int KILOGRAM_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static WeightUnit valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static WeightUnit forNumber(int value) { + switch (value) { + case 0: + return WEIGHT_UNIT_UNSPECIFIED; + case 1: + return POUND; + case 2: + return KILOGRAM; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public WeightUnit findValueByNumber(int number) { + return WeightUnit.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.shopping.type.Weight.getDescriptor().getEnumTypes().get(0); + } + + private static final WeightUnit[] VALUES = values(); + + public static WeightUnit valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private WeightUnit(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.shopping.type.Weight.WeightUnit) + } + + private int bitField0_; + public static final int AMOUNT_MICROS_FIELD_NUMBER = 1; + private long amountMicros_ = 0L; + /** + * + * + *
+   * Required. The weight represented as a number in micros (1 million micros is
+   * an equivalent to one's currency standard unit, for example, 1 kg = 1000000
+   * micros).
+   * This field can also be set as infinity by setting to -1.
+   * This field only support -1 and positive value.
+   * 
+ * + * optional int64 amount_micros = 1; + * + * @return Whether the amountMicros field is set. + */ + @java.lang.Override + public boolean hasAmountMicros() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * Required. The weight represented as a number in micros (1 million micros is
+   * an equivalent to one's currency standard unit, for example, 1 kg = 1000000
+   * micros).
+   * This field can also be set as infinity by setting to -1.
+   * This field only support -1 and positive value.
+   * 
+ * + * optional int64 amount_micros = 1; + * + * @return The amountMicros. + */ + @java.lang.Override + public long getAmountMicros() { + return amountMicros_; + } + + public static final int UNIT_FIELD_NUMBER = 2; + private int unit_ = 0; + /** + * + * + *
+   * Required. The weight unit.
+   * Acceptable values are: kg and lb
+   * 
+ * + * .google.shopping.type.Weight.WeightUnit unit = 2; + * + * @return The enum numeric value on the wire for unit. + */ + @java.lang.Override + public int getUnitValue() { + return unit_; + } + /** + * + * + *
+   * Required. The weight unit.
+   * Acceptable values are: kg and lb
+   * 
+ * + * .google.shopping.type.Weight.WeightUnit unit = 2; + * + * @return The unit. + */ + @java.lang.Override + public com.google.shopping.type.Weight.WeightUnit getUnit() { + com.google.shopping.type.Weight.WeightUnit result = + com.google.shopping.type.Weight.WeightUnit.forNumber(unit_); + return result == null ? com.google.shopping.type.Weight.WeightUnit.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeInt64(1, amountMicros_); + } + if (unit_ != com.google.shopping.type.Weight.WeightUnit.WEIGHT_UNIT_UNSPECIFIED.getNumber()) { + output.writeEnum(2, unit_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, amountMicros_); + } + if (unit_ != com.google.shopping.type.Weight.WeightUnit.WEIGHT_UNIT_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, unit_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.shopping.type.Weight)) { + return super.equals(obj); + } + com.google.shopping.type.Weight other = (com.google.shopping.type.Weight) obj; + + if (hasAmountMicros() != other.hasAmountMicros()) return false; + if (hasAmountMicros()) { + if (getAmountMicros() != other.getAmountMicros()) return false; + } + if (unit_ != other.unit_) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasAmountMicros()) { + hash = (37 * hash) + AMOUNT_MICROS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getAmountMicros()); + } + hash = (37 * hash) + UNIT_FIELD_NUMBER; + hash = (53 * hash) + unit_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.shopping.type.Weight parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.shopping.type.Weight parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.shopping.type.Weight parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.shopping.type.Weight parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.shopping.type.Weight parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.shopping.type.Weight parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.shopping.type.Weight parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.shopping.type.Weight parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.shopping.type.Weight parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.shopping.type.Weight parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.shopping.type.Weight parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.shopping.type.Weight parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.shopping.type.Weight prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The weight represented as the value in string and the unit.
+   * 
+ * + * Protobuf type {@code google.shopping.type.Weight} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.shopping.type.Weight) + com.google.shopping.type.WeightOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.shopping.type.TypesProto + .internal_static_google_shopping_type_Weight_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.shopping.type.TypesProto + .internal_static_google_shopping_type_Weight_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.shopping.type.Weight.class, com.google.shopping.type.Weight.Builder.class); + } + + // Construct using com.google.shopping.type.Weight.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + amountMicros_ = 0L; + unit_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.shopping.type.TypesProto + .internal_static_google_shopping_type_Weight_descriptor; + } + + @java.lang.Override + public com.google.shopping.type.Weight getDefaultInstanceForType() { + return com.google.shopping.type.Weight.getDefaultInstance(); + } + + @java.lang.Override + public com.google.shopping.type.Weight build() { + com.google.shopping.type.Weight result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.shopping.type.Weight buildPartial() { + com.google.shopping.type.Weight result = new com.google.shopping.type.Weight(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.shopping.type.Weight result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.amountMicros_ = amountMicros_; + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.unit_ = unit_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.shopping.type.Weight) { + return mergeFrom((com.google.shopping.type.Weight) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.shopping.type.Weight other) { + if (other == com.google.shopping.type.Weight.getDefaultInstance()) return this; + if (other.hasAmountMicros()) { + setAmountMicros(other.getAmountMicros()); + } + if (other.unit_ != 0) { + setUnitValue(other.getUnitValue()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + amountMicros_ = input.readInt64(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: + { + unit_ = input.readEnum(); + bitField0_ |= 0x00000002; + break; + } // case 16 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private long amountMicros_; + /** + * + * + *
+     * Required. The weight represented as a number in micros (1 million micros is
+     * an equivalent to one's currency standard unit, for example, 1 kg = 1000000
+     * micros).
+     * This field can also be set as infinity by setting to -1.
+     * This field only support -1 and positive value.
+     * 
+ * + * optional int64 amount_micros = 1; + * + * @return Whether the amountMicros field is set. + */ + @java.lang.Override + public boolean hasAmountMicros() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+     * Required. The weight represented as a number in micros (1 million micros is
+     * an equivalent to one's currency standard unit, for example, 1 kg = 1000000
+     * micros).
+     * This field can also be set as infinity by setting to -1.
+     * This field only support -1 and positive value.
+     * 
+ * + * optional int64 amount_micros = 1; + * + * @return The amountMicros. + */ + @java.lang.Override + public long getAmountMicros() { + return amountMicros_; + } + /** + * + * + *
+     * Required. The weight represented as a number in micros (1 million micros is
+     * an equivalent to one's currency standard unit, for example, 1 kg = 1000000
+     * micros).
+     * This field can also be set as infinity by setting to -1.
+     * This field only support -1 and positive value.
+     * 
+ * + * optional int64 amount_micros = 1; + * + * @param value The amountMicros to set. + * @return This builder for chaining. + */ + public Builder setAmountMicros(long value) { + + amountMicros_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The weight represented as a number in micros (1 million micros is
+     * an equivalent to one's currency standard unit, for example, 1 kg = 1000000
+     * micros).
+     * This field can also be set as infinity by setting to -1.
+     * This field only support -1 and positive value.
+     * 
+ * + * optional int64 amount_micros = 1; + * + * @return This builder for chaining. + */ + public Builder clearAmountMicros() { + bitField0_ = (bitField0_ & ~0x00000001); + amountMicros_ = 0L; + onChanged(); + return this; + } + + private int unit_ = 0; + /** + * + * + *
+     * Required. The weight unit.
+     * Acceptable values are: kg and lb
+     * 
+ * + * .google.shopping.type.Weight.WeightUnit unit = 2; + * + * @return The enum numeric value on the wire for unit. + */ + @java.lang.Override + public int getUnitValue() { + return unit_; + } + /** + * + * + *
+     * Required. The weight unit.
+     * Acceptable values are: kg and lb
+     * 
+ * + * .google.shopping.type.Weight.WeightUnit unit = 2; + * + * @param value The enum numeric value on the wire for unit to set. + * @return This builder for chaining. + */ + public Builder setUnitValue(int value) { + unit_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The weight unit.
+     * Acceptable values are: kg and lb
+     * 
+ * + * .google.shopping.type.Weight.WeightUnit unit = 2; + * + * @return The unit. + */ + @java.lang.Override + public com.google.shopping.type.Weight.WeightUnit getUnit() { + com.google.shopping.type.Weight.WeightUnit result = + com.google.shopping.type.Weight.WeightUnit.forNumber(unit_); + return result == null ? com.google.shopping.type.Weight.WeightUnit.UNRECOGNIZED : result; + } + /** + * + * + *
+     * Required. The weight unit.
+     * Acceptable values are: kg and lb
+     * 
+ * + * .google.shopping.type.Weight.WeightUnit unit = 2; + * + * @param value The unit to set. + * @return This builder for chaining. + */ + public Builder setUnit(com.google.shopping.type.Weight.WeightUnit value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + unit_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The weight unit.
+     * Acceptable values are: kg and lb
+     * 
+ * + * .google.shopping.type.Weight.WeightUnit unit = 2; + * + * @return This builder for chaining. + */ + public Builder clearUnit() { + bitField0_ = (bitField0_ & ~0x00000002); + unit_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.shopping.type.Weight) + } + + // @@protoc_insertion_point(class_scope:google.shopping.type.Weight) + private static final com.google.shopping.type.Weight DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.shopping.type.Weight(); + } + + public static com.google.shopping.type.Weight getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Weight parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.shopping.type.Weight getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/WeightOrBuilder.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/WeightOrBuilder.java new file mode 100644 index 00000000000..2e52f5a014d --- /dev/null +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/shopping/type/WeightOrBuilder.java @@ -0,0 +1,86 @@ +/* + * Copyright 2020 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 + * + * https://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 by the protocol buffer compiler. DO NOT EDIT! +// source: google/shopping/type/types.proto + +// Protobuf Java Version: 3.25.3 +package com.google.shopping.type; + +public interface WeightOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.shopping.type.Weight) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The weight represented as a number in micros (1 million micros is
+   * an equivalent to one's currency standard unit, for example, 1 kg = 1000000
+   * micros).
+   * This field can also be set as infinity by setting to -1.
+   * This field only support -1 and positive value.
+   * 
+ * + * optional int64 amount_micros = 1; + * + * @return Whether the amountMicros field is set. + */ + boolean hasAmountMicros(); + /** + * + * + *
+   * Required. The weight represented as a number in micros (1 million micros is
+   * an equivalent to one's currency standard unit, for example, 1 kg = 1000000
+   * micros).
+   * This field can also be set as infinity by setting to -1.
+   * This field only support -1 and positive value.
+   * 
+ * + * optional int64 amount_micros = 1; + * + * @return The amountMicros. + */ + long getAmountMicros(); + + /** + * + * + *
+   * Required. The weight unit.
+   * Acceptable values are: kg and lb
+   * 
+ * + * .google.shopping.type.Weight.WeightUnit unit = 2; + * + * @return The enum numeric value on the wire for unit. + */ + int getUnitValue(); + /** + * + * + *
+   * Required. The weight unit.
+   * Acceptable values are: kg and lb
+   * 
+ * + * .google.shopping.type.Weight.WeightUnit unit = 2; + * + * @return The unit. + */ + com.google.shopping.type.Weight.WeightUnit getUnit(); +} diff --git a/java-common-protos/proto-google-common-protos/src/main/proto/google/shopping/type/types.proto b/java-common-protos/proto-google-common-protos/src/main/proto/google/shopping/type/types.proto index c23bf52d626..f5c218694fe 100644 --- a/java-common-protos/proto-google-common-protos/src/main/proto/google/shopping/type/types.proto +++ b/java-common-protos/proto-google-common-protos/src/main/proto/google/shopping/type/types.proto @@ -22,13 +22,37 @@ option java_multiple_files = true; option java_outer_classname = "TypesProto"; option java_package = "com.google.shopping.type"; +// The weight represented as the value in string and the unit. +message Weight { + // The weight unit. + enum WeightUnit { + // unit unspecified + WEIGHT_UNIT_UNSPECIFIED = 0; + + // lb unit. + POUND = 1; + + // kg unit. + KILOGRAM = 2; + } + + // Required. The weight represented as a number in micros (1 million micros is + // an equivalent to one's currency standard unit, for example, 1 kg = 1000000 + // micros). + // This field can also be set as infinity by setting to -1. + // This field only support -1 and positive value. + optional int64 amount_micros = 1; + + // Required. The weight unit. + // Acceptable values are: kg and lb + WeightUnit unit = 2; +} + // The price represented as a number and currency. message Price { // The price represented as a number in micros (1 million micros is an // equivalent to one's currency standard unit, for example, 1 USD = 1000000 // micros). - // This field can also be set as infinity by setting to -1. - // This field only support -1 and positive value. optional int64 amount_micros = 1; // The currency of the price using three-letter acronyms according to [ISO