diff --git a/gapic-libraries-bom/pom.xml b/gapic-libraries-bom/pom.xml index e4c647aaa02c..43b5258b74ad 100644 --- a/gapic-libraries-bom/pom.xml +++ b/gapic-libraries-bom/pom.xml @@ -301,6 +301,13 @@ pom import + + com.google.cloud + google-cloud-confidentialcomputing-bom + 0.0.1-SNAPSHOT + pom + import + com.google.cloud google-cloud-contact-center-insights-bom diff --git a/java-confidentialcomputing/.OwlBot.yaml b/java-confidentialcomputing/.OwlBot.yaml new file mode 100644 index 000000000000..a61164024e7e --- /dev/null +++ b/java-confidentialcomputing/.OwlBot.yaml @@ -0,0 +1,36 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +deep-remove-regex: +- "/java-confidentialcomputing/grpc-google-.*/src" +- "/java-confidentialcomputing/proto-google-.*/src" +- "/java-confidentialcomputing/google-.*/src" +- "/java-confidentialcomputing/samples/snippets/generated" + +deep-preserve-regex: +- "/java-confidentialcomputing/google-.*/src/test/java/com/google/cloud/.*/v.*/it/IT.*Test.java" + +deep-copy-regex: +- source: "/google/cloud/confidentialcomputing/(v.*)/.*-java/proto-google-.*/src" + dest: "/owl-bot-staging/java-confidentialcomputing/$1/proto-google-cloud-confidentialcomputing-$1/src" +- source: "/google/cloud/confidentialcomputing/(v.*)/.*-java/grpc-google-.*/src" + dest: "/owl-bot-staging/java-confidentialcomputing/$1/grpc-google-cloud-confidentialcomputing-$1/src" +- source: "/google/cloud/confidentialcomputing/(v.*)/.*-java/gapic-google-.*/src" + dest: "/owl-bot-staging/java-confidentialcomputing/$1/google-cloud-confidentialcomputing/src" +- source: "/google/cloud/confidentialcomputing/(v.*)/.*-java/samples/snippets/generated" + dest: "/owl-bot-staging/java-confidentialcomputing/$1/samples/snippets/generated" + + +api-name: confidentialcomputing \ No newline at end of file diff --git a/java-confidentialcomputing/.repo-metadata.json b/java-confidentialcomputing/.repo-metadata.json new file mode 100644 index 000000000000..ae296627f779 --- /dev/null +++ b/java-confidentialcomputing/.repo-metadata.json @@ -0,0 +1,16 @@ +{ + "api_shortname": "confidentialcomputing", + "name_pretty": "Confidential Computing API", + "product_documentation": "https://cloud.google.com/confidential-computing/", + "api_description": "Protect data in-use with Confidential VMs, Confidential GKE, Confidential Dataproc, and Confidential Space.", + "client_documentation": "https://cloud.google.com/java/docs/reference/google-cloud-confidentialcomputing/latest/overview", + "release_level": "preview", + "transport": "grpc", + "language": "java", + "repo": "googleapis/java-confidentialcomputing", + "repo_short": "java-confidentialcomputing", + "distribution_name": "com.google.cloud:google-cloud-confidentialcomputing", + "api_id": "confidentialcomputing.googleapis.com", + "library_type": "GAPIC_AUTO", + "requires_billing": true +} \ No newline at end of file diff --git a/java-confidentialcomputing/README.md b/java-confidentialcomputing/README.md new file mode 100644 index 000000000000..9e9a4560b92a --- /dev/null +++ b/java-confidentialcomputing/README.md @@ -0,0 +1,225 @@ +# Google Confidential Computing API Client for Java + +Java idiomatic client for [Confidential Computing API][product-docs]. + +[![Maven][maven-version-image]][maven-version-link] +![Stability][stability-image] + +- [Product Documentation][product-docs] +- [Client Library Documentation][javadocs] + +> Note: This client is a work-in-progress, and may occasionally +> make backwards-incompatible changes. + + +## Quickstart + + +If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file: + +```xml + + + + com.google.cloud + libraries-bom + 26.12.0 + pom + import + + + + + + + com.google.cloud + google-cloud-confidentialcomputing + +``` + +If you are using Maven without the BOM, add this to your dependencies: + + + +```xml + + com.google.cloud + google-cloud-confidentialcomputing + 0.0.0 + +``` + +If you are using Gradle without BOM, add this to your dependencies: + +```Groovy +implementation 'com.google.cloud:google-cloud-confidentialcomputing:0.0.0' +``` + +If you are using SBT, add this to your dependencies: + +```Scala +libraryDependencies += "com.google.cloud" % "google-cloud-confidentialcomputing" % "0.0.0" +``` + + +## Authentication + +See the [Authentication][authentication] section in the base directory's README. + +## Authorization + +The client application making API calls must be granted [authorization scopes][auth-scopes] required for the desired Confidential Computing API APIs, and the authenticated principal must have the [IAM role(s)][predefined-iam-roles] required to access GCP resources using the Confidential Computing API API calls. + +## Getting Started + +### Prerequisites + +You will need a [Google Cloud Platform Console][developer-console] project with the Confidential Computing API [API enabled][enable-api]. +You will need to [enable billing][enable-billing] to use Google Confidential Computing API. +[Follow these instructions][create-project] to get your project set up. You will also need to set up the local development environment by +[installing the Google Cloud Command Line Interface][cloud-cli] and running the following commands in command line: +`gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`. + +### Installation and setup + +You'll need to obtain the `google-cloud-confidentialcomputing` library. See the [Quickstart](#quickstart) section +to add `google-cloud-confidentialcomputing` as a dependency in your code. + +## About Confidential Computing API + + +[Confidential Computing API][product-docs] Protect data in-use with Confidential VMs, Confidential GKE, Confidential Dataproc, and Confidential Space. + +See the [Confidential Computing API client library docs][javadocs] to learn how to +use this Confidential Computing API Client Library. + + + + + + +## Troubleshooting + +To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting]. + +## Transport + +Confidential Computing API uses gRPC for the transport layer. + +## Supported Java Versions + +Java 8 or above is required for using this client. + +Google's Java client libraries, +[Google Cloud Client Libraries][cloudlibs] +and +[Google Cloud API Libraries][apilibs], +follow the +[Oracle Java SE support roadmap][oracle] +(see the Oracle Java SE Product Releases section). + +### For new development + +In general, new feature development occurs with support for the lowest Java +LTS version covered by Oracle's Premier Support (which typically lasts 5 years +from initial General Availability). If the minimum required JVM for a given +library is changed, it is accompanied by a [semver][semver] major release. + +Java 11 and (in September 2021) Java 17 are the best choices for new +development. + +### Keeping production systems current + +Google tests its client libraries with all current LTS versions covered by +Oracle's Extended Support (which typically lasts 8 years from initial +General Availability). + +#### Legacy support + +Google's client libraries support legacy versions of Java runtimes with long +term stable libraries that don't receive feature updates on a best efforts basis +as it may not be possible to backport all patches. + +Google provides updates on a best efforts basis to apps that continue to use +Java 7, though apps might need to upgrade to current versions of the library +that supports their JVM. + +#### Where to find specific information + +The latest versions and the supported Java versions are identified on +the individual GitHub repository `github.com/GoogleAPIs/java-SERVICENAME` +and on [google-cloud-java][g-c-j]. + +## Versioning + + +This library follows [Semantic Versioning](http://semver.org/). + + +It is currently in major version zero (``0.y.z``), which means that anything may change at any time +and the public API should not be considered stable. + + +## Contributing + + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING][contributing] for more information how to get started. + +Please note that this project is released with a Contributor Code of Conduct. By participating in +this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more +information. + + +## License + +Apache 2.0 - See [LICENSE][license] for more information. + +## CI Status + +Java Version | Status +------------ | ------ +Java 8 | [![Kokoro CI][kokoro-badge-image-2]][kokoro-badge-link-2] +Java 8 OSX | [![Kokoro CI][kokoro-badge-image-3]][kokoro-badge-link-3] +Java 8 Windows | [![Kokoro CI][kokoro-badge-image-4]][kokoro-badge-link-4] +Java 11 | [![Kokoro CI][kokoro-badge-image-5]][kokoro-badge-link-5] + +Java is a registered trademark of Oracle and/or its affiliates. + +[product-docs]: https://cloud.google.com/confidential-computing/ +[javadocs]: https://cloud.google.com/java/docs/reference/google-cloud-confidentialcomputing/latest/overview +[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-confidentialcomputing/java7.svg +[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-confidentialcomputing/java7.html +[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-confidentialcomputing/java8.svg +[kokoro-badge-link-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-confidentialcomputing/java8.html +[kokoro-badge-image-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-confidentialcomputing/java8-osx.svg +[kokoro-badge-link-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-confidentialcomputing/java8-osx.html +[kokoro-badge-image-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-confidentialcomputing/java8-win.svg +[kokoro-badge-link-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-confidentialcomputing/java8-win.html +[kokoro-badge-image-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-confidentialcomputing/java11.svg +[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-confidentialcomputing/java11.html +[stability-image]: https://img.shields.io/badge/stability-preview-yellow +[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-confidentialcomputing.svg +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-confidentialcomputing/0.0.0 +[authentication]: https://github.com/googleapis/google-cloud-java#authentication +[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes +[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles +[iam-policy]: https://cloud.google.com/iam/docs/overview#cloud-iam-policy +[developer-console]: https://console.developers.google.com/ +[create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects +[cloud-cli]: https://cloud.google.com/cli +[troubleshooting]: https://github.com/googleapis/google-cloud-java/blob/main/TROUBLESHOOTING.md +[contributing]: https://github.com/googleapis/java-confidentialcomputing/blob/main/CONTRIBUTING.md +[code-of-conduct]: https://github.com/googleapis/java-confidentialcomputing/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct +[license]: https://github.com/googleapis/java-confidentialcomputing/blob/main/LICENSE +[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing +[enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=confidentialcomputing.googleapis.com +[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM +[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png + +[semver]: https://semver.org/ +[cloudlibs]: https://cloud.google.com/apis/docs/client-libraries-explained +[apilibs]: https://cloud.google.com/apis/docs/client-libraries-explained#google_api_client_libraries +[oracle]: https://www.oracle.com/java/technologies/java-se-support-roadmap.html +[g-c-j]: http://github.com/googleapis/google-cloud-java diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing-bom/pom.xml b/java-confidentialcomputing/google-cloud-confidentialcomputing-bom/pom.xml new file mode 100644 index 000000000000..914aa7afc3be --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing-bom/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + com.google.cloud + google-cloud-confidentialcomputing-bom + 0.0.1-SNAPSHOT + pom + + + com.google.cloud + google-cloud-pom-parent + 1.9.0-SNAPSHOT + ../../google-cloud-pom-parent/pom.xml + + + Google Confidential Computing API BOM + + BOM for Confidential Computing API + + + + true + + + + + + com.google.cloud + google-cloud-confidentialcomputing + 0.0.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-confidentialcomputing-v1 + 0.0.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-confidentialcomputing-v1alpha1 + 0.0.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-confidentialcomputing-v1 + 0.0.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-confidentialcomputing-v1alpha1 + 0.0.1-SNAPSHOT + + + + diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/pom.xml b/java-confidentialcomputing/google-cloud-confidentialcomputing/pom.xml new file mode 100644 index 000000000000..ffe9a50a2a4c --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/pom.xml @@ -0,0 +1,122 @@ + + + 4.0.0 + com.google.cloud + google-cloud-confidentialcomputing + 0.0.1-SNAPSHOT + jar + Google Confidential Computing API + Confidential Computing API Protect data in-use with Confidential VMs, Confidential GKE, Confidential Dataproc, and Confidential Space. + + com.google.cloud + google-cloud-confidentialcomputing-parent + 0.0.1-SNAPSHOT + + + google-cloud-confidentialcomputing + + + + io.grpc + grpc-api + + + io.grpc + grpc-stub + + + io.grpc + grpc-protobuf + + + com.google.api + api-common + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + + com.google.api.grpc + proto-google-cloud-confidentialcomputing-v1 + + + com.google.api.grpc + proto-google-cloud-confidentialcomputing-v1alpha1 + + + com.google.guava + guava + + + com.google.api + gax + + + com.google.api + gax-grpc + + + com.google.api + gax-httpjson + + + com.google.api.grpc + grpc-google-common-protos + + + com.google.api.grpc + proto-google-iam-v1 + + + com.google.api.grpc + grpc-google-iam-v1 + + + org.threeten + threetenbp + + + + + junit + junit + test + + + + com.google.api.grpc + grpc-google-cloud-confidentialcomputing-v1 + test + + + com.google.api.grpc + grpc-google-cloud-confidentialcomputing-v1alpha1 + test + + + + com.google.api + gax + testlib + test + + + com.google.api + gax-grpc + testlib + test + + + com.google.api + gax-httpjson + testlib + test + + + diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingClient.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingClient.java new file mode 100644 index 000000000000..c2188105f3fb --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingClient.java @@ -0,0 +1,641 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.confidentialcomputing.v1.stub.ConfidentialComputingStub; +import com.google.cloud.confidentialcomputing.v1.stub.ConfidentialComputingStubSettings; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.util.concurrent.MoreExecutors; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: Service describing handlers for resources + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (ConfidentialComputingClient confidentialComputingClient =
+ *     ConfidentialComputingClient.create()) {
+ *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ *   Challenge challenge = Challenge.newBuilder().build();
+ *   Challenge response = confidentialComputingClient.createChallenge(parent, challenge);
+ * }
+ * }
+ * + *

Note: close() needs to be called on the ConfidentialComputingClient object to clean up + * resources such as threads. In the example above, try-with-resources is used, which automatically + * calls close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of ConfidentialComputingSettings + * to create(). For example: + * + *

To customize credentials: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * ConfidentialComputingSettings confidentialComputingSettings =
+ *     ConfidentialComputingSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * ConfidentialComputingClient confidentialComputingClient =
+ *     ConfidentialComputingClient.create(confidentialComputingSettings);
+ * }
+ * + *

To customize the endpoint: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * ConfidentialComputingSettings confidentialComputingSettings =
+ *     ConfidentialComputingSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * ConfidentialComputingClient confidentialComputingClient =
+ *     ConfidentialComputingClient.create(confidentialComputingSettings);
+ * }
+ * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * ConfidentialComputingSettings confidentialComputingSettings =
+ *     ConfidentialComputingSettings.newHttpJsonBuilder().build();
+ * ConfidentialComputingClient confidentialComputingClient =
+ *     ConfidentialComputingClient.create(confidentialComputingSettings);
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@Generated("by gapic-generator-java") +public class ConfidentialComputingClient implements BackgroundResource { + private final ConfidentialComputingSettings settings; + private final ConfidentialComputingStub stub; + + /** Constructs an instance of ConfidentialComputingClient with default settings. */ + public static final ConfidentialComputingClient create() throws IOException { + return create(ConfidentialComputingSettings.newBuilder().build()); + } + + /** + * Constructs an instance of ConfidentialComputingClient, using the given settings. The channels + * are created based on the settings passed in, or defaults for any settings that are not set. + */ + public static final ConfidentialComputingClient create(ConfidentialComputingSettings settings) + throws IOException { + return new ConfidentialComputingClient(settings); + } + + /** + * Constructs an instance of ConfidentialComputingClient, using the given stub for making calls. + * This is for advanced usage - prefer using create(ConfidentialComputingSettings). + */ + public static final ConfidentialComputingClient create(ConfidentialComputingStub stub) { + return new ConfidentialComputingClient(stub); + } + + /** + * Constructs an instance of ConfidentialComputingClient, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected ConfidentialComputingClient(ConfidentialComputingSettings settings) throws IOException { + this.settings = settings; + this.stub = ((ConfidentialComputingStubSettings) settings.getStubSettings()).createStub(); + } + + protected ConfidentialComputingClient(ConfidentialComputingStub stub) { + this.settings = null; + this.stub = stub; + } + + public final ConfidentialComputingSettings getSettings() { + return settings; + } + + public ConfidentialComputingStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new Challenge in a given project and location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   Challenge challenge = Challenge.newBuilder().build();
+   *   Challenge response = confidentialComputingClient.createChallenge(parent, challenge);
+   * }
+   * }
+ * + * @param parent Required. The resource name of the location where the Challenge will be used, in + * the format `projects/*/locations/*`. + * @param challenge Required. The Challenge to be created. Currently this field can be empty as + * all the Challenge fields are set by the server. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Challenge createChallenge(LocationName parent, Challenge challenge) { + CreateChallengeRequest request = + CreateChallengeRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setChallenge(challenge) + .build(); + return createChallenge(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new Challenge in a given project and location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   Challenge challenge = Challenge.newBuilder().build();
+   *   Challenge response = confidentialComputingClient.createChallenge(parent, challenge);
+   * }
+   * }
+ * + * @param parent Required. The resource name of the location where the Challenge will be used, in + * the format `projects/*/locations/*`. + * @param challenge Required. The Challenge to be created. Currently this field can be empty as + * all the Challenge fields are set by the server. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Challenge createChallenge(String parent, Challenge challenge) { + CreateChallengeRequest request = + CreateChallengeRequest.newBuilder().setParent(parent).setChallenge(challenge).build(); + return createChallenge(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new Challenge in a given project and location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   CreateChallengeRequest request =
+   *       CreateChallengeRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setChallenge(Challenge.newBuilder().build())
+   *           .build();
+   *   Challenge response = confidentialComputingClient.createChallenge(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Challenge createChallenge(CreateChallengeRequest request) { + return createChallengeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new Challenge in a given project and location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   CreateChallengeRequest request =
+   *       CreateChallengeRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setChallenge(Challenge.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       confidentialComputingClient.createChallengeCallable().futureCall(request);
+   *   // Do something.
+   *   Challenge response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable createChallengeCallable() { + return stub.createChallengeCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Verifies the provided attestation info, returning a signed OIDC token. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   VerifyAttestationRequest request =
+   *       VerifyAttestationRequest.newBuilder()
+   *           .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString())
+   *           .setGcpCredentials(GcpCredentials.newBuilder().build())
+   *           .setTpmAttestation(TpmAttestation.newBuilder().build())
+   *           .build();
+   *   VerifyAttestationResponse response = confidentialComputingClient.verifyAttestation(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final VerifyAttestationResponse verifyAttestation(VerifyAttestationRequest request) { + return verifyAttestationCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Verifies the provided attestation info, returning a signed OIDC token. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   VerifyAttestationRequest request =
+   *       VerifyAttestationRequest.newBuilder()
+   *           .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString())
+   *           .setGcpCredentials(GcpCredentials.newBuilder().build())
+   *           .setTpmAttestation(TpmAttestation.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       confidentialComputingClient.verifyAttestationCallable().futureCall(request);
+   *   // Do something.
+   *   VerifyAttestationResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + verifyAttestationCallable() { + return stub.verifyAttestationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Location element : confidentialComputingClient.listLocations(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) { + return listLocationsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       confidentialComputingClient.listLocationsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Location element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listLocationsPagedCallable() { + return stub.listLocationsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   while (true) {
+   *     ListLocationsResponse response =
+   *         confidentialComputingClient.listLocationsCallable().call(request);
+   *     for (Location element : response.getLocationsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable listLocationsCallable() { + return stub.listLocationsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
+   *   Location response = confidentialComputingClient.getLocation(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Location getLocation(GetLocationRequest request) { + return getLocationCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
+   *   ApiFuture future =
+   *       confidentialComputingClient.getLocationCallable().futureCall(request);
+   *   // Do something.
+   *   Location response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getLocationCallable() { + return stub.getLocationCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListLocationsPagedResponse + extends AbstractPagedListResponse< + ListLocationsRequest, + ListLocationsResponse, + Location, + ListLocationsPage, + ListLocationsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + input -> new ListLocationsPagedResponse(input), + MoreExecutors.directExecutor()); + } + + private ListLocationsPagedResponse(ListLocationsPage page) { + super(page, ListLocationsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListLocationsPage + extends AbstractPage< + ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> { + + private ListLocationsPage( + PageContext context, + ListLocationsResponse response) { + super(context, response); + } + + private static ListLocationsPage createEmptyPage() { + return new ListLocationsPage(null, null); + } + + @Override + protected ListLocationsPage createPage( + PageContext context, + ListLocationsResponse response) { + return new ListLocationsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListLocationsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListLocationsRequest, + ListLocationsResponse, + Location, + ListLocationsPage, + ListLocationsFixedSizeCollection> { + + private ListLocationsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListLocationsFixedSizeCollection createEmptyCollection() { + return new ListLocationsFixedSizeCollection(null, 0); + } + + @Override + protected ListLocationsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListLocationsFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingSettings.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingSettings.java new file mode 100644 index 000000000000..31d0c352a8fc --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingSettings.java @@ -0,0 +1,250 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1; + +import static com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.confidentialcomputing.v1.stub.ConfidentialComputingStubSettings; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link ConfidentialComputingClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (confidentialcomputing.googleapis.com) and default port (443) + * are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *

For example, to set the total timeout of createChallenge to 30 seconds: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * ConfidentialComputingSettings.Builder confidentialComputingSettingsBuilder =
+ *     ConfidentialComputingSettings.newBuilder();
+ * confidentialComputingSettingsBuilder
+ *     .createChallengeSettings()
+ *     .setRetrySettings(
+ *         confidentialComputingSettingsBuilder
+ *             .createChallengeSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * ConfidentialComputingSettings confidentialComputingSettings =
+ *     confidentialComputingSettingsBuilder.build();
+ * }
+ */ +@Generated("by gapic-generator-java") +public class ConfidentialComputingSettings extends ClientSettings { + + /** Returns the object with the settings used for calls to createChallenge. */ + public UnaryCallSettings createChallengeSettings() { + return ((ConfidentialComputingStubSettings) getStubSettings()).createChallengeSettings(); + } + + /** Returns the object with the settings used for calls to verifyAttestation. */ + public UnaryCallSettings + verifyAttestationSettings() { + return ((ConfidentialComputingStubSettings) getStubSettings()).verifyAttestationSettings(); + } + + /** Returns the object with the settings used for calls to listLocations. */ + public PagedCallSettings + listLocationsSettings() { + return ((ConfidentialComputingStubSettings) getStubSettings()).listLocationsSettings(); + } + + /** Returns the object with the settings used for calls to getLocation. */ + public UnaryCallSettings getLocationSettings() { + return ((ConfidentialComputingStubSettings) getStubSettings()).getLocationSettings(); + } + + public static final ConfidentialComputingSettings create(ConfidentialComputingStubSettings stub) + throws IOException { + return new ConfidentialComputingSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return ConfidentialComputingStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return ConfidentialComputingStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return ConfidentialComputingStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return ConfidentialComputingStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return ConfidentialComputingStubSettings.defaultGrpcTransportProviderBuilder(); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ConfidentialComputingStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return ConfidentialComputingStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ConfidentialComputingStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected ConfidentialComputingSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for ConfidentialComputingSettings. */ + public static class Builder + extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(ConfidentialComputingStubSettings.newBuilder(clientContext)); + } + + protected Builder(ConfidentialComputingSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(ConfidentialComputingStubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(ConfidentialComputingStubSettings.newBuilder()); + } + + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ConfidentialComputingStubSettings.newHttpJsonBuilder()); + } + + public ConfidentialComputingStubSettings.Builder getStubSettingsBuilder() { + return ((ConfidentialComputingStubSettings.Builder) getStubSettings()); + } + + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to createChallenge. */ + public UnaryCallSettings.Builder createChallengeSettings() { + return getStubSettingsBuilder().createChallengeSettings(); + } + + /** Returns the builder for the settings used for calls to verifyAttestation. */ + public UnaryCallSettings.Builder + verifyAttestationSettings() { + return getStubSettingsBuilder().verifyAttestationSettings(); + } + + /** Returns the builder for the settings used for calls to listLocations. */ + public PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings() { + return getStubSettingsBuilder().listLocationsSettings(); + } + + /** Returns the builder for the settings used for calls to getLocation. */ + public UnaryCallSettings.Builder getLocationSettings() { + return getStubSettingsBuilder().getLocationSettings(); + } + + @Override + public ConfidentialComputingSettings build() throws IOException { + return new ConfidentialComputingSettings(this); + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/gapic_metadata.json b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/gapic_metadata.json new file mode 100644 index 000000000000..cfa27aeced6b --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/gapic_metadata.json @@ -0,0 +1,30 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "java", + "protoPackage": "google.cloud.confidentialcomputing.v1", + "libraryPackage": "com.google.cloud.confidentialcomputing.v1", + "services": { + "ConfidentialComputing": { + "clients": { + "grpc": { + "libraryClient": "ConfidentialComputingClient", + "rpcs": { + "CreateChallenge": { + "methods": ["createChallenge", "createChallenge", "createChallenge", "createChallengeCallable"] + }, + "GetLocation": { + "methods": ["getLocation", "getLocationCallable"] + }, + "ListLocations": { + "methods": ["listLocations", "listLocationsPagedCallable", "listLocationsCallable"] + }, + "VerifyAttestation": { + "methods": ["verifyAttestation", "verifyAttestationCallable"] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/package-info.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/package-info.java new file mode 100644 index 000000000000..1801cebd0eec --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/package-info.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +/** + * A client to Confidential Computing API + * + *

The interfaces provided are listed below, along with usage samples. + * + *

======================= ConfidentialComputingClient ======================= + * + *

Service Description: Service describing handlers for resources + * + *

Sample for ConfidentialComputingClient: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (ConfidentialComputingClient confidentialComputingClient =
+ *     ConfidentialComputingClient.create()) {
+ *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ *   Challenge challenge = Challenge.newBuilder().build();
+ *   Challenge response = confidentialComputingClient.createChallenge(parent, challenge);
+ * }
+ * }
+ */ +@Generated("by gapic-generator-java") +package com.google.cloud.confidentialcomputing.v1; + +import javax.annotation.Generated; diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/ConfidentialComputingStub.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/ConfidentialComputingStub.java new file mode 100644 index 000000000000..263781562d7e --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/ConfidentialComputingStub.java @@ -0,0 +1,66 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.stub; + +import static com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.confidentialcomputing.v1.Challenge; +import com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest; +import com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest; +import com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Base stub class for the ConfidentialComputing service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public abstract class ConfidentialComputingStub implements BackgroundResource { + + public UnaryCallable createChallengeCallable() { + throw new UnsupportedOperationException("Not implemented: createChallengeCallable()"); + } + + public UnaryCallable + verifyAttestationCallable() { + throw new UnsupportedOperationException("Not implemented: verifyAttestationCallable()"); + } + + public UnaryCallable + listLocationsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listLocationsPagedCallable()"); + } + + public UnaryCallable listLocationsCallable() { + throw new UnsupportedOperationException("Not implemented: listLocationsCallable()"); + } + + public UnaryCallable getLocationCallable() { + throw new UnsupportedOperationException("Not implemented: getLocationCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/ConfidentialComputingStubSettings.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/ConfidentialComputingStubSettings.java new file mode 100644 index 000000000000..ca44c21cd5dd --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/ConfidentialComputingStubSettings.java @@ -0,0 +1,487 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.stub; + +import static com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.confidentialcomputing.v1.Challenge; +import com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest; +import com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest; +import com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link ConfidentialComputingStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (confidentialcomputing.googleapis.com) and default port (443) + * are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *

For example, to set the total timeout of createChallenge to 30 seconds: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * ConfidentialComputingStubSettings.Builder confidentialComputingSettingsBuilder =
+ *     ConfidentialComputingStubSettings.newBuilder();
+ * confidentialComputingSettingsBuilder
+ *     .createChallengeSettings()
+ *     .setRetrySettings(
+ *         confidentialComputingSettingsBuilder
+ *             .createChallengeSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * ConfidentialComputingStubSettings confidentialComputingSettings =
+ *     confidentialComputingSettingsBuilder.build();
+ * }
+ */ +@Generated("by gapic-generator-java") +public class ConfidentialComputingStubSettings + extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); + + private final UnaryCallSettings createChallengeSettings; + private final UnaryCallSettings + verifyAttestationSettings; + private final PagedCallSettings< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings; + private final UnaryCallSettings getLocationSettings; + + private static final PagedListDescriptor + LIST_LOCATIONS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListLocationsRequest injectToken(ListLocationsRequest payload, String token) { + return ListLocationsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListLocationsRequest injectPageSize(ListLocationsRequest payload, int pageSize) { + return ListLocationsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListLocationsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListLocationsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListLocationsResponse payload) { + return payload.getLocationsList() == null + ? ImmutableList.of() + : payload.getLocationsList(); + } + }; + + private static final PagedListResponseFactory< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + LIST_LOCATIONS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListLocationsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_LOCATIONS_PAGE_STR_DESC, request, context); + return ListLocationsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Returns the object with the settings used for calls to createChallenge. */ + public UnaryCallSettings createChallengeSettings() { + return createChallengeSettings; + } + + /** Returns the object with the settings used for calls to verifyAttestation. */ + public UnaryCallSettings + verifyAttestationSettings() { + return verifyAttestationSettings; + } + + /** Returns the object with the settings used for calls to listLocations. */ + public PagedCallSettings + listLocationsSettings() { + return listLocationsSettings; + } + + /** Returns the object with the settings used for calls to getLocation. */ + public UnaryCallSettings getLocationSettings() { + return getLocationSettings; + } + + public ConfidentialComputingStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcConfidentialComputingStub.create(this); + } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonConfidentialComputingStub.create(this); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "confidentialcomputing.googleapis.com:443"; + } + + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "confidentialcomputing.mtls.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder() + .setScopesToApply(DEFAULT_SERVICE_SCOPES) + .setUseJwtAccessWithScope(true); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder() + .setMaxInboundMessageSize(Integer.MAX_VALUE); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ConfidentialComputingStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ConfidentialComputingStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ConfidentialComputingStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected ConfidentialComputingStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + createChallengeSettings = settingsBuilder.createChallengeSettings().build(); + verifyAttestationSettings = settingsBuilder.verifyAttestationSettings().build(); + listLocationsSettings = settingsBuilder.listLocationsSettings().build(); + getLocationSettings = settingsBuilder.getLocationSettings().build(); + } + + /** Builder for ConfidentialComputingStubSettings. */ + public static class Builder + extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final UnaryCallSettings.Builder + createChallengeSettings; + private final UnaryCallSettings.Builder + verifyAttestationSettings; + private final PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings; + private final UnaryCallSettings.Builder getLocationSettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "retry_policy_0_codes", + ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.UNAVAILABLE))); + definitions.put( + "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(1000L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(60000L)) + .setTotalTimeout(Duration.ofMillis(60000L)) + .build(); + definitions.put("retry_policy_0_params", settings); + settings = + RetrySettings.newBuilder() + .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(60000L)) + .setTotalTimeout(Duration.ofMillis(60000L)) + .build(); + definitions.put("no_retry_1_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + createChallengeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + verifyAttestationSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listLocationsSettings = PagedCallSettings.newBuilder(LIST_LOCATIONS_PAGE_STR_FACT); + getLocationSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + createChallengeSettings, + verifyAttestationSettings, + listLocationsSettings, + getLocationSettings); + initDefaults(this); + } + + protected Builder(ConfidentialComputingStubSettings settings) { + super(settings); + + createChallengeSettings = settings.createChallengeSettings.toBuilder(); + verifyAttestationSettings = settings.verifyAttestationSettings.toBuilder(); + listLocationsSettings = settings.listLocationsSettings.toBuilder(); + getLocationSettings = settings.getLocationSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + createChallengeSettings, + verifyAttestationSettings, + listLocationsSettings, + getLocationSettings); + } + + private static Builder createDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + builder + .createChallengeSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .verifyAttestationSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .listLocationsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + + builder + .getLocationSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + + return builder; + } + + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to createChallenge. */ + public UnaryCallSettings.Builder createChallengeSettings() { + return createChallengeSettings; + } + + /** Returns the builder for the settings used for calls to verifyAttestation. */ + public UnaryCallSettings.Builder + verifyAttestationSettings() { + return verifyAttestationSettings; + } + + /** Returns the builder for the settings used for calls to listLocations. */ + public PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings() { + return listLocationsSettings; + } + + /** Returns the builder for the settings used for calls to getLocation. */ + public UnaryCallSettings.Builder getLocationSettings() { + return getLocationSettings; + } + + @Override + public ConfidentialComputingStubSettings build() throws IOException { + return new ConfidentialComputingStubSettings(this); + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/GrpcConfidentialComputingCallableFactory.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/GrpcConfidentialComputingCallableFactory.java new file mode 100644 index 000000000000..672d649eb7c3 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/GrpcConfidentialComputingCallableFactory.java @@ -0,0 +1,113 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.stub; + +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC callable factory implementation for the ConfidentialComputing service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +public class GrpcConfidentialComputingCallableFactory implements GrpcStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, callSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/GrpcConfidentialComputingStub.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/GrpcConfidentialComputingStub.java new file mode 100644 index 000000000000..a9779dfa3523 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/GrpcConfidentialComputingStub.java @@ -0,0 +1,275 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.stub; + +import static com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.confidentialcomputing.v1.Challenge; +import com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest; +import com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest; +import com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.collect.ImmutableMap; +import com.google.longrunning.stub.GrpcOperationsStub; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC stub implementation for the ConfidentialComputing service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class GrpcConfidentialComputingStub extends ConfidentialComputingStub { + private static final MethodDescriptor + createChallengeMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.cloud.confidentialcomputing.v1.ConfidentialComputing/CreateChallenge") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateChallengeRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Challenge.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + verifyAttestationMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.cloud.confidentialcomputing.v1.ConfidentialComputing/VerifyAttestation") + .setRequestMarshaller( + ProtoUtils.marshaller(VerifyAttestationRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(VerifyAttestationResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + listLocationsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.location.Locations/ListLocations") + .setRequestMarshaller( + ProtoUtils.marshaller(ListLocationsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListLocationsResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor getLocationMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.location.Locations/GetLocation") + .setRequestMarshaller(ProtoUtils.marshaller(GetLocationRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Location.getDefaultInstance())) + .build(); + + private final UnaryCallable createChallengeCallable; + private final UnaryCallable + verifyAttestationCallable; + private final UnaryCallable listLocationsCallable; + private final UnaryCallable + listLocationsPagedCallable; + private final UnaryCallable getLocationCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcConfidentialComputingStub create( + ConfidentialComputingStubSettings settings) throws IOException { + return new GrpcConfidentialComputingStub(settings, ClientContext.create(settings)); + } + + public static final GrpcConfidentialComputingStub create(ClientContext clientContext) + throws IOException { + return new GrpcConfidentialComputingStub( + ConfidentialComputingStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcConfidentialComputingStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcConfidentialComputingStub( + ConfidentialComputingStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcConfidentialComputingStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected GrpcConfidentialComputingStub( + ConfidentialComputingStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new GrpcConfidentialComputingCallableFactory()); + } + + /** + * Constructs an instance of GrpcConfidentialComputingStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected GrpcConfidentialComputingStub( + ConfidentialComputingStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings createChallengeTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createChallengeMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + }) + .build(); + GrpcCallSettings + verifyAttestationTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(verifyAttestationMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("challenge", String.valueOf(request.getChallenge())); + return params.build(); + }) + .build(); + GrpcCallSettings listLocationsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listLocationsMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + }) + .build(); + GrpcCallSettings getLocationTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getLocationMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + }) + .build(); + + this.createChallengeCallable = + callableFactory.createUnaryCallable( + createChallengeTransportSettings, settings.createChallengeSettings(), clientContext); + this.verifyAttestationCallable = + callableFactory.createUnaryCallable( + verifyAttestationTransportSettings, + settings.verifyAttestationSettings(), + clientContext); + this.listLocationsCallable = + callableFactory.createUnaryCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.listLocationsPagedCallable = + callableFactory.createPagedCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.getLocationCallable = + callableFactory.createUnaryCallable( + getLocationTransportSettings, settings.getLocationSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + @Override + public UnaryCallable createChallengeCallable() { + return createChallengeCallable; + } + + @Override + public UnaryCallable + verifyAttestationCallable() { + return verifyAttestationCallable; + } + + @Override + public UnaryCallable listLocationsCallable() { + return listLocationsCallable; + } + + @Override + public UnaryCallable + listLocationsPagedCallable() { + return listLocationsPagedCallable; + } + + @Override + public UnaryCallable getLocationCallable() { + return getLocationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/HttpJsonConfidentialComputingCallableFactory.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/HttpJsonConfidentialComputingCallableFactory.java new file mode 100644 index 000000000000..cc7ae7db01ad --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/HttpJsonConfidentialComputingCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ConfidentialComputing service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonConfidentialComputingCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/HttpJsonConfidentialComputingStub.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/HttpJsonConfidentialComputingStub.java new file mode 100644 index 000000000000..e366027ed586 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1/stub/HttpJsonConfidentialComputingStub.java @@ -0,0 +1,374 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.stub; + +import static com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.confidentialcomputing.v1.Challenge; +import com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest; +import com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest; +import com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ConfidentialComputing service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonConfidentialComputingStub extends ConfidentialComputingStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createChallengeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.confidentialcomputing.v1.ConfidentialComputing/CreateChallenge") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/challenges", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("challenge", request.getChallenge(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Challenge.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + verifyAttestationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.confidentialcomputing.v1.ConfidentialComputing/VerifyAttestation") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{challenge=projects/*/locations/*/challenges/*}:verifyAttestation", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "challenge", request.getChallenge()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearChallenge().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(VerifyAttestationResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listLocationsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.location.Locations/ListLocations") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*}/locations", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListLocationsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getLocationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.location.Locations/GetLocation") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Location.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createChallengeCallable; + private final UnaryCallable + verifyAttestationCallable; + private final UnaryCallable listLocationsCallable; + private final UnaryCallable + listLocationsPagedCallable; + private final UnaryCallable getLocationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonConfidentialComputingStub create( + ConfidentialComputingStubSettings settings) throws IOException { + return new HttpJsonConfidentialComputingStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonConfidentialComputingStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonConfidentialComputingStub( + ConfidentialComputingStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonConfidentialComputingStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonConfidentialComputingStub( + ConfidentialComputingStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonConfidentialComputingStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonConfidentialComputingStub( + ConfidentialComputingStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonConfidentialComputingCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonConfidentialComputingStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonConfidentialComputingStub( + ConfidentialComputingStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createChallengeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createChallengeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + verifyAttestationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(verifyAttestationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listLocationsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listLocationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getLocationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getLocationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createChallengeCallable = + callableFactory.createUnaryCallable( + createChallengeTransportSettings, settings.createChallengeSettings(), clientContext); + this.verifyAttestationCallable = + callableFactory.createUnaryCallable( + verifyAttestationTransportSettings, + settings.verifyAttestationSettings(), + clientContext); + this.listLocationsCallable = + callableFactory.createUnaryCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.listLocationsPagedCallable = + callableFactory.createPagedCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.getLocationCallable = + callableFactory.createUnaryCallable( + getLocationTransportSettings, settings.getLocationSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createChallengeMethodDescriptor); + methodDescriptors.add(verifyAttestationMethodDescriptor); + methodDescriptors.add(listLocationsMethodDescriptor); + methodDescriptors.add(getLocationMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createChallengeCallable() { + return createChallengeCallable; + } + + @Override + public UnaryCallable + verifyAttestationCallable() { + return verifyAttestationCallable; + } + + @Override + public UnaryCallable listLocationsCallable() { + return listLocationsCallable; + } + + @Override + public UnaryCallable + listLocationsPagedCallable() { + return listLocationsPagedCallable; + } + + @Override + public UnaryCallable getLocationCallable() { + return getLocationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingClient.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingClient.java new file mode 100644 index 000000000000..2b55bc174575 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingClient.java @@ -0,0 +1,643 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.confidentialcomputing.v1alpha1.stub.ConfidentialComputingStub; +import com.google.cloud.confidentialcomputing.v1alpha1.stub.ConfidentialComputingStubSettings; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.util.concurrent.MoreExecutors; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: Service describing handlers for resources + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (ConfidentialComputingClient confidentialComputingClient =
+ *     ConfidentialComputingClient.create()) {
+ *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ *   Challenge challenge = Challenge.newBuilder().build();
+ *   Challenge response = confidentialComputingClient.createChallenge(parent, challenge);
+ * }
+ * }
+ * + *

Note: close() needs to be called on the ConfidentialComputingClient object to clean up + * resources such as threads. In the example above, try-with-resources is used, which automatically + * calls close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of ConfidentialComputingSettings + * to create(). For example: + * + *

To customize credentials: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * ConfidentialComputingSettings confidentialComputingSettings =
+ *     ConfidentialComputingSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * ConfidentialComputingClient confidentialComputingClient =
+ *     ConfidentialComputingClient.create(confidentialComputingSettings);
+ * }
+ * + *

To customize the endpoint: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * ConfidentialComputingSettings confidentialComputingSettings =
+ *     ConfidentialComputingSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * ConfidentialComputingClient confidentialComputingClient =
+ *     ConfidentialComputingClient.create(confidentialComputingSettings);
+ * }
+ * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * ConfidentialComputingSettings confidentialComputingSettings =
+ *     ConfidentialComputingSettings.newHttpJsonBuilder().build();
+ * ConfidentialComputingClient confidentialComputingClient =
+ *     ConfidentialComputingClient.create(confidentialComputingSettings);
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class ConfidentialComputingClient implements BackgroundResource { + private final ConfidentialComputingSettings settings; + private final ConfidentialComputingStub stub; + + /** Constructs an instance of ConfidentialComputingClient with default settings. */ + public static final ConfidentialComputingClient create() throws IOException { + return create(ConfidentialComputingSettings.newBuilder().build()); + } + + /** + * Constructs an instance of ConfidentialComputingClient, using the given settings. The channels + * are created based on the settings passed in, or defaults for any settings that are not set. + */ + public static final ConfidentialComputingClient create(ConfidentialComputingSettings settings) + throws IOException { + return new ConfidentialComputingClient(settings); + } + + /** + * Constructs an instance of ConfidentialComputingClient, using the given stub for making calls. + * This is for advanced usage - prefer using create(ConfidentialComputingSettings). + */ + public static final ConfidentialComputingClient create(ConfidentialComputingStub stub) { + return new ConfidentialComputingClient(stub); + } + + /** + * Constructs an instance of ConfidentialComputingClient, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected ConfidentialComputingClient(ConfidentialComputingSettings settings) throws IOException { + this.settings = settings; + this.stub = ((ConfidentialComputingStubSettings) settings.getStubSettings()).createStub(); + } + + protected ConfidentialComputingClient(ConfidentialComputingStub stub) { + this.settings = null; + this.stub = stub; + } + + public final ConfidentialComputingSettings getSettings() { + return settings; + } + + public ConfidentialComputingStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new Challenge in a given project and location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   Challenge challenge = Challenge.newBuilder().build();
+   *   Challenge response = confidentialComputingClient.createChallenge(parent, challenge);
+   * }
+   * }
+ * + * @param parent Required. The resource name of the location where the Challenge will be used, in + * the format `projects/*/locations/*`. + * @param challenge Required. The Challenge to be created. Currently this field can be empty as + * all the Challenge fields are set by the server. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Challenge createChallenge(LocationName parent, Challenge challenge) { + CreateChallengeRequest request = + CreateChallengeRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setChallenge(challenge) + .build(); + return createChallenge(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new Challenge in a given project and location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   Challenge challenge = Challenge.newBuilder().build();
+   *   Challenge response = confidentialComputingClient.createChallenge(parent, challenge);
+   * }
+   * }
+ * + * @param parent Required. The resource name of the location where the Challenge will be used, in + * the format `projects/*/locations/*`. + * @param challenge Required. The Challenge to be created. Currently this field can be empty as + * all the Challenge fields are set by the server. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Challenge createChallenge(String parent, Challenge challenge) { + CreateChallengeRequest request = + CreateChallengeRequest.newBuilder().setParent(parent).setChallenge(challenge).build(); + return createChallenge(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new Challenge in a given project and location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   CreateChallengeRequest request =
+   *       CreateChallengeRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setChallenge(Challenge.newBuilder().build())
+   *           .build();
+   *   Challenge response = confidentialComputingClient.createChallenge(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Challenge createChallenge(CreateChallengeRequest request) { + return createChallengeCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new Challenge in a given project and location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   CreateChallengeRequest request =
+   *       CreateChallengeRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setChallenge(Challenge.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       confidentialComputingClient.createChallengeCallable().futureCall(request);
+   *   // Do something.
+   *   Challenge response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable createChallengeCallable() { + return stub.createChallengeCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Verifies the provided attestation info, returning a signed OIDC token. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   VerifyAttestationRequest request =
+   *       VerifyAttestationRequest.newBuilder()
+   *           .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString())
+   *           .setGcpCredentials(GcpCredentials.newBuilder().build())
+   *           .setTpmAttestation(TpmAttestation.newBuilder().build())
+   *           .build();
+   *   VerifyAttestationResponse response = confidentialComputingClient.verifyAttestation(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final VerifyAttestationResponse verifyAttestation(VerifyAttestationRequest request) { + return verifyAttestationCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Verifies the provided attestation info, returning a signed OIDC token. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   VerifyAttestationRequest request =
+   *       VerifyAttestationRequest.newBuilder()
+   *           .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString())
+   *           .setGcpCredentials(GcpCredentials.newBuilder().build())
+   *           .setTpmAttestation(TpmAttestation.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       confidentialComputingClient.verifyAttestationCallable().futureCall(request);
+   *   // Do something.
+   *   VerifyAttestationResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + verifyAttestationCallable() { + return stub.verifyAttestationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Location element : confidentialComputingClient.listLocations(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) { + return listLocationsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       confidentialComputingClient.listLocationsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Location element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listLocationsPagedCallable() { + return stub.listLocationsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   while (true) {
+   *     ListLocationsResponse response =
+   *         confidentialComputingClient.listLocationsCallable().call(request);
+   *     for (Location element : response.getLocationsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable listLocationsCallable() { + return stub.listLocationsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
+   *   Location response = confidentialComputingClient.getLocation(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Location getLocation(GetLocationRequest request) { + return getLocationCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (ConfidentialComputingClient confidentialComputingClient =
+   *     ConfidentialComputingClient.create()) {
+   *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
+   *   ApiFuture future =
+   *       confidentialComputingClient.getLocationCallable().futureCall(request);
+   *   // Do something.
+   *   Location response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getLocationCallable() { + return stub.getLocationCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListLocationsPagedResponse + extends AbstractPagedListResponse< + ListLocationsRequest, + ListLocationsResponse, + Location, + ListLocationsPage, + ListLocationsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + input -> new ListLocationsPagedResponse(input), + MoreExecutors.directExecutor()); + } + + private ListLocationsPagedResponse(ListLocationsPage page) { + super(page, ListLocationsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListLocationsPage + extends AbstractPage< + ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> { + + private ListLocationsPage( + PageContext context, + ListLocationsResponse response) { + super(context, response); + } + + private static ListLocationsPage createEmptyPage() { + return new ListLocationsPage(null, null); + } + + @Override + protected ListLocationsPage createPage( + PageContext context, + ListLocationsResponse response) { + return new ListLocationsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListLocationsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListLocationsRequest, + ListLocationsResponse, + Location, + ListLocationsPage, + ListLocationsFixedSizeCollection> { + + private ListLocationsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListLocationsFixedSizeCollection createEmptyCollection() { + return new ListLocationsFixedSizeCollection(null, 0); + } + + @Override + protected ListLocationsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListLocationsFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingSettings.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingSettings.java new file mode 100644 index 000000000000..fc4ce3223447 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingSettings.java @@ -0,0 +1,251 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1; + +import static com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.confidentialcomputing.v1alpha1.stub.ConfidentialComputingStubSettings; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link ConfidentialComputingClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (confidentialcomputing.googleapis.com) and default port (443) + * are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *

For example, to set the total timeout of createChallenge to 30 seconds: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * ConfidentialComputingSettings.Builder confidentialComputingSettingsBuilder =
+ *     ConfidentialComputingSettings.newBuilder();
+ * confidentialComputingSettingsBuilder
+ *     .createChallengeSettings()
+ *     .setRetrySettings(
+ *         confidentialComputingSettingsBuilder
+ *             .createChallengeSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * ConfidentialComputingSettings confidentialComputingSettings =
+ *     confidentialComputingSettingsBuilder.build();
+ * }
+ */ +@BetaApi +@Generated("by gapic-generator-java") +public class ConfidentialComputingSettings extends ClientSettings { + + /** Returns the object with the settings used for calls to createChallenge. */ + public UnaryCallSettings createChallengeSettings() { + return ((ConfidentialComputingStubSettings) getStubSettings()).createChallengeSettings(); + } + + /** Returns the object with the settings used for calls to verifyAttestation. */ + public UnaryCallSettings + verifyAttestationSettings() { + return ((ConfidentialComputingStubSettings) getStubSettings()).verifyAttestationSettings(); + } + + /** Returns the object with the settings used for calls to listLocations. */ + public PagedCallSettings + listLocationsSettings() { + return ((ConfidentialComputingStubSettings) getStubSettings()).listLocationsSettings(); + } + + /** Returns the object with the settings used for calls to getLocation. */ + public UnaryCallSettings getLocationSettings() { + return ((ConfidentialComputingStubSettings) getStubSettings()).getLocationSettings(); + } + + public static final ConfidentialComputingSettings create(ConfidentialComputingStubSettings stub) + throws IOException { + return new ConfidentialComputingSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return ConfidentialComputingStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return ConfidentialComputingStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return ConfidentialComputingStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return ConfidentialComputingStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return ConfidentialComputingStubSettings.defaultGrpcTransportProviderBuilder(); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ConfidentialComputingStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return ConfidentialComputingStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ConfidentialComputingStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected ConfidentialComputingSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for ConfidentialComputingSettings. */ + public static class Builder + extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(ConfidentialComputingStubSettings.newBuilder(clientContext)); + } + + protected Builder(ConfidentialComputingSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(ConfidentialComputingStubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(ConfidentialComputingStubSettings.newBuilder()); + } + + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ConfidentialComputingStubSettings.newHttpJsonBuilder()); + } + + public ConfidentialComputingStubSettings.Builder getStubSettingsBuilder() { + return ((ConfidentialComputingStubSettings.Builder) getStubSettings()); + } + + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to createChallenge. */ + public UnaryCallSettings.Builder createChallengeSettings() { + return getStubSettingsBuilder().createChallengeSettings(); + } + + /** Returns the builder for the settings used for calls to verifyAttestation. */ + public UnaryCallSettings.Builder + verifyAttestationSettings() { + return getStubSettingsBuilder().verifyAttestationSettings(); + } + + /** Returns the builder for the settings used for calls to listLocations. */ + public PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings() { + return getStubSettingsBuilder().listLocationsSettings(); + } + + /** Returns the builder for the settings used for calls to getLocation. */ + public UnaryCallSettings.Builder getLocationSettings() { + return getStubSettingsBuilder().getLocationSettings(); + } + + @Override + public ConfidentialComputingSettings build() throws IOException { + return new ConfidentialComputingSettings(this); + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/gapic_metadata.json b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/gapic_metadata.json new file mode 100644 index 000000000000..1bb712340638 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/gapic_metadata.json @@ -0,0 +1,30 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "java", + "protoPackage": "google.cloud.confidentialcomputing.v1alpha1", + "libraryPackage": "com.google.cloud.confidentialcomputing.v1alpha1", + "services": { + "ConfidentialComputing": { + "clients": { + "grpc": { + "libraryClient": "ConfidentialComputingClient", + "rpcs": { + "CreateChallenge": { + "methods": ["createChallenge", "createChallenge", "createChallenge", "createChallengeCallable"] + }, + "GetLocation": { + "methods": ["getLocation", "getLocationCallable"] + }, + "ListLocations": { + "methods": ["listLocations", "listLocationsPagedCallable", "listLocationsCallable"] + }, + "VerifyAttestation": { + "methods": ["verifyAttestation", "verifyAttestationCallable"] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/package-info.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/package-info.java new file mode 100644 index 000000000000..626e583c0383 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/package-info.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +/** + * A client to Confidential Computing API + * + *

The interfaces provided are listed below, along with usage samples. + * + *

======================= ConfidentialComputingClient ======================= + * + *

Service Description: Service describing handlers for resources + * + *

Sample for ConfidentialComputingClient: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (ConfidentialComputingClient confidentialComputingClient =
+ *     ConfidentialComputingClient.create()) {
+ *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ *   Challenge challenge = Challenge.newBuilder().build();
+ *   Challenge response = confidentialComputingClient.createChallenge(parent, challenge);
+ * }
+ * }
+ */ +@Generated("by gapic-generator-java") +package com.google.cloud.confidentialcomputing.v1alpha1; + +import javax.annotation.Generated; diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/ConfidentialComputingStub.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/ConfidentialComputingStub.java new file mode 100644 index 000000000000..eca75ca3900f --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/ConfidentialComputingStub.java @@ -0,0 +1,68 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.stub; + +import static com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.confidentialcomputing.v1alpha1.Challenge; +import com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest; +import com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest; +import com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Base stub class for the ConfidentialComputing service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public abstract class ConfidentialComputingStub implements BackgroundResource { + + public UnaryCallable createChallengeCallable() { + throw new UnsupportedOperationException("Not implemented: createChallengeCallable()"); + } + + public UnaryCallable + verifyAttestationCallable() { + throw new UnsupportedOperationException("Not implemented: verifyAttestationCallable()"); + } + + public UnaryCallable + listLocationsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listLocationsPagedCallable()"); + } + + public UnaryCallable listLocationsCallable() { + throw new UnsupportedOperationException("Not implemented: listLocationsCallable()"); + } + + public UnaryCallable getLocationCallable() { + throw new UnsupportedOperationException("Not implemented: getLocationCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/ConfidentialComputingStubSettings.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/ConfidentialComputingStubSettings.java new file mode 100644 index 000000000000..704227905ddb --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/ConfidentialComputingStubSettings.java @@ -0,0 +1,488 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.stub; + +import static com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.confidentialcomputing.v1alpha1.Challenge; +import com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest; +import com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest; +import com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link ConfidentialComputingStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (confidentialcomputing.googleapis.com) and default port (443) + * are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *

For example, to set the total timeout of createChallenge to 30 seconds: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * ConfidentialComputingStubSettings.Builder confidentialComputingSettingsBuilder =
+ *     ConfidentialComputingStubSettings.newBuilder();
+ * confidentialComputingSettingsBuilder
+ *     .createChallengeSettings()
+ *     .setRetrySettings(
+ *         confidentialComputingSettingsBuilder
+ *             .createChallengeSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * ConfidentialComputingStubSettings confidentialComputingSettings =
+ *     confidentialComputingSettingsBuilder.build();
+ * }
+ */ +@BetaApi +@Generated("by gapic-generator-java") +public class ConfidentialComputingStubSettings + extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); + + private final UnaryCallSettings createChallengeSettings; + private final UnaryCallSettings + verifyAttestationSettings; + private final PagedCallSettings< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings; + private final UnaryCallSettings getLocationSettings; + + private static final PagedListDescriptor + LIST_LOCATIONS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListLocationsRequest injectToken(ListLocationsRequest payload, String token) { + return ListLocationsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListLocationsRequest injectPageSize(ListLocationsRequest payload, int pageSize) { + return ListLocationsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListLocationsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListLocationsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListLocationsResponse payload) { + return payload.getLocationsList() == null + ? ImmutableList.of() + : payload.getLocationsList(); + } + }; + + private static final PagedListResponseFactory< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + LIST_LOCATIONS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListLocationsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_LOCATIONS_PAGE_STR_DESC, request, context); + return ListLocationsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Returns the object with the settings used for calls to createChallenge. */ + public UnaryCallSettings createChallengeSettings() { + return createChallengeSettings; + } + + /** Returns the object with the settings used for calls to verifyAttestation. */ + public UnaryCallSettings + verifyAttestationSettings() { + return verifyAttestationSettings; + } + + /** Returns the object with the settings used for calls to listLocations. */ + public PagedCallSettings + listLocationsSettings() { + return listLocationsSettings; + } + + /** Returns the object with the settings used for calls to getLocation. */ + public UnaryCallSettings getLocationSettings() { + return getLocationSettings; + } + + public ConfidentialComputingStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcConfidentialComputingStub.create(this); + } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonConfidentialComputingStub.create(this); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "confidentialcomputing.googleapis.com:443"; + } + + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "confidentialcomputing.mtls.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder() + .setScopesToApply(DEFAULT_SERVICE_SCOPES) + .setUseJwtAccessWithScope(true); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder() + .setMaxInboundMessageSize(Integer.MAX_VALUE); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ConfidentialComputingStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ConfidentialComputingStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ConfidentialComputingStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected ConfidentialComputingStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + createChallengeSettings = settingsBuilder.createChallengeSettings().build(); + verifyAttestationSettings = settingsBuilder.verifyAttestationSettings().build(); + listLocationsSettings = settingsBuilder.listLocationsSettings().build(); + getLocationSettings = settingsBuilder.getLocationSettings().build(); + } + + /** Builder for ConfidentialComputingStubSettings. */ + public static class Builder + extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final UnaryCallSettings.Builder + createChallengeSettings; + private final UnaryCallSettings.Builder + verifyAttestationSettings; + private final PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings; + private final UnaryCallSettings.Builder getLocationSettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "retry_policy_0_codes", + ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.UNAVAILABLE))); + definitions.put( + "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(1000L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(60000L)) + .setTotalTimeout(Duration.ofMillis(60000L)) + .build(); + definitions.put("retry_policy_0_params", settings); + settings = + RetrySettings.newBuilder() + .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(60000L)) + .setTotalTimeout(Duration.ofMillis(60000L)) + .build(); + definitions.put("no_retry_1_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + createChallengeSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + verifyAttestationSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listLocationsSettings = PagedCallSettings.newBuilder(LIST_LOCATIONS_PAGE_STR_FACT); + getLocationSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + createChallengeSettings, + verifyAttestationSettings, + listLocationsSettings, + getLocationSettings); + initDefaults(this); + } + + protected Builder(ConfidentialComputingStubSettings settings) { + super(settings); + + createChallengeSettings = settings.createChallengeSettings.toBuilder(); + verifyAttestationSettings = settings.verifyAttestationSettings.toBuilder(); + listLocationsSettings = settings.listLocationsSettings.toBuilder(); + getLocationSettings = settings.getLocationSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + createChallengeSettings, + verifyAttestationSettings, + listLocationsSettings, + getLocationSettings); + } + + private static Builder createDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + builder + .createChallengeSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .verifyAttestationSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .listLocationsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + + builder + .getLocationSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + + return builder; + } + + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to createChallenge. */ + public UnaryCallSettings.Builder createChallengeSettings() { + return createChallengeSettings; + } + + /** Returns the builder for the settings used for calls to verifyAttestation. */ + public UnaryCallSettings.Builder + verifyAttestationSettings() { + return verifyAttestationSettings; + } + + /** Returns the builder for the settings used for calls to listLocations. */ + public PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings() { + return listLocationsSettings; + } + + /** Returns the builder for the settings used for calls to getLocation. */ + public UnaryCallSettings.Builder getLocationSettings() { + return getLocationSettings; + } + + @Override + public ConfidentialComputingStubSettings build() throws IOException { + return new ConfidentialComputingStubSettings(this); + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/GrpcConfidentialComputingCallableFactory.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/GrpcConfidentialComputingCallableFactory.java new file mode 100644 index 000000000000..2c489c63638e --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/GrpcConfidentialComputingCallableFactory.java @@ -0,0 +1,115 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC callable factory implementation for the ConfidentialComputing service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class GrpcConfidentialComputingCallableFactory implements GrpcStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, callSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/GrpcConfidentialComputingStub.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/GrpcConfidentialComputingStub.java new file mode 100644 index 000000000000..8025a02a9b0c --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/GrpcConfidentialComputingStub.java @@ -0,0 +1,277 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.stub; + +import static com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.confidentialcomputing.v1alpha1.Challenge; +import com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest; +import com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest; +import com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.collect.ImmutableMap; +import com.google.longrunning.stub.GrpcOperationsStub; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC stub implementation for the ConfidentialComputing service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class GrpcConfidentialComputingStub extends ConfidentialComputingStub { + private static final MethodDescriptor + createChallengeMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputing/CreateChallenge") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateChallengeRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Challenge.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + verifyAttestationMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputing/VerifyAttestation") + .setRequestMarshaller( + ProtoUtils.marshaller(VerifyAttestationRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(VerifyAttestationResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + listLocationsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.location.Locations/ListLocations") + .setRequestMarshaller( + ProtoUtils.marshaller(ListLocationsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListLocationsResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor getLocationMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.location.Locations/GetLocation") + .setRequestMarshaller(ProtoUtils.marshaller(GetLocationRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Location.getDefaultInstance())) + .build(); + + private final UnaryCallable createChallengeCallable; + private final UnaryCallable + verifyAttestationCallable; + private final UnaryCallable listLocationsCallable; + private final UnaryCallable + listLocationsPagedCallable; + private final UnaryCallable getLocationCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcConfidentialComputingStub create( + ConfidentialComputingStubSettings settings) throws IOException { + return new GrpcConfidentialComputingStub(settings, ClientContext.create(settings)); + } + + public static final GrpcConfidentialComputingStub create(ClientContext clientContext) + throws IOException { + return new GrpcConfidentialComputingStub( + ConfidentialComputingStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcConfidentialComputingStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcConfidentialComputingStub( + ConfidentialComputingStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcConfidentialComputingStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected GrpcConfidentialComputingStub( + ConfidentialComputingStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new GrpcConfidentialComputingCallableFactory()); + } + + /** + * Constructs an instance of GrpcConfidentialComputingStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected GrpcConfidentialComputingStub( + ConfidentialComputingStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings createChallengeTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createChallengeMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + }) + .build(); + GrpcCallSettings + verifyAttestationTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(verifyAttestationMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("challenge", String.valueOf(request.getChallenge())); + return params.build(); + }) + .build(); + GrpcCallSettings listLocationsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listLocationsMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + }) + .build(); + GrpcCallSettings getLocationTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getLocationMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + }) + .build(); + + this.createChallengeCallable = + callableFactory.createUnaryCallable( + createChallengeTransportSettings, settings.createChallengeSettings(), clientContext); + this.verifyAttestationCallable = + callableFactory.createUnaryCallable( + verifyAttestationTransportSettings, + settings.verifyAttestationSettings(), + clientContext); + this.listLocationsCallable = + callableFactory.createUnaryCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.listLocationsPagedCallable = + callableFactory.createPagedCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.getLocationCallable = + callableFactory.createUnaryCallable( + getLocationTransportSettings, settings.getLocationSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + @Override + public UnaryCallable createChallengeCallable() { + return createChallengeCallable; + } + + @Override + public UnaryCallable + verifyAttestationCallable() { + return verifyAttestationCallable; + } + + @Override + public UnaryCallable listLocationsCallable() { + return listLocationsCallable; + } + + @Override + public UnaryCallable + listLocationsPagedCallable() { + return listLocationsPagedCallable; + } + + @Override + public UnaryCallable getLocationCallable() { + return getLocationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/HttpJsonConfidentialComputingCallableFactory.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/HttpJsonConfidentialComputingCallableFactory.java new file mode 100644 index 000000000000..c2feab8eeaa3 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/HttpJsonConfidentialComputingCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ConfidentialComputing service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonConfidentialComputingCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/HttpJsonConfidentialComputingStub.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/HttpJsonConfidentialComputingStub.java new file mode 100644 index 000000000000..74f98c41d03c --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/stub/HttpJsonConfidentialComputingStub.java @@ -0,0 +1,374 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.stub; + +import static com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.confidentialcomputing.v1alpha1.Challenge; +import com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest; +import com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest; +import com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the ConfidentialComputing service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonConfidentialComputingStub extends ConfidentialComputingStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createChallengeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputing/CreateChallenge") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{parent=projects/*/locations/*}/challenges", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("challenge", request.getChallenge(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Challenge.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + verifyAttestationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputing/VerifyAttestation") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{challenge=projects/*/locations/*/challenges/*}:verifyAttestation", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "challenge", request.getChallenge()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearChallenge().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(VerifyAttestationResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listLocationsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.location.Locations/ListLocations") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{name=projects/*}/locations", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListLocationsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getLocationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.location.Locations/GetLocation") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha1/{name=projects/*/locations/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Location.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createChallengeCallable; + private final UnaryCallable + verifyAttestationCallable; + private final UnaryCallable listLocationsCallable; + private final UnaryCallable + listLocationsPagedCallable; + private final UnaryCallable getLocationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonConfidentialComputingStub create( + ConfidentialComputingStubSettings settings) throws IOException { + return new HttpJsonConfidentialComputingStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonConfidentialComputingStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonConfidentialComputingStub( + ConfidentialComputingStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonConfidentialComputingStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonConfidentialComputingStub( + ConfidentialComputingStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonConfidentialComputingStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonConfidentialComputingStub( + ConfidentialComputingStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonConfidentialComputingCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonConfidentialComputingStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonConfidentialComputingStub( + ConfidentialComputingStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createChallengeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createChallengeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + verifyAttestationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(verifyAttestationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listLocationsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listLocationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getLocationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getLocationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createChallengeCallable = + callableFactory.createUnaryCallable( + createChallengeTransportSettings, settings.createChallengeSettings(), clientContext); + this.verifyAttestationCallable = + callableFactory.createUnaryCallable( + verifyAttestationTransportSettings, + settings.verifyAttestationSettings(), + clientContext); + this.listLocationsCallable = + callableFactory.createUnaryCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.listLocationsPagedCallable = + callableFactory.createPagedCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.getLocationCallable = + callableFactory.createUnaryCallable( + getLocationTransportSettings, settings.getLocationSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createChallengeMethodDescriptor); + methodDescriptors.add(verifyAttestationMethodDescriptor); + methodDescriptors.add(listLocationsMethodDescriptor); + methodDescriptors.add(getLocationMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createChallengeCallable() { + return createChallengeCallable; + } + + @Override + public UnaryCallable + verifyAttestationCallable() { + return verifyAttestationCallable; + } + + @Override + public UnaryCallable listLocationsCallable() { + return listLocationsCallable; + } + + @Override + public UnaryCallable + listLocationsPagedCallable() { + return listLocationsPagedCallable; + } + + @Override + public UnaryCallable getLocationCallable() { + return getLocationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingClientHttpJsonTest.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingClientHttpJsonTest.java new file mode 100644 index 000000000000..eb864fbc9ac8 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingClientHttpJsonTest.java @@ -0,0 +1,354 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1; + +import static com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.confidentialcomputing.v1.stub.HttpJsonConfidentialComputingStub; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.collect.Lists; +import com.google.protobuf.Any; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ConfidentialComputingClientHttpJsonTest { + private static MockHttpService mockService; + private static ConfidentialComputingClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonConfidentialComputingStub.getMethodDescriptors(), + ConfidentialComputingSettings.getDefaultEndpoint()); + ConfidentialComputingSettings settings = + ConfidentialComputingSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ConfidentialComputingSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ConfidentialComputingClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createChallengeTest() throws Exception { + Challenge expectedResponse = + Challenge.newBuilder() + .setName(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setUsed(true) + .setTpmNonce("tpmNonce-180239106") + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Challenge challenge = Challenge.newBuilder().build(); + + Challenge actualResponse = client.createChallenge(parent, challenge); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createChallengeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Challenge challenge = Challenge.newBuilder().build(); + client.createChallenge(parent, challenge); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createChallengeTest2() throws Exception { + Challenge expectedResponse = + Challenge.newBuilder() + .setName(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setUsed(true) + .setTpmNonce("tpmNonce-180239106") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + Challenge challenge = Challenge.newBuilder().build(); + + Challenge actualResponse = client.createChallenge(parent, challenge); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createChallengeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Challenge challenge = Challenge.newBuilder().build(); + client.createChallenge(parent, challenge); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void verifyAttestationTest() throws Exception { + VerifyAttestationResponse expectedResponse = + VerifyAttestationResponse.newBuilder() + .setOidcClaimsToken("oidcClaimsToken-566980887") + .build(); + mockService.addResponse(expectedResponse); + + VerifyAttestationRequest request = + VerifyAttestationRequest.newBuilder() + .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setGcpCredentials(GcpCredentials.newBuilder().build()) + .setTpmAttestation(TpmAttestation.newBuilder().build()) + .build(); + + VerifyAttestationResponse actualResponse = client.verifyAttestation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void verifyAttestationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + VerifyAttestationRequest request = + VerifyAttestationRequest.newBuilder() + .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setGcpCredentials(GcpCredentials.newBuilder().build()) + .setTpmAttestation(TpmAttestation.newBuilder().build()) + .build(); + client.verifyAttestation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listLocationsTest() throws Exception { + Location responsesElement = Location.newBuilder().build(); + ListLocationsResponse expectedResponse = + ListLocationsResponse.newBuilder() + .setNextPageToken("") + .addAllLocations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("projects/project-3664") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListLocationsPagedResponse pagedListResponse = client.listLocations(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getLocationsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listLocationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("projects/project-3664") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listLocations(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getLocationTest() throws Exception { + Location expectedResponse = + Location.newBuilder() + .setName("name3373707") + .setLocationId("locationId1541836720") + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setMetadata(Any.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetLocationRequest request = + GetLocationRequest.newBuilder() + .setName("projects/project-9062/locations/location-9062") + .build(); + + Location actualResponse = client.getLocation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getLocationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetLocationRequest request = + GetLocationRequest.newBuilder() + .setName("projects/project-9062/locations/location-9062") + .build(); + client.getLocation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingClientTest.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingClientTest.java new file mode 100644 index 000000000000..2d28c4c4bc78 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingClientTest.java @@ -0,0 +1,331 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1; + +import static com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.collect.Lists; +import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Any; +import com.google.protobuf.Timestamp; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ConfidentialComputingClientTest { + private static MockConfidentialComputing mockConfidentialComputing; + private static MockLocations mockLocations; + private static MockServiceHelper mockServiceHelper; + private LocalChannelProvider channelProvider; + private ConfidentialComputingClient client; + + @BeforeClass + public static void startStaticServer() { + mockConfidentialComputing = new MockConfidentialComputing(); + mockLocations = new MockLocations(); + mockServiceHelper = + new MockServiceHelper( + UUID.randomUUID().toString(), + Arrays.asList(mockConfidentialComputing, mockLocations)); + mockServiceHelper.start(); + } + + @AfterClass + public static void stopServer() { + mockServiceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); + ConfidentialComputingSettings settings = + ConfidentialComputingSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ConfidentialComputingClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + public void createChallengeTest() throws Exception { + Challenge expectedResponse = + Challenge.newBuilder() + .setName(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setUsed(true) + .setTpmNonce("tpmNonce-180239106") + .build(); + mockConfidentialComputing.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Challenge challenge = Challenge.newBuilder().build(); + + Challenge actualResponse = client.createChallenge(parent, challenge); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockConfidentialComputing.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateChallengeRequest actualRequest = ((CreateChallengeRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(challenge, actualRequest.getChallenge()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createChallengeExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockConfidentialComputing.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Challenge challenge = Challenge.newBuilder().build(); + client.createChallenge(parent, challenge); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createChallengeTest2() throws Exception { + Challenge expectedResponse = + Challenge.newBuilder() + .setName(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setUsed(true) + .setTpmNonce("tpmNonce-180239106") + .build(); + mockConfidentialComputing.addResponse(expectedResponse); + + String parent = "parent-995424086"; + Challenge challenge = Challenge.newBuilder().build(); + + Challenge actualResponse = client.createChallenge(parent, challenge); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockConfidentialComputing.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateChallengeRequest actualRequest = ((CreateChallengeRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(challenge, actualRequest.getChallenge()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createChallengeExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockConfidentialComputing.addException(exception); + + try { + String parent = "parent-995424086"; + Challenge challenge = Challenge.newBuilder().build(); + client.createChallenge(parent, challenge); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void verifyAttestationTest() throws Exception { + VerifyAttestationResponse expectedResponse = + VerifyAttestationResponse.newBuilder() + .setOidcClaimsToken("oidcClaimsToken-566980887") + .build(); + mockConfidentialComputing.addResponse(expectedResponse); + + VerifyAttestationRequest request = + VerifyAttestationRequest.newBuilder() + .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setGcpCredentials(GcpCredentials.newBuilder().build()) + .setTpmAttestation(TpmAttestation.newBuilder().build()) + .build(); + + VerifyAttestationResponse actualResponse = client.verifyAttestation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockConfidentialComputing.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + VerifyAttestationRequest actualRequest = ((VerifyAttestationRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getChallenge(), actualRequest.getChallenge()); + Assert.assertEquals(request.getGcpCredentials(), actualRequest.getGcpCredentials()); + Assert.assertEquals(request.getTpmAttestation(), actualRequest.getTpmAttestation()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void verifyAttestationExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockConfidentialComputing.addException(exception); + + try { + VerifyAttestationRequest request = + VerifyAttestationRequest.newBuilder() + .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setGcpCredentials(GcpCredentials.newBuilder().build()) + .setTpmAttestation(TpmAttestation.newBuilder().build()) + .build(); + client.verifyAttestation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listLocationsTest() throws Exception { + Location responsesElement = Location.newBuilder().build(); + ListLocationsResponse expectedResponse = + ListLocationsResponse.newBuilder() + .setNextPageToken("") + .addAllLocations(Arrays.asList(responsesElement)) + .build(); + mockLocations.addResponse(expectedResponse); + + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListLocationsPagedResponse pagedListResponse = client.listLocations(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getLocationsList().get(0), resources.get(0)); + + List actualRequests = mockLocations.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListLocationsRequest actualRequest = ((ListLocationsRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getName(), actualRequest.getName()); + Assert.assertEquals(request.getFilter(), actualRequest.getFilter()); + Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize()); + Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listLocationsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockLocations.addException(exception); + + try { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listLocations(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getLocationTest() throws Exception { + Location expectedResponse = + Location.newBuilder() + .setName("name3373707") + .setLocationId("locationId1541836720") + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setMetadata(Any.newBuilder().build()) + .build(); + mockLocations.addResponse(expectedResponse); + + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + + Location actualResponse = client.getLocation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockLocations.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetLocationRequest actualRequest = ((GetLocationRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getName(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getLocationExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockLocations.addException(exception); + + try { + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + client.getLocation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/MockConfidentialComputing.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/MockConfidentialComputing.java new file mode 100644 index 000000000000..fd4092e33a08 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/MockConfidentialComputing.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockConfidentialComputing implements MockGrpcService { + private final MockConfidentialComputingImpl serviceImpl; + + public MockConfidentialComputing() { + serviceImpl = new MockConfidentialComputingImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/MockConfidentialComputingImpl.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/MockConfidentialComputingImpl.java new file mode 100644 index 000000000000..1c5fe30be504 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/MockConfidentialComputingImpl.java @@ -0,0 +1,103 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1; + +import com.google.api.core.BetaApi; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingGrpc.ConfidentialComputingImplBase; +import com.google.protobuf.AbstractMessage; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockConfidentialComputingImpl extends ConfidentialComputingImplBase { + private List requests; + private Queue responses; + + public MockConfidentialComputingImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void createChallenge( + CreateChallengeRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Challenge) { + requests.add(request); + responseObserver.onNext(((Challenge) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CreateChallenge, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Challenge.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void verifyAttestation( + VerifyAttestationRequest request, + StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof VerifyAttestationResponse) { + requests.add(request); + responseObserver.onNext(((VerifyAttestationResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method VerifyAttestation, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + VerifyAttestationResponse.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/MockLocations.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/MockLocations.java new file mode 100644 index 000000000000..82b48803bfa2 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/MockLocations.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockLocations implements MockGrpcService { + private final MockLocationsImpl serviceImpl; + + public MockLocations() { + serviceImpl = new MockLocationsImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/MockLocationsImpl.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/MockLocationsImpl.java new file mode 100644 index 000000000000..c0b6d80d61b5 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1/MockLocationsImpl.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1; + +import com.google.api.core.BetaApi; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.cloud.location.LocationsGrpc.LocationsImplBase; +import com.google.protobuf.AbstractMessage; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockLocationsImpl extends LocationsImplBase { + private List requests; + private Queue responses; + + public MockLocationsImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void listLocations( + ListLocationsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListLocationsResponse) { + requests.add(request); + responseObserver.onNext(((ListLocationsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListLocations, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListLocationsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getLocation(GetLocationRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Location) { + requests.add(request); + responseObserver.onNext(((Location) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetLocation, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Location.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingClientHttpJsonTest.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingClientHttpJsonTest.java new file mode 100644 index 000000000000..e48e1d0cd428 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingClientHttpJsonTest.java @@ -0,0 +1,353 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1; + +import static com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.confidentialcomputing.v1alpha1.stub.HttpJsonConfidentialComputingStub; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.collect.Lists; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ConfidentialComputingClientHttpJsonTest { + private static MockHttpService mockService; + private static ConfidentialComputingClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonConfidentialComputingStub.getMethodDescriptors(), + ConfidentialComputingSettings.getDefaultEndpoint()); + ConfidentialComputingSettings settings = + ConfidentialComputingSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ConfidentialComputingSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ConfidentialComputingClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createChallengeTest() throws Exception { + Challenge expectedResponse = + Challenge.newBuilder() + .setName(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setUsed(true) + .setNonce(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Challenge challenge = Challenge.newBuilder().build(); + + Challenge actualResponse = client.createChallenge(parent, challenge); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createChallengeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Challenge challenge = Challenge.newBuilder().build(); + client.createChallenge(parent, challenge); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createChallengeTest2() throws Exception { + Challenge expectedResponse = + Challenge.newBuilder() + .setName(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setUsed(true) + .setNonce(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + Challenge challenge = Challenge.newBuilder().build(); + + Challenge actualResponse = client.createChallenge(parent, challenge); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createChallengeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Challenge challenge = Challenge.newBuilder().build(); + client.createChallenge(parent, challenge); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void verifyAttestationTest() throws Exception { + VerifyAttestationResponse expectedResponse = + VerifyAttestationResponse.newBuilder().setClaimsToken(ByteString.EMPTY).build(); + mockService.addResponse(expectedResponse); + + VerifyAttestationRequest request = + VerifyAttestationRequest.newBuilder() + .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setGcpCredentials(GcpCredentials.newBuilder().build()) + .setTpmAttestation(TpmAttestation.newBuilder().build()) + .build(); + + VerifyAttestationResponse actualResponse = client.verifyAttestation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void verifyAttestationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + VerifyAttestationRequest request = + VerifyAttestationRequest.newBuilder() + .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setGcpCredentials(GcpCredentials.newBuilder().build()) + .setTpmAttestation(TpmAttestation.newBuilder().build()) + .build(); + client.verifyAttestation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listLocationsTest() throws Exception { + Location responsesElement = Location.newBuilder().build(); + ListLocationsResponse expectedResponse = + ListLocationsResponse.newBuilder() + .setNextPageToken("") + .addAllLocations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("projects/project-3664") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListLocationsPagedResponse pagedListResponse = client.listLocations(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getLocationsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listLocationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("projects/project-3664") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listLocations(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getLocationTest() throws Exception { + Location expectedResponse = + Location.newBuilder() + .setName("name3373707") + .setLocationId("locationId1541836720") + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setMetadata(Any.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetLocationRequest request = + GetLocationRequest.newBuilder() + .setName("projects/project-9062/locations/location-9062") + .build(); + + Location actualResponse = client.getLocation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getLocationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetLocationRequest request = + GetLocationRequest.newBuilder() + .setName("projects/project-9062/locations/location-9062") + .build(); + client.getLocation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingClientTest.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingClientTest.java new file mode 100644 index 000000000000..e25e2fba7a37 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingClientTest.java @@ -0,0 +1,330 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1; + +import static com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient.ListLocationsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.collect.Lists; +import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ConfidentialComputingClientTest { + private static MockConfidentialComputing mockConfidentialComputing; + private static MockLocations mockLocations; + private static MockServiceHelper mockServiceHelper; + private LocalChannelProvider channelProvider; + private ConfidentialComputingClient client; + + @BeforeClass + public static void startStaticServer() { + mockConfidentialComputing = new MockConfidentialComputing(); + mockLocations = new MockLocations(); + mockServiceHelper = + new MockServiceHelper( + UUID.randomUUID().toString(), + Arrays.asList(mockConfidentialComputing, mockLocations)); + mockServiceHelper.start(); + } + + @AfterClass + public static void stopServer() { + mockServiceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); + ConfidentialComputingSettings settings = + ConfidentialComputingSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ConfidentialComputingClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + public void createChallengeTest() throws Exception { + Challenge expectedResponse = + Challenge.newBuilder() + .setName(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setUsed(true) + .setNonce(ByteString.EMPTY) + .build(); + mockConfidentialComputing.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Challenge challenge = Challenge.newBuilder().build(); + + Challenge actualResponse = client.createChallenge(parent, challenge); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockConfidentialComputing.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateChallengeRequest actualRequest = ((CreateChallengeRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(challenge, actualRequest.getChallenge()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createChallengeExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockConfidentialComputing.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Challenge challenge = Challenge.newBuilder().build(); + client.createChallenge(parent, challenge); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createChallengeTest2() throws Exception { + Challenge expectedResponse = + Challenge.newBuilder() + .setName(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setUsed(true) + .setNonce(ByteString.EMPTY) + .build(); + mockConfidentialComputing.addResponse(expectedResponse); + + String parent = "parent-995424086"; + Challenge challenge = Challenge.newBuilder().build(); + + Challenge actualResponse = client.createChallenge(parent, challenge); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockConfidentialComputing.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateChallengeRequest actualRequest = ((CreateChallengeRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(challenge, actualRequest.getChallenge()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createChallengeExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockConfidentialComputing.addException(exception); + + try { + String parent = "parent-995424086"; + Challenge challenge = Challenge.newBuilder().build(); + client.createChallenge(parent, challenge); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void verifyAttestationTest() throws Exception { + VerifyAttestationResponse expectedResponse = + VerifyAttestationResponse.newBuilder().setClaimsToken(ByteString.EMPTY).build(); + mockConfidentialComputing.addResponse(expectedResponse); + + VerifyAttestationRequest request = + VerifyAttestationRequest.newBuilder() + .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setGcpCredentials(GcpCredentials.newBuilder().build()) + .setTpmAttestation(TpmAttestation.newBuilder().build()) + .build(); + + VerifyAttestationResponse actualResponse = client.verifyAttestation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockConfidentialComputing.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + VerifyAttestationRequest actualRequest = ((VerifyAttestationRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getChallenge(), actualRequest.getChallenge()); + Assert.assertEquals(request.getGcpCredentials(), actualRequest.getGcpCredentials()); + Assert.assertEquals(request.getTpmAttestation(), actualRequest.getTpmAttestation()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void verifyAttestationExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockConfidentialComputing.addException(exception); + + try { + VerifyAttestationRequest request = + VerifyAttestationRequest.newBuilder() + .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setGcpCredentials(GcpCredentials.newBuilder().build()) + .setTpmAttestation(TpmAttestation.newBuilder().build()) + .build(); + client.verifyAttestation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listLocationsTest() throws Exception { + Location responsesElement = Location.newBuilder().build(); + ListLocationsResponse expectedResponse = + ListLocationsResponse.newBuilder() + .setNextPageToken("") + .addAllLocations(Arrays.asList(responsesElement)) + .build(); + mockLocations.addResponse(expectedResponse); + + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListLocationsPagedResponse pagedListResponse = client.listLocations(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getLocationsList().get(0), resources.get(0)); + + List actualRequests = mockLocations.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListLocationsRequest actualRequest = ((ListLocationsRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getName(), actualRequest.getName()); + Assert.assertEquals(request.getFilter(), actualRequest.getFilter()); + Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize()); + Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listLocationsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockLocations.addException(exception); + + try { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listLocations(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getLocationTest() throws Exception { + Location expectedResponse = + Location.newBuilder() + .setName("name3373707") + .setLocationId("locationId1541836720") + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setMetadata(Any.newBuilder().build()) + .build(); + mockLocations.addResponse(expectedResponse); + + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + + Location actualResponse = client.getLocation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockLocations.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetLocationRequest actualRequest = ((GetLocationRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getName(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getLocationExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockLocations.addException(exception); + + try { + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + client.getLocation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/MockConfidentialComputing.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/MockConfidentialComputing.java new file mode 100644 index 000000000000..cebc3a8199f2 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/MockConfidentialComputing.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockConfidentialComputing implements MockGrpcService { + private final MockConfidentialComputingImpl serviceImpl; + + public MockConfidentialComputing() { + serviceImpl = new MockConfidentialComputingImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/MockConfidentialComputingImpl.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/MockConfidentialComputingImpl.java new file mode 100644 index 000000000000..a90e254105eb --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/MockConfidentialComputingImpl.java @@ -0,0 +1,103 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1; + +import com.google.api.core.BetaApi; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingGrpc.ConfidentialComputingImplBase; +import com.google.protobuf.AbstractMessage; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockConfidentialComputingImpl extends ConfidentialComputingImplBase { + private List requests; + private Queue responses; + + public MockConfidentialComputingImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void createChallenge( + CreateChallengeRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Challenge) { + requests.add(request); + responseObserver.onNext(((Challenge) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CreateChallenge, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Challenge.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void verifyAttestation( + VerifyAttestationRequest request, + StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof VerifyAttestationResponse) { + requests.add(request); + responseObserver.onNext(((VerifyAttestationResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method VerifyAttestation, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + VerifyAttestationResponse.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/MockLocations.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/MockLocations.java new file mode 100644 index 000000000000..b402cba7f265 --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/MockLocations.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockLocations implements MockGrpcService { + private final MockLocationsImpl serviceImpl; + + public MockLocations() { + serviceImpl = new MockLocationsImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/MockLocationsImpl.java b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/MockLocationsImpl.java new file mode 100644 index 000000000000..3c313bc5a8fc --- /dev/null +++ b/java-confidentialcomputing/google-cloud-confidentialcomputing/src/test/java/com/google/cloud/confidentialcomputing/v1alpha1/MockLocationsImpl.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1; + +import com.google.api.core.BetaApi; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.cloud.location.LocationsGrpc.LocationsImplBase; +import com.google.protobuf.AbstractMessage; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockLocationsImpl extends LocationsImplBase { + private List requests; + private Queue responses; + + public MockLocationsImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void listLocations( + ListLocationsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListLocationsResponse) { + requests.add(request); + responseObserver.onNext(((ListLocationsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListLocations, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListLocationsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getLocation(GetLocationRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Location) { + requests.add(request); + responseObserver.onNext(((Location) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetLocation, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Location.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/java-confidentialcomputing/grpc-google-cloud-confidentialcomputing-v1/pom.xml b/java-confidentialcomputing/grpc-google-cloud-confidentialcomputing-v1/pom.xml new file mode 100644 index 000000000000..8a177074bd92 --- /dev/null +++ b/java-confidentialcomputing/grpc-google-cloud-confidentialcomputing-v1/pom.xml @@ -0,0 +1,45 @@ + + 4.0.0 + com.google.api.grpc + grpc-google-cloud-confidentialcomputing-v1 + 0.0.1-SNAPSHOT + grpc-google-cloud-confidentialcomputing-v1 + GRPC library for google-cloud-confidentialcomputing + + com.google.cloud + google-cloud-confidentialcomputing-parent + 0.0.1-SNAPSHOT + + + + io.grpc + grpc-api + + + io.grpc + grpc-stub + + + io.grpc + grpc-protobuf + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + com.google.api.grpc + proto-google-cloud-confidentialcomputing-v1 + + + com.google.guava + guava + + + \ No newline at end of file diff --git a/java-confidentialcomputing/grpc-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingGrpc.java b/java-confidentialcomputing/grpc-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingGrpc.java new file mode 100644 index 000000000000..52c16832c640 --- /dev/null +++ b/java-confidentialcomputing/grpc-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/ConfidentialComputingGrpc.java @@ -0,0 +1,511 @@ +/* + * 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. + */ +package com.google.cloud.confidentialcomputing.v1; + +import static io.grpc.MethodDescriptor.generateFullMethodName; + +/** + * + * + *
+ * Service describing handlers for resources
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler", + comments = "Source: google/cloud/confidentialcomputing/v1/service.proto") +@io.grpc.stub.annotations.GrpcGenerated +public final class ConfidentialComputingGrpc { + + private ConfidentialComputingGrpc() {} + + public static final String SERVICE_NAME = + "google.cloud.confidentialcomputing.v1.ConfidentialComputing"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor< + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest, + com.google.cloud.confidentialcomputing.v1.Challenge> + getCreateChallengeMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CreateChallenge", + requestType = com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest.class, + responseType = com.google.cloud.confidentialcomputing.v1.Challenge.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest, + com.google.cloud.confidentialcomputing.v1.Challenge> + getCreateChallengeMethod() { + io.grpc.MethodDescriptor< + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest, + com.google.cloud.confidentialcomputing.v1.Challenge> + getCreateChallengeMethod; + if ((getCreateChallengeMethod = ConfidentialComputingGrpc.getCreateChallengeMethod) == null) { + synchronized (ConfidentialComputingGrpc.class) { + if ((getCreateChallengeMethod = ConfidentialComputingGrpc.getCreateChallengeMethod) + == null) { + ConfidentialComputingGrpc.getCreateChallengeMethod = + getCreateChallengeMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "CreateChallenge")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.confidentialcomputing.v1.Challenge + .getDefaultInstance())) + .setSchemaDescriptor( + new ConfidentialComputingMethodDescriptorSupplier("CreateChallenge")) + .build(); + } + } + } + return getCreateChallengeMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest, + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse> + getVerifyAttestationMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "VerifyAttestation", + requestType = com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest.class, + responseType = com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest, + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse> + getVerifyAttestationMethod() { + io.grpc.MethodDescriptor< + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest, + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse> + getVerifyAttestationMethod; + if ((getVerifyAttestationMethod = ConfidentialComputingGrpc.getVerifyAttestationMethod) + == null) { + synchronized (ConfidentialComputingGrpc.class) { + if ((getVerifyAttestationMethod = ConfidentialComputingGrpc.getVerifyAttestationMethod) + == null) { + ConfidentialComputingGrpc.getVerifyAttestationMethod = + getVerifyAttestationMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "VerifyAttestation")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new ConfidentialComputingMethodDescriptorSupplier("VerifyAttestation")) + .build(); + } + } + } + return getVerifyAttestationMethod; + } + + /** Creates a new async stub that supports all call types for the service */ + public static ConfidentialComputingStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public ConfidentialComputingStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ConfidentialComputingStub(channel, callOptions); + } + }; + return ConfidentialComputingStub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static ConfidentialComputingBlockingStub newBlockingStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public ConfidentialComputingBlockingStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ConfidentialComputingBlockingStub(channel, callOptions); + } + }; + return ConfidentialComputingBlockingStub.newStub(factory, channel); + } + + /** Creates a new ListenableFuture-style stub that supports unary calls on the service */ + public static ConfidentialComputingFutureStub newFutureStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public ConfidentialComputingFutureStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ConfidentialComputingFutureStub(channel, callOptions); + } + }; + return ConfidentialComputingFutureStub.newStub(factory, channel); + } + + /** + * + * + *
+   * Service describing handlers for resources
+   * 
+ */ + public interface AsyncService { + + /** + * + * + *
+     * Creates a new Challenge in a given project and location.
+     * 
+ */ + default void createChallenge( + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCreateChallengeMethod(), responseObserver); + } + + /** + * + * + *
+     * Verifies the provided attestation info, returning a signed OIDC token.
+     * 
+ */ + default void verifyAttestation( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest request, + io.grpc.stub.StreamObserver< + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse> + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getVerifyAttestationMethod(), responseObserver); + } + } + + /** + * Base class for the server implementation of the service ConfidentialComputing. + * + *
+   * Service describing handlers for resources
+   * 
+ */ + public abstract static class ConfidentialComputingImplBase + implements io.grpc.BindableService, AsyncService { + + @java.lang.Override + public final io.grpc.ServerServiceDefinition bindService() { + return ConfidentialComputingGrpc.bindService(this); + } + } + + /** + * A stub to allow clients to do asynchronous rpc calls to service ConfidentialComputing. + * + *
+   * Service describing handlers for resources
+   * 
+ */ + public static final class ConfidentialComputingStub + extends io.grpc.stub.AbstractAsyncStub { + private ConfidentialComputingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ConfidentialComputingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ConfidentialComputingStub(channel, callOptions); + } + + /** + * + * + *
+     * Creates a new Challenge in a given project and location.
+     * 
+ */ + public void createChallenge( + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCreateChallengeMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Verifies the provided attestation info, returning a signed OIDC token.
+     * 
+ */ + public void verifyAttestation( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest request, + io.grpc.stub.StreamObserver< + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse> + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getVerifyAttestationMethod(), getCallOptions()), + request, + responseObserver); + } + } + + /** + * A stub to allow clients to do synchronous rpc calls to service ConfidentialComputing. + * + *
+   * Service describing handlers for resources
+   * 
+ */ + public static final class ConfidentialComputingBlockingStub + extends io.grpc.stub.AbstractBlockingStub { + private ConfidentialComputingBlockingStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ConfidentialComputingBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ConfidentialComputingBlockingStub(channel, callOptions); + } + + /** + * + * + *
+     * Creates a new Challenge in a given project and location.
+     * 
+ */ + public com.google.cloud.confidentialcomputing.v1.Challenge createChallenge( + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCreateChallengeMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Verifies the provided attestation info, returning a signed OIDC token.
+     * 
+ */ + public com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse verifyAttestation( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getVerifyAttestationMethod(), getCallOptions(), request); + } + } + + /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service + * ConfidentialComputing. + * + *
+   * Service describing handlers for resources
+   * 
+ */ + public static final class ConfidentialComputingFutureStub + extends io.grpc.stub.AbstractFutureStub { + private ConfidentialComputingFutureStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ConfidentialComputingFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ConfidentialComputingFutureStub(channel, callOptions); + } + + /** + * + * + *
+     * Creates a new Challenge in a given project and location.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.cloud.confidentialcomputing.v1.Challenge> + createChallenge(com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCreateChallengeMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Verifies the provided attestation info, returning a signed OIDC token.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse> + verifyAttestation( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getVerifyAttestationMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_CREATE_CHALLENGE = 0; + private static final int METHODID_VERIFY_ATTESTATION = 1; + + private static final class MethodHandlers + implements io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final AsyncService serviceImpl; + private final int methodId; + + MethodHandlers(AsyncService serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_CREATE_CHALLENGE: + serviceImpl.createChallenge( + (com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_VERIFY_ATTESTATION: + serviceImpl.verifyAttestation( + (com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest) request, + (io.grpc.stub.StreamObserver< + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse>) + responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getCreateChallengeMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest, + com.google.cloud.confidentialcomputing.v1.Challenge>( + service, METHODID_CREATE_CHALLENGE))) + .addMethod( + getVerifyAttestationMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest, + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse>( + service, METHODID_VERIFY_ATTESTATION))) + .build(); + } + + private abstract static class ConfidentialComputingBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, + io.grpc.protobuf.ProtoServiceDescriptorSupplier { + ConfidentialComputingBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("ConfidentialComputing"); + } + } + + private static final class ConfidentialComputingFileDescriptorSupplier + extends ConfidentialComputingBaseDescriptorSupplier { + ConfidentialComputingFileDescriptorSupplier() {} + } + + private static final class ConfidentialComputingMethodDescriptorSupplier + extends ConfidentialComputingBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + ConfidentialComputingMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (ConfidentialComputingGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = + result = + io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new ConfidentialComputingFileDescriptorSupplier()) + .addMethod(getCreateChallengeMethod()) + .addMethod(getVerifyAttestationMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/java-confidentialcomputing/grpc-google-cloud-confidentialcomputing-v1alpha1/pom.xml b/java-confidentialcomputing/grpc-google-cloud-confidentialcomputing-v1alpha1/pom.xml new file mode 100644 index 000000000000..a56952e8e12f --- /dev/null +++ b/java-confidentialcomputing/grpc-google-cloud-confidentialcomputing-v1alpha1/pom.xml @@ -0,0 +1,45 @@ + + 4.0.0 + com.google.api.grpc + grpc-google-cloud-confidentialcomputing-v1alpha1 + 0.0.1-SNAPSHOT + grpc-google-cloud-confidentialcomputing-v1alpha1 + GRPC library for google-cloud-confidentialcomputing + + com.google.cloud + google-cloud-confidentialcomputing-parent + 0.0.1-SNAPSHOT + + + + io.grpc + grpc-api + + + io.grpc + grpc-stub + + + io.grpc + grpc-protobuf + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + com.google.api.grpc + proto-google-cloud-confidentialcomputing-v1alpha1 + + + com.google.guava + guava + + + \ No newline at end of file diff --git a/java-confidentialcomputing/grpc-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingGrpc.java b/java-confidentialcomputing/grpc-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingGrpc.java new file mode 100644 index 000000000000..2367fe760984 --- /dev/null +++ b/java-confidentialcomputing/grpc-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ConfidentialComputingGrpc.java @@ -0,0 +1,515 @@ +/* + * 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. + */ +package com.google.cloud.confidentialcomputing.v1alpha1; + +import static io.grpc.MethodDescriptor.generateFullMethodName; + +/** + * + * + *
+ * Service describing handlers for resources
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler", + comments = "Source: google/cloud/confidentialcomputing/v1alpha1/service.proto") +@io.grpc.stub.annotations.GrpcGenerated +public final class ConfidentialComputingGrpc { + + private ConfidentialComputingGrpc() {} + + public static final String SERVICE_NAME = + "google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputing"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor< + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest, + com.google.cloud.confidentialcomputing.v1alpha1.Challenge> + getCreateChallengeMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CreateChallenge", + requestType = com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest.class, + responseType = com.google.cloud.confidentialcomputing.v1alpha1.Challenge.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest, + com.google.cloud.confidentialcomputing.v1alpha1.Challenge> + getCreateChallengeMethod() { + io.grpc.MethodDescriptor< + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest, + com.google.cloud.confidentialcomputing.v1alpha1.Challenge> + getCreateChallengeMethod; + if ((getCreateChallengeMethod = ConfidentialComputingGrpc.getCreateChallengeMethod) == null) { + synchronized (ConfidentialComputingGrpc.class) { + if ((getCreateChallengeMethod = ConfidentialComputingGrpc.getCreateChallengeMethod) + == null) { + ConfidentialComputingGrpc.getCreateChallengeMethod = + getCreateChallengeMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "CreateChallenge")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.confidentialcomputing.v1alpha1.Challenge + .getDefaultInstance())) + .setSchemaDescriptor( + new ConfidentialComputingMethodDescriptorSupplier("CreateChallenge")) + .build(); + } + } + } + return getCreateChallengeMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest, + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse> + getVerifyAttestationMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "VerifyAttestation", + requestType = com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest.class, + responseType = + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest, + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse> + getVerifyAttestationMethod() { + io.grpc.MethodDescriptor< + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest, + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse> + getVerifyAttestationMethod; + if ((getVerifyAttestationMethod = ConfidentialComputingGrpc.getVerifyAttestationMethod) + == null) { + synchronized (ConfidentialComputingGrpc.class) { + if ((getVerifyAttestationMethod = ConfidentialComputingGrpc.getVerifyAttestationMethod) + == null) { + ConfidentialComputingGrpc.getVerifyAttestationMethod = + getVerifyAttestationMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "VerifyAttestation")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.confidentialcomputing.v1alpha1 + .VerifyAttestationRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.confidentialcomputing.v1alpha1 + .VerifyAttestationResponse.getDefaultInstance())) + .setSchemaDescriptor( + new ConfidentialComputingMethodDescriptorSupplier("VerifyAttestation")) + .build(); + } + } + } + return getVerifyAttestationMethod; + } + + /** Creates a new async stub that supports all call types for the service */ + public static ConfidentialComputingStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public ConfidentialComputingStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ConfidentialComputingStub(channel, callOptions); + } + }; + return ConfidentialComputingStub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static ConfidentialComputingBlockingStub newBlockingStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public ConfidentialComputingBlockingStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ConfidentialComputingBlockingStub(channel, callOptions); + } + }; + return ConfidentialComputingBlockingStub.newStub(factory, channel); + } + + /** Creates a new ListenableFuture-style stub that supports unary calls on the service */ + public static ConfidentialComputingFutureStub newFutureStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public ConfidentialComputingFutureStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ConfidentialComputingFutureStub(channel, callOptions); + } + }; + return ConfidentialComputingFutureStub.newStub(factory, channel); + } + + /** + * + * + *
+   * Service describing handlers for resources
+   * 
+ */ + public interface AsyncService { + + /** + * + * + *
+     * Creates a new Challenge in a given project and location.
+     * 
+ */ + default void createChallenge( + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCreateChallengeMethod(), responseObserver); + } + + /** + * + * + *
+     * Verifies the provided attestation info, returning a signed OIDC token.
+     * 
+ */ + default void verifyAttestation( + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest request, + io.grpc.stub.StreamObserver< + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse> + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getVerifyAttestationMethod(), responseObserver); + } + } + + /** + * Base class for the server implementation of the service ConfidentialComputing. + * + *
+   * Service describing handlers for resources
+   * 
+ */ + public abstract static class ConfidentialComputingImplBase + implements io.grpc.BindableService, AsyncService { + + @java.lang.Override + public final io.grpc.ServerServiceDefinition bindService() { + return ConfidentialComputingGrpc.bindService(this); + } + } + + /** + * A stub to allow clients to do asynchronous rpc calls to service ConfidentialComputing. + * + *
+   * Service describing handlers for resources
+   * 
+ */ + public static final class ConfidentialComputingStub + extends io.grpc.stub.AbstractAsyncStub { + private ConfidentialComputingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ConfidentialComputingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ConfidentialComputingStub(channel, callOptions); + } + + /** + * + * + *
+     * Creates a new Challenge in a given project and location.
+     * 
+ */ + public void createChallenge( + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCreateChallengeMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Verifies the provided attestation info, returning a signed OIDC token.
+     * 
+ */ + public void verifyAttestation( + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest request, + io.grpc.stub.StreamObserver< + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse> + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getVerifyAttestationMethod(), getCallOptions()), + request, + responseObserver); + } + } + + /** + * A stub to allow clients to do synchronous rpc calls to service ConfidentialComputing. + * + *
+   * Service describing handlers for resources
+   * 
+ */ + public static final class ConfidentialComputingBlockingStub + extends io.grpc.stub.AbstractBlockingStub { + private ConfidentialComputingBlockingStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ConfidentialComputingBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ConfidentialComputingBlockingStub(channel, callOptions); + } + + /** + * + * + *
+     * Creates a new Challenge in a given project and location.
+     * 
+ */ + public com.google.cloud.confidentialcomputing.v1alpha1.Challenge createChallenge( + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCreateChallengeMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Verifies the provided attestation info, returning a signed OIDC token.
+     * 
+ */ + public com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse + verifyAttestation( + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getVerifyAttestationMethod(), getCallOptions(), request); + } + } + + /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service + * ConfidentialComputing. + * + *
+   * Service describing handlers for resources
+   * 
+ */ + public static final class ConfidentialComputingFutureStub + extends io.grpc.stub.AbstractFutureStub { + private ConfidentialComputingFutureStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ConfidentialComputingFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ConfidentialComputingFutureStub(channel, callOptions); + } + + /** + * + * + *
+     * Creates a new Challenge in a given project and location.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.cloud.confidentialcomputing.v1alpha1.Challenge> + createChallenge( + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCreateChallengeMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Verifies the provided attestation info, returning a signed OIDC token.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse> + verifyAttestation( + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getVerifyAttestationMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_CREATE_CHALLENGE = 0; + private static final int METHODID_VERIFY_ATTESTATION = 1; + + private static final class MethodHandlers + implements io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final AsyncService serviceImpl; + private final int methodId; + + MethodHandlers(AsyncService serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_CREATE_CHALLENGE: + serviceImpl.createChallenge( + (com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest) request, + (io.grpc.stub.StreamObserver< + com.google.cloud.confidentialcomputing.v1alpha1.Challenge>) + responseObserver); + break; + case METHODID_VERIFY_ATTESTATION: + serviceImpl.verifyAttestation( + (com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest) request, + (io.grpc.stub.StreamObserver< + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse>) + responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getCreateChallengeMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest, + com.google.cloud.confidentialcomputing.v1alpha1.Challenge>( + service, METHODID_CREATE_CHALLENGE))) + .addMethod( + getVerifyAttestationMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest, + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse>( + service, METHODID_VERIFY_ATTESTATION))) + .build(); + } + + private abstract static class ConfidentialComputingBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, + io.grpc.protobuf.ProtoServiceDescriptorSupplier { + ConfidentialComputingBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("ConfidentialComputing"); + } + } + + private static final class ConfidentialComputingFileDescriptorSupplier + extends ConfidentialComputingBaseDescriptorSupplier { + ConfidentialComputingFileDescriptorSupplier() {} + } + + private static final class ConfidentialComputingMethodDescriptorSupplier + extends ConfidentialComputingBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + ConfidentialComputingMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (ConfidentialComputingGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = + result = + io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new ConfidentialComputingFileDescriptorSupplier()) + .addMethod(getCreateChallengeMethod()) + .addMethod(getVerifyAttestationMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/java-confidentialcomputing/owlbot.py b/java-confidentialcomputing/owlbot.py new file mode 100644 index 000000000000..03c0f6686d3f --- /dev/null +++ b/java-confidentialcomputing/owlbot.py @@ -0,0 +1,36 @@ +# Copyright 2021 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. + +import synthtool as s +from synthtool.languages import java + + +for library in s.get_staging_dirs(): + # put any special-case replacements here + s.move(library) + +s.remove_staging_dirs() +java.common_templates(monorepo=True, excludes=[ + ".github/*", + ".kokoro/*", + "samples/*", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.md", + "LICENSE", + "SECURITY.md", + "java.header", + "license-checks.xml", + "renovate.json", + ".gitignore" +]) \ No newline at end of file diff --git a/java-confidentialcomputing/pom.xml b/java-confidentialcomputing/pom.xml new file mode 100644 index 000000000000..5ffa505920b4 --- /dev/null +++ b/java-confidentialcomputing/pom.xml @@ -0,0 +1,66 @@ + + + 4.0.0 + com.google.cloud + google-cloud-confidentialcomputing-parent + pom + 0.0.1-SNAPSHOT + Google Confidential Computing API Parent + + Java idiomatic client for Google Cloud Platform services. + + + + com.google.cloud + google-cloud-jar-parent + 1.9.0-SNAPSHOT + ../google-cloud-jar-parent/pom.xml + + + + UTF-8 + UTF-8 + github + google-cloud-confidentialcomputing-parent + + + + + + com.google.cloud + google-cloud-confidentialcomputing + 0.0.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-confidentialcomputing-v1 + 0.0.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-confidentialcomputing-v1alpha1 + 0.0.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-confidentialcomputing-v1 + 0.0.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-confidentialcomputing-v1alpha1 + 0.0.1-SNAPSHOT + + + + + + google-cloud-confidentialcomputing + grpc-google-cloud-confidentialcomputing-v1 + grpc-google-cloud-confidentialcomputing-v1alpha1 + proto-google-cloud-confidentialcomputing-v1 + proto-google-cloud-confidentialcomputing-v1alpha1 + google-cloud-confidentialcomputing-bom + + + diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/clirr-ignored-differences.xml b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/clirr-ignored-differences.xml new file mode 100644 index 000000000000..4487233dba82 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/clirr-ignored-differences.xml @@ -0,0 +1,19 @@ + + + + + 7012 + com/google/cloud/confidentialcomputing/v1/*OrBuilder + * get*(*) + + + 7012 + com/google/cloud/confidentialcomputing/v1/*OrBuilder + boolean contains*(*) + + + 7012 + com/google/cloud/confidentialcomputing/v1/*OrBuilder + boolean has*(*) + + diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/pom.xml b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/pom.xml new file mode 100644 index 000000000000..d15124fba6ce --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/pom.xml @@ -0,0 +1,37 @@ + + 4.0.0 + com.google.api.grpc + proto-google-cloud-confidentialcomputing-v1 + 0.0.1-SNAPSHOT + proto-google-cloud-confidentialcomputing-v1 + Proto library for google-cloud-confidentialcomputing + + com.google.cloud + google-cloud-confidentialcomputing-parent + 0.0.1-SNAPSHOT + + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + com.google.api.grpc + proto-google-iam-v1 + + + com.google.api + api-common + + + com.google.guava + guava + + + diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/Challenge.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/Challenge.java new file mode 100644 index 000000000000..a125eb7badd8 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/Challenge.java @@ -0,0 +1,1485 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +/** + * + * + *
+ * A Challenge from the server used to guarantee freshness of attestations
+ * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.Challenge} + */ +public final class Challenge extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1.Challenge) + ChallengeOrBuilder { + private static final long serialVersionUID = 0L; + // Use Challenge.newBuilder() to construct. + private Challenge(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Challenge() { + name_ = ""; + tpmNonce_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Challenge(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_Challenge_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_Challenge_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.Challenge.class, + com.google.cloud.confidentialcomputing.v1.Challenge.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+   * Output only. The resource name for this Challenge in the format
+   * `projects/*/locations/*/challenges/*`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Output only. The resource name for this Challenge in the format
+   * `projects/*/locations/*/challenges/*`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CREATE_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp createTime_; + /** + * + * + *
+   * Output only. The time at which this Challenge was created
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + @java.lang.Override + public boolean hasCreateTime() { + return createTime_ != null; + } + /** + * + * + *
+   * Output only. The time at which this Challenge was created
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCreateTime() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + /** + * + * + *
+   * Output only. The time at which this Challenge was created
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + public static final int EXPIRE_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp expireTime_; + /** + * + * + *
+   * Output only. The time at which this Challenge will no longer be usable. It
+   * is also the expiration time for any tokens generated from this Challenge.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the expireTime field is set. + */ + @java.lang.Override + public boolean hasExpireTime() { + return expireTime_ != null; + } + /** + * + * + *
+   * Output only. The time at which this Challenge will no longer be usable. It
+   * is also the expiration time for any tokens generated from this Challenge.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The expireTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getExpireTime() { + return expireTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : expireTime_; + } + /** + * + * + *
+   * Output only. The time at which this Challenge will no longer be usable. It
+   * is also the expiration time for any tokens generated from this Challenge.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder() { + return expireTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : expireTime_; + } + + public static final int USED_FIELD_NUMBER = 4; + private boolean used_ = false; + /** + * + * + *
+   * Output only. Indicates if this challenge has been used to generate a token.
+   * 
+ * + * bool used = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The used. + */ + @java.lang.Override + public boolean getUsed() { + return used_; + } + + public static final int TPM_NONCE_FIELD_NUMBER = 6; + + @SuppressWarnings("serial") + private volatile java.lang.Object tpmNonce_ = ""; + /** + * + * + *
+   * Output only. Identical to nonce, but as a string.
+   * 
+ * + * string tpm_nonce = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The tpmNonce. + */ + @java.lang.Override + public java.lang.String getTpmNonce() { + java.lang.Object ref = tpmNonce_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + tpmNonce_ = s; + return s; + } + } + /** + * + * + *
+   * Output only. Identical to nonce, but as a string.
+   * 
+ * + * string tpm_nonce = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for tpmNonce. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTpmNonceBytes() { + java.lang.Object ref = tpmNonce_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + tpmNonce_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + 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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (createTime_ != null) { + output.writeMessage(2, getCreateTime()); + } + if (expireTime_ != null) { + output.writeMessage(3, getExpireTime()); + } + if (used_ != false) { + output.writeBool(4, used_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(tpmNonce_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, tpmNonce_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (createTime_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getCreateTime()); + } + if (expireTime_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getExpireTime()); + } + if (used_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(4, used_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(tpmNonce_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, tpmNonce_); + } + 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.cloud.confidentialcomputing.v1.Challenge)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1.Challenge other = + (com.google.cloud.confidentialcomputing.v1.Challenge) obj; + + if (!getName().equals(other.getName())) return false; + if (hasCreateTime() != other.hasCreateTime()) return false; + if (hasCreateTime()) { + if (!getCreateTime().equals(other.getCreateTime())) return false; + } + if (hasExpireTime() != other.hasExpireTime()) return false; + if (hasExpireTime()) { + if (!getExpireTime().equals(other.getExpireTime())) return false; + } + if (getUsed() != other.getUsed()) return false; + if (!getTpmNonce().equals(other.getTpmNonce())) 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(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasCreateTime()) { + hash = (37 * hash) + CREATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getCreateTime().hashCode(); + } + if (hasExpireTime()) { + hash = (37 * hash) + EXPIRE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getExpireTime().hashCode(); + } + hash = (37 * hash) + USED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getUsed()); + hash = (37 * hash) + TPM_NONCE_FIELD_NUMBER; + hash = (53 * hash) + getTpmNonce().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1.Challenge parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.Challenge parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.Challenge parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.Challenge 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.cloud.confidentialcomputing.v1.Challenge parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.Challenge parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.Challenge parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.Challenge 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.cloud.confidentialcomputing.v1.Challenge parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.Challenge 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.cloud.confidentialcomputing.v1.Challenge parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.Challenge 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.cloud.confidentialcomputing.v1.Challenge 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; + } + /** + * + * + *
+   * A Challenge from the server used to guarantee freshness of attestations
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.Challenge} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1.Challenge) + com.google.cloud.confidentialcomputing.v1.ChallengeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_Challenge_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_Challenge_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.Challenge.class, + com.google.cloud.confidentialcomputing.v1.Challenge.Builder.class); + } + + // Construct using com.google.cloud.confidentialcomputing.v1.Challenge.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + expireTime_ = null; + if (expireTimeBuilder_ != null) { + expireTimeBuilder_.dispose(); + expireTimeBuilder_ = null; + } + used_ = false; + tpmNonce_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_Challenge_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.Challenge getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1.Challenge.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.Challenge build() { + com.google.cloud.confidentialcomputing.v1.Challenge result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.Challenge buildPartial() { + com.google.cloud.confidentialcomputing.v1.Challenge result = + new com.google.cloud.confidentialcomputing.v1.Challenge(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.cloud.confidentialcomputing.v1.Challenge result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.createTime_ = createTimeBuilder_ == null ? createTime_ : createTimeBuilder_.build(); + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.expireTime_ = expireTimeBuilder_ == null ? expireTime_ : expireTimeBuilder_.build(); + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.used_ = used_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.tpmNonce_ = tpmNonce_; + } + } + + @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.cloud.confidentialcomputing.v1.Challenge) { + return mergeFrom((com.google.cloud.confidentialcomputing.v1.Challenge) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.confidentialcomputing.v1.Challenge other) { + if (other == com.google.cloud.confidentialcomputing.v1.Challenge.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasCreateTime()) { + mergeCreateTime(other.getCreateTime()); + } + if (other.hasExpireTime()) { + mergeExpireTime(other.getExpireTime()); + } + if (other.getUsed() != false) { + setUsed(other.getUsed()); + } + if (!other.getTpmNonce().isEmpty()) { + tpmNonce_ = other.tpmNonce_; + bitField0_ |= 0x00000010; + onChanged(); + } + 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 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getCreateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage(getExpireTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 32: + { + used_ = input.readBool(); + bitField0_ |= 0x00000008; + break; + } // case 32 + case 50: + { + tpmNonce_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000010; + break; + } // case 50 + 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 java.lang.Object name_ = ""; + /** + * + * + *
+     * Output only. The resource name for this Challenge in the format
+     * `projects/*/locations/*/challenges/*`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Output only. The resource name for this Challenge in the format
+     * `projects/*/locations/*/challenges/*`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Output only. The resource name for this Challenge in the format
+     * `projects/*/locations/*/challenges/*`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The resource name for this Challenge in the format
+     * `projects/*/locations/*/challenges/*`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The resource name for this Challenge in the format
+     * `projects/*/locations/*/challenges/*`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp createTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + createTimeBuilder_; + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + public com.google.protobuf.Timestamp getCreateTime() { + if (createTimeBuilder_ == null) { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } else { + return createTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + createTime_ = value; + } else { + createTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (createTimeBuilder_ == null) { + createTime_ = builderForValue.build(); + } else { + createTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && createTime_ != null + && createTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getCreateTimeBuilder().mergeFrom(value); + } else { + createTime_ = value; + } + } else { + createTimeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearCreateTime() { + bitField0_ = (bitField0_ & ~0x00000002); + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getCreateTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getCreateTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + if (createTimeBuilder_ != null) { + return createTimeBuilder_.getMessageOrBuilder(); + } else { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getCreateTimeFieldBuilder() { + if (createTimeBuilder_ == null) { + createTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getCreateTime(), getParentForChildren(), isClean()); + createTime_ = null; + } + return createTimeBuilder_; + } + + private com.google.protobuf.Timestamp expireTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + expireTimeBuilder_; + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the expireTime field is set. + */ + public boolean hasExpireTime() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The expireTime. + */ + public com.google.protobuf.Timestamp getExpireTime() { + if (expireTimeBuilder_ == null) { + return expireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : expireTime_; + } else { + return expireTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setExpireTime(com.google.protobuf.Timestamp value) { + if (expireTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + expireTime_ = value; + } else { + expireTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setExpireTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (expireTimeBuilder_ == null) { + expireTime_ = builderForValue.build(); + } else { + expireTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeExpireTime(com.google.protobuf.Timestamp value) { + if (expireTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && expireTime_ != null + && expireTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getExpireTimeBuilder().mergeFrom(value); + } else { + expireTime_ = value; + } + } else { + expireTimeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearExpireTime() { + bitField0_ = (bitField0_ & ~0x00000004); + expireTime_ = null; + if (expireTimeBuilder_ != null) { + expireTimeBuilder_.dispose(); + expireTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getExpireTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getExpireTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder() { + if (expireTimeBuilder_ != null) { + return expireTimeBuilder_.getMessageOrBuilder(); + } else { + return expireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : expireTime_; + } + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getExpireTimeFieldBuilder() { + if (expireTimeBuilder_ == null) { + expireTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getExpireTime(), getParentForChildren(), isClean()); + expireTime_ = null; + } + return expireTimeBuilder_; + } + + private boolean used_; + /** + * + * + *
+     * Output only. Indicates if this challenge has been used to generate a token.
+     * 
+ * + * bool used = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The used. + */ + @java.lang.Override + public boolean getUsed() { + return used_; + } + /** + * + * + *
+     * Output only. Indicates if this challenge has been used to generate a token.
+     * 
+ * + * bool used = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The used to set. + * @return This builder for chaining. + */ + public Builder setUsed(boolean value) { + + used_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Indicates if this challenge has been used to generate a token.
+     * 
+ * + * bool used = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearUsed() { + bitField0_ = (bitField0_ & ~0x00000008); + used_ = false; + onChanged(); + return this; + } + + private java.lang.Object tpmNonce_ = ""; + /** + * + * + *
+     * Output only. Identical to nonce, but as a string.
+     * 
+ * + * string tpm_nonce = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The tpmNonce. + */ + public java.lang.String getTpmNonce() { + java.lang.Object ref = tpmNonce_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + tpmNonce_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Output only. Identical to nonce, but as a string.
+     * 
+ * + * string tpm_nonce = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for tpmNonce. + */ + public com.google.protobuf.ByteString getTpmNonceBytes() { + java.lang.Object ref = tpmNonce_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + tpmNonce_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Output only. Identical to nonce, but as a string.
+     * 
+ * + * string tpm_nonce = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The tpmNonce to set. + * @return This builder for chaining. + */ + public Builder setTpmNonce(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + tpmNonce_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Identical to nonce, but as a string.
+     * 
+ * + * string tpm_nonce = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearTpmNonce() { + tpmNonce_ = getDefaultInstance().getTpmNonce(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Identical to nonce, but as a string.
+     * 
+ * + * string tpm_nonce = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for tpmNonce to set. + * @return This builder for chaining. + */ + public Builder setTpmNonceBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + tpmNonce_ = value; + bitField0_ |= 0x00000010; + 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.cloud.confidentialcomputing.v1.Challenge) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1.Challenge) + private static final com.google.cloud.confidentialcomputing.v1.Challenge DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.confidentialcomputing.v1.Challenge(); + } + + public static com.google.cloud.confidentialcomputing.v1.Challenge getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Challenge 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.cloud.confidentialcomputing.v1.Challenge getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/ChallengeName.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/ChallengeName.java new file mode 100644 index 000000000000..429e67bb9524 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/ChallengeName.java @@ -0,0 +1,218 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class ChallengeName implements ResourceName { + private static final PathTemplate PROJECT_LOCATION_UUID = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/locations/{location}/challenges/{uuid}"); + private volatile Map fieldValuesMap; + private final String project; + private final String location; + private final String uuid; + + @Deprecated + protected ChallengeName() { + project = null; + location = null; + uuid = null; + } + + private ChallengeName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + uuid = Preconditions.checkNotNull(builder.getUuid()); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getUuid() { + return uuid; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static ChallengeName of(String project, String location, String uuid) { + return newBuilder().setProject(project).setLocation(location).setUuid(uuid).build(); + } + + public static String format(String project, String location, String uuid) { + return newBuilder().setProject(project).setLocation(location).setUuid(uuid).build().toString(); + } + + public static ChallengeName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_LOCATION_UUID.validatedMatch( + formattedString, "ChallengeName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("location"), matchMap.get("uuid")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (ChallengeName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_LOCATION_UUID.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + if (uuid != null) { + fieldMapBuilder.put("uuid", uuid); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_LOCATION_UUID.instantiate( + "project", project, "location", location, "uuid", uuid); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + ChallengeName that = ((ChallengeName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location) + && Objects.equals(this.uuid, that.uuid); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + h *= 1000003; + h ^= Objects.hashCode(uuid); + return h; + } + + /** Builder for projects/{project}/locations/{location}/challenges/{uuid}. */ + public static class Builder { + private String project; + private String location; + private String uuid; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getUuid() { + return uuid; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + public Builder setUuid(String uuid) { + this.uuid = uuid; + return this; + } + + private Builder(ChallengeName challengeName) { + this.project = challengeName.project; + this.location = challengeName.location; + this.uuid = challengeName.uuid; + } + + public ChallengeName build() { + return new ChallengeName(this); + } + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/ChallengeOrBuilder.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/ChallengeOrBuilder.java new file mode 100644 index 000000000000..b027bcfc2410 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/ChallengeOrBuilder.java @@ -0,0 +1,169 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +public interface ChallengeOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1.Challenge) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Output only. The resource name for this Challenge in the format
+   * `projects/*/locations/*/challenges/*`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Output only. The resource name for this Challenge in the format
+   * `projects/*/locations/*/challenges/*`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Output only. The time at which this Challenge was created
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + boolean hasCreateTime(); + /** + * + * + *
+   * Output only. The time at which this Challenge was created
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + com.google.protobuf.Timestamp getCreateTime(); + /** + * + * + *
+   * Output only. The time at which this Challenge was created
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder(); + + /** + * + * + *
+   * Output only. The time at which this Challenge will no longer be usable. It
+   * is also the expiration time for any tokens generated from this Challenge.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the expireTime field is set. + */ + boolean hasExpireTime(); + /** + * + * + *
+   * Output only. The time at which this Challenge will no longer be usable. It
+   * is also the expiration time for any tokens generated from this Challenge.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The expireTime. + */ + com.google.protobuf.Timestamp getExpireTime(); + /** + * + * + *
+   * Output only. The time at which this Challenge will no longer be usable. It
+   * is also the expiration time for any tokens generated from this Challenge.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder(); + + /** + * + * + *
+   * Output only. Indicates if this challenge has been used to generate a token.
+   * 
+ * + * bool used = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The used. + */ + boolean getUsed(); + + /** + * + * + *
+   * Output only. Identical to nonce, but as a string.
+   * 
+ * + * string tpm_nonce = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The tpmNonce. + */ + java.lang.String getTpmNonce(); + /** + * + * + *
+   * Output only. Identical to nonce, but as a string.
+   * 
+ * + * string tpm_nonce = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for tpmNonce. + */ + com.google.protobuf.ByteString getTpmNonceBytes(); +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/CreateChallengeRequest.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/CreateChallengeRequest.java new file mode 100644 index 000000000000..a9035ce13a31 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/CreateChallengeRequest.java @@ -0,0 +1,960 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +/** + * + * + *
+ * Message for creating a Challenge
+ * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.CreateChallengeRequest} + */ +public final class CreateChallengeRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1.CreateChallengeRequest) + CreateChallengeRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use CreateChallengeRequest.newBuilder() to construct. + private CreateChallengeRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CreateChallengeRequest() { + parent_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CreateChallengeRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_CreateChallengeRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_CreateChallengeRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest.class, + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + /** + * + * + *
+   * Required. The resource name of the location where the Challenge will be
+   * used, in the format `projects/*/locations/*`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The resource name of the location where the Challenge will be
+   * used, in the format `projects/*/locations/*`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CHALLENGE_FIELD_NUMBER = 2; + private com.google.cloud.confidentialcomputing.v1.Challenge challenge_; + /** + * + * + *
+   * Required. The Challenge to be created. Currently this field can be empty as
+   * all the Challenge fields are set by the server.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the challenge field is set. + */ + @java.lang.Override + public boolean hasChallenge() { + return challenge_ != null; + } + /** + * + * + *
+   * Required. The Challenge to be created. Currently this field can be empty as
+   * all the Challenge fields are set by the server.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The challenge. + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.Challenge getChallenge() { + return challenge_ == null + ? com.google.cloud.confidentialcomputing.v1.Challenge.getDefaultInstance() + : challenge_; + } + /** + * + * + *
+   * Required. The Challenge to be created. Currently this field can be empty as
+   * all the Challenge fields are set by the server.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.ChallengeOrBuilder getChallengeOrBuilder() { + return challenge_ == null + ? com.google.cloud.confidentialcomputing.v1.Challenge.getDefaultInstance() + : challenge_; + } + + 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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + if (challenge_ != null) { + output.writeMessage(2, getChallenge()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); + } + if (challenge_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getChallenge()); + } + 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.cloud.confidentialcomputing.v1.CreateChallengeRequest)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest other = + (com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (hasChallenge() != other.hasChallenge()) return false; + if (hasChallenge()) { + if (!getChallenge().equals(other.getChallenge())) 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(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + if (hasChallenge()) { + hash = (37 * hash) + CHALLENGE_FIELD_NUMBER; + hash = (53 * hash) + getChallenge().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest 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.cloud.confidentialcomputing.v1.CreateChallengeRequest parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest 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.cloud.confidentialcomputing.v1.CreateChallengeRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest 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.cloud.confidentialcomputing.v1.CreateChallengeRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest 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.cloud.confidentialcomputing.v1.CreateChallengeRequest 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; + } + /** + * + * + *
+   * Message for creating a Challenge
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.CreateChallengeRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1.CreateChallengeRequest) + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_CreateChallengeRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_CreateChallengeRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest.class, + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest.Builder.class); + } + + // Construct using com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + challenge_ = null; + if (challengeBuilder_ != null) { + challengeBuilder_.dispose(); + challengeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_CreateChallengeRequest_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest + getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest build() { + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest buildPartial() { + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest result = + new com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.challenge_ = challengeBuilder_ == null ? challenge_ : challengeBuilder_.build(); + } + } + + @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.cloud.confidentialcomputing.v1.CreateChallengeRequest) { + return mergeFrom((com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest other) { + if (other + == com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasChallenge()) { + mergeChallenge(other.getChallenge()); + } + 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 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getChallengeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + 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 java.lang.Object parent_ = ""; + /** + * + * + *
+     * Required. The resource name of the location where the Challenge will be
+     * used, in the format `projects/*/locations/*`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The resource name of the location where the Challenge will be
+     * used, in the format `projects/*/locations/*`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The resource name of the location where the Challenge will be
+     * used, in the format `projects/*/locations/*`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The resource name of the location where the Challenge will be
+     * used, in the format `projects/*/locations/*`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The resource name of the location where the Challenge will be
+     * used, in the format `projects/*/locations/*`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.cloud.confidentialcomputing.v1.Challenge challenge_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1.Challenge, + com.google.cloud.confidentialcomputing.v1.Challenge.Builder, + com.google.cloud.confidentialcomputing.v1.ChallengeOrBuilder> + challengeBuilder_; + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the challenge field is set. + */ + public boolean hasChallenge() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The challenge. + */ + public com.google.cloud.confidentialcomputing.v1.Challenge getChallenge() { + if (challengeBuilder_ == null) { + return challenge_ == null + ? com.google.cloud.confidentialcomputing.v1.Challenge.getDefaultInstance() + : challenge_; + } else { + return challengeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setChallenge(com.google.cloud.confidentialcomputing.v1.Challenge value) { + if (challengeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + challenge_ = value; + } else { + challengeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setChallenge( + com.google.cloud.confidentialcomputing.v1.Challenge.Builder builderForValue) { + if (challengeBuilder_ == null) { + challenge_ = builderForValue.build(); + } else { + challengeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeChallenge(com.google.cloud.confidentialcomputing.v1.Challenge value) { + if (challengeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && challenge_ != null + && challenge_ + != com.google.cloud.confidentialcomputing.v1.Challenge.getDefaultInstance()) { + getChallengeBuilder().mergeFrom(value); + } else { + challenge_ = value; + } + } else { + challengeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearChallenge() { + bitField0_ = (bitField0_ & ~0x00000002); + challenge_ = null; + if (challengeBuilder_ != null) { + challengeBuilder_.dispose(); + challengeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.confidentialcomputing.v1.Challenge.Builder getChallengeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getChallengeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.confidentialcomputing.v1.ChallengeOrBuilder getChallengeOrBuilder() { + if (challengeBuilder_ != null) { + return challengeBuilder_.getMessageOrBuilder(); + } else { + return challenge_ == null + ? com.google.cloud.confidentialcomputing.v1.Challenge.getDefaultInstance() + : challenge_; + } + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1.Challenge, + com.google.cloud.confidentialcomputing.v1.Challenge.Builder, + com.google.cloud.confidentialcomputing.v1.ChallengeOrBuilder> + getChallengeFieldBuilder() { + if (challengeBuilder_ == null) { + challengeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1.Challenge, + com.google.cloud.confidentialcomputing.v1.Challenge.Builder, + com.google.cloud.confidentialcomputing.v1.ChallengeOrBuilder>( + getChallenge(), getParentForChildren(), isClean()); + challenge_ = null; + } + return challengeBuilder_; + } + + @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.cloud.confidentialcomputing.v1.CreateChallengeRequest) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1.CreateChallengeRequest) + private static final com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest(); + } + + public static com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CreateChallengeRequest 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.cloud.confidentialcomputing.v1.CreateChallengeRequest + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/CreateChallengeRequestOrBuilder.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/CreateChallengeRequestOrBuilder.java new file mode 100644 index 000000000000..f60095eefe4a --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/CreateChallengeRequestOrBuilder.java @@ -0,0 +1,100 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +public interface CreateChallengeRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1.CreateChallengeRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The resource name of the location where the Challenge will be
+   * used, in the format `projects/*/locations/*`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. The resource name of the location where the Challenge will be
+   * used, in the format `projects/*/locations/*`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The Challenge to be created. Currently this field can be empty as
+   * all the Challenge fields are set by the server.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the challenge field is set. + */ + boolean hasChallenge(); + /** + * + * + *
+   * Required. The Challenge to be created. Currently this field can be empty as
+   * all the Challenge fields are set by the server.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The challenge. + */ + com.google.cloud.confidentialcomputing.v1.Challenge getChallenge(); + /** + * + * + *
+   * Required. The Challenge to be created. Currently this field can be empty as
+   * all the Challenge fields are set by the server.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.cloud.confidentialcomputing.v1.ChallengeOrBuilder getChallengeOrBuilder(); +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/GcpCredentials.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/GcpCredentials.java new file mode 100644 index 000000000000..d7a97776fb61 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/GcpCredentials.java @@ -0,0 +1,730 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +/** + * + * + *
+ * Credentials issued by GCP which are linked to the platform attestation. These
+ * will be verified server-side as part of attestaion verification.
+ * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.GcpCredentials} + */ +public final class GcpCredentials extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1.GcpCredentials) + GcpCredentialsOrBuilder { + private static final long serialVersionUID = 0L; + // Use GcpCredentials.newBuilder() to construct. + private GcpCredentials(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private GcpCredentials() { + serviceAccountIdTokens_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GcpCredentials(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_GcpCredentials_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_GcpCredentials_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.GcpCredentials.class, + com.google.cloud.confidentialcomputing.v1.GcpCredentials.Builder.class); + } + + public static final int SERVICE_ACCOUNT_ID_TOKENS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringList serviceAccountIdTokens_; + /** + * + * + *
+   * Same as id_tokens, but as a string.
+   * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @return A list containing the serviceAccountIdTokens. + */ + public com.google.protobuf.ProtocolStringList getServiceAccountIdTokensList() { + return serviceAccountIdTokens_; + } + /** + * + * + *
+   * Same as id_tokens, but as a string.
+   * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @return The count of serviceAccountIdTokens. + */ + public int getServiceAccountIdTokensCount() { + return serviceAccountIdTokens_.size(); + } + /** + * + * + *
+   * Same as id_tokens, but as a string.
+   * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @param index The index of the element to return. + * @return The serviceAccountIdTokens at the given index. + */ + public java.lang.String getServiceAccountIdTokens(int index) { + return serviceAccountIdTokens_.get(index); + } + /** + * + * + *
+   * Same as id_tokens, but as a string.
+   * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @param index The index of the value to return. + * @return The bytes of the serviceAccountIdTokens at the given index. + */ + public com.google.protobuf.ByteString getServiceAccountIdTokensBytes(int index) { + return serviceAccountIdTokens_.getByteString(index); + } + + 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 { + for (int i = 0; i < serviceAccountIdTokens_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString( + output, 2, serviceAccountIdTokens_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < serviceAccountIdTokens_.size(); i++) { + dataSize += computeStringSizeNoTag(serviceAccountIdTokens_.getRaw(i)); + } + size += dataSize; + size += 1 * getServiceAccountIdTokensList().size(); + } + 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.cloud.confidentialcomputing.v1.GcpCredentials)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1.GcpCredentials other = + (com.google.cloud.confidentialcomputing.v1.GcpCredentials) obj; + + if (!getServiceAccountIdTokensList().equals(other.getServiceAccountIdTokensList())) + 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 (getServiceAccountIdTokensCount() > 0) { + hash = (37 * hash) + SERVICE_ACCOUNT_ID_TOKENS_FIELD_NUMBER; + hash = (53 * hash) + getServiceAccountIdTokensList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1.GcpCredentials parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.GcpCredentials parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.GcpCredentials parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.GcpCredentials 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.cloud.confidentialcomputing.v1.GcpCredentials parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.GcpCredentials parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.GcpCredentials parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.GcpCredentials 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.cloud.confidentialcomputing.v1.GcpCredentials parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.GcpCredentials 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.cloud.confidentialcomputing.v1.GcpCredentials parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.GcpCredentials 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.cloud.confidentialcomputing.v1.GcpCredentials 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; + } + /** + * + * + *
+   * Credentials issued by GCP which are linked to the platform attestation. These
+   * will be verified server-side as part of attestaion verification.
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.GcpCredentials} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1.GcpCredentials) + com.google.cloud.confidentialcomputing.v1.GcpCredentialsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_GcpCredentials_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_GcpCredentials_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.GcpCredentials.class, + com.google.cloud.confidentialcomputing.v1.GcpCredentials.Builder.class); + } + + // Construct using com.google.cloud.confidentialcomputing.v1.GcpCredentials.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + serviceAccountIdTokens_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_GcpCredentials_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.GcpCredentials getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1.GcpCredentials.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.GcpCredentials build() { + com.google.cloud.confidentialcomputing.v1.GcpCredentials result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.GcpCredentials buildPartial() { + com.google.cloud.confidentialcomputing.v1.GcpCredentials result = + new com.google.cloud.confidentialcomputing.v1.GcpCredentials(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.cloud.confidentialcomputing.v1.GcpCredentials result) { + if (((bitField0_ & 0x00000001) != 0)) { + serviceAccountIdTokens_ = serviceAccountIdTokens_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.serviceAccountIdTokens_ = serviceAccountIdTokens_; + } + + private void buildPartial0(com.google.cloud.confidentialcomputing.v1.GcpCredentials result) { + int from_bitField0_ = 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.cloud.confidentialcomputing.v1.GcpCredentials) { + return mergeFrom((com.google.cloud.confidentialcomputing.v1.GcpCredentials) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.confidentialcomputing.v1.GcpCredentials other) { + if (other == com.google.cloud.confidentialcomputing.v1.GcpCredentials.getDefaultInstance()) + return this; + if (!other.serviceAccountIdTokens_.isEmpty()) { + if (serviceAccountIdTokens_.isEmpty()) { + serviceAccountIdTokens_ = other.serviceAccountIdTokens_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureServiceAccountIdTokensIsMutable(); + serviceAccountIdTokens_.addAll(other.serviceAccountIdTokens_); + } + onChanged(); + } + 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 18: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureServiceAccountIdTokensIsMutable(); + serviceAccountIdTokens_.add(s); + break; + } // case 18 + 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 com.google.protobuf.LazyStringList serviceAccountIdTokens_ = + com.google.protobuf.LazyStringArrayList.EMPTY; + + private void ensureServiceAccountIdTokensIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + serviceAccountIdTokens_ = + new com.google.protobuf.LazyStringArrayList(serviceAccountIdTokens_); + bitField0_ |= 0x00000001; + } + } + /** + * + * + *
+     * Same as id_tokens, but as a string.
+     * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @return A list containing the serviceAccountIdTokens. + */ + public com.google.protobuf.ProtocolStringList getServiceAccountIdTokensList() { + return serviceAccountIdTokens_.getUnmodifiableView(); + } + /** + * + * + *
+     * Same as id_tokens, but as a string.
+     * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @return The count of serviceAccountIdTokens. + */ + public int getServiceAccountIdTokensCount() { + return serviceAccountIdTokens_.size(); + } + /** + * + * + *
+     * Same as id_tokens, but as a string.
+     * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @param index The index of the element to return. + * @return The serviceAccountIdTokens at the given index. + */ + public java.lang.String getServiceAccountIdTokens(int index) { + return serviceAccountIdTokens_.get(index); + } + /** + * + * + *
+     * Same as id_tokens, but as a string.
+     * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @param index The index of the value to return. + * @return The bytes of the serviceAccountIdTokens at the given index. + */ + public com.google.protobuf.ByteString getServiceAccountIdTokensBytes(int index) { + return serviceAccountIdTokens_.getByteString(index); + } + /** + * + * + *
+     * Same as id_tokens, but as a string.
+     * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @param index The index to set the value at. + * @param value The serviceAccountIdTokens to set. + * @return This builder for chaining. + */ + public Builder setServiceAccountIdTokens(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureServiceAccountIdTokensIsMutable(); + serviceAccountIdTokens_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+     * Same as id_tokens, but as a string.
+     * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @param value The serviceAccountIdTokens to add. + * @return This builder for chaining. + */ + public Builder addServiceAccountIdTokens(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureServiceAccountIdTokensIsMutable(); + serviceAccountIdTokens_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+     * Same as id_tokens, but as a string.
+     * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @param values The serviceAccountIdTokens to add. + * @return This builder for chaining. + */ + public Builder addAllServiceAccountIdTokens(java.lang.Iterable values) { + ensureServiceAccountIdTokensIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, serviceAccountIdTokens_); + onChanged(); + return this; + } + /** + * + * + *
+     * Same as id_tokens, but as a string.
+     * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @return This builder for chaining. + */ + public Builder clearServiceAccountIdTokens() { + serviceAccountIdTokens_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Same as id_tokens, but as a string.
+     * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @param value The bytes of the serviceAccountIdTokens to add. + * @return This builder for chaining. + */ + public Builder addServiceAccountIdTokensBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureServiceAccountIdTokensIsMutable(); + serviceAccountIdTokens_.add(value); + 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.cloud.confidentialcomputing.v1.GcpCredentials) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1.GcpCredentials) + private static final com.google.cloud.confidentialcomputing.v1.GcpCredentials DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.confidentialcomputing.v1.GcpCredentials(); + } + + public static com.google.cloud.confidentialcomputing.v1.GcpCredentials getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GcpCredentials 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.cloud.confidentialcomputing.v1.GcpCredentials getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/GcpCredentialsOrBuilder.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/GcpCredentialsOrBuilder.java new file mode 100644 index 000000000000..47855801efac --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/GcpCredentialsOrBuilder.java @@ -0,0 +1,76 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +public interface GcpCredentialsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1.GcpCredentials) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Same as id_tokens, but as a string.
+   * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @return A list containing the serviceAccountIdTokens. + */ + java.util.List getServiceAccountIdTokensList(); + /** + * + * + *
+   * Same as id_tokens, but as a string.
+   * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @return The count of serviceAccountIdTokens. + */ + int getServiceAccountIdTokensCount(); + /** + * + * + *
+   * Same as id_tokens, but as a string.
+   * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @param index The index of the element to return. + * @return The serviceAccountIdTokens at the given index. + */ + java.lang.String getServiceAccountIdTokens(int index); + /** + * + * + *
+   * Same as id_tokens, but as a string.
+   * 
+ * + * repeated string service_account_id_tokens = 2; + * + * @param index The index of the value to return. + * @return The bytes of the serviceAccountIdTokens at the given index. + */ + com.google.protobuf.ByteString getServiceAccountIdTokensBytes(int index); +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/LocationName.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/LocationName.java new file mode 100644 index 000000000000..ea86e77e5e2e --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/LocationName.java @@ -0,0 +1,192 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class LocationName implements ResourceName { + private static final PathTemplate PROJECT_LOCATION = + PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}"); + private volatile Map fieldValuesMap; + private final String project; + private final String location; + + @Deprecated + protected LocationName() { + project = null; + location = null; + } + + private LocationName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static LocationName of(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build(); + } + + public static String format(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build().toString(); + } + + public static LocationName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_LOCATION.validatedMatch( + formattedString, "LocationName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("location")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (LocationName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_LOCATION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_LOCATION.instantiate("project", project, "location", location); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + LocationName that = ((LocationName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + return h; + } + + /** Builder for projects/{project}/locations/{location}. */ + public static class Builder { + private String project; + private String location; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + private Builder(LocationName locationName) { + this.project = locationName.project; + this.location = locationName.location; + } + + public LocationName build() { + return new LocationName(this); + } + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/ServiceProto.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/ServiceProto.java new file mode 100644 index 000000000000..182f783950f7 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/ServiceProto.java @@ -0,0 +1,228 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +public final class ServiceProto { + private ServiceProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1_Challenge_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1_Challenge_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1_CreateChallengeRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1_CreateChallengeRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1_GcpCredentials_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1_GcpCredentials_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_PcrValuesEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_PcrValuesEntry_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n3google/cloud/confidentialcomputing/v1/" + + "service.proto\022%google.cloud.confidential" + + "computing.v1\032\034google/api/annotations.pro" + + "to\032\027google/api/client.proto\032\037google/api/" + + "field_behavior.proto\032\031google/api/resourc" + + "e.proto\032\037google/protobuf/timestamp.proto" + + "\"\245\002\n\tChallenge\022\021\n\004name\030\001 \001(\tB\003\340A\003\0224\n\013cre" + + "ate_time\030\002 \001(\0132\032.google.protobuf.Timesta" + + "mpB\003\340A\003\0224\n\013expire_time\030\003 \001(\0132\032.google.pr" + + "otobuf.TimestampB\003\340A\003\022\021\n\004used\030\004 \001(\010B\003\340A\003" + + "\022\026\n\ttpm_nonce\030\006 \001(\tB\003\340A\003:n\352Ak\n.confident" + + "ialcomputing.googleapis.com/Challenge\0229p" + + "rojects/{project}/locations/{location}/c" + + "hallenges/{uuid}\"\235\001\n\026CreateChallengeRequ" + + "est\0229\n\006parent\030\001 \001(\tB)\340A\002\372A#\n!locations.g" + + "oogleapis.com/Location\022H\n\tchallenge\030\002 \001(" + + "\01320.google.cloud.confidentialcomputing.v" + + "1.ChallengeB\003\340A\002\"\217\002\n\030VerifyAttestationRe" + + "quest\022I\n\tchallenge\030\001 \001(\tB6\340A\002\372A0\n.confid" + + "entialcomputing.googleapis.com/Challenge" + + "\022S\n\017gcp_credentials\030\002 \001(\01325.google.cloud" + + ".confidentialcomputing.v1.GcpCredentials" + + "B\003\340A\001\022S\n\017tpm_attestation\030\003 \001(\01325.google." + + "cloud.confidentialcomputing.v1.TpmAttest" + + "ationB\003\340A\002\";\n\031VerifyAttestationResponse\022" + + "\036\n\021oidc_claims_token\030\002 \001(\tB\003\340A\003\"3\n\016GcpCr" + + "edentials\022!\n\031service_account_id_tokens\030\002" + + " \003(\t\"\217\003\n\016TpmAttestation\022K\n\006quotes\030\001 \003(\0132" + + ";.google.cloud.confidentialcomputing.v1." + + "TpmAttestation.Quote\022\025\n\rtcg_event_log\030\002 " + + "\001(\014\022\033\n\023canonical_event_log\030\003 \001(\014\022\017\n\007ak_c" + + "ert\030\004 \001(\014\022\022\n\ncert_chain\030\005 \003(\014\032\326\001\n\005Quote\022" + + "\021\n\thash_algo\030\001 \001(\005\022^\n\npcr_values\030\002 \003(\0132J" + + ".google.cloud.confidentialcomputing.v1.T" + + "pmAttestation.Quote.PcrValuesEntry\022\021\n\tra" + + "w_quote\030\003 \001(\014\022\025\n\rraw_signature\030\004 \001(\014\0320\n\016" + + "PcrValuesEntry\022\013\n\003key\030\001 \001(\005\022\r\n\005value\030\002 \001" + + "(\014:\0028\0012\267\004\n\025ConfidentialComputing\022\330\001\n\017Cre" + + "ateChallenge\022=.google.cloud.confidential" + + "computing.v1.CreateChallengeRequest\0320.go" + + "ogle.cloud.confidentialcomputing.v1.Chal" + + "lenge\"T\202\323\344\223\002;\"./v1/{parent=projects/*/lo" + + "cations/*}/challenges:\tchallenge\332A\020paren" + + "t,challenge\022\350\001\n\021VerifyAttestation\022?.goog" + + "le.cloud.confidentialcomputing.v1.Verify" + + "AttestationRequest\032@.google.cloud.confid" + + "entialcomputing.v1.VerifyAttestationResp" + + "onse\"P\202\323\344\223\002J\"E/v1/{challenge=projects/*/" + + "locations/*/challenges/*}:verifyAttestat" + + "ion:\001*\032X\312A$confidentialcomputing.googlea" + + "pis.com\322A.https://www.googleapis.com/aut" + + "h/cloud-platformB\227\002\n)com.google.cloud.co" + + "nfidentialcomputing.v1B\014ServiceProtoP\001Z_" + + "cloud.google.com/go/confidentialcomputin" + + "g/apiv1/confidentialcomputingpb;confiden" + + "tialcomputingpb\252\002%Google.Cloud.Confident" + + "ialComputing.V1\312\002%Google\\Cloud\\Confident" + + "ialComputing\\V1\352\002(Google::Cloud::Confide" + + "ntialComputing::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.AnnotationsProto.getDescriptor(), + com.google.api.ClientProto.getDescriptor(), + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_cloud_confidentialcomputing_v1_Challenge_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_cloud_confidentialcomputing_v1_Challenge_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1_Challenge_descriptor, + new java.lang.String[] { + "Name", "CreateTime", "ExpireTime", "Used", "TpmNonce", + }); + internal_static_google_cloud_confidentialcomputing_v1_CreateChallengeRequest_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_cloud_confidentialcomputing_v1_CreateChallengeRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1_CreateChallengeRequest_descriptor, + new java.lang.String[] { + "Parent", "Challenge", + }); + internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationRequest_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationRequest_descriptor, + new java.lang.String[] { + "Challenge", "GcpCredentials", "TpmAttestation", + }); + internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationResponse_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationResponse_descriptor, + new java.lang.String[] { + "OidcClaimsToken", + }); + internal_static_google_cloud_confidentialcomputing_v1_GcpCredentials_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_cloud_confidentialcomputing_v1_GcpCredentials_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1_GcpCredentials_descriptor, + new java.lang.String[] { + "ServiceAccountIdTokens", + }); + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_descriptor, + new java.lang.String[] { + "Quotes", "TcgEventLog", "CanonicalEventLog", "AkCert", "CertChain", + }); + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_descriptor = + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_descriptor + .getNestedTypes() + .get(0); + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_descriptor, + new java.lang.String[] { + "HashAlgo", "PcrValues", "RawQuote", "RawSignature", + }); + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_PcrValuesEntry_descriptor = + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_descriptor + .getNestedTypes() + .get(0); + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_PcrValuesEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_PcrValuesEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.ClientProto.defaultHost); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.AnnotationsProto.http); + registry.add(com.google.api.ClientProto.methodSignature); + registry.add(com.google.api.ClientProto.oauthScopes); + registry.add(com.google.api.ResourceProto.resource); + registry.add(com.google.api.ResourceProto.resourceReference); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + com.google.api.AnnotationsProto.getDescriptor(); + com.google.api.ClientProto.getDescriptor(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/TpmAttestation.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/TpmAttestation.java new file mode 100644 index 000000000000..ceb809f8b6e7 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/TpmAttestation.java @@ -0,0 +1,2669 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +/** + * + * + *
+ * TPM2 data containing everything necessary to validate any platform state
+ * measured into the TPM.
+ * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.TpmAttestation} + */ +public final class TpmAttestation extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1.TpmAttestation) + TpmAttestationOrBuilder { + private static final long serialVersionUID = 0L; + // Use TpmAttestation.newBuilder() to construct. + private TpmAttestation(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private TpmAttestation() { + quotes_ = java.util.Collections.emptyList(); + tcgEventLog_ = com.google.protobuf.ByteString.EMPTY; + canonicalEventLog_ = com.google.protobuf.ByteString.EMPTY; + akCert_ = com.google.protobuf.ByteString.EMPTY; + certChain_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new TpmAttestation(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.TpmAttestation.class, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Builder.class); + } + + public interface QuoteOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1.TpmAttestation.Quote) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The hash algorithm of the PCR bank being quoted, encoded as a TPM_ALG_ID
+     * 
+ * + * int32 hash_algo = 1; + * + * @return The hashAlgo. + */ + int getHashAlgo(); + + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + int getPcrValuesCount(); + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + boolean containsPcrValues(int key); + /** Use {@link #getPcrValuesMap()} instead. */ + @java.lang.Deprecated + java.util.Map getPcrValues(); + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + java.util.Map getPcrValuesMap(); + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + /* nullable */ + com.google.protobuf.ByteString getPcrValuesOrDefault( + int key, + /* nullable */ + com.google.protobuf.ByteString defaultValue); + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + com.google.protobuf.ByteString getPcrValuesOrThrow(int key); + + /** + * + * + *
+     * TPM2 quote, encoded as a TPMS_ATTEST
+     * 
+ * + * bytes raw_quote = 3; + * + * @return The rawQuote. + */ + com.google.protobuf.ByteString getRawQuote(); + + /** + * + * + *
+     * TPM2 signature, encoded as a TPMT_SIGNATURE
+     * 
+ * + * bytes raw_signature = 4; + * + * @return The rawSignature. + */ + com.google.protobuf.ByteString getRawSignature(); + } + /** + * + * + *
+   * Information about Platform Control Registers (PCRs) including a signature
+   * over their values, which can be used for remote validation.
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.TpmAttestation.Quote} + */ + public static final class Quote extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1.TpmAttestation.Quote) + QuoteOrBuilder { + private static final long serialVersionUID = 0L; + // Use Quote.newBuilder() to construct. + private Quote(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Quote() { + rawQuote_ = com.google.protobuf.ByteString.EMPTY; + rawSignature_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Quote(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapField internalGetMapField(int number) { + switch (number) { + case 2: + return internalGetPcrValues(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.class, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.Builder.class); + } + + public static final int HASH_ALGO_FIELD_NUMBER = 1; + private int hashAlgo_ = 0; + /** + * + * + *
+     * The hash algorithm of the PCR bank being quoted, encoded as a TPM_ALG_ID
+     * 
+ * + * int32 hash_algo = 1; + * + * @return The hashAlgo. + */ + @java.lang.Override + public int getHashAlgo() { + return hashAlgo_; + } + + public static final int PCR_VALUES_FIELD_NUMBER = 2; + + private static final class PcrValuesDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_PcrValuesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.INT32, + 0, + com.google.protobuf.WireFormat.FieldType.BYTES, + com.google.protobuf.ByteString.EMPTY); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField + pcrValues_; + + private com.google.protobuf.MapField + internalGetPcrValues() { + if (pcrValues_ == null) { + return com.google.protobuf.MapField.emptyMapField(PcrValuesDefaultEntryHolder.defaultEntry); + } + return pcrValues_; + } + + public int getPcrValuesCount() { + return internalGetPcrValues().getMap().size(); + } + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public boolean containsPcrValues(int key) { + + return internalGetPcrValues().getMap().containsKey(key); + } + /** Use {@link #getPcrValuesMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getPcrValues() { + return getPcrValuesMap(); + } + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public java.util.Map getPcrValuesMap() { + return internalGetPcrValues().getMap(); + } + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public /* nullable */ com.google.protobuf.ByteString getPcrValuesOrDefault( + int key, + /* nullable */ + com.google.protobuf.ByteString defaultValue) { + + java.util.Map map = + internalGetPcrValues().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public com.google.protobuf.ByteString getPcrValuesOrThrow(int key) { + + java.util.Map map = + internalGetPcrValues().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int RAW_QUOTE_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString rawQuote_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * TPM2 quote, encoded as a TPMS_ATTEST
+     * 
+ * + * bytes raw_quote = 3; + * + * @return The rawQuote. + */ + @java.lang.Override + public com.google.protobuf.ByteString getRawQuote() { + return rawQuote_; + } + + public static final int RAW_SIGNATURE_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString rawSignature_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * TPM2 signature, encoded as a TPMT_SIGNATURE
+     * 
+ * + * bytes raw_signature = 4; + * + * @return The rawSignature. + */ + @java.lang.Override + public com.google.protobuf.ByteString getRawSignature() { + return rawSignature_; + } + + 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 (hashAlgo_ != 0) { + output.writeInt32(1, hashAlgo_); + } + com.google.protobuf.GeneratedMessageV3.serializeIntegerMapTo( + output, internalGetPcrValues(), PcrValuesDefaultEntryHolder.defaultEntry, 2); + if (!rawQuote_.isEmpty()) { + output.writeBytes(3, rawQuote_); + } + if (!rawSignature_.isEmpty()) { + output.writeBytes(4, rawSignature_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (hashAlgo_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, hashAlgo_); + } + for (java.util.Map.Entry entry : + internalGetPcrValues().getMap().entrySet()) { + com.google.protobuf.MapEntry + pcrValues__ = + PcrValuesDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, pcrValues__); + } + if (!rawQuote_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, rawQuote_); + } + if (!rawSignature_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(4, rawSignature_); + } + 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.cloud.confidentialcomputing.v1.TpmAttestation.Quote)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote other = + (com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote) obj; + + if (getHashAlgo() != other.getHashAlgo()) return false; + if (!internalGetPcrValues().equals(other.internalGetPcrValues())) return false; + if (!getRawQuote().equals(other.getRawQuote())) return false; + if (!getRawSignature().equals(other.getRawSignature())) 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(); + hash = (37 * hash) + HASH_ALGO_FIELD_NUMBER; + hash = (53 * hash) + getHashAlgo(); + if (!internalGetPcrValues().getMap().isEmpty()) { + hash = (37 * hash) + PCR_VALUES_FIELD_NUMBER; + hash = (53 * hash) + internalGetPcrValues().hashCode(); + } + hash = (37 * hash) + RAW_QUOTE_FIELD_NUMBER; + hash = (53 * hash) + getRawQuote().hashCode(); + hash = (37 * hash) + RAW_SIGNATURE_FIELD_NUMBER; + hash = (53 * hash) + getRawSignature().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote 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.cloud.confidentialcomputing.v1.TpmAttestation.Quote parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote 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.cloud.confidentialcomputing.v1.TpmAttestation.Quote parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote 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.cloud.confidentialcomputing.v1.TpmAttestation.Quote parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote 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.cloud.confidentialcomputing.v1.TpmAttestation.Quote 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; + } + /** + * + * + *
+     * Information about Platform Control Registers (PCRs) including a signature
+     * over their values, which can be used for remote validation.
+     * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.TpmAttestation.Quote} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1.TpmAttestation.Quote) + com.google.cloud.confidentialcomputing.v1.TpmAttestation.QuoteOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField(int number) { + switch (number) { + case 2: + return internalGetPcrValues(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField(int number) { + switch (number) { + case 2: + return internalGetMutablePcrValues(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.class, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.Builder.class); + } + + // Construct using com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + hashAlgo_ = 0; + internalGetMutablePcrValues().clear(); + rawQuote_ = com.google.protobuf.ByteString.EMPTY; + rawSignature_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_Quote_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote + getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote build() { + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote buildPartial() { + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote result = + new com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.hashAlgo_ = hashAlgo_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.pcrValues_ = internalGetPcrValues(); + result.pcrValues_.makeImmutable(); + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.rawQuote_ = rawQuote_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.rawSignature_ = rawSignature_; + } + } + + @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.cloud.confidentialcomputing.v1.TpmAttestation.Quote) { + return mergeFrom((com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote other) { + if (other + == com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.getDefaultInstance()) + return this; + if (other.getHashAlgo() != 0) { + setHashAlgo(other.getHashAlgo()); + } + internalGetMutablePcrValues().mergeFrom(other.internalGetPcrValues()); + bitField0_ |= 0x00000002; + if (other.getRawQuote() != com.google.protobuf.ByteString.EMPTY) { + setRawQuote(other.getRawQuote()); + } + if (other.getRawSignature() != com.google.protobuf.ByteString.EMPTY) { + setRawSignature(other.getRawSignature()); + } + 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: + { + hashAlgo_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: + { + com.google.protobuf.MapEntry + pcrValues__ = + input.readMessage( + PcrValuesDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutablePcrValues() + .getMutableMap() + .put(pcrValues__.getKey(), pcrValues__.getValue()); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + rawQuote_ = input.readBytes(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + rawSignature_ = input.readBytes(); + bitField0_ |= 0x00000008; + break; + } // case 34 + 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 int hashAlgo_; + /** + * + * + *
+       * The hash algorithm of the PCR bank being quoted, encoded as a TPM_ALG_ID
+       * 
+ * + * int32 hash_algo = 1; + * + * @return The hashAlgo. + */ + @java.lang.Override + public int getHashAlgo() { + return hashAlgo_; + } + /** + * + * + *
+       * The hash algorithm of the PCR bank being quoted, encoded as a TPM_ALG_ID
+       * 
+ * + * int32 hash_algo = 1; + * + * @param value The hashAlgo to set. + * @return This builder for chaining. + */ + public Builder setHashAlgo(int value) { + + hashAlgo_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+       * The hash algorithm of the PCR bank being quoted, encoded as a TPM_ALG_ID
+       * 
+ * + * int32 hash_algo = 1; + * + * @return This builder for chaining. + */ + public Builder clearHashAlgo() { + bitField0_ = (bitField0_ & ~0x00000001); + hashAlgo_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.MapField + pcrValues_; + + private com.google.protobuf.MapField + internalGetPcrValues() { + if (pcrValues_ == null) { + return com.google.protobuf.MapField.emptyMapField( + PcrValuesDefaultEntryHolder.defaultEntry); + } + return pcrValues_; + } + + private com.google.protobuf.MapField + internalGetMutablePcrValues() { + if (pcrValues_ == null) { + pcrValues_ = + com.google.protobuf.MapField.newMapField(PcrValuesDefaultEntryHolder.defaultEntry); + } + if (!pcrValues_.isMutable()) { + pcrValues_ = pcrValues_.copy(); + } + bitField0_ |= 0x00000002; + onChanged(); + return pcrValues_; + } + + public int getPcrValuesCount() { + return internalGetPcrValues().getMap().size(); + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public boolean containsPcrValues(int key) { + + return internalGetPcrValues().getMap().containsKey(key); + } + /** Use {@link #getPcrValuesMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getPcrValues() { + return getPcrValuesMap(); + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public java.util.Map getPcrValuesMap() { + return internalGetPcrValues().getMap(); + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public /* nullable */ com.google.protobuf.ByteString getPcrValuesOrDefault( + int key, + /* nullable */ + com.google.protobuf.ByteString defaultValue) { + + java.util.Map map = + internalGetPcrValues().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public com.google.protobuf.ByteString getPcrValuesOrThrow(int key) { + + java.util.Map map = + internalGetPcrValues().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearPcrValues() { + bitField0_ = (bitField0_ & ~0x00000002); + internalGetMutablePcrValues().getMutableMap().clear(); + return this; + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + public Builder removePcrValues(int key) { + + internalGetMutablePcrValues().getMutableMap().remove(key); + return this; + } + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map + getMutablePcrValues() { + bitField0_ |= 0x00000002; + return internalGetMutablePcrValues().getMutableMap(); + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + public Builder putPcrValues(int key, com.google.protobuf.ByteString value) { + + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutablePcrValues().getMutableMap().put(key, value); + bitField0_ |= 0x00000002; + return this; + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + public Builder putAllPcrValues( + java.util.Map values) { + internalGetMutablePcrValues().getMutableMap().putAll(values); + bitField0_ |= 0x00000002; + return this; + } + + private com.google.protobuf.ByteString rawQuote_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+       * TPM2 quote, encoded as a TPMS_ATTEST
+       * 
+ * + * bytes raw_quote = 3; + * + * @return The rawQuote. + */ + @java.lang.Override + public com.google.protobuf.ByteString getRawQuote() { + return rawQuote_; + } + /** + * + * + *
+       * TPM2 quote, encoded as a TPMS_ATTEST
+       * 
+ * + * bytes raw_quote = 3; + * + * @param value The rawQuote to set. + * @return This builder for chaining. + */ + public Builder setRawQuote(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + rawQuote_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+       * TPM2 quote, encoded as a TPMS_ATTEST
+       * 
+ * + * bytes raw_quote = 3; + * + * @return This builder for chaining. + */ + public Builder clearRawQuote() { + bitField0_ = (bitField0_ & ~0x00000004); + rawQuote_ = getDefaultInstance().getRawQuote(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString rawSignature_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+       * TPM2 signature, encoded as a TPMT_SIGNATURE
+       * 
+ * + * bytes raw_signature = 4; + * + * @return The rawSignature. + */ + @java.lang.Override + public com.google.protobuf.ByteString getRawSignature() { + return rawSignature_; + } + /** + * + * + *
+       * TPM2 signature, encoded as a TPMT_SIGNATURE
+       * 
+ * + * bytes raw_signature = 4; + * + * @param value The rawSignature to set. + * @return This builder for chaining. + */ + public Builder setRawSignature(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + rawSignature_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+       * TPM2 signature, encoded as a TPMT_SIGNATURE
+       * 
+ * + * bytes raw_signature = 4; + * + * @return This builder for chaining. + */ + public Builder clearRawSignature() { + bitField0_ = (bitField0_ & ~0x00000008); + rawSignature_ = getDefaultInstance().getRawSignature(); + 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.cloud.confidentialcomputing.v1.TpmAttestation.Quote) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1.TpmAttestation.Quote) + private static final com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote(); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Quote 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.cloud.confidentialcomputing.v1.TpmAttestation.Quote + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public static final int QUOTES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List quotes_; + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + @java.lang.Override + public java.util.List + getQuotesList() { + return quotes_; + } + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + @java.lang.Override + public java.util.List< + ? extends com.google.cloud.confidentialcomputing.v1.TpmAttestation.QuoteOrBuilder> + getQuotesOrBuilderList() { + return quotes_; + } + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + @java.lang.Override + public int getQuotesCount() { + return quotes_.size(); + } + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote getQuotes(int index) { + return quotes_.get(index); + } + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.TpmAttestation.QuoteOrBuilder getQuotesOrBuilder( + int index) { + return quotes_.get(index); + } + + public static final int TCG_EVENT_LOG_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString tcgEventLog_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+   * The binary TCG Event Log containing events measured into the TPM by the
+   * platform firmware and operating system. Formatted as described in the
+   * "TCG PC Client Platform Firmware Profile Specification".
+   * 
+ * + * bytes tcg_event_log = 2; + * + * @return The tcgEventLog. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTcgEventLog() { + return tcgEventLog_; + } + + public static final int CANONICAL_EVENT_LOG_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString canonicalEventLog_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+   * An Event Log containing additional events measured into the TPM that are
+   * not already present in the tcg_event_log. Formatted as described in the
+   * "Canonical Event Log Format" TCG Specification.
+   * 
+ * + * bytes canonical_event_log = 3; + * + * @return The canonicalEventLog. + */ + @java.lang.Override + public com.google.protobuf.ByteString getCanonicalEventLog() { + return canonicalEventLog_; + } + + public static final int AK_CERT_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString akCert_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+   * DER-encoded X.509 certificate of the Attestation Key (otherwise known as
+   * an AK or a TPM restricted signing key) used to generate the quotes.
+   * 
+ * + * bytes ak_cert = 4; + * + * @return The akCert. + */ + @java.lang.Override + public com.google.protobuf.ByteString getAkCert() { + return akCert_; + } + + public static final int CERT_CHAIN_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private java.util.List certChain_; + /** + * + * + *
+   * List of DER-encoded X.509 certificates which, together with the ak_cert,
+   * chain back to a trusted Root Certificate.
+   * 
+ * + * repeated bytes cert_chain = 5; + * + * @return A list containing the certChain. + */ + @java.lang.Override + public java.util.List getCertChainList() { + return certChain_; + } + /** + * + * + *
+   * List of DER-encoded X.509 certificates which, together with the ak_cert,
+   * chain back to a trusted Root Certificate.
+   * 
+ * + * repeated bytes cert_chain = 5; + * + * @return The count of certChain. + */ + public int getCertChainCount() { + return certChain_.size(); + } + /** + * + * + *
+   * List of DER-encoded X.509 certificates which, together with the ak_cert,
+   * chain back to a trusted Root Certificate.
+   * 
+ * + * repeated bytes cert_chain = 5; + * + * @param index The index of the element to return. + * @return The certChain at the given index. + */ + public com.google.protobuf.ByteString getCertChain(int index) { + return certChain_.get(index); + } + + 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 { + for (int i = 0; i < quotes_.size(); i++) { + output.writeMessage(1, quotes_.get(i)); + } + if (!tcgEventLog_.isEmpty()) { + output.writeBytes(2, tcgEventLog_); + } + if (!canonicalEventLog_.isEmpty()) { + output.writeBytes(3, canonicalEventLog_); + } + if (!akCert_.isEmpty()) { + output.writeBytes(4, akCert_); + } + for (int i = 0; i < certChain_.size(); i++) { + output.writeBytes(5, certChain_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < quotes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, quotes_.get(i)); + } + if (!tcgEventLog_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, tcgEventLog_); + } + if (!canonicalEventLog_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, canonicalEventLog_); + } + if (!akCert_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(4, akCert_); + } + { + int dataSize = 0; + for (int i = 0; i < certChain_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream.computeBytesSizeNoTag(certChain_.get(i)); + } + size += dataSize; + size += 1 * getCertChainList().size(); + } + 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.cloud.confidentialcomputing.v1.TpmAttestation)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1.TpmAttestation other = + (com.google.cloud.confidentialcomputing.v1.TpmAttestation) obj; + + if (!getQuotesList().equals(other.getQuotesList())) return false; + if (!getTcgEventLog().equals(other.getTcgEventLog())) return false; + if (!getCanonicalEventLog().equals(other.getCanonicalEventLog())) return false; + if (!getAkCert().equals(other.getAkCert())) return false; + if (!getCertChainList().equals(other.getCertChainList())) 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 (getQuotesCount() > 0) { + hash = (37 * hash) + QUOTES_FIELD_NUMBER; + hash = (53 * hash) + getQuotesList().hashCode(); + } + hash = (37 * hash) + TCG_EVENT_LOG_FIELD_NUMBER; + hash = (53 * hash) + getTcgEventLog().hashCode(); + hash = (37 * hash) + CANONICAL_EVENT_LOG_FIELD_NUMBER; + hash = (53 * hash) + getCanonicalEventLog().hashCode(); + hash = (37 * hash) + AK_CERT_FIELD_NUMBER; + hash = (53 * hash) + getAkCert().hashCode(); + if (getCertChainCount() > 0) { + hash = (37 * hash) + CERT_CHAIN_FIELD_NUMBER; + hash = (53 * hash) + getCertChainList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation 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.cloud.confidentialcomputing.v1.TpmAttestation parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation 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.cloud.confidentialcomputing.v1.TpmAttestation parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation 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.cloud.confidentialcomputing.v1.TpmAttestation parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation 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.cloud.confidentialcomputing.v1.TpmAttestation 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; + } + /** + * + * + *
+   * TPM2 data containing everything necessary to validate any platform state
+   * measured into the TPM.
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.TpmAttestation} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1.TpmAttestation) + com.google.cloud.confidentialcomputing.v1.TpmAttestationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.TpmAttestation.class, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Builder.class); + } + + // Construct using com.google.cloud.confidentialcomputing.v1.TpmAttestation.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (quotesBuilder_ == null) { + quotes_ = java.util.Collections.emptyList(); + } else { + quotes_ = null; + quotesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + tcgEventLog_ = com.google.protobuf.ByteString.EMPTY; + canonicalEventLog_ = com.google.protobuf.ByteString.EMPTY; + akCert_ = com.google.protobuf.ByteString.EMPTY; + certChain_ = java.util.Collections.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_TpmAttestation_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.TpmAttestation getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1.TpmAttestation.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.TpmAttestation build() { + com.google.cloud.confidentialcomputing.v1.TpmAttestation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.TpmAttestation buildPartial() { + com.google.cloud.confidentialcomputing.v1.TpmAttestation result = + new com.google.cloud.confidentialcomputing.v1.TpmAttestation(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.cloud.confidentialcomputing.v1.TpmAttestation result) { + if (quotesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + quotes_ = java.util.Collections.unmodifiableList(quotes_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.quotes_ = quotes_; + } else { + result.quotes_ = quotesBuilder_.build(); + } + if (((bitField0_ & 0x00000010) != 0)) { + certChain_ = java.util.Collections.unmodifiableList(certChain_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.certChain_ = certChain_; + } + + private void buildPartial0(com.google.cloud.confidentialcomputing.v1.TpmAttestation result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.tcgEventLog_ = tcgEventLog_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.canonicalEventLog_ = canonicalEventLog_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.akCert_ = akCert_; + } + } + + @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.cloud.confidentialcomputing.v1.TpmAttestation) { + return mergeFrom((com.google.cloud.confidentialcomputing.v1.TpmAttestation) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.confidentialcomputing.v1.TpmAttestation other) { + if (other == com.google.cloud.confidentialcomputing.v1.TpmAttestation.getDefaultInstance()) + return this; + if (quotesBuilder_ == null) { + if (!other.quotes_.isEmpty()) { + if (quotes_.isEmpty()) { + quotes_ = other.quotes_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureQuotesIsMutable(); + quotes_.addAll(other.quotes_); + } + onChanged(); + } + } else { + if (!other.quotes_.isEmpty()) { + if (quotesBuilder_.isEmpty()) { + quotesBuilder_.dispose(); + quotesBuilder_ = null; + quotes_ = other.quotes_; + bitField0_ = (bitField0_ & ~0x00000001); + quotesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getQuotesFieldBuilder() + : null; + } else { + quotesBuilder_.addAllMessages(other.quotes_); + } + } + } + if (other.getTcgEventLog() != com.google.protobuf.ByteString.EMPTY) { + setTcgEventLog(other.getTcgEventLog()); + } + if (other.getCanonicalEventLog() != com.google.protobuf.ByteString.EMPTY) { + setCanonicalEventLog(other.getCanonicalEventLog()); + } + if (other.getAkCert() != com.google.protobuf.ByteString.EMPTY) { + setAkCert(other.getAkCert()); + } + if (!other.certChain_.isEmpty()) { + if (certChain_.isEmpty()) { + certChain_ = other.certChain_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureCertChainIsMutable(); + certChain_.addAll(other.certChain_); + } + onChanged(); + } + 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 10: + { + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote m = + input.readMessage( + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.parser(), + extensionRegistry); + if (quotesBuilder_ == null) { + ensureQuotesIsMutable(); + quotes_.add(m); + } else { + quotesBuilder_.addMessage(m); + } + break; + } // case 10 + case 18: + { + tcgEventLog_ = input.readBytes(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + canonicalEventLog_ = input.readBytes(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + akCert_ = input.readBytes(); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + com.google.protobuf.ByteString v = input.readBytes(); + ensureCertChainIsMutable(); + certChain_.add(v); + break; + } // case 42 + 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 java.util.List quotes_ = + java.util.Collections.emptyList(); + + private void ensureQuotesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + quotes_ = + new java.util.ArrayList( + quotes_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.Builder, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.QuoteOrBuilder> + quotesBuilder_; + + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public java.util.List + getQuotesList() { + if (quotesBuilder_ == null) { + return java.util.Collections.unmodifiableList(quotes_); + } else { + return quotesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public int getQuotesCount() { + if (quotesBuilder_ == null) { + return quotes_.size(); + } else { + return quotesBuilder_.getCount(); + } + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote getQuotes(int index) { + if (quotesBuilder_ == null) { + return quotes_.get(index); + } else { + return quotesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public Builder setQuotes( + int index, com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote value) { + if (quotesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureQuotesIsMutable(); + quotes_.set(index, value); + onChanged(); + } else { + quotesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public Builder setQuotes( + int index, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.Builder builderForValue) { + if (quotesBuilder_ == null) { + ensureQuotesIsMutable(); + quotes_.set(index, builderForValue.build()); + onChanged(); + } else { + quotesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public Builder addQuotes(com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote value) { + if (quotesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureQuotesIsMutable(); + quotes_.add(value); + onChanged(); + } else { + quotesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public Builder addQuotes( + int index, com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote value) { + if (quotesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureQuotesIsMutable(); + quotes_.add(index, value); + onChanged(); + } else { + quotesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public Builder addQuotes( + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.Builder builderForValue) { + if (quotesBuilder_ == null) { + ensureQuotesIsMutable(); + quotes_.add(builderForValue.build()); + onChanged(); + } else { + quotesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public Builder addQuotes( + int index, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.Builder builderForValue) { + if (quotesBuilder_ == null) { + ensureQuotesIsMutable(); + quotes_.add(index, builderForValue.build()); + onChanged(); + } else { + quotesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public Builder addAllQuotes( + java.lang.Iterable + values) { + if (quotesBuilder_ == null) { + ensureQuotesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, quotes_); + onChanged(); + } else { + quotesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public Builder clearQuotes() { + if (quotesBuilder_ == null) { + quotes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + quotesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public Builder removeQuotes(int index) { + if (quotesBuilder_ == null) { + ensureQuotesIsMutable(); + quotes_.remove(index); + onChanged(); + } else { + quotesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.Builder getQuotesBuilder( + int index) { + return getQuotesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public com.google.cloud.confidentialcomputing.v1.TpmAttestation.QuoteOrBuilder + getQuotesOrBuilder(int index) { + if (quotesBuilder_ == null) { + return quotes_.get(index); + } else { + return quotesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public java.util.List< + ? extends com.google.cloud.confidentialcomputing.v1.TpmAttestation.QuoteOrBuilder> + getQuotesOrBuilderList() { + if (quotesBuilder_ != null) { + return quotesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(quotes_); + } + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.Builder + addQuotesBuilder() { + return getQuotesFieldBuilder() + .addBuilder( + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.getDefaultInstance()); + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.Builder addQuotesBuilder( + int index) { + return getQuotesFieldBuilder() + .addBuilder( + index, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.getDefaultInstance()); + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + public java.util.List + getQuotesBuilderList() { + return getQuotesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.Builder, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.QuoteOrBuilder> + getQuotesFieldBuilder() { + if (quotesBuilder_ == null) { + quotesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote.Builder, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.QuoteOrBuilder>( + quotes_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + quotes_ = null; + } + return quotesBuilder_; + } + + private com.google.protobuf.ByteString tcgEventLog_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * The binary TCG Event Log containing events measured into the TPM by the
+     * platform firmware and operating system. Formatted as described in the
+     * "TCG PC Client Platform Firmware Profile Specification".
+     * 
+ * + * bytes tcg_event_log = 2; + * + * @return The tcgEventLog. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTcgEventLog() { + return tcgEventLog_; + } + /** + * + * + *
+     * The binary TCG Event Log containing events measured into the TPM by the
+     * platform firmware and operating system. Formatted as described in the
+     * "TCG PC Client Platform Firmware Profile Specification".
+     * 
+ * + * bytes tcg_event_log = 2; + * + * @param value The tcgEventLog to set. + * @return This builder for chaining. + */ + public Builder setTcgEventLog(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + tcgEventLog_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * The binary TCG Event Log containing events measured into the TPM by the
+     * platform firmware and operating system. Formatted as described in the
+     * "TCG PC Client Platform Firmware Profile Specification".
+     * 
+ * + * bytes tcg_event_log = 2; + * + * @return This builder for chaining. + */ + public Builder clearTcgEventLog() { + bitField0_ = (bitField0_ & ~0x00000002); + tcgEventLog_ = getDefaultInstance().getTcgEventLog(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString canonicalEventLog_ = + com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * An Event Log containing additional events measured into the TPM that are
+     * not already present in the tcg_event_log. Formatted as described in the
+     * "Canonical Event Log Format" TCG Specification.
+     * 
+ * + * bytes canonical_event_log = 3; + * + * @return The canonicalEventLog. + */ + @java.lang.Override + public com.google.protobuf.ByteString getCanonicalEventLog() { + return canonicalEventLog_; + } + /** + * + * + *
+     * An Event Log containing additional events measured into the TPM that are
+     * not already present in the tcg_event_log. Formatted as described in the
+     * "Canonical Event Log Format" TCG Specification.
+     * 
+ * + * bytes canonical_event_log = 3; + * + * @param value The canonicalEventLog to set. + * @return This builder for chaining. + */ + public Builder setCanonicalEventLog(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + canonicalEventLog_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * An Event Log containing additional events measured into the TPM that are
+     * not already present in the tcg_event_log. Formatted as described in the
+     * "Canonical Event Log Format" TCG Specification.
+     * 
+ * + * bytes canonical_event_log = 3; + * + * @return This builder for chaining. + */ + public Builder clearCanonicalEventLog() { + bitField0_ = (bitField0_ & ~0x00000004); + canonicalEventLog_ = getDefaultInstance().getCanonicalEventLog(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString akCert_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * DER-encoded X.509 certificate of the Attestation Key (otherwise known as
+     * an AK or a TPM restricted signing key) used to generate the quotes.
+     * 
+ * + * bytes ak_cert = 4; + * + * @return The akCert. + */ + @java.lang.Override + public com.google.protobuf.ByteString getAkCert() { + return akCert_; + } + /** + * + * + *
+     * DER-encoded X.509 certificate of the Attestation Key (otherwise known as
+     * an AK or a TPM restricted signing key) used to generate the quotes.
+     * 
+ * + * bytes ak_cert = 4; + * + * @param value The akCert to set. + * @return This builder for chaining. + */ + public Builder setAkCert(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + akCert_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * DER-encoded X.509 certificate of the Attestation Key (otherwise known as
+     * an AK or a TPM restricted signing key) used to generate the quotes.
+     * 
+ * + * bytes ak_cert = 4; + * + * @return This builder for chaining. + */ + public Builder clearAkCert() { + bitField0_ = (bitField0_ & ~0x00000008); + akCert_ = getDefaultInstance().getAkCert(); + onChanged(); + return this; + } + + private java.util.List certChain_ = + java.util.Collections.emptyList(); + + private void ensureCertChainIsMutable() { + if (!((bitField0_ & 0x00000010) != 0)) { + certChain_ = new java.util.ArrayList(certChain_); + bitField0_ |= 0x00000010; + } + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @return A list containing the certChain. + */ + public java.util.List getCertChainList() { + return ((bitField0_ & 0x00000010) != 0) + ? java.util.Collections.unmodifiableList(certChain_) + : certChain_; + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @return The count of certChain. + */ + public int getCertChainCount() { + return certChain_.size(); + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @param index The index of the element to return. + * @return The certChain at the given index. + */ + public com.google.protobuf.ByteString getCertChain(int index) { + return certChain_.get(index); + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @param index The index to set the value at. + * @param value The certChain to set. + * @return This builder for chaining. + */ + public Builder setCertChain(int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCertChainIsMutable(); + certChain_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @param value The certChain to add. + * @return This builder for chaining. + */ + public Builder addCertChain(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCertChainIsMutable(); + certChain_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @param values The certChain to add. + * @return This builder for chaining. + */ + public Builder addAllCertChain( + java.lang.Iterable values) { + ensureCertChainIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, certChain_); + onChanged(); + return this; + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @return This builder for chaining. + */ + public Builder clearCertChain() { + certChain_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + 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.cloud.confidentialcomputing.v1.TpmAttestation) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1.TpmAttestation) + private static final com.google.cloud.confidentialcomputing.v1.TpmAttestation DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.confidentialcomputing.v1.TpmAttestation(); + } + + public static com.google.cloud.confidentialcomputing.v1.TpmAttestation getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TpmAttestation 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.cloud.confidentialcomputing.v1.TpmAttestation getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/TpmAttestationOrBuilder.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/TpmAttestationOrBuilder.java new file mode 100644 index 000000000000..8f4c79230fe0 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/TpmAttestationOrBuilder.java @@ -0,0 +1,163 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +public interface TpmAttestationOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1.TpmAttestation) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + java.util.List getQuotesList(); + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Quote getQuotes(int index); + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + int getQuotesCount(); + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + java.util.List + getQuotesOrBuilderList(); + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1.TpmAttestation.Quote quotes = 1; + */ + com.google.cloud.confidentialcomputing.v1.TpmAttestation.QuoteOrBuilder getQuotesOrBuilder( + int index); + + /** + * + * + *
+   * The binary TCG Event Log containing events measured into the TPM by the
+   * platform firmware and operating system. Formatted as described in the
+   * "TCG PC Client Platform Firmware Profile Specification".
+   * 
+ * + * bytes tcg_event_log = 2; + * + * @return The tcgEventLog. + */ + com.google.protobuf.ByteString getTcgEventLog(); + + /** + * + * + *
+   * An Event Log containing additional events measured into the TPM that are
+   * not already present in the tcg_event_log. Formatted as described in the
+   * "Canonical Event Log Format" TCG Specification.
+   * 
+ * + * bytes canonical_event_log = 3; + * + * @return The canonicalEventLog. + */ + com.google.protobuf.ByteString getCanonicalEventLog(); + + /** + * + * + *
+   * DER-encoded X.509 certificate of the Attestation Key (otherwise known as
+   * an AK or a TPM restricted signing key) used to generate the quotes.
+   * 
+ * + * bytes ak_cert = 4; + * + * @return The akCert. + */ + com.google.protobuf.ByteString getAkCert(); + + /** + * + * + *
+   * List of DER-encoded X.509 certificates which, together with the ak_cert,
+   * chain back to a trusted Root Certificate.
+   * 
+ * + * repeated bytes cert_chain = 5; + * + * @return A list containing the certChain. + */ + java.util.List getCertChainList(); + /** + * + * + *
+   * List of DER-encoded X.509 certificates which, together with the ak_cert,
+   * chain back to a trusted Root Certificate.
+   * 
+ * + * repeated bytes cert_chain = 5; + * + * @return The count of certChain. + */ + int getCertChainCount(); + /** + * + * + *
+   * List of DER-encoded X.509 certificates which, together with the ak_cert,
+   * chain back to a trusted Root Certificate.
+   * 
+ * + * repeated bytes cert_chain = 5; + * + * @param index The index of the element to return. + * @return The certChain at the given index. + */ + com.google.protobuf.ByteString getCertChain(int index); +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/VerifyAttestationRequest.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/VerifyAttestationRequest.java new file mode 100644 index 000000000000..cb50abcf1600 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/VerifyAttestationRequest.java @@ -0,0 +1,1287 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +/** + * + * + *
+ * A request for an OIDC token, providing all the necessary information needed
+ * for this service to verify the plaform state of the requestor.
+ * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.VerifyAttestationRequest} + */ +public final class VerifyAttestationRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1.VerifyAttestationRequest) + VerifyAttestationRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use VerifyAttestationRequest.newBuilder() to construct. + private VerifyAttestationRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private VerifyAttestationRequest() { + challenge_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new VerifyAttestationRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest.class, + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest.Builder.class); + } + + public static final int CHALLENGE_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object challenge_ = ""; + /** + * + * + *
+   * Required. The name of the Challenge whose nonce was used to generate the
+   * attestation, in the format `projects/*/locations/*/challenges/*`. The
+   * provided Challenge will be consumed, and cannot be used again.
+   * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The challenge. + */ + @java.lang.Override + public java.lang.String getChallenge() { + java.lang.Object ref = challenge_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + challenge_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The name of the Challenge whose nonce was used to generate the
+   * attestation, in the format `projects/*/locations/*/challenges/*`. The
+   * provided Challenge will be consumed, and cannot be used again.
+   * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for challenge. + */ + @java.lang.Override + public com.google.protobuf.ByteString getChallengeBytes() { + java.lang.Object ref = challenge_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + challenge_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int GCP_CREDENTIALS_FIELD_NUMBER = 2; + private com.google.cloud.confidentialcomputing.v1.GcpCredentials gcpCredentials_; + /** + * + * + *
+   * Optional. Credentials used to populate the "emails" claim in the
+   * claims_token.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the gcpCredentials field is set. + */ + @java.lang.Override + public boolean hasGcpCredentials() { + return gcpCredentials_ != null; + } + /** + * + * + *
+   * Optional. Credentials used to populate the "emails" claim in the
+   * claims_token.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The gcpCredentials. + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.GcpCredentials getGcpCredentials() { + return gcpCredentials_ == null + ? com.google.cloud.confidentialcomputing.v1.GcpCredentials.getDefaultInstance() + : gcpCredentials_; + } + /** + * + * + *
+   * Optional. Credentials used to populate the "emails" claim in the
+   * claims_token.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.GcpCredentialsOrBuilder + getGcpCredentialsOrBuilder() { + return gcpCredentials_ == null + ? com.google.cloud.confidentialcomputing.v1.GcpCredentials.getDefaultInstance() + : gcpCredentials_; + } + + public static final int TPM_ATTESTATION_FIELD_NUMBER = 3; + private com.google.cloud.confidentialcomputing.v1.TpmAttestation tpmAttestation_; + /** + * + * + *
+   * Required. The TPM-specific data provided by the attesting platform, used to
+   * populate any of the claims regarding platform state.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the tpmAttestation field is set. + */ + @java.lang.Override + public boolean hasTpmAttestation() { + return tpmAttestation_ != null; + } + /** + * + * + *
+   * Required. The TPM-specific data provided by the attesting platform, used to
+   * populate any of the claims regarding platform state.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The tpmAttestation. + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.TpmAttestation getTpmAttestation() { + return tpmAttestation_ == null + ? com.google.cloud.confidentialcomputing.v1.TpmAttestation.getDefaultInstance() + : tpmAttestation_; + } + /** + * + * + *
+   * Required. The TPM-specific data provided by the attesting platform, used to
+   * populate any of the claims regarding platform state.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.TpmAttestationOrBuilder + getTpmAttestationOrBuilder() { + return tpmAttestation_ == null + ? com.google.cloud.confidentialcomputing.v1.TpmAttestation.getDefaultInstance() + : tpmAttestation_; + } + + 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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(challenge_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, challenge_); + } + if (gcpCredentials_ != null) { + output.writeMessage(2, getGcpCredentials()); + } + if (tpmAttestation_ != null) { + output.writeMessage(3, getTpmAttestation()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(challenge_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, challenge_); + } + if (gcpCredentials_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getGcpCredentials()); + } + if (tpmAttestation_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getTpmAttestation()); + } + 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.cloud.confidentialcomputing.v1.VerifyAttestationRequest)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest other = + (com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest) obj; + + if (!getChallenge().equals(other.getChallenge())) return false; + if (hasGcpCredentials() != other.hasGcpCredentials()) return false; + if (hasGcpCredentials()) { + if (!getGcpCredentials().equals(other.getGcpCredentials())) return false; + } + if (hasTpmAttestation() != other.hasTpmAttestation()) return false; + if (hasTpmAttestation()) { + if (!getTpmAttestation().equals(other.getTpmAttestation())) 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(); + hash = (37 * hash) + CHALLENGE_FIELD_NUMBER; + hash = (53 * hash) + getChallenge().hashCode(); + if (hasGcpCredentials()) { + hash = (37 * hash) + GCP_CREDENTIALS_FIELD_NUMBER; + hash = (53 * hash) + getGcpCredentials().hashCode(); + } + if (hasTpmAttestation()) { + hash = (37 * hash) + TPM_ATTESTATION_FIELD_NUMBER; + hash = (53 * hash) + getTpmAttestation().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest 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.cloud.confidentialcomputing.v1.VerifyAttestationRequest parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest 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.cloud.confidentialcomputing.v1.VerifyAttestationRequest + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest + 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.cloud.confidentialcomputing.v1.VerifyAttestationRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest 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.cloud.confidentialcomputing.v1.VerifyAttestationRequest 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; + } + /** + * + * + *
+   * A request for an OIDC token, providing all the necessary information needed
+   * for this service to verify the plaform state of the requestor.
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.VerifyAttestationRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1.VerifyAttestationRequest) + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest.class, + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest.Builder.class); + } + + // Construct using + // com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + challenge_ = ""; + gcpCredentials_ = null; + if (gcpCredentialsBuilder_ != null) { + gcpCredentialsBuilder_.dispose(); + gcpCredentialsBuilder_ = null; + } + tpmAttestation_ = null; + if (tpmAttestationBuilder_ != null) { + tpmAttestationBuilder_.dispose(); + tpmAttestationBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationRequest_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest + getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest build() { + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest buildPartial() { + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest result = + new com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.challenge_ = challenge_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.gcpCredentials_ = + gcpCredentialsBuilder_ == null ? gcpCredentials_ : gcpCredentialsBuilder_.build(); + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.tpmAttestation_ = + tpmAttestationBuilder_ == null ? tpmAttestation_ : tpmAttestationBuilder_.build(); + } + } + + @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.cloud.confidentialcomputing.v1.VerifyAttestationRequest) { + return mergeFrom( + (com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest other) { + if (other + == com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest + .getDefaultInstance()) return this; + if (!other.getChallenge().isEmpty()) { + challenge_ = other.challenge_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasGcpCredentials()) { + mergeGcpCredentials(other.getGcpCredentials()); + } + if (other.hasTpmAttestation()) { + mergeTpmAttestation(other.getTpmAttestation()); + } + 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 10: + { + challenge_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getGcpCredentialsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage(getTpmAttestationFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + 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 java.lang.Object challenge_ = ""; + /** + * + * + *
+     * Required. The name of the Challenge whose nonce was used to generate the
+     * attestation, in the format `projects/*/locations/*/challenges/*`. The
+     * provided Challenge will be consumed, and cannot be used again.
+     * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The challenge. + */ + public java.lang.String getChallenge() { + java.lang.Object ref = challenge_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + challenge_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The name of the Challenge whose nonce was used to generate the
+     * attestation, in the format `projects/*/locations/*/challenges/*`. The
+     * provided Challenge will be consumed, and cannot be used again.
+     * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for challenge. + */ + public com.google.protobuf.ByteString getChallengeBytes() { + java.lang.Object ref = challenge_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + challenge_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The name of the Challenge whose nonce was used to generate the
+     * attestation, in the format `projects/*/locations/*/challenges/*`. The
+     * provided Challenge will be consumed, and cannot be used again.
+     * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The challenge to set. + * @return This builder for chaining. + */ + public Builder setChallenge(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + challenge_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the Challenge whose nonce was used to generate the
+     * attestation, in the format `projects/*/locations/*/challenges/*`. The
+     * provided Challenge will be consumed, and cannot be used again.
+     * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearChallenge() { + challenge_ = getDefaultInstance().getChallenge(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the Challenge whose nonce was used to generate the
+     * attestation, in the format `projects/*/locations/*/challenges/*`. The
+     * provided Challenge will be consumed, and cannot be used again.
+     * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for challenge to set. + * @return This builder for chaining. + */ + public Builder setChallengeBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + challenge_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.cloud.confidentialcomputing.v1.GcpCredentials gcpCredentials_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1.GcpCredentials, + com.google.cloud.confidentialcomputing.v1.GcpCredentials.Builder, + com.google.cloud.confidentialcomputing.v1.GcpCredentialsOrBuilder> + gcpCredentialsBuilder_; + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the gcpCredentials field is set. + */ + public boolean hasGcpCredentials() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The gcpCredentials. + */ + public com.google.cloud.confidentialcomputing.v1.GcpCredentials getGcpCredentials() { + if (gcpCredentialsBuilder_ == null) { + return gcpCredentials_ == null + ? com.google.cloud.confidentialcomputing.v1.GcpCredentials.getDefaultInstance() + : gcpCredentials_; + } else { + return gcpCredentialsBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setGcpCredentials( + com.google.cloud.confidentialcomputing.v1.GcpCredentials value) { + if (gcpCredentialsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + gcpCredentials_ = value; + } else { + gcpCredentialsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setGcpCredentials( + com.google.cloud.confidentialcomputing.v1.GcpCredentials.Builder builderForValue) { + if (gcpCredentialsBuilder_ == null) { + gcpCredentials_ = builderForValue.build(); + } else { + gcpCredentialsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeGcpCredentials( + com.google.cloud.confidentialcomputing.v1.GcpCredentials value) { + if (gcpCredentialsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && gcpCredentials_ != null + && gcpCredentials_ + != com.google.cloud.confidentialcomputing.v1.GcpCredentials.getDefaultInstance()) { + getGcpCredentialsBuilder().mergeFrom(value); + } else { + gcpCredentials_ = value; + } + } else { + gcpCredentialsBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearGcpCredentials() { + bitField0_ = (bitField0_ & ~0x00000002); + gcpCredentials_ = null; + if (gcpCredentialsBuilder_ != null) { + gcpCredentialsBuilder_.dispose(); + gcpCredentialsBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.cloud.confidentialcomputing.v1.GcpCredentials.Builder + getGcpCredentialsBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getGcpCredentialsFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.cloud.confidentialcomputing.v1.GcpCredentialsOrBuilder + getGcpCredentialsOrBuilder() { + if (gcpCredentialsBuilder_ != null) { + return gcpCredentialsBuilder_.getMessageOrBuilder(); + } else { + return gcpCredentials_ == null + ? com.google.cloud.confidentialcomputing.v1.GcpCredentials.getDefaultInstance() + : gcpCredentials_; + } + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1.GcpCredentials, + com.google.cloud.confidentialcomputing.v1.GcpCredentials.Builder, + com.google.cloud.confidentialcomputing.v1.GcpCredentialsOrBuilder> + getGcpCredentialsFieldBuilder() { + if (gcpCredentialsBuilder_ == null) { + gcpCredentialsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1.GcpCredentials, + com.google.cloud.confidentialcomputing.v1.GcpCredentials.Builder, + com.google.cloud.confidentialcomputing.v1.GcpCredentialsOrBuilder>( + getGcpCredentials(), getParentForChildren(), isClean()); + gcpCredentials_ = null; + } + return gcpCredentialsBuilder_; + } + + private com.google.cloud.confidentialcomputing.v1.TpmAttestation tpmAttestation_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1.TpmAttestation, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Builder, + com.google.cloud.confidentialcomputing.v1.TpmAttestationOrBuilder> + tpmAttestationBuilder_; + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the tpmAttestation field is set. + */ + public boolean hasTpmAttestation() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The tpmAttestation. + */ + public com.google.cloud.confidentialcomputing.v1.TpmAttestation getTpmAttestation() { + if (tpmAttestationBuilder_ == null) { + return tpmAttestation_ == null + ? com.google.cloud.confidentialcomputing.v1.TpmAttestation.getDefaultInstance() + : tpmAttestation_; + } else { + return tpmAttestationBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setTpmAttestation( + com.google.cloud.confidentialcomputing.v1.TpmAttestation value) { + if (tpmAttestationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + tpmAttestation_ = value; + } else { + tpmAttestationBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setTpmAttestation( + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Builder builderForValue) { + if (tpmAttestationBuilder_ == null) { + tpmAttestation_ = builderForValue.build(); + } else { + tpmAttestationBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeTpmAttestation( + com.google.cloud.confidentialcomputing.v1.TpmAttestation value) { + if (tpmAttestationBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && tpmAttestation_ != null + && tpmAttestation_ + != com.google.cloud.confidentialcomputing.v1.TpmAttestation.getDefaultInstance()) { + getTpmAttestationBuilder().mergeFrom(value); + } else { + tpmAttestation_ = value; + } + } else { + tpmAttestationBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearTpmAttestation() { + bitField0_ = (bitField0_ & ~0x00000004); + tpmAttestation_ = null; + if (tpmAttestationBuilder_ != null) { + tpmAttestationBuilder_.dispose(); + tpmAttestationBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.confidentialcomputing.v1.TpmAttestation.Builder + getTpmAttestationBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getTpmAttestationFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.confidentialcomputing.v1.TpmAttestationOrBuilder + getTpmAttestationOrBuilder() { + if (tpmAttestationBuilder_ != null) { + return tpmAttestationBuilder_.getMessageOrBuilder(); + } else { + return tpmAttestation_ == null + ? com.google.cloud.confidentialcomputing.v1.TpmAttestation.getDefaultInstance() + : tpmAttestation_; + } + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1.TpmAttestation, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Builder, + com.google.cloud.confidentialcomputing.v1.TpmAttestationOrBuilder> + getTpmAttestationFieldBuilder() { + if (tpmAttestationBuilder_ == null) { + tpmAttestationBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1.TpmAttestation, + com.google.cloud.confidentialcomputing.v1.TpmAttestation.Builder, + com.google.cloud.confidentialcomputing.v1.TpmAttestationOrBuilder>( + getTpmAttestation(), getParentForChildren(), isClean()); + tpmAttestation_ = null; + } + return tpmAttestationBuilder_; + } + + @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.cloud.confidentialcomputing.v1.VerifyAttestationRequest) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1.VerifyAttestationRequest) + private static final com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest(); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public VerifyAttestationRequest 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.cloud.confidentialcomputing.v1.VerifyAttestationRequest + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/VerifyAttestationRequestOrBuilder.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/VerifyAttestationRequestOrBuilder.java new file mode 100644 index 000000000000..2b669691307d --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/VerifyAttestationRequestOrBuilder.java @@ -0,0 +1,146 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +public interface VerifyAttestationRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1.VerifyAttestationRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The name of the Challenge whose nonce was used to generate the
+   * attestation, in the format `projects/*/locations/*/challenges/*`. The
+   * provided Challenge will be consumed, and cannot be used again.
+   * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The challenge. + */ + java.lang.String getChallenge(); + /** + * + * + *
+   * Required. The name of the Challenge whose nonce was used to generate the
+   * attestation, in the format `projects/*/locations/*/challenges/*`. The
+   * provided Challenge will be consumed, and cannot be used again.
+   * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for challenge. + */ + com.google.protobuf.ByteString getChallengeBytes(); + + /** + * + * + *
+   * Optional. Credentials used to populate the "emails" claim in the
+   * claims_token.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the gcpCredentials field is set. + */ + boolean hasGcpCredentials(); + /** + * + * + *
+   * Optional. Credentials used to populate the "emails" claim in the
+   * claims_token.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The gcpCredentials. + */ + com.google.cloud.confidentialcomputing.v1.GcpCredentials getGcpCredentials(); + /** + * + * + *
+   * Optional. Credentials used to populate the "emails" claim in the
+   * claims_token.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.cloud.confidentialcomputing.v1.GcpCredentialsOrBuilder getGcpCredentialsOrBuilder(); + + /** + * + * + *
+   * Required. The TPM-specific data provided by the attesting platform, used to
+   * populate any of the claims regarding platform state.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the tpmAttestation field is set. + */ + boolean hasTpmAttestation(); + /** + * + * + *
+   * Required. The TPM-specific data provided by the attesting platform, used to
+   * populate any of the claims regarding platform state.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The tpmAttestation. + */ + com.google.cloud.confidentialcomputing.v1.TpmAttestation getTpmAttestation(); + /** + * + * + *
+   * Required. The TPM-specific data provided by the attesting platform, used to
+   * populate any of the claims regarding platform state.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.cloud.confidentialcomputing.v1.TpmAttestationOrBuilder getTpmAttestationOrBuilder(); +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/VerifyAttestationResponse.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/VerifyAttestationResponse.java new file mode 100644 index 000000000000..f540935e6335 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/VerifyAttestationResponse.java @@ -0,0 +1,643 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +/** + * + * + *
+ * A response once an attestation has been successfully verified, containing a
+ * signed OIDC token.
+ * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.VerifyAttestationResponse} + */ +public final class VerifyAttestationResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1.VerifyAttestationResponse) + VerifyAttestationResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use VerifyAttestationResponse.newBuilder() to construct. + private VerifyAttestationResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private VerifyAttestationResponse() { + oidcClaimsToken_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new VerifyAttestationResponse(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse.class, + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse.Builder.class); + } + + public static final int OIDC_CLAIMS_TOKEN_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object oidcClaimsToken_ = ""; + /** + * + * + *
+   * Output only. Same as claims_token, but as a string.
+   * 
+ * + * string oidc_claims_token = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The oidcClaimsToken. + */ + @java.lang.Override + public java.lang.String getOidcClaimsToken() { + java.lang.Object ref = oidcClaimsToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + oidcClaimsToken_ = s; + return s; + } + } + /** + * + * + *
+   * Output only. Same as claims_token, but as a string.
+   * 
+ * + * string oidc_claims_token = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for oidcClaimsToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getOidcClaimsTokenBytes() { + java.lang.Object ref = oidcClaimsToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + oidcClaimsToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + 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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(oidcClaimsToken_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, oidcClaimsToken_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(oidcClaimsToken_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, oidcClaimsToken_); + } + 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.cloud.confidentialcomputing.v1.VerifyAttestationResponse)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse other = + (com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse) obj; + + if (!getOidcClaimsToken().equals(other.getOidcClaimsToken())) 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(); + hash = (37 * hash) + OIDC_CLAIMS_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getOidcClaimsToken().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse 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.cloud.confidentialcomputing.v1.VerifyAttestationResponse parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse 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.cloud.confidentialcomputing.v1.VerifyAttestationResponse + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse + 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.cloud.confidentialcomputing.v1.VerifyAttestationResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse 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.cloud.confidentialcomputing.v1.VerifyAttestationResponse 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; + } + /** + * + * + *
+   * A response once an attestation has been successfully verified, containing a
+   * signed OIDC token.
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1.VerifyAttestationResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1.VerifyAttestationResponse) + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse.class, + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse.Builder.class); + } + + // Construct using + // com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + oidcClaimsToken_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1_VerifyAttestationResponse_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse + getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse build() { + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse buildPartial() { + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse result = + new com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.oidcClaimsToken_ = oidcClaimsToken_; + } + } + + @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.cloud.confidentialcomputing.v1.VerifyAttestationResponse) { + return mergeFrom( + (com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse other) { + if (other + == com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse + .getDefaultInstance()) return this; + if (!other.getOidcClaimsToken().isEmpty()) { + oidcClaimsToken_ = other.oidcClaimsToken_; + bitField0_ |= 0x00000001; + onChanged(); + } + 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 18: + { + oidcClaimsToken_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 18 + 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 java.lang.Object oidcClaimsToken_ = ""; + /** + * + * + *
+     * Output only. Same as claims_token, but as a string.
+     * 
+ * + * string oidc_claims_token = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The oidcClaimsToken. + */ + public java.lang.String getOidcClaimsToken() { + java.lang.Object ref = oidcClaimsToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + oidcClaimsToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Output only. Same as claims_token, but as a string.
+     * 
+ * + * string oidc_claims_token = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for oidcClaimsToken. + */ + public com.google.protobuf.ByteString getOidcClaimsTokenBytes() { + java.lang.Object ref = oidcClaimsToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + oidcClaimsToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Output only. Same as claims_token, but as a string.
+     * 
+ * + * string oidc_claims_token = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The oidcClaimsToken to set. + * @return This builder for chaining. + */ + public Builder setOidcClaimsToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + oidcClaimsToken_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Same as claims_token, but as a string.
+     * 
+ * + * string oidc_claims_token = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearOidcClaimsToken() { + oidcClaimsToken_ = getDefaultInstance().getOidcClaimsToken(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Same as claims_token, but as a string.
+     * 
+ * + * string oidc_claims_token = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for oidcClaimsToken to set. + * @return This builder for chaining. + */ + public Builder setOidcClaimsTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + oidcClaimsToken_ = value; + bitField0_ |= 0x00000001; + 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.cloud.confidentialcomputing.v1.VerifyAttestationResponse) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1.VerifyAttestationResponse) + private static final com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse(); + } + + public static com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public VerifyAttestationResponse 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.cloud.confidentialcomputing.v1.VerifyAttestationResponse + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/VerifyAttestationResponseOrBuilder.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/VerifyAttestationResponseOrBuilder.java new file mode 100644 index 000000000000..cc091f8668eb --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/java/com/google/cloud/confidentialcomputing/v1/VerifyAttestationResponseOrBuilder.java @@ -0,0 +1,50 @@ +/* + * 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/cloud/confidentialcomputing/v1/service.proto + +package com.google.cloud.confidentialcomputing.v1; + +public interface VerifyAttestationResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1.VerifyAttestationResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Output only. Same as claims_token, but as a string.
+   * 
+ * + * string oidc_claims_token = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The oidcClaimsToken. + */ + java.lang.String getOidcClaimsToken(); + /** + * + * + *
+   * Output only. Same as claims_token, but as a string.
+   * 
+ * + * string oidc_claims_token = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for oidcClaimsToken. + */ + com.google.protobuf.ByteString getOidcClaimsTokenBytes(); +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/proto/google/cloud/confidentialcomputing/v1/service.proto b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/proto/google/cloud/confidentialcomputing/v1/service.proto new file mode 100644 index 000000000000..846b4de0470a --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1/src/main/proto/google/cloud/confidentialcomputing/v1/service.proto @@ -0,0 +1,176 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.confidentialcomputing.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ConfidentialComputing.V1"; +option go_package = "cloud.google.com/go/confidentialcomputing/apiv1/confidentialcomputingpb;confidentialcomputingpb"; +option java_multiple_files = true; +option java_outer_classname = "ServiceProto"; +option java_package = "com.google.cloud.confidentialcomputing.v1"; +option php_namespace = "Google\\Cloud\\ConfidentialComputing\\V1"; +option ruby_package = "Google::Cloud::ConfidentialComputing::V1"; + +// Service describing handlers for resources +service ConfidentialComputing { + option (google.api.default_host) = "confidentialcomputing.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new Challenge in a given project and location. + rpc CreateChallenge(CreateChallengeRequest) returns (Challenge) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/challenges" + body: "challenge" + }; + option (google.api.method_signature) = "parent,challenge"; + } + + // Verifies the provided attestation info, returning a signed OIDC token. + rpc VerifyAttestation(VerifyAttestationRequest) + returns (VerifyAttestationResponse) { + option (google.api.http) = { + post: "/v1/{challenge=projects/*/locations/*/challenges/*}:verifyAttestation" + body: "*" + }; + } +} + +// A Challenge from the server used to guarantee freshness of attestations +message Challenge { + option (google.api.resource) = { + type: "confidentialcomputing.googleapis.com/Challenge" + pattern: "projects/{project}/locations/{location}/challenges/{uuid}" + }; + + // Output only. The resource name for this Challenge in the format + // `projects/*/locations/*/challenges/*` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this Challenge was created + google.protobuf.Timestamp create_time = 2 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this Challenge will no longer be usable. It + // is also the expiration time for any tokens generated from this Challenge. + google.protobuf.Timestamp expire_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Indicates if this challenge has been used to generate a token. + bool used = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Identical to nonce, but as a string. + string tpm_nonce = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Message for creating a Challenge +message CreateChallengeRequest { + // Required. The resource name of the location where the Challenge will be + // used, in the format `projects/*/locations/*`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The Challenge to be created. Currently this field can be empty as + // all the Challenge fields are set by the server. + Challenge challenge = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// A request for an OIDC token, providing all the necessary information needed +// for this service to verify the plaform state of the requestor. +message VerifyAttestationRequest { + // Required. The name of the Challenge whose nonce was used to generate the + // attestation, in the format `projects/*/locations/*/challenges/*`. The + // provided Challenge will be consumed, and cannot be used again. + string challenge = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "confidentialcomputing.googleapis.com/Challenge" + } + ]; + + // Optional. Credentials used to populate the "emails" claim in the + // claims_token. + GcpCredentials gcp_credentials = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Required. The TPM-specific data provided by the attesting platform, used to + // populate any of the claims regarding platform state. + TpmAttestation tpm_attestation = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// A response once an attestation has been successfully verified, containing a +// signed OIDC token. +message VerifyAttestationResponse { + // Output only. Same as claims_token, but as a string. + string oidc_claims_token = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Credentials issued by GCP which are linked to the platform attestation. These +// will be verified server-side as part of attestaion verification. +message GcpCredentials { + // Same as id_tokens, but as a string. + repeated string service_account_id_tokens = 2; +} + +// TPM2 data containing everything necessary to validate any platform state +// measured into the TPM. +message TpmAttestation { + // Information about Platform Control Registers (PCRs) including a signature + // over their values, which can be used for remote validation. + message Quote { + // The hash algorithm of the PCR bank being quoted, encoded as a TPM_ALG_ID + int32 hash_algo = 1; + + // Raw binary values of each PCRs being quoted. + map pcr_values = 2; + + // TPM2 quote, encoded as a TPMS_ATTEST + bytes raw_quote = 3; + + // TPM2 signature, encoded as a TPMT_SIGNATURE + bytes raw_signature = 4; + } + + // TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank. + repeated Quote quotes = 1; + + // The binary TCG Event Log containing events measured into the TPM by the + // platform firmware and operating system. Formatted as described in the + // "TCG PC Client Platform Firmware Profile Specification". + bytes tcg_event_log = 2; + + // An Event Log containing additional events measured into the TPM that are + // not already present in the tcg_event_log. Formatted as described in the + // "Canonical Event Log Format" TCG Specification. + bytes canonical_event_log = 3; + + // DER-encoded X.509 certificate of the Attestation Key (otherwise known as + // an AK or a TPM restricted signing key) used to generate the quotes. + bytes ak_cert = 4; + + // List of DER-encoded X.509 certificates which, together with the ak_cert, + // chain back to a trusted Root Certificate. + repeated bytes cert_chain = 5; +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/clirr-ignored-differences.xml b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/clirr-ignored-differences.xml new file mode 100644 index 000000000000..13f7d3b95220 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/clirr-ignored-differences.xml @@ -0,0 +1,19 @@ + + + + + 7012 + com/google/cloud/confidentialcomputing/v1alpha1/*OrBuilder + * get*(*) + + + 7012 + com/google/cloud/confidentialcomputing/v1alpha1/*OrBuilder + boolean contains*(*) + + + 7012 + com/google/cloud/confidentialcomputing/v1alpha1/*OrBuilder + boolean has*(*) + + diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/pom.xml b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/pom.xml new file mode 100644 index 000000000000..ceeaaae7e7fb --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/pom.xml @@ -0,0 +1,37 @@ + + 4.0.0 + com.google.api.grpc + proto-google-cloud-confidentialcomputing-v1alpha1 + 0.0.1-SNAPSHOT + proto-google-cloud-confidentialcomputing-v1alpha1 + Proto library for google-cloud-confidentialcomputing + + com.google.cloud + google-cloud-confidentialcomputing-parent + 0.0.1-SNAPSHOT + + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + com.google.api.grpc + proto-google-iam-v1 + + + com.google.api + api-common + + + com.google.guava + guava + + + diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/Challenge.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/Challenge.java new file mode 100644 index 000000000000..1cfabaa21b39 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/Challenge.java @@ -0,0 +1,1404 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +/** + * + * + *
+ * A Challenge from the server used to guarantee freshness of attestations
+ * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.Challenge} + */ +public final class Challenge extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1alpha1.Challenge) + ChallengeOrBuilder { + private static final long serialVersionUID = 0L; + // Use Challenge.newBuilder() to construct. + private Challenge(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Challenge() { + name_ = ""; + nonce_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Challenge(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_Challenge_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_Challenge_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.Challenge.class, + com.google.cloud.confidentialcomputing.v1alpha1.Challenge.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+   * Output only. The resource name for this Challenge in the format
+   * `projects/*/locations/*/challenges/*`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Output only. The resource name for this Challenge in the format
+   * `projects/*/locations/*/challenges/*`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CREATE_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp createTime_; + /** + * + * + *
+   * Output only. The time at which this Challenge was created
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + @java.lang.Override + public boolean hasCreateTime() { + return createTime_ != null; + } + /** + * + * + *
+   * Output only. The time at which this Challenge was created
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCreateTime() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + /** + * + * + *
+   * Output only. The time at which this Challenge was created
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + public static final int EXPIRE_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp expireTime_; + /** + * + * + *
+   * Output only. The time at which this Challenge will no longer be usable. It
+   * is also the expiration time for any tokens generated from this Challenge.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the expireTime field is set. + */ + @java.lang.Override + public boolean hasExpireTime() { + return expireTime_ != null; + } + /** + * + * + *
+   * Output only. The time at which this Challenge will no longer be usable. It
+   * is also the expiration time for any tokens generated from this Challenge.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The expireTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getExpireTime() { + return expireTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : expireTime_; + } + /** + * + * + *
+   * Output only. The time at which this Challenge will no longer be usable. It
+   * is also the expiration time for any tokens generated from this Challenge.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder() { + return expireTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : expireTime_; + } + + public static final int USED_FIELD_NUMBER = 4; + private boolean used_ = false; + /** + * + * + *
+   * Output only. Indicates if this challenge has been used to generate a token.
+   * 
+ * + * bool used = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The used. + */ + @java.lang.Override + public boolean getUsed() { + return used_; + } + + public static final int NONCE_FIELD_NUMBER = 5; + private com.google.protobuf.ByteString nonce_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+   * Output only. Random data which should be used when calling TPM2_Quote.
+   * --
+   * 
+ * + * bytes nonce = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The nonce. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNonce() { + return nonce_; + } + + 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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (createTime_ != null) { + output.writeMessage(2, getCreateTime()); + } + if (expireTime_ != null) { + output.writeMessage(3, getExpireTime()); + } + if (used_ != false) { + output.writeBool(4, used_); + } + if (!nonce_.isEmpty()) { + output.writeBytes(5, nonce_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (createTime_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getCreateTime()); + } + if (expireTime_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getExpireTime()); + } + if (used_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(4, used_); + } + if (!nonce_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(5, nonce_); + } + 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.cloud.confidentialcomputing.v1alpha1.Challenge)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1alpha1.Challenge other = + (com.google.cloud.confidentialcomputing.v1alpha1.Challenge) obj; + + if (!getName().equals(other.getName())) return false; + if (hasCreateTime() != other.hasCreateTime()) return false; + if (hasCreateTime()) { + if (!getCreateTime().equals(other.getCreateTime())) return false; + } + if (hasExpireTime() != other.hasExpireTime()) return false; + if (hasExpireTime()) { + if (!getExpireTime().equals(other.getExpireTime())) return false; + } + if (getUsed() != other.getUsed()) return false; + if (!getNonce().equals(other.getNonce())) 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(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasCreateTime()) { + hash = (37 * hash) + CREATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getCreateTime().hashCode(); + } + if (hasExpireTime()) { + hash = (37 * hash) + EXPIRE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getExpireTime().hashCode(); + } + hash = (37 * hash) + USED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getUsed()); + hash = (37 * hash) + NONCE_FIELD_NUMBER; + hash = (53 * hash) + getNonce().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.Challenge parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.Challenge parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.Challenge parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.Challenge 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.cloud.confidentialcomputing.v1alpha1.Challenge parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.Challenge parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.Challenge parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.Challenge 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.cloud.confidentialcomputing.v1alpha1.Challenge parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.Challenge 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.cloud.confidentialcomputing.v1alpha1.Challenge parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.Challenge 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.cloud.confidentialcomputing.v1alpha1.Challenge 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; + } + /** + * + * + *
+   * A Challenge from the server used to guarantee freshness of attestations
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.Challenge} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1alpha1.Challenge) + com.google.cloud.confidentialcomputing.v1alpha1.ChallengeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_Challenge_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_Challenge_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.Challenge.class, + com.google.cloud.confidentialcomputing.v1alpha1.Challenge.Builder.class); + } + + // Construct using com.google.cloud.confidentialcomputing.v1alpha1.Challenge.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + expireTime_ = null; + if (expireTimeBuilder_ != null) { + expireTimeBuilder_.dispose(); + expireTimeBuilder_ = null; + } + used_ = false; + nonce_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_Challenge_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.Challenge getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.Challenge.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.Challenge build() { + com.google.cloud.confidentialcomputing.v1alpha1.Challenge result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.Challenge buildPartial() { + com.google.cloud.confidentialcomputing.v1alpha1.Challenge result = + new com.google.cloud.confidentialcomputing.v1alpha1.Challenge(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.cloud.confidentialcomputing.v1alpha1.Challenge result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.createTime_ = createTimeBuilder_ == null ? createTime_ : createTimeBuilder_.build(); + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.expireTime_ = expireTimeBuilder_ == null ? expireTime_ : expireTimeBuilder_.build(); + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.used_ = used_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.nonce_ = nonce_; + } + } + + @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.cloud.confidentialcomputing.v1alpha1.Challenge) { + return mergeFrom((com.google.cloud.confidentialcomputing.v1alpha1.Challenge) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.confidentialcomputing.v1alpha1.Challenge other) { + if (other == com.google.cloud.confidentialcomputing.v1alpha1.Challenge.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasCreateTime()) { + mergeCreateTime(other.getCreateTime()); + } + if (other.hasExpireTime()) { + mergeExpireTime(other.getExpireTime()); + } + if (other.getUsed() != false) { + setUsed(other.getUsed()); + } + if (other.getNonce() != com.google.protobuf.ByteString.EMPTY) { + setNonce(other.getNonce()); + } + 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 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getCreateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage(getExpireTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 32: + { + used_ = input.readBool(); + bitField0_ |= 0x00000008; + break; + } // case 32 + case 42: + { + nonce_ = input.readBytes(); + bitField0_ |= 0x00000010; + break; + } // case 42 + 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 java.lang.Object name_ = ""; + /** + * + * + *
+     * Output only. The resource name for this Challenge in the format
+     * `projects/*/locations/*/challenges/*`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Output only. The resource name for this Challenge in the format
+     * `projects/*/locations/*/challenges/*`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Output only. The resource name for this Challenge in the format
+     * `projects/*/locations/*/challenges/*`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The resource name for this Challenge in the format
+     * `projects/*/locations/*/challenges/*`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The resource name for this Challenge in the format
+     * `projects/*/locations/*/challenges/*`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp createTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + createTimeBuilder_; + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + public com.google.protobuf.Timestamp getCreateTime() { + if (createTimeBuilder_ == null) { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } else { + return createTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + createTime_ = value; + } else { + createTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (createTimeBuilder_ == null) { + createTime_ = builderForValue.build(); + } else { + createTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && createTime_ != null + && createTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getCreateTimeBuilder().mergeFrom(value); + } else { + createTime_ = value; + } + } else { + createTimeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearCreateTime() { + bitField0_ = (bitField0_ & ~0x00000002); + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getCreateTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getCreateTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + if (createTimeBuilder_ != null) { + return createTimeBuilder_.getMessageOrBuilder(); + } else { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } + } + /** + * + * + *
+     * Output only. The time at which this Challenge was created
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getCreateTimeFieldBuilder() { + if (createTimeBuilder_ == null) { + createTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getCreateTime(), getParentForChildren(), isClean()); + createTime_ = null; + } + return createTimeBuilder_; + } + + private com.google.protobuf.Timestamp expireTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + expireTimeBuilder_; + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the expireTime field is set. + */ + public boolean hasExpireTime() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The expireTime. + */ + public com.google.protobuf.Timestamp getExpireTime() { + if (expireTimeBuilder_ == null) { + return expireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : expireTime_; + } else { + return expireTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setExpireTime(com.google.protobuf.Timestamp value) { + if (expireTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + expireTime_ = value; + } else { + expireTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setExpireTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (expireTimeBuilder_ == null) { + expireTime_ = builderForValue.build(); + } else { + expireTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeExpireTime(com.google.protobuf.Timestamp value) { + if (expireTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && expireTime_ != null + && expireTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getExpireTimeBuilder().mergeFrom(value); + } else { + expireTime_ = value; + } + } else { + expireTimeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearExpireTime() { + bitField0_ = (bitField0_ & ~0x00000004); + expireTime_ = null; + if (expireTimeBuilder_ != null) { + expireTimeBuilder_.dispose(); + expireTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getExpireTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getExpireTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder() { + if (expireTimeBuilder_ != null) { + return expireTimeBuilder_.getMessageOrBuilder(); + } else { + return expireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : expireTime_; + } + } + /** + * + * + *
+     * Output only. The time at which this Challenge will no longer be usable. It
+     * is also the expiration time for any tokens generated from this Challenge.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getExpireTimeFieldBuilder() { + if (expireTimeBuilder_ == null) { + expireTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getExpireTime(), getParentForChildren(), isClean()); + expireTime_ = null; + } + return expireTimeBuilder_; + } + + private boolean used_; + /** + * + * + *
+     * Output only. Indicates if this challenge has been used to generate a token.
+     * 
+ * + * bool used = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The used. + */ + @java.lang.Override + public boolean getUsed() { + return used_; + } + /** + * + * + *
+     * Output only. Indicates if this challenge has been used to generate a token.
+     * 
+ * + * bool used = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The used to set. + * @return This builder for chaining. + */ + public Builder setUsed(boolean value) { + + used_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Indicates if this challenge has been used to generate a token.
+     * 
+ * + * bool used = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearUsed() { + bitField0_ = (bitField0_ & ~0x00000008); + used_ = false; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString nonce_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * Output only. Random data which should be used when calling TPM2_Quote.
+     * --
+     * 
+ * + * bytes nonce = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The nonce. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNonce() { + return nonce_; + } + /** + * + * + *
+     * Output only. Random data which should be used when calling TPM2_Quote.
+     * --
+     * 
+ * + * bytes nonce = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The nonce to set. + * @return This builder for chaining. + */ + public Builder setNonce(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + nonce_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Random data which should be used when calling TPM2_Quote.
+     * --
+     * 
+ * + * bytes nonce = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearNonce() { + bitField0_ = (bitField0_ & ~0x00000010); + nonce_ = getDefaultInstance().getNonce(); + 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.cloud.confidentialcomputing.v1alpha1.Challenge) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1alpha1.Challenge) + private static final com.google.cloud.confidentialcomputing.v1alpha1.Challenge DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.confidentialcomputing.v1alpha1.Challenge(); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.Challenge getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Challenge 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.cloud.confidentialcomputing.v1alpha1.Challenge getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ChallengeName.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ChallengeName.java new file mode 100644 index 000000000000..511739b932fd --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ChallengeName.java @@ -0,0 +1,218 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class ChallengeName implements ResourceName { + private static final PathTemplate PROJECT_LOCATION_UUID = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/locations/{location}/challenges/{uuid}"); + private volatile Map fieldValuesMap; + private final String project; + private final String location; + private final String uuid; + + @Deprecated + protected ChallengeName() { + project = null; + location = null; + uuid = null; + } + + private ChallengeName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + uuid = Preconditions.checkNotNull(builder.getUuid()); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getUuid() { + return uuid; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static ChallengeName of(String project, String location, String uuid) { + return newBuilder().setProject(project).setLocation(location).setUuid(uuid).build(); + } + + public static String format(String project, String location, String uuid) { + return newBuilder().setProject(project).setLocation(location).setUuid(uuid).build().toString(); + } + + public static ChallengeName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_LOCATION_UUID.validatedMatch( + formattedString, "ChallengeName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("location"), matchMap.get("uuid")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (ChallengeName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_LOCATION_UUID.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + if (uuid != null) { + fieldMapBuilder.put("uuid", uuid); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_LOCATION_UUID.instantiate( + "project", project, "location", location, "uuid", uuid); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + ChallengeName that = ((ChallengeName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location) + && Objects.equals(this.uuid, that.uuid); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + h *= 1000003; + h ^= Objects.hashCode(uuid); + return h; + } + + /** Builder for projects/{project}/locations/{location}/challenges/{uuid}. */ + public static class Builder { + private String project; + private String location; + private String uuid; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getUuid() { + return uuid; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + public Builder setUuid(String uuid) { + this.uuid = uuid; + return this; + } + + private Builder(ChallengeName challengeName) { + this.project = challengeName.project; + this.location = challengeName.location; + this.uuid = challengeName.uuid; + } + + public ChallengeName build() { + return new ChallengeName(this); + } + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ChallengeOrBuilder.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ChallengeOrBuilder.java new file mode 100644 index 000000000000..ac7ea132389a --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ChallengeOrBuilder.java @@ -0,0 +1,158 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +public interface ChallengeOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1alpha1.Challenge) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Output only. The resource name for this Challenge in the format
+   * `projects/*/locations/*/challenges/*`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Output only. The resource name for this Challenge in the format
+   * `projects/*/locations/*/challenges/*`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Output only. The time at which this Challenge was created
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + boolean hasCreateTime(); + /** + * + * + *
+   * Output only. The time at which this Challenge was created
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + com.google.protobuf.Timestamp getCreateTime(); + /** + * + * + *
+   * Output only. The time at which this Challenge was created
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder(); + + /** + * + * + *
+   * Output only. The time at which this Challenge will no longer be usable. It
+   * is also the expiration time for any tokens generated from this Challenge.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the expireTime field is set. + */ + boolean hasExpireTime(); + /** + * + * + *
+   * Output only. The time at which this Challenge will no longer be usable. It
+   * is also the expiration time for any tokens generated from this Challenge.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The expireTime. + */ + com.google.protobuf.Timestamp getExpireTime(); + /** + * + * + *
+   * Output only. The time at which this Challenge will no longer be usable. It
+   * is also the expiration time for any tokens generated from this Challenge.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder(); + + /** + * + * + *
+   * Output only. Indicates if this challenge has been used to generate a token.
+   * 
+ * + * bool used = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The used. + */ + boolean getUsed(); + + /** + * + * + *
+   * Output only. Random data which should be used when calling TPM2_Quote.
+   * --
+   * 
+ * + * bytes nonce = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The nonce. + */ + com.google.protobuf.ByteString getNonce(); +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/CreateChallengeRequest.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/CreateChallengeRequest.java new file mode 100644 index 000000000000..9f447d6ac5e2 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/CreateChallengeRequest.java @@ -0,0 +1,967 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +/** + * + * + *
+ * Message for creating a Challenge
+ * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest} + */ +public final class CreateChallengeRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest) + CreateChallengeRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use CreateChallengeRequest.newBuilder() to construct. + private CreateChallengeRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CreateChallengeRequest() { + parent_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CreateChallengeRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_CreateChallengeRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_CreateChallengeRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest.class, + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + /** + * + * + *
+   * Required. The resource name of the location where the Challenge will be
+   * used, in the format `projects/*/locations/*`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The resource name of the location where the Challenge will be
+   * used, in the format `projects/*/locations/*`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CHALLENGE_FIELD_NUMBER = 2; + private com.google.cloud.confidentialcomputing.v1alpha1.Challenge challenge_; + /** + * + * + *
+   * Required. The Challenge to be created. Currently this field can be empty as
+   * all the Challenge fields are set by the server.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the challenge field is set. + */ + @java.lang.Override + public boolean hasChallenge() { + return challenge_ != null; + } + /** + * + * + *
+   * Required. The Challenge to be created. Currently this field can be empty as
+   * all the Challenge fields are set by the server.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The challenge. + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.Challenge getChallenge() { + return challenge_ == null + ? com.google.cloud.confidentialcomputing.v1alpha1.Challenge.getDefaultInstance() + : challenge_; + } + /** + * + * + *
+   * Required. The Challenge to be created. Currently this field can be empty as
+   * all the Challenge fields are set by the server.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.ChallengeOrBuilder + getChallengeOrBuilder() { + return challenge_ == null + ? com.google.cloud.confidentialcomputing.v1alpha1.Challenge.getDefaultInstance() + : challenge_; + } + + 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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + if (challenge_ != null) { + output.writeMessage(2, getChallenge()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); + } + if (challenge_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getChallenge()); + } + 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.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest other = + (com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (hasChallenge() != other.hasChallenge()) return false; + if (hasChallenge()) { + if (!getChallenge().equals(other.getChallenge())) 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(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + if (hasChallenge()) { + hash = (37 * hash) + CHALLENGE_FIELD_NUMBER; + hash = (53 * hash) + getChallenge().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest 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.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest 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.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest + 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.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest 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.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest 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; + } + /** + * + * + *
+   * Message for creating a Challenge
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest) + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_CreateChallengeRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_CreateChallengeRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest.class, + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest.Builder.class); + } + + // Construct using + // com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + challenge_ = null; + if (challengeBuilder_ != null) { + challengeBuilder_.dispose(); + challengeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_CreateChallengeRequest_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest + getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest build() { + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest buildPartial() { + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest result = + new com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.challenge_ = challengeBuilder_ == null ? challenge_ : challengeBuilder_.build(); + } + } + + @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.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest) { + return mergeFrom( + (com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest other) { + if (other + == com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest + .getDefaultInstance()) return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasChallenge()) { + mergeChallenge(other.getChallenge()); + } + 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 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getChallengeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + 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 java.lang.Object parent_ = ""; + /** + * + * + *
+     * Required. The resource name of the location where the Challenge will be
+     * used, in the format `projects/*/locations/*`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The resource name of the location where the Challenge will be
+     * used, in the format `projects/*/locations/*`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The resource name of the location where the Challenge will be
+     * used, in the format `projects/*/locations/*`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The resource name of the location where the Challenge will be
+     * used, in the format `projects/*/locations/*`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The resource name of the location where the Challenge will be
+     * used, in the format `projects/*/locations/*`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.cloud.confidentialcomputing.v1alpha1.Challenge challenge_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1alpha1.Challenge, + com.google.cloud.confidentialcomputing.v1alpha1.Challenge.Builder, + com.google.cloud.confidentialcomputing.v1alpha1.ChallengeOrBuilder> + challengeBuilder_; + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the challenge field is set. + */ + public boolean hasChallenge() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The challenge. + */ + public com.google.cloud.confidentialcomputing.v1alpha1.Challenge getChallenge() { + if (challengeBuilder_ == null) { + return challenge_ == null + ? com.google.cloud.confidentialcomputing.v1alpha1.Challenge.getDefaultInstance() + : challenge_; + } else { + return challengeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setChallenge(com.google.cloud.confidentialcomputing.v1alpha1.Challenge value) { + if (challengeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + challenge_ = value; + } else { + challengeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setChallenge( + com.google.cloud.confidentialcomputing.v1alpha1.Challenge.Builder builderForValue) { + if (challengeBuilder_ == null) { + challenge_ = builderForValue.build(); + } else { + challengeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeChallenge(com.google.cloud.confidentialcomputing.v1alpha1.Challenge value) { + if (challengeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && challenge_ != null + && challenge_ + != com.google.cloud.confidentialcomputing.v1alpha1.Challenge.getDefaultInstance()) { + getChallengeBuilder().mergeFrom(value); + } else { + challenge_ = value; + } + } else { + challengeBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearChallenge() { + bitField0_ = (bitField0_ & ~0x00000002); + challenge_ = null; + if (challengeBuilder_ != null) { + challengeBuilder_.dispose(); + challengeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.confidentialcomputing.v1alpha1.Challenge.Builder getChallengeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getChallengeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.confidentialcomputing.v1alpha1.ChallengeOrBuilder + getChallengeOrBuilder() { + if (challengeBuilder_ != null) { + return challengeBuilder_.getMessageOrBuilder(); + } else { + return challenge_ == null + ? com.google.cloud.confidentialcomputing.v1alpha1.Challenge.getDefaultInstance() + : challenge_; + } + } + /** + * + * + *
+     * Required. The Challenge to be created. Currently this field can be empty as
+     * all the Challenge fields are set by the server.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1alpha1.Challenge, + com.google.cloud.confidentialcomputing.v1alpha1.Challenge.Builder, + com.google.cloud.confidentialcomputing.v1alpha1.ChallengeOrBuilder> + getChallengeFieldBuilder() { + if (challengeBuilder_ == null) { + challengeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1alpha1.Challenge, + com.google.cloud.confidentialcomputing.v1alpha1.Challenge.Builder, + com.google.cloud.confidentialcomputing.v1alpha1.ChallengeOrBuilder>( + getChallenge(), getParentForChildren(), isClean()); + challenge_ = null; + } + return challengeBuilder_; + } + + @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.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest) + private static final com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest(); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CreateChallengeRequest 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.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/CreateChallengeRequestOrBuilder.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/CreateChallengeRequestOrBuilder.java new file mode 100644 index 000000000000..4246239dc832 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/CreateChallengeRequestOrBuilder.java @@ -0,0 +1,100 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +public interface CreateChallengeRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The resource name of the location where the Challenge will be
+   * used, in the format `projects/*/locations/*`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. The resource name of the location where the Challenge will be
+   * used, in the format `projects/*/locations/*`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The Challenge to be created. Currently this field can be empty as
+   * all the Challenge fields are set by the server.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the challenge field is set. + */ + boolean hasChallenge(); + /** + * + * + *
+   * Required. The Challenge to be created. Currently this field can be empty as
+   * all the Challenge fields are set by the server.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The challenge. + */ + com.google.cloud.confidentialcomputing.v1alpha1.Challenge getChallenge(); + /** + * + * + *
+   * Required. The Challenge to be created. Currently this field can be empty as
+   * all the Challenge fields are set by the server.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.Challenge challenge = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.cloud.confidentialcomputing.v1alpha1.ChallengeOrBuilder getChallengeOrBuilder(); +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/GcpCredentials.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/GcpCredentials.java new file mode 100644 index 000000000000..cbeff48dc450 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/GcpCredentials.java @@ -0,0 +1,734 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +/** + * + * + *
+ * Credentials issued by GCP which are linked to the platform attestation. These
+ * will be verified server-side as part of attestaion verification.
+ * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.GcpCredentials} + */ +public final class GcpCredentials extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1alpha1.GcpCredentials) + GcpCredentialsOrBuilder { + private static final long serialVersionUID = 0L; + // Use GcpCredentials.newBuilder() to construct. + private GcpCredentials(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private GcpCredentials() { + idTokens_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GcpCredentials(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_GcpCredentials_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_GcpCredentials_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.class, + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.Builder.class); + } + + public static final int ID_TOKENS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List idTokens_; + /** + * + * + *
+   * A list of service account OpenID Connect ID tokens identifying which
+   * service account identities should be included in the claims_token. These
+   * can be generated by calling `serviceAccounts.generateIdToken`. The
+   * Challenge.name must be used as the `audience` parameter, and the
+   * `includeEmail` parameter must be `true`.
+   * --
+   * 
+ * + * repeated bytes id_tokens = 1; + * + * @return A list containing the idTokens. + */ + @java.lang.Override + public java.util.List getIdTokensList() { + return idTokens_; + } + /** + * + * + *
+   * A list of service account OpenID Connect ID tokens identifying which
+   * service account identities should be included in the claims_token. These
+   * can be generated by calling `serviceAccounts.generateIdToken`. The
+   * Challenge.name must be used as the `audience` parameter, and the
+   * `includeEmail` parameter must be `true`.
+   * --
+   * 
+ * + * repeated bytes id_tokens = 1; + * + * @return The count of idTokens. + */ + public int getIdTokensCount() { + return idTokens_.size(); + } + /** + * + * + *
+   * A list of service account OpenID Connect ID tokens identifying which
+   * service account identities should be included in the claims_token. These
+   * can be generated by calling `serviceAccounts.generateIdToken`. The
+   * Challenge.name must be used as the `audience` parameter, and the
+   * `includeEmail` parameter must be `true`.
+   * --
+   * 
+ * + * repeated bytes id_tokens = 1; + * + * @param index The index of the element to return. + * @return The idTokens at the given index. + */ + public com.google.protobuf.ByteString getIdTokens(int index) { + return idTokens_.get(index); + } + + 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 { + for (int i = 0; i < idTokens_.size(); i++) { + output.writeBytes(1, idTokens_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < idTokens_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream.computeBytesSizeNoTag(idTokens_.get(i)); + } + size += dataSize; + size += 1 * getIdTokensList().size(); + } + 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.cloud.confidentialcomputing.v1alpha1.GcpCredentials)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials other = + (com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials) obj; + + if (!getIdTokensList().equals(other.getIdTokensList())) 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 (getIdTokensCount() > 0) { + hash = (37 * hash) + ID_TOKENS_FIELD_NUMBER; + hash = (53 * hash) + getIdTokensList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials 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.cloud.confidentialcomputing.v1alpha1.GcpCredentials parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials 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.cloud.confidentialcomputing.v1alpha1.GcpCredentials parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials 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.cloud.confidentialcomputing.v1alpha1.GcpCredentials parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials 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.cloud.confidentialcomputing.v1alpha1.GcpCredentials 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; + } + /** + * + * + *
+   * Credentials issued by GCP which are linked to the platform attestation. These
+   * will be verified server-side as part of attestaion verification.
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.GcpCredentials} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1alpha1.GcpCredentials) + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentialsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_GcpCredentials_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_GcpCredentials_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.class, + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.Builder.class); + } + + // Construct using com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + idTokens_ = java.util.Collections.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_GcpCredentials_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials + getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials build() { + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials buildPartial() { + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials result = + new com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials result) { + if (((bitField0_ & 0x00000001) != 0)) { + idTokens_ = java.util.Collections.unmodifiableList(idTokens_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.idTokens_ = idTokens_; + } + + private void buildPartial0( + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials result) { + int from_bitField0_ = 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.cloud.confidentialcomputing.v1alpha1.GcpCredentials) { + return mergeFrom((com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials other) { + if (other + == com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.getDefaultInstance()) + return this; + if (!other.idTokens_.isEmpty()) { + if (idTokens_.isEmpty()) { + idTokens_ = other.idTokens_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureIdTokensIsMutable(); + idTokens_.addAll(other.idTokens_); + } + onChanged(); + } + 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 10: + { + com.google.protobuf.ByteString v = input.readBytes(); + ensureIdTokensIsMutable(); + idTokens_.add(v); + break; + } // case 10 + 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 java.util.List idTokens_ = + java.util.Collections.emptyList(); + + private void ensureIdTokensIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + idTokens_ = new java.util.ArrayList(idTokens_); + bitField0_ |= 0x00000001; + } + } + /** + * + * + *
+     * A list of service account OpenID Connect ID tokens identifying which
+     * service account identities should be included in the claims_token. These
+     * can be generated by calling `serviceAccounts.generateIdToken`. The
+     * Challenge.name must be used as the `audience` parameter, and the
+     * `includeEmail` parameter must be `true`.
+     * --
+     * 
+ * + * repeated bytes id_tokens = 1; + * + * @return A list containing the idTokens. + */ + public java.util.List getIdTokensList() { + return ((bitField0_ & 0x00000001) != 0) + ? java.util.Collections.unmodifiableList(idTokens_) + : idTokens_; + } + /** + * + * + *
+     * A list of service account OpenID Connect ID tokens identifying which
+     * service account identities should be included in the claims_token. These
+     * can be generated by calling `serviceAccounts.generateIdToken`. The
+     * Challenge.name must be used as the `audience` parameter, and the
+     * `includeEmail` parameter must be `true`.
+     * --
+     * 
+ * + * repeated bytes id_tokens = 1; + * + * @return The count of idTokens. + */ + public int getIdTokensCount() { + return idTokens_.size(); + } + /** + * + * + *
+     * A list of service account OpenID Connect ID tokens identifying which
+     * service account identities should be included in the claims_token. These
+     * can be generated by calling `serviceAccounts.generateIdToken`. The
+     * Challenge.name must be used as the `audience` parameter, and the
+     * `includeEmail` parameter must be `true`.
+     * --
+     * 
+ * + * repeated bytes id_tokens = 1; + * + * @param index The index of the element to return. + * @return The idTokens at the given index. + */ + public com.google.protobuf.ByteString getIdTokens(int index) { + return idTokens_.get(index); + } + /** + * + * + *
+     * A list of service account OpenID Connect ID tokens identifying which
+     * service account identities should be included in the claims_token. These
+     * can be generated by calling `serviceAccounts.generateIdToken`. The
+     * Challenge.name must be used as the `audience` parameter, and the
+     * `includeEmail` parameter must be `true`.
+     * --
+     * 
+ * + * repeated bytes id_tokens = 1; + * + * @param index The index to set the value at. + * @param value The idTokens to set. + * @return This builder for chaining. + */ + public Builder setIdTokens(int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureIdTokensIsMutable(); + idTokens_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+     * A list of service account OpenID Connect ID tokens identifying which
+     * service account identities should be included in the claims_token. These
+     * can be generated by calling `serviceAccounts.generateIdToken`. The
+     * Challenge.name must be used as the `audience` parameter, and the
+     * `includeEmail` parameter must be `true`.
+     * --
+     * 
+ * + * repeated bytes id_tokens = 1; + * + * @param value The idTokens to add. + * @return This builder for chaining. + */ + public Builder addIdTokens(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureIdTokensIsMutable(); + idTokens_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+     * A list of service account OpenID Connect ID tokens identifying which
+     * service account identities should be included in the claims_token. These
+     * can be generated by calling `serviceAccounts.generateIdToken`. The
+     * Challenge.name must be used as the `audience` parameter, and the
+     * `includeEmail` parameter must be `true`.
+     * --
+     * 
+ * + * repeated bytes id_tokens = 1; + * + * @param values The idTokens to add. + * @return This builder for chaining. + */ + public Builder addAllIdTokens( + java.lang.Iterable values) { + ensureIdTokensIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, idTokens_); + onChanged(); + return this; + } + /** + * + * + *
+     * A list of service account OpenID Connect ID tokens identifying which
+     * service account identities should be included in the claims_token. These
+     * can be generated by calling `serviceAccounts.generateIdToken`. The
+     * Challenge.name must be used as the `audience` parameter, and the
+     * `includeEmail` parameter must be `true`.
+     * --
+     * 
+ * + * repeated bytes id_tokens = 1; + * + * @return This builder for chaining. + */ + public Builder clearIdTokens() { + idTokens_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + 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.cloud.confidentialcomputing.v1alpha1.GcpCredentials) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1alpha1.GcpCredentials) + private static final com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials(); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GcpCredentials 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.cloud.confidentialcomputing.v1alpha1.GcpCredentials + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/GcpCredentialsOrBuilder.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/GcpCredentialsOrBuilder.java new file mode 100644 index 000000000000..ceac451a4651 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/GcpCredentialsOrBuilder.java @@ -0,0 +1,78 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +public interface GcpCredentialsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1alpha1.GcpCredentials) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * A list of service account OpenID Connect ID tokens identifying which
+   * service account identities should be included in the claims_token. These
+   * can be generated by calling `serviceAccounts.generateIdToken`. The
+   * Challenge.name must be used as the `audience` parameter, and the
+   * `includeEmail` parameter must be `true`.
+   * --
+   * 
+ * + * repeated bytes id_tokens = 1; + * + * @return A list containing the idTokens. + */ + java.util.List getIdTokensList(); + /** + * + * + *
+   * A list of service account OpenID Connect ID tokens identifying which
+   * service account identities should be included in the claims_token. These
+   * can be generated by calling `serviceAccounts.generateIdToken`. The
+   * Challenge.name must be used as the `audience` parameter, and the
+   * `includeEmail` parameter must be `true`.
+   * --
+   * 
+ * + * repeated bytes id_tokens = 1; + * + * @return The count of idTokens. + */ + int getIdTokensCount(); + /** + * + * + *
+   * A list of service account OpenID Connect ID tokens identifying which
+   * service account identities should be included in the claims_token. These
+   * can be generated by calling `serviceAccounts.generateIdToken`. The
+   * Challenge.name must be used as the `audience` parameter, and the
+   * `includeEmail` parameter must be `true`.
+   * --
+   * 
+ * + * repeated bytes id_tokens = 1; + * + * @param index The index of the element to return. + * @return The idTokens at the given index. + */ + com.google.protobuf.ByteString getIdTokens(int index); +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/LocationName.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/LocationName.java new file mode 100644 index 000000000000..f912057620e9 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/LocationName.java @@ -0,0 +1,192 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class LocationName implements ResourceName { + private static final PathTemplate PROJECT_LOCATION = + PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}"); + private volatile Map fieldValuesMap; + private final String project; + private final String location; + + @Deprecated + protected LocationName() { + project = null; + location = null; + } + + private LocationName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static LocationName of(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build(); + } + + public static String format(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build().toString(); + } + + public static LocationName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_LOCATION.validatedMatch( + formattedString, "LocationName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("location")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (LocationName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_LOCATION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_LOCATION.instantiate("project", project, "location", location); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + LocationName that = ((LocationName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + return h; + } + + /** Builder for projects/{project}/locations/{location}. */ + public static class Builder { + private String project; + private String location; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + private Builder(LocationName locationName) { + this.project = locationName.project; + this.location = locationName.location; + } + + public LocationName build() { + return new LocationName(this); + } + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ServiceProto.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ServiceProto.java new file mode 100644 index 000000000000..d0de8544f158 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/ServiceProto.java @@ -0,0 +1,230 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +public final class ServiceProto { + private ServiceProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1alpha1_Challenge_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1alpha1_Challenge_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1alpha1_CreateChallengeRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1alpha1_CreateChallengeRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1alpha1_GcpCredentials_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1alpha1_GcpCredentials_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_PcrValuesEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_PcrValuesEntry_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n9google/cloud/confidentialcomputing/v1a" + + "lpha1/service.proto\022+google.cloud.confid" + + "entialcomputing.v1alpha1\032\034google/api/ann" + + "otations.proto\032\027google/api/client.proto\032" + + "\037google/api/field_behavior.proto\032\031google" + + "/api/resource.proto\032\037google/protobuf/tim" + + "estamp.proto\"\241\002\n\tChallenge\022\021\n\004name\030\001 \001(\t" + + "B\003\340A\003\0224\n\013create_time\030\002 \001(\0132\032.google.prot" + + "obuf.TimestampB\003\340A\003\0224\n\013expire_time\030\003 \001(\013" + + "2\032.google.protobuf.TimestampB\003\340A\003\022\021\n\004use" + + "d\030\004 \001(\010B\003\340A\003\022\022\n\005nonce\030\005 \001(\014B\003\340A\003:n\352Ak\n.c" + + "onfidentialcomputing.googleapis.com/Chal" + + "lenge\0229projects/{project}/locations/{loc" + + "ation}/challenges/{uuid}\"\243\001\n\026CreateChall" + + "engeRequest\0229\n\006parent\030\001 \001(\tB)\340A\002\372A#\n!loc" + + "ations.googleapis.com/Location\022N\n\tchalle" + + "nge\030\002 \001(\01326.google.cloud.confidentialcom" + + "puting.v1alpha1.ChallengeB\003\340A\002\"\233\002\n\030Verif" + + "yAttestationRequest\022I\n\tchallenge\030\001 \001(\tB6" + + "\340A\002\372A0\n.confidentialcomputing.googleapis" + + ".com/Challenge\022Y\n\017gcp_credentials\030\002 \001(\0132" + + ";.google.cloud.confidentialcomputing.v1a" + + "lpha1.GcpCredentialsB\003\340A\001\022Y\n\017tpm_attesta" + + "tion\030\003 \001(\0132;.google.cloud.confidentialco" + + "mputing.v1alpha1.TpmAttestationB\003\340A\002\"6\n\031" + + "VerifyAttestationResponse\022\031\n\014claims_toke" + + "n\030\001 \001(\014B\003\340A\003\"#\n\016GcpCredentials\022\021\n\tid_tok" + + "ens\030\001 \003(\014\"\233\003\n\016TpmAttestation\022Q\n\006quotes\030\001" + + " \003(\0132A.google.cloud.confidentialcomputin" + + "g.v1alpha1.TpmAttestation.Quote\022\025\n\rtcg_e" + + "vent_log\030\002 \001(\014\022\033\n\023canonical_event_log\030\003 " + + "\001(\014\022\017\n\007ak_cert\030\004 \001(\014\022\022\n\ncert_chain\030\005 \003(\014" + + "\032\334\001\n\005Quote\022\021\n\thash_algo\030\001 \001(\005\022d\n\npcr_val" + + "ues\030\002 \003(\0132P.google.cloud.confidentialcom" + + "puting.v1alpha1.TpmAttestation.Quote.Pcr" + + "ValuesEntry\022\021\n\traw_quote\030\003 \001(\014\022\025\n\rraw_si" + + "gnature\030\004 \001(\014\0320\n\016PcrValuesEntry\022\013\n\003key\030\001" + + " \001(\005\022\r\n\005value\030\002 \001(\014:\0028\0012\333\004\n\025Confidential" + + "Computing\022\352\001\n\017CreateChallenge\022C.google.c" + + "loud.confidentialcomputing.v1alpha1.Crea" + + "teChallengeRequest\0326.google.cloud.confid" + + "entialcomputing.v1alpha1.Challenge\"Z\202\323\344\223" + + "\002A\"4/v1alpha1/{parent=projects/*/locatio" + + "ns/*}/challenges:\tchallenge\332A\020parent,cha" + + "llenge\022\372\001\n\021VerifyAttestation\022E.google.cl" + + "oud.confidentialcomputing.v1alpha1.Verif" + + "yAttestationRequest\032F.google.cloud.confi" + + "dentialcomputing.v1alpha1.VerifyAttestat" + + "ionResponse\"V\202\323\344\223\002P\"K/v1alpha1/{challeng" + + "e=projects/*/locations/*/challenges/*}:v" + + "erifyAttestation:\001*\032X\312A$confidentialcomp" + + "uting.googleapis.com\322A.https://www.googl" + + "eapis.com/auth/cloud-platformB\265\002\n/com.go" + + "ogle.cloud.confidentialcomputing.v1alpha" + + "1B\014ServiceProtoP\001Zecloud.google.com/go/c" + + "onfidentialcomputing/apiv1alpha1/confide" + + "ntialcomputingpb;confidentialcomputingpb" + + "\252\002+Google.Cloud.ConfidentialComputing.V1" + + "Alpha1\312\002+Google\\Cloud\\ConfidentialComput" + + "ing\\V1alpha1\352\002.Google::Cloud::Confidenti" + + "alComputing::V1alpha1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.AnnotationsProto.getDescriptor(), + com.google.api.ClientProto.getDescriptor(), + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_cloud_confidentialcomputing_v1alpha1_Challenge_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_cloud_confidentialcomputing_v1alpha1_Challenge_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1alpha1_Challenge_descriptor, + new java.lang.String[] { + "Name", "CreateTime", "ExpireTime", "Used", "Nonce", + }); + internal_static_google_cloud_confidentialcomputing_v1alpha1_CreateChallengeRequest_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_cloud_confidentialcomputing_v1alpha1_CreateChallengeRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1alpha1_CreateChallengeRequest_descriptor, + new java.lang.String[] { + "Parent", "Challenge", + }); + internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationRequest_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationRequest_descriptor, + new java.lang.String[] { + "Challenge", "GcpCredentials", "TpmAttestation", + }); + internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationResponse_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationResponse_descriptor, + new java.lang.String[] { + "ClaimsToken", + }); + internal_static_google_cloud_confidentialcomputing_v1alpha1_GcpCredentials_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_cloud_confidentialcomputing_v1alpha1_GcpCredentials_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1alpha1_GcpCredentials_descriptor, + new java.lang.String[] { + "IdTokens", + }); + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_descriptor, + new java.lang.String[] { + "Quotes", "TcgEventLog", "CanonicalEventLog", "AkCert", "CertChain", + }); + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_descriptor = + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_descriptor + .getNestedTypes() + .get(0); + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_descriptor, + new java.lang.String[] { + "HashAlgo", "PcrValues", "RawQuote", "RawSignature", + }); + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_PcrValuesEntry_descriptor = + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_descriptor + .getNestedTypes() + .get(0); + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_PcrValuesEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_PcrValuesEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.ClientProto.defaultHost); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.AnnotationsProto.http); + registry.add(com.google.api.ClientProto.methodSignature); + registry.add(com.google.api.ClientProto.oauthScopes); + registry.add(com.google.api.ResourceProto.resource); + registry.add(com.google.api.ResourceProto.resourceReference); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + com.google.api.AnnotationsProto.getDescriptor(); + com.google.api.ClientProto.getDescriptor(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/TpmAttestation.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/TpmAttestation.java new file mode 100644 index 000000000000..13d36cc61838 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/TpmAttestation.java @@ -0,0 +1,2714 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +/** + * + * + *
+ * TPM2 data containing everything necessary to validate any platform state
+ * measured into the TPM.
+ * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.TpmAttestation} + */ +public final class TpmAttestation extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1alpha1.TpmAttestation) + TpmAttestationOrBuilder { + private static final long serialVersionUID = 0L; + // Use TpmAttestation.newBuilder() to construct. + private TpmAttestation(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private TpmAttestation() { + quotes_ = java.util.Collections.emptyList(); + tcgEventLog_ = com.google.protobuf.ByteString.EMPTY; + canonicalEventLog_ = com.google.protobuf.ByteString.EMPTY; + akCert_ = com.google.protobuf.ByteString.EMPTY; + certChain_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new TpmAttestation(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.class, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Builder.class); + } + + public interface QuoteOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The hash algorithm of the PCR bank being quoted, encoded as a TPM_ALG_ID
+     * 
+ * + * int32 hash_algo = 1; + * + * @return The hashAlgo. + */ + int getHashAlgo(); + + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + int getPcrValuesCount(); + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + boolean containsPcrValues(int key); + /** Use {@link #getPcrValuesMap()} instead. */ + @java.lang.Deprecated + java.util.Map getPcrValues(); + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + java.util.Map getPcrValuesMap(); + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + /* nullable */ + com.google.protobuf.ByteString getPcrValuesOrDefault( + int key, + /* nullable */ + com.google.protobuf.ByteString defaultValue); + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + com.google.protobuf.ByteString getPcrValuesOrThrow(int key); + + /** + * + * + *
+     * TPM2 quote, encoded as a TPMS_ATTEST
+     * 
+ * + * bytes raw_quote = 3; + * + * @return The rawQuote. + */ + com.google.protobuf.ByteString getRawQuote(); + + /** + * + * + *
+     * TPM2 signature, encoded as a TPMT_SIGNATURE
+     * 
+ * + * bytes raw_signature = 4; + * + * @return The rawSignature. + */ + com.google.protobuf.ByteString getRawSignature(); + } + /** + * + * + *
+   * Information about Platform Control Registers (PCRs) including a signature
+   * over their values, which can be used for remote validation.
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote} + */ + public static final class Quote extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote) + QuoteOrBuilder { + private static final long serialVersionUID = 0L; + // Use Quote.newBuilder() to construct. + private Quote(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Quote() { + rawQuote_ = com.google.protobuf.ByteString.EMPTY; + rawSignature_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Quote(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapField internalGetMapField(int number) { + switch (number) { + case 2: + return internalGetPcrValues(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.class, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.Builder.class); + } + + public static final int HASH_ALGO_FIELD_NUMBER = 1; + private int hashAlgo_ = 0; + /** + * + * + *
+     * The hash algorithm of the PCR bank being quoted, encoded as a TPM_ALG_ID
+     * 
+ * + * int32 hash_algo = 1; + * + * @return The hashAlgo. + */ + @java.lang.Override + public int getHashAlgo() { + return hashAlgo_; + } + + public static final int PCR_VALUES_FIELD_NUMBER = 2; + + private static final class PcrValuesDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_PcrValuesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.INT32, + 0, + com.google.protobuf.WireFormat.FieldType.BYTES, + com.google.protobuf.ByteString.EMPTY); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField + pcrValues_; + + private com.google.protobuf.MapField + internalGetPcrValues() { + if (pcrValues_ == null) { + return com.google.protobuf.MapField.emptyMapField(PcrValuesDefaultEntryHolder.defaultEntry); + } + return pcrValues_; + } + + public int getPcrValuesCount() { + return internalGetPcrValues().getMap().size(); + } + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public boolean containsPcrValues(int key) { + + return internalGetPcrValues().getMap().containsKey(key); + } + /** Use {@link #getPcrValuesMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getPcrValues() { + return getPcrValuesMap(); + } + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public java.util.Map getPcrValuesMap() { + return internalGetPcrValues().getMap(); + } + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public /* nullable */ com.google.protobuf.ByteString getPcrValuesOrDefault( + int key, + /* nullable */ + com.google.protobuf.ByteString defaultValue) { + + java.util.Map map = + internalGetPcrValues().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * + * + *
+     * Raw binary values of each PCRs being quoted.
+     * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public com.google.protobuf.ByteString getPcrValuesOrThrow(int key) { + + java.util.Map map = + internalGetPcrValues().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int RAW_QUOTE_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString rawQuote_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * TPM2 quote, encoded as a TPMS_ATTEST
+     * 
+ * + * bytes raw_quote = 3; + * + * @return The rawQuote. + */ + @java.lang.Override + public com.google.protobuf.ByteString getRawQuote() { + return rawQuote_; + } + + public static final int RAW_SIGNATURE_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString rawSignature_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * TPM2 signature, encoded as a TPMT_SIGNATURE
+     * 
+ * + * bytes raw_signature = 4; + * + * @return The rawSignature. + */ + @java.lang.Override + public com.google.protobuf.ByteString getRawSignature() { + return rawSignature_; + } + + 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 (hashAlgo_ != 0) { + output.writeInt32(1, hashAlgo_); + } + com.google.protobuf.GeneratedMessageV3.serializeIntegerMapTo( + output, internalGetPcrValues(), PcrValuesDefaultEntryHolder.defaultEntry, 2); + if (!rawQuote_.isEmpty()) { + output.writeBytes(3, rawQuote_); + } + if (!rawSignature_.isEmpty()) { + output.writeBytes(4, rawSignature_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (hashAlgo_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, hashAlgo_); + } + for (java.util.Map.Entry entry : + internalGetPcrValues().getMap().entrySet()) { + com.google.protobuf.MapEntry + pcrValues__ = + PcrValuesDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, pcrValues__); + } + if (!rawQuote_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, rawQuote_); + } + if (!rawSignature_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(4, rawSignature_); + } + 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote other = + (com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote) obj; + + if (getHashAlgo() != other.getHashAlgo()) return false; + if (!internalGetPcrValues().equals(other.internalGetPcrValues())) return false; + if (!getRawQuote().equals(other.getRawQuote())) return false; + if (!getRawSignature().equals(other.getRawSignature())) 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(); + hash = (37 * hash) + HASH_ALGO_FIELD_NUMBER; + hash = (53 * hash) + getHashAlgo(); + if (!internalGetPcrValues().getMap().isEmpty()) { + hash = (37 * hash) + PCR_VALUES_FIELD_NUMBER; + hash = (53 * hash) + internalGetPcrValues().hashCode(); + } + hash = (37 * hash) + RAW_QUOTE_FIELD_NUMBER; + hash = (53 * hash) + getRawQuote().hashCode(); + hash = (37 * hash) + RAW_SIGNATURE_FIELD_NUMBER; + hash = (53 * hash) + getRawSignature().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote + 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote 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; + } + /** + * + * + *
+     * Information about Platform Control Registers (PCRs) including a signature
+     * over their values, which can be used for remote validation.
+     * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote) + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.QuoteOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField(int number) { + switch (number) { + case 2: + return internalGetPcrValues(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField(int number) { + switch (number) { + case 2: + return internalGetMutablePcrValues(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.class, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.Builder.class); + } + + // Construct using + // com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + hashAlgo_ = 0; + internalGetMutablePcrValues().clear(); + rawQuote_ = com.google.protobuf.ByteString.EMPTY; + rawSignature_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_Quote_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote + getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote build() { + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote buildPartial() { + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote result = + new com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.hashAlgo_ = hashAlgo_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.pcrValues_ = internalGetPcrValues(); + result.pcrValues_.makeImmutable(); + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.rawQuote_ = rawQuote_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.rawSignature_ = rawSignature_; + } + } + + @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.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote) { + return mergeFrom( + (com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote other) { + if (other + == com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote + .getDefaultInstance()) return this; + if (other.getHashAlgo() != 0) { + setHashAlgo(other.getHashAlgo()); + } + internalGetMutablePcrValues().mergeFrom(other.internalGetPcrValues()); + bitField0_ |= 0x00000002; + if (other.getRawQuote() != com.google.protobuf.ByteString.EMPTY) { + setRawQuote(other.getRawQuote()); + } + if (other.getRawSignature() != com.google.protobuf.ByteString.EMPTY) { + setRawSignature(other.getRawSignature()); + } + 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: + { + hashAlgo_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: + { + com.google.protobuf.MapEntry + pcrValues__ = + input.readMessage( + PcrValuesDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutablePcrValues() + .getMutableMap() + .put(pcrValues__.getKey(), pcrValues__.getValue()); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + rawQuote_ = input.readBytes(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + rawSignature_ = input.readBytes(); + bitField0_ |= 0x00000008; + break; + } // case 34 + 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 int hashAlgo_; + /** + * + * + *
+       * The hash algorithm of the PCR bank being quoted, encoded as a TPM_ALG_ID
+       * 
+ * + * int32 hash_algo = 1; + * + * @return The hashAlgo. + */ + @java.lang.Override + public int getHashAlgo() { + return hashAlgo_; + } + /** + * + * + *
+       * The hash algorithm of the PCR bank being quoted, encoded as a TPM_ALG_ID
+       * 
+ * + * int32 hash_algo = 1; + * + * @param value The hashAlgo to set. + * @return This builder for chaining. + */ + public Builder setHashAlgo(int value) { + + hashAlgo_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+       * The hash algorithm of the PCR bank being quoted, encoded as a TPM_ALG_ID
+       * 
+ * + * int32 hash_algo = 1; + * + * @return This builder for chaining. + */ + public Builder clearHashAlgo() { + bitField0_ = (bitField0_ & ~0x00000001); + hashAlgo_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.MapField + pcrValues_; + + private com.google.protobuf.MapField + internalGetPcrValues() { + if (pcrValues_ == null) { + return com.google.protobuf.MapField.emptyMapField( + PcrValuesDefaultEntryHolder.defaultEntry); + } + return pcrValues_; + } + + private com.google.protobuf.MapField + internalGetMutablePcrValues() { + if (pcrValues_ == null) { + pcrValues_ = + com.google.protobuf.MapField.newMapField(PcrValuesDefaultEntryHolder.defaultEntry); + } + if (!pcrValues_.isMutable()) { + pcrValues_ = pcrValues_.copy(); + } + bitField0_ |= 0x00000002; + onChanged(); + return pcrValues_; + } + + public int getPcrValuesCount() { + return internalGetPcrValues().getMap().size(); + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public boolean containsPcrValues(int key) { + + return internalGetPcrValues().getMap().containsKey(key); + } + /** Use {@link #getPcrValuesMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getPcrValues() { + return getPcrValuesMap(); + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public java.util.Map getPcrValuesMap() { + return internalGetPcrValues().getMap(); + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public /* nullable */ com.google.protobuf.ByteString getPcrValuesOrDefault( + int key, + /* nullable */ + com.google.protobuf.ByteString defaultValue) { + + java.util.Map map = + internalGetPcrValues().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + @java.lang.Override + public com.google.protobuf.ByteString getPcrValuesOrThrow(int key) { + + java.util.Map map = + internalGetPcrValues().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearPcrValues() { + bitField0_ = (bitField0_ & ~0x00000002); + internalGetMutablePcrValues().getMutableMap().clear(); + return this; + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + public Builder removePcrValues(int key) { + + internalGetMutablePcrValues().getMutableMap().remove(key); + return this; + } + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map + getMutablePcrValues() { + bitField0_ |= 0x00000002; + return internalGetMutablePcrValues().getMutableMap(); + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + public Builder putPcrValues(int key, com.google.protobuf.ByteString value) { + + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutablePcrValues().getMutableMap().put(key, value); + bitField0_ |= 0x00000002; + return this; + } + /** + * + * + *
+       * Raw binary values of each PCRs being quoted.
+       * 
+ * + * map<int32, bytes> pcr_values = 2; + */ + public Builder putAllPcrValues( + java.util.Map values) { + internalGetMutablePcrValues().getMutableMap().putAll(values); + bitField0_ |= 0x00000002; + return this; + } + + private com.google.protobuf.ByteString rawQuote_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+       * TPM2 quote, encoded as a TPMS_ATTEST
+       * 
+ * + * bytes raw_quote = 3; + * + * @return The rawQuote. + */ + @java.lang.Override + public com.google.protobuf.ByteString getRawQuote() { + return rawQuote_; + } + /** + * + * + *
+       * TPM2 quote, encoded as a TPMS_ATTEST
+       * 
+ * + * bytes raw_quote = 3; + * + * @param value The rawQuote to set. + * @return This builder for chaining. + */ + public Builder setRawQuote(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + rawQuote_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+       * TPM2 quote, encoded as a TPMS_ATTEST
+       * 
+ * + * bytes raw_quote = 3; + * + * @return This builder for chaining. + */ + public Builder clearRawQuote() { + bitField0_ = (bitField0_ & ~0x00000004); + rawQuote_ = getDefaultInstance().getRawQuote(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString rawSignature_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+       * TPM2 signature, encoded as a TPMT_SIGNATURE
+       * 
+ * + * bytes raw_signature = 4; + * + * @return The rawSignature. + */ + @java.lang.Override + public com.google.protobuf.ByteString getRawSignature() { + return rawSignature_; + } + /** + * + * + *
+       * TPM2 signature, encoded as a TPMT_SIGNATURE
+       * 
+ * + * bytes raw_signature = 4; + * + * @param value The rawSignature to set. + * @return This builder for chaining. + */ + public Builder setRawSignature(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + rawSignature_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+       * TPM2 signature, encoded as a TPMT_SIGNATURE
+       * 
+ * + * bytes raw_signature = 4; + * + * @return This builder for chaining. + */ + public Builder clearRawSignature() { + bitField0_ = (bitField0_ & ~0x00000008); + rawSignature_ = getDefaultInstance().getRawSignature(); + 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote) + private static final com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote(); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Quote 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public static final int QUOTES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List + quotes_; + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + @java.lang.Override + public java.util.List + getQuotesList() { + return quotes_; + } + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + @java.lang.Override + public java.util.List< + ? extends com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.QuoteOrBuilder> + getQuotesOrBuilderList() { + return quotes_; + } + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + @java.lang.Override + public int getQuotesCount() { + return quotes_.size(); + } + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote getQuotes(int index) { + return quotes_.get(index); + } + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.QuoteOrBuilder + getQuotesOrBuilder(int index) { + return quotes_.get(index); + } + + public static final int TCG_EVENT_LOG_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString tcgEventLog_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+   * The binary TCG Event Log containing events measured into the TPM by the
+   * platform firmware and operating system. Formatted as described in the
+   * "TCG PC Client Platform Firmware Profile Specification".
+   * 
+ * + * bytes tcg_event_log = 2; + * + * @return The tcgEventLog. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTcgEventLog() { + return tcgEventLog_; + } + + public static final int CANONICAL_EVENT_LOG_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString canonicalEventLog_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+   * An Event Log containing additional events measured into the TPM that are
+   * not already present in the tcg_event_log. Formatted as described in the
+   * "Canonical Event Log Format" TCG Specification.
+   * 
+ * + * bytes canonical_event_log = 3; + * + * @return The canonicalEventLog. + */ + @java.lang.Override + public com.google.protobuf.ByteString getCanonicalEventLog() { + return canonicalEventLog_; + } + + public static final int AK_CERT_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString akCert_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+   * DER-encoded X.509 certificate of the Attestation Key (otherwise known as
+   * an AK or a TPM restricted signing key) used to generate the quotes.
+   * 
+ * + * bytes ak_cert = 4; + * + * @return The akCert. + */ + @java.lang.Override + public com.google.protobuf.ByteString getAkCert() { + return akCert_; + } + + public static final int CERT_CHAIN_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private java.util.List certChain_; + /** + * + * + *
+   * List of DER-encoded X.509 certificates which, together with the ak_cert,
+   * chain back to a trusted Root Certificate.
+   * 
+ * + * repeated bytes cert_chain = 5; + * + * @return A list containing the certChain. + */ + @java.lang.Override + public java.util.List getCertChainList() { + return certChain_; + } + /** + * + * + *
+   * List of DER-encoded X.509 certificates which, together with the ak_cert,
+   * chain back to a trusted Root Certificate.
+   * 
+ * + * repeated bytes cert_chain = 5; + * + * @return The count of certChain. + */ + public int getCertChainCount() { + return certChain_.size(); + } + /** + * + * + *
+   * List of DER-encoded X.509 certificates which, together with the ak_cert,
+   * chain back to a trusted Root Certificate.
+   * 
+ * + * repeated bytes cert_chain = 5; + * + * @param index The index of the element to return. + * @return The certChain at the given index. + */ + public com.google.protobuf.ByteString getCertChain(int index) { + return certChain_.get(index); + } + + 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 { + for (int i = 0; i < quotes_.size(); i++) { + output.writeMessage(1, quotes_.get(i)); + } + if (!tcgEventLog_.isEmpty()) { + output.writeBytes(2, tcgEventLog_); + } + if (!canonicalEventLog_.isEmpty()) { + output.writeBytes(3, canonicalEventLog_); + } + if (!akCert_.isEmpty()) { + output.writeBytes(4, akCert_); + } + for (int i = 0; i < certChain_.size(); i++) { + output.writeBytes(5, certChain_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < quotes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, quotes_.get(i)); + } + if (!tcgEventLog_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, tcgEventLog_); + } + if (!canonicalEventLog_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, canonicalEventLog_); + } + if (!akCert_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(4, akCert_); + } + { + int dataSize = 0; + for (int i = 0; i < certChain_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream.computeBytesSizeNoTag(certChain_.get(i)); + } + size += dataSize; + size += 1 * getCertChainList().size(); + } + 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation other = + (com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation) obj; + + if (!getQuotesList().equals(other.getQuotesList())) return false; + if (!getTcgEventLog().equals(other.getTcgEventLog())) return false; + if (!getCanonicalEventLog().equals(other.getCanonicalEventLog())) return false; + if (!getAkCert().equals(other.getAkCert())) return false; + if (!getCertChainList().equals(other.getCertChainList())) 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 (getQuotesCount() > 0) { + hash = (37 * hash) + QUOTES_FIELD_NUMBER; + hash = (53 * hash) + getQuotesList().hashCode(); + } + hash = (37 * hash) + TCG_EVENT_LOG_FIELD_NUMBER; + hash = (53 * hash) + getTcgEventLog().hashCode(); + hash = (37 * hash) + CANONICAL_EVENT_LOG_FIELD_NUMBER; + hash = (53 * hash) + getCanonicalEventLog().hashCode(); + hash = (37 * hash) + AK_CERT_FIELD_NUMBER; + hash = (53 * hash) + getAkCert().hashCode(); + if (getCertChainCount() > 0) { + hash = (37 * hash) + CERT_CHAIN_FIELD_NUMBER; + hash = (53 * hash) + getCertChainList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation 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; + } + /** + * + * + *
+   * TPM2 data containing everything necessary to validate any platform state
+   * measured into the TPM.
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.TpmAttestation} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1alpha1.TpmAttestation) + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.class, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Builder.class); + } + + // Construct using com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (quotesBuilder_ == null) { + quotes_ = java.util.Collections.emptyList(); + } else { + quotes_ = null; + quotesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + tcgEventLog_ = com.google.protobuf.ByteString.EMPTY; + canonicalEventLog_ = com.google.protobuf.ByteString.EMPTY; + akCert_ = com.google.protobuf.ByteString.EMPTY; + certChain_ = java.util.Collections.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_TpmAttestation_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation + getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation build() { + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation buildPartial() { + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation result = + new com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation result) { + if (quotesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + quotes_ = java.util.Collections.unmodifiableList(quotes_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.quotes_ = quotes_; + } else { + result.quotes_ = quotesBuilder_.build(); + } + if (((bitField0_ & 0x00000010) != 0)) { + certChain_ = java.util.Collections.unmodifiableList(certChain_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.certChain_ = certChain_; + } + + private void buildPartial0( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.tcgEventLog_ = tcgEventLog_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.canonicalEventLog_ = canonicalEventLog_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.akCert_ = akCert_; + } + } + + @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.cloud.confidentialcomputing.v1alpha1.TpmAttestation) { + return mergeFrom((com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation other) { + if (other + == com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.getDefaultInstance()) + return this; + if (quotesBuilder_ == null) { + if (!other.quotes_.isEmpty()) { + if (quotes_.isEmpty()) { + quotes_ = other.quotes_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureQuotesIsMutable(); + quotes_.addAll(other.quotes_); + } + onChanged(); + } + } else { + if (!other.quotes_.isEmpty()) { + if (quotesBuilder_.isEmpty()) { + quotesBuilder_.dispose(); + quotesBuilder_ = null; + quotes_ = other.quotes_; + bitField0_ = (bitField0_ & ~0x00000001); + quotesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getQuotesFieldBuilder() + : null; + } else { + quotesBuilder_.addAllMessages(other.quotes_); + } + } + } + if (other.getTcgEventLog() != com.google.protobuf.ByteString.EMPTY) { + setTcgEventLog(other.getTcgEventLog()); + } + if (other.getCanonicalEventLog() != com.google.protobuf.ByteString.EMPTY) { + setCanonicalEventLog(other.getCanonicalEventLog()); + } + if (other.getAkCert() != com.google.protobuf.ByteString.EMPTY) { + setAkCert(other.getAkCert()); + } + if (!other.certChain_.isEmpty()) { + if (certChain_.isEmpty()) { + certChain_ = other.certChain_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureCertChainIsMutable(); + certChain_.addAll(other.certChain_); + } + onChanged(); + } + 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 10: + { + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote m = + input.readMessage( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote + .parser(), + extensionRegistry); + if (quotesBuilder_ == null) { + ensureQuotesIsMutable(); + quotes_.add(m); + } else { + quotesBuilder_.addMessage(m); + } + break; + } // case 10 + case 18: + { + tcgEventLog_ = input.readBytes(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + canonicalEventLog_ = input.readBytes(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + akCert_ = input.readBytes(); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + com.google.protobuf.ByteString v = input.readBytes(); + ensureCertChainIsMutable(); + certChain_.add(v); + break; + } // case 42 + 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 java.util.List + quotes_ = java.util.Collections.emptyList(); + + private void ensureQuotesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + quotes_ = + new java.util.ArrayList< + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote>(quotes_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.Builder, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.QuoteOrBuilder> + quotesBuilder_; + + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public java.util.List + getQuotesList() { + if (quotesBuilder_ == null) { + return java.util.Collections.unmodifiableList(quotes_); + } else { + return quotesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public int getQuotesCount() { + if (quotesBuilder_ == null) { + return quotes_.size(); + } else { + return quotesBuilder_.getCount(); + } + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote getQuotes( + int index) { + if (quotesBuilder_ == null) { + return quotes_.get(index); + } else { + return quotesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public Builder setQuotes( + int index, com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote value) { + if (quotesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureQuotesIsMutable(); + quotes_.set(index, value); + onChanged(); + } else { + quotesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public Builder setQuotes( + int index, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.Builder + builderForValue) { + if (quotesBuilder_ == null) { + ensureQuotesIsMutable(); + quotes_.set(index, builderForValue.build()); + onChanged(); + } else { + quotesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public Builder addQuotes( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote value) { + if (quotesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureQuotesIsMutable(); + quotes_.add(value); + onChanged(); + } else { + quotesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public Builder addQuotes( + int index, com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote value) { + if (quotesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureQuotesIsMutable(); + quotes_.add(index, value); + onChanged(); + } else { + quotesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public Builder addQuotes( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.Builder + builderForValue) { + if (quotesBuilder_ == null) { + ensureQuotesIsMutable(); + quotes_.add(builderForValue.build()); + onChanged(); + } else { + quotesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public Builder addQuotes( + int index, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.Builder + builderForValue) { + if (quotesBuilder_ == null) { + ensureQuotesIsMutable(); + quotes_.add(index, builderForValue.build()); + onChanged(); + } else { + quotesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public Builder addAllQuotes( + java.lang.Iterable< + ? extends com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote> + values) { + if (quotesBuilder_ == null) { + ensureQuotesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, quotes_); + onChanged(); + } else { + quotesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public Builder clearQuotes() { + if (quotesBuilder_ == null) { + quotes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + quotesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public Builder removeQuotes(int index) { + if (quotesBuilder_ == null) { + ensureQuotesIsMutable(); + quotes_.remove(index); + onChanged(); + } else { + quotesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.Builder + getQuotesBuilder(int index) { + return getQuotesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.QuoteOrBuilder + getQuotesOrBuilder(int index) { + if (quotesBuilder_ == null) { + return quotes_.get(index); + } else { + return quotesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public java.util.List< + ? extends com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.QuoteOrBuilder> + getQuotesOrBuilderList() { + if (quotesBuilder_ != null) { + return quotesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(quotes_); + } + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.Builder + addQuotesBuilder() { + return getQuotesFieldBuilder() + .addBuilder( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote + .getDefaultInstance()); + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.Builder + addQuotesBuilder(int index) { + return getQuotesFieldBuilder() + .addBuilder( + index, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote + .getDefaultInstance()); + } + /** + * + * + *
+     * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+     * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + public java.util.List< + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.Builder> + getQuotesBuilderList() { + return getQuotesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.Builder, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.QuoteOrBuilder> + getQuotesFieldBuilder() { + if (quotesBuilder_ == null) { + quotesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote.Builder, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.QuoteOrBuilder>( + quotes_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + quotes_ = null; + } + return quotesBuilder_; + } + + private com.google.protobuf.ByteString tcgEventLog_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * The binary TCG Event Log containing events measured into the TPM by the
+     * platform firmware and operating system. Formatted as described in the
+     * "TCG PC Client Platform Firmware Profile Specification".
+     * 
+ * + * bytes tcg_event_log = 2; + * + * @return The tcgEventLog. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTcgEventLog() { + return tcgEventLog_; + } + /** + * + * + *
+     * The binary TCG Event Log containing events measured into the TPM by the
+     * platform firmware and operating system. Formatted as described in the
+     * "TCG PC Client Platform Firmware Profile Specification".
+     * 
+ * + * bytes tcg_event_log = 2; + * + * @param value The tcgEventLog to set. + * @return This builder for chaining. + */ + public Builder setTcgEventLog(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + tcgEventLog_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * The binary TCG Event Log containing events measured into the TPM by the
+     * platform firmware and operating system. Formatted as described in the
+     * "TCG PC Client Platform Firmware Profile Specification".
+     * 
+ * + * bytes tcg_event_log = 2; + * + * @return This builder for chaining. + */ + public Builder clearTcgEventLog() { + bitField0_ = (bitField0_ & ~0x00000002); + tcgEventLog_ = getDefaultInstance().getTcgEventLog(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString canonicalEventLog_ = + com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * An Event Log containing additional events measured into the TPM that are
+     * not already present in the tcg_event_log. Formatted as described in the
+     * "Canonical Event Log Format" TCG Specification.
+     * 
+ * + * bytes canonical_event_log = 3; + * + * @return The canonicalEventLog. + */ + @java.lang.Override + public com.google.protobuf.ByteString getCanonicalEventLog() { + return canonicalEventLog_; + } + /** + * + * + *
+     * An Event Log containing additional events measured into the TPM that are
+     * not already present in the tcg_event_log. Formatted as described in the
+     * "Canonical Event Log Format" TCG Specification.
+     * 
+ * + * bytes canonical_event_log = 3; + * + * @param value The canonicalEventLog to set. + * @return This builder for chaining. + */ + public Builder setCanonicalEventLog(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + canonicalEventLog_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * An Event Log containing additional events measured into the TPM that are
+     * not already present in the tcg_event_log. Formatted as described in the
+     * "Canonical Event Log Format" TCG Specification.
+     * 
+ * + * bytes canonical_event_log = 3; + * + * @return This builder for chaining. + */ + public Builder clearCanonicalEventLog() { + bitField0_ = (bitField0_ & ~0x00000004); + canonicalEventLog_ = getDefaultInstance().getCanonicalEventLog(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString akCert_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * DER-encoded X.509 certificate of the Attestation Key (otherwise known as
+     * an AK or a TPM restricted signing key) used to generate the quotes.
+     * 
+ * + * bytes ak_cert = 4; + * + * @return The akCert. + */ + @java.lang.Override + public com.google.protobuf.ByteString getAkCert() { + return akCert_; + } + /** + * + * + *
+     * DER-encoded X.509 certificate of the Attestation Key (otherwise known as
+     * an AK or a TPM restricted signing key) used to generate the quotes.
+     * 
+ * + * bytes ak_cert = 4; + * + * @param value The akCert to set. + * @return This builder for chaining. + */ + public Builder setAkCert(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + akCert_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * DER-encoded X.509 certificate of the Attestation Key (otherwise known as
+     * an AK or a TPM restricted signing key) used to generate the quotes.
+     * 
+ * + * bytes ak_cert = 4; + * + * @return This builder for chaining. + */ + public Builder clearAkCert() { + bitField0_ = (bitField0_ & ~0x00000008); + akCert_ = getDefaultInstance().getAkCert(); + onChanged(); + return this; + } + + private java.util.List certChain_ = + java.util.Collections.emptyList(); + + private void ensureCertChainIsMutable() { + if (!((bitField0_ & 0x00000010) != 0)) { + certChain_ = new java.util.ArrayList(certChain_); + bitField0_ |= 0x00000010; + } + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @return A list containing the certChain. + */ + public java.util.List getCertChainList() { + return ((bitField0_ & 0x00000010) != 0) + ? java.util.Collections.unmodifiableList(certChain_) + : certChain_; + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @return The count of certChain. + */ + public int getCertChainCount() { + return certChain_.size(); + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @param index The index of the element to return. + * @return The certChain at the given index. + */ + public com.google.protobuf.ByteString getCertChain(int index) { + return certChain_.get(index); + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @param index The index to set the value at. + * @param value The certChain to set. + * @return This builder for chaining. + */ + public Builder setCertChain(int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCertChainIsMutable(); + certChain_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @param value The certChain to add. + * @return This builder for chaining. + */ + public Builder addCertChain(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCertChainIsMutable(); + certChain_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @param values The certChain to add. + * @return This builder for chaining. + */ + public Builder addAllCertChain( + java.lang.Iterable values) { + ensureCertChainIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, certChain_); + onChanged(); + return this; + } + /** + * + * + *
+     * List of DER-encoded X.509 certificates which, together with the ak_cert,
+     * chain back to a trusted Root Certificate.
+     * 
+ * + * repeated bytes cert_chain = 5; + * + * @return This builder for chaining. + */ + public Builder clearCertChain() { + certChain_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1alpha1.TpmAttestation) + private static final com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation(); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TpmAttestation 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.cloud.confidentialcomputing.v1alpha1.TpmAttestation + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/TpmAttestationOrBuilder.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/TpmAttestationOrBuilder.java new file mode 100644 index 000000000000..8f31402afc05 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/TpmAttestationOrBuilder.java @@ -0,0 +1,170 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +public interface TpmAttestationOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1alpha1.TpmAttestation) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + java.util.List + getQuotesList(); + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote getQuotes(int index); + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + int getQuotesCount(); + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + java.util.List< + ? extends com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.QuoteOrBuilder> + getQuotesOrBuilderList(); + /** + * + * + *
+   * TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank.
+   * 
+ * + * repeated .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Quote quotes = 1; + * + */ + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.QuoteOrBuilder getQuotesOrBuilder( + int index); + + /** + * + * + *
+   * The binary TCG Event Log containing events measured into the TPM by the
+   * platform firmware and operating system. Formatted as described in the
+   * "TCG PC Client Platform Firmware Profile Specification".
+   * 
+ * + * bytes tcg_event_log = 2; + * + * @return The tcgEventLog. + */ + com.google.protobuf.ByteString getTcgEventLog(); + + /** + * + * + *
+   * An Event Log containing additional events measured into the TPM that are
+   * not already present in the tcg_event_log. Formatted as described in the
+   * "Canonical Event Log Format" TCG Specification.
+   * 
+ * + * bytes canonical_event_log = 3; + * + * @return The canonicalEventLog. + */ + com.google.protobuf.ByteString getCanonicalEventLog(); + + /** + * + * + *
+   * DER-encoded X.509 certificate of the Attestation Key (otherwise known as
+   * an AK or a TPM restricted signing key) used to generate the quotes.
+   * 
+ * + * bytes ak_cert = 4; + * + * @return The akCert. + */ + com.google.protobuf.ByteString getAkCert(); + + /** + * + * + *
+   * List of DER-encoded X.509 certificates which, together with the ak_cert,
+   * chain back to a trusted Root Certificate.
+   * 
+ * + * repeated bytes cert_chain = 5; + * + * @return A list containing the certChain. + */ + java.util.List getCertChainList(); + /** + * + * + *
+   * List of DER-encoded X.509 certificates which, together with the ak_cert,
+   * chain back to a trusted Root Certificate.
+   * 
+ * + * repeated bytes cert_chain = 5; + * + * @return The count of certChain. + */ + int getCertChainCount(); + /** + * + * + *
+   * List of DER-encoded X.509 certificates which, together with the ak_cert,
+   * chain back to a trusted Root Certificate.
+   * 
+ * + * repeated bytes cert_chain = 5; + * + * @param index The index of the element to return. + * @return The certChain at the given index. + */ + com.google.protobuf.ByteString getCertChain(int index); +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/VerifyAttestationRequest.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/VerifyAttestationRequest.java new file mode 100644 index 000000000000..d3375cdbac08 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/VerifyAttestationRequest.java @@ -0,0 +1,1294 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +/** + * + * + *
+ * A request for an OIDC token, providing all the necessary information needed
+ * for this service to verify the plaform state of the requestor.
+ * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest} + */ +public final class VerifyAttestationRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest) + VerifyAttestationRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use VerifyAttestationRequest.newBuilder() to construct. + private VerifyAttestationRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private VerifyAttestationRequest() { + challenge_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new VerifyAttestationRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest.class, + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest.Builder.class); + } + + public static final int CHALLENGE_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object challenge_ = ""; + /** + * + * + *
+   * Required. The name of the Challenge whose nonce was used to generate the
+   * attestation, in the format `projects/*/locations/*/challenges/*`. The
+   * provided Challenge will be consumed, and cannot be used again.
+   * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The challenge. + */ + @java.lang.Override + public java.lang.String getChallenge() { + java.lang.Object ref = challenge_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + challenge_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The name of the Challenge whose nonce was used to generate the
+   * attestation, in the format `projects/*/locations/*/challenges/*`. The
+   * provided Challenge will be consumed, and cannot be used again.
+   * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for challenge. + */ + @java.lang.Override + public com.google.protobuf.ByteString getChallengeBytes() { + java.lang.Object ref = challenge_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + challenge_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int GCP_CREDENTIALS_FIELD_NUMBER = 2; + private com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcpCredentials_; + /** + * + * + *
+   * Optional. Credentials used to populate the "emails" claim in the
+   * claims_token.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the gcpCredentials field is set. + */ + @java.lang.Override + public boolean hasGcpCredentials() { + return gcpCredentials_ != null; + } + /** + * + * + *
+   * Optional. Credentials used to populate the "emails" claim in the
+   * claims_token.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The gcpCredentials. + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials getGcpCredentials() { + return gcpCredentials_ == null + ? com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.getDefaultInstance() + : gcpCredentials_; + } + /** + * + * + *
+   * Optional. Credentials used to populate the "emails" claim in the
+   * claims_token.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentialsOrBuilder + getGcpCredentialsOrBuilder() { + return gcpCredentials_ == null + ? com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.getDefaultInstance() + : gcpCredentials_; + } + + public static final int TPM_ATTESTATION_FIELD_NUMBER = 3; + private com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpmAttestation_; + /** + * + * + *
+   * Required. The TPM-specific data provided by the attesting platform, used to
+   * populate any of the claims regarding platform state.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the tpmAttestation field is set. + */ + @java.lang.Override + public boolean hasTpmAttestation() { + return tpmAttestation_ != null; + } + /** + * + * + *
+   * Required. The TPM-specific data provided by the attesting platform, used to
+   * populate any of the claims regarding platform state.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The tpmAttestation. + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation getTpmAttestation() { + return tpmAttestation_ == null + ? com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.getDefaultInstance() + : tpmAttestation_; + } + /** + * + * + *
+   * Required. The TPM-specific data provided by the attesting platform, used to
+   * populate any of the claims regarding platform state.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestationOrBuilder + getTpmAttestationOrBuilder() { + return tpmAttestation_ == null + ? com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.getDefaultInstance() + : tpmAttestation_; + } + + 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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(challenge_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, challenge_); + } + if (gcpCredentials_ != null) { + output.writeMessage(2, getGcpCredentials()); + } + if (tpmAttestation_ != null) { + output.writeMessage(3, getTpmAttestation()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(challenge_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, challenge_); + } + if (gcpCredentials_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getGcpCredentials()); + } + if (tpmAttestation_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getTpmAttestation()); + } + 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest other = + (com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest) obj; + + if (!getChallenge().equals(other.getChallenge())) return false; + if (hasGcpCredentials() != other.hasGcpCredentials()) return false; + if (hasGcpCredentials()) { + if (!getGcpCredentials().equals(other.getGcpCredentials())) return false; + } + if (hasTpmAttestation() != other.hasTpmAttestation()) return false; + if (hasTpmAttestation()) { + if (!getTpmAttestation().equals(other.getTpmAttestation())) 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(); + hash = (37 * hash) + CHALLENGE_FIELD_NUMBER; + hash = (53 * hash) + getChallenge().hashCode(); + if (hasGcpCredentials()) { + hash = (37 * hash) + GCP_CREDENTIALS_FIELD_NUMBER; + hash = (53 * hash) + getGcpCredentials().hashCode(); + } + if (hasTpmAttestation()) { + hash = (37 * hash) + TPM_ATTESTATION_FIELD_NUMBER; + hash = (53 * hash) + getTpmAttestation().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest + 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest 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; + } + /** + * + * + *
+   * A request for an OIDC token, providing all the necessary information needed
+   * for this service to verify the plaform state of the requestor.
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest) + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest.class, + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest.Builder + .class); + } + + // Construct using + // com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + challenge_ = ""; + gcpCredentials_ = null; + if (gcpCredentialsBuilder_ != null) { + gcpCredentialsBuilder_.dispose(); + gcpCredentialsBuilder_ = null; + } + tpmAttestation_ = null; + if (tpmAttestationBuilder_ != null) { + tpmAttestationBuilder_.dispose(); + tpmAttestationBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationRequest_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest + getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest build() { + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest buildPartial() { + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest result = + new com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.challenge_ = challenge_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.gcpCredentials_ = + gcpCredentialsBuilder_ == null ? gcpCredentials_ : gcpCredentialsBuilder_.build(); + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.tpmAttestation_ = + tpmAttestationBuilder_ == null ? tpmAttestation_ : tpmAttestationBuilder_.build(); + } + } + + @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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest) { + return mergeFrom( + (com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest other) { + if (other + == com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest + .getDefaultInstance()) return this; + if (!other.getChallenge().isEmpty()) { + challenge_ = other.challenge_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasGcpCredentials()) { + mergeGcpCredentials(other.getGcpCredentials()); + } + if (other.hasTpmAttestation()) { + mergeTpmAttestation(other.getTpmAttestation()); + } + 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 10: + { + challenge_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getGcpCredentialsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage(getTpmAttestationFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + 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 java.lang.Object challenge_ = ""; + /** + * + * + *
+     * Required. The name of the Challenge whose nonce was used to generate the
+     * attestation, in the format `projects/*/locations/*/challenges/*`. The
+     * provided Challenge will be consumed, and cannot be used again.
+     * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The challenge. + */ + public java.lang.String getChallenge() { + java.lang.Object ref = challenge_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + challenge_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The name of the Challenge whose nonce was used to generate the
+     * attestation, in the format `projects/*/locations/*/challenges/*`. The
+     * provided Challenge will be consumed, and cannot be used again.
+     * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for challenge. + */ + public com.google.protobuf.ByteString getChallengeBytes() { + java.lang.Object ref = challenge_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + challenge_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The name of the Challenge whose nonce was used to generate the
+     * attestation, in the format `projects/*/locations/*/challenges/*`. The
+     * provided Challenge will be consumed, and cannot be used again.
+     * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The challenge to set. + * @return This builder for chaining. + */ + public Builder setChallenge(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + challenge_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the Challenge whose nonce was used to generate the
+     * attestation, in the format `projects/*/locations/*/challenges/*`. The
+     * provided Challenge will be consumed, and cannot be used again.
+     * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearChallenge() { + challenge_ = getDefaultInstance().getChallenge(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the Challenge whose nonce was used to generate the
+     * attestation, in the format `projects/*/locations/*/challenges/*`. The
+     * provided Challenge will be consumed, and cannot be used again.
+     * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for challenge to set. + * @return This builder for chaining. + */ + public Builder setChallengeBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + challenge_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcpCredentials_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials, + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.Builder, + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentialsOrBuilder> + gcpCredentialsBuilder_; + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the gcpCredentials field is set. + */ + public boolean hasGcpCredentials() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The gcpCredentials. + */ + public com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials getGcpCredentials() { + if (gcpCredentialsBuilder_ == null) { + return gcpCredentials_ == null + ? com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.getDefaultInstance() + : gcpCredentials_; + } else { + return gcpCredentialsBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setGcpCredentials( + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials value) { + if (gcpCredentialsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + gcpCredentials_ = value; + } else { + gcpCredentialsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setGcpCredentials( + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.Builder builderForValue) { + if (gcpCredentialsBuilder_ == null) { + gcpCredentials_ = builderForValue.build(); + } else { + gcpCredentialsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeGcpCredentials( + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials value) { + if (gcpCredentialsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && gcpCredentials_ != null + && gcpCredentials_ + != com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials + .getDefaultInstance()) { + getGcpCredentialsBuilder().mergeFrom(value); + } else { + gcpCredentials_ = value; + } + } else { + gcpCredentialsBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearGcpCredentials() { + bitField0_ = (bitField0_ & ~0x00000002); + gcpCredentials_ = null; + if (gcpCredentialsBuilder_ != null) { + gcpCredentialsBuilder_.dispose(); + gcpCredentialsBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.Builder + getGcpCredentialsBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getGcpCredentialsFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentialsOrBuilder + getGcpCredentialsOrBuilder() { + if (gcpCredentialsBuilder_ != null) { + return gcpCredentialsBuilder_.getMessageOrBuilder(); + } else { + return gcpCredentials_ == null + ? com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.getDefaultInstance() + : gcpCredentials_; + } + } + /** + * + * + *
+     * Optional. Credentials used to populate the "emails" claim in the
+     * claims_token.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials, + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.Builder, + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentialsOrBuilder> + getGcpCredentialsFieldBuilder() { + if (gcpCredentialsBuilder_ == null) { + gcpCredentialsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials, + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials.Builder, + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentialsOrBuilder>( + getGcpCredentials(), getParentForChildren(), isClean()); + gcpCredentials_ = null; + } + return gcpCredentialsBuilder_; + } + + private com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpmAttestation_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Builder, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestationOrBuilder> + tpmAttestationBuilder_; + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the tpmAttestation field is set. + */ + public boolean hasTpmAttestation() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The tpmAttestation. + */ + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation getTpmAttestation() { + if (tpmAttestationBuilder_ == null) { + return tpmAttestation_ == null + ? com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.getDefaultInstance() + : tpmAttestation_; + } else { + return tpmAttestationBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setTpmAttestation( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation value) { + if (tpmAttestationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + tpmAttestation_ = value; + } else { + tpmAttestationBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setTpmAttestation( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Builder builderForValue) { + if (tpmAttestationBuilder_ == null) { + tpmAttestation_ = builderForValue.build(); + } else { + tpmAttestationBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeTpmAttestation( + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation value) { + if (tpmAttestationBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && tpmAttestation_ != null + && tpmAttestation_ + != com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation + .getDefaultInstance()) { + getTpmAttestationBuilder().mergeFrom(value); + } else { + tpmAttestation_ = value; + } + } else { + tpmAttestationBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearTpmAttestation() { + bitField0_ = (bitField0_ & ~0x00000004); + tpmAttestation_ = null; + if (tpmAttestationBuilder_ != null) { + tpmAttestationBuilder_.dispose(); + tpmAttestationBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Builder + getTpmAttestationBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getTpmAttestationFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestationOrBuilder + getTpmAttestationOrBuilder() { + if (tpmAttestationBuilder_ != null) { + return tpmAttestationBuilder_.getMessageOrBuilder(); + } else { + return tpmAttestation_ == null + ? com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.getDefaultInstance() + : tpmAttestation_; + } + } + /** + * + * + *
+     * Required. The TPM-specific data provided by the attesting platform, used to
+     * populate any of the claims regarding platform state.
+     * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Builder, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestationOrBuilder> + getTpmAttestationFieldBuilder() { + if (tpmAttestationBuilder_ == null) { + tpmAttestationBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation.Builder, + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestationOrBuilder>( + getTpmAttestation(), getParentForChildren(), isClean()); + tpmAttestation_ = null; + } + return tpmAttestationBuilder_; + } + + @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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest) + private static final com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest(); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public VerifyAttestationRequest 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/VerifyAttestationRequestOrBuilder.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/VerifyAttestationRequestOrBuilder.java new file mode 100644 index 000000000000..92b361babcb3 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/VerifyAttestationRequestOrBuilder.java @@ -0,0 +1,148 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +public interface VerifyAttestationRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The name of the Challenge whose nonce was used to generate the
+   * attestation, in the format `projects/*/locations/*/challenges/*`. The
+   * provided Challenge will be consumed, and cannot be used again.
+   * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The challenge. + */ + java.lang.String getChallenge(); + /** + * + * + *
+   * Required. The name of the Challenge whose nonce was used to generate the
+   * attestation, in the format `projects/*/locations/*/challenges/*`. The
+   * provided Challenge will be consumed, and cannot be used again.
+   * 
+ * + * + * string challenge = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for challenge. + */ + com.google.protobuf.ByteString getChallengeBytes(); + + /** + * + * + *
+   * Optional. Credentials used to populate the "emails" claim in the
+   * claims_token.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the gcpCredentials field is set. + */ + boolean hasGcpCredentials(); + /** + * + * + *
+   * Optional. Credentials used to populate the "emails" claim in the
+   * claims_token.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The gcpCredentials. + */ + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials getGcpCredentials(); + /** + * + * + *
+   * Optional. Credentials used to populate the "emails" claim in the
+   * claims_token.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.GcpCredentials gcp_credentials = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentialsOrBuilder + getGcpCredentialsOrBuilder(); + + /** + * + * + *
+   * Required. The TPM-specific data provided by the attesting platform, used to
+   * populate any of the claims regarding platform state.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the tpmAttestation field is set. + */ + boolean hasTpmAttestation(); + /** + * + * + *
+   * Required. The TPM-specific data provided by the attesting platform, used to
+   * populate any of the claims regarding platform state.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The tpmAttestation. + */ + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation getTpmAttestation(); + /** + * + * + *
+   * Required. The TPM-specific data provided by the attesting platform, used to
+   * populate any of the claims regarding platform state.
+   * 
+ * + * + * .google.cloud.confidentialcomputing.v1alpha1.TpmAttestation tpm_attestation = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestationOrBuilder + getTpmAttestationOrBuilder(); +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/VerifyAttestationResponse.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/VerifyAttestationResponse.java new file mode 100644 index 000000000000..52ea926a0d18 --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/VerifyAttestationResponse.java @@ -0,0 +1,572 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +/** + * + * + *
+ * A response once an attestation has been successfully verified, containing a
+ * signed OIDC token.
+ * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse} + */ +public final class VerifyAttestationResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse) + VerifyAttestationResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use VerifyAttestationResponse.newBuilder() to construct. + private VerifyAttestationResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private VerifyAttestationResponse() { + claimsToken_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new VerifyAttestationResponse(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse.class, + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse.Builder + .class); + } + + public static final int CLAIMS_TOKEN_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString claimsToken_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+   * Output only. The OIDC token issued by this service. It contains specific
+   * platform claims based on the contents of the provided attestation.
+   * --
+   * 
+ * + * bytes claims_token = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The claimsToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getClaimsToken() { + return claimsToken_; + } + + 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 (!claimsToken_.isEmpty()) { + output.writeBytes(1, claimsToken_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!claimsToken_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(1, claimsToken_); + } + 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse)) { + return super.equals(obj); + } + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse other = + (com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse) obj; + + if (!getClaimsToken().equals(other.getClaimsToken())) 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(); + hash = (37 * hash) + CLAIMS_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getClaimsToken().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse + 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse 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; + } + /** + * + * + *
+   * A response once an attestation has been successfully verified, containing a
+   * signed OIDC token.
+   * 
+ * + * Protobuf type {@code google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse) + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse.class, + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse.Builder + .class); + } + + // Construct using + // com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + claimsToken_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.ServiceProto + .internal_static_google_cloud_confidentialcomputing_v1alpha1_VerifyAttestationResponse_descriptor; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse + getDefaultInstanceForType() { + return com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse build() { + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse + buildPartial() { + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse result = + new com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.claimsToken_ = claimsToken_; + } + } + + @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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse) { + return mergeFrom( + (com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse other) { + if (other + == com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse + .getDefaultInstance()) return this; + if (other.getClaimsToken() != com.google.protobuf.ByteString.EMPTY) { + setClaimsToken(other.getClaimsToken()); + } + 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 10: + { + claimsToken_ = input.readBytes(); + bitField0_ |= 0x00000001; + break; + } // case 10 + 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 com.google.protobuf.ByteString claimsToken_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * Output only. The OIDC token issued by this service. It contains specific
+     * platform claims based on the contents of the provided attestation.
+     * --
+     * 
+ * + * bytes claims_token = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The claimsToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getClaimsToken() { + return claimsToken_; + } + /** + * + * + *
+     * Output only. The OIDC token issued by this service. It contains specific
+     * platform claims based on the contents of the provided attestation.
+     * --
+     * 
+ * + * bytes claims_token = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The claimsToken to set. + * @return This builder for chaining. + */ + public Builder setClaimsToken(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + claimsToken_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The OIDC token issued by this service. It contains specific
+     * platform claims based on the contents of the provided attestation.
+     * --
+     * 
+ * + * bytes claims_token = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearClaimsToken() { + bitField0_ = (bitField0_ & ~0x00000001); + claimsToken_ = getDefaultInstance().getClaimsToken(); + 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse) + } + + // @@protoc_insertion_point(class_scope:google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse) + private static final com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse(); + } + + public static com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public VerifyAttestationResponse 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.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/VerifyAttestationResponseOrBuilder.java b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/VerifyAttestationResponseOrBuilder.java new file mode 100644 index 000000000000..583c43b7210b --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/java/com/google/cloud/confidentialcomputing/v1alpha1/VerifyAttestationResponseOrBuilder.java @@ -0,0 +1,40 @@ +/* + * 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/cloud/confidentialcomputing/v1alpha1/service.proto + +package com.google.cloud.confidentialcomputing.v1alpha1; + +public interface VerifyAttestationResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Output only. The OIDC token issued by this service. It contains specific
+   * platform claims based on the contents of the provided attestation.
+   * --
+   * 
+ * + * bytes claims_token = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The claimsToken. + */ + com.google.protobuf.ByteString getClaimsToken(); +} diff --git a/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/proto/google/cloud/confidentialcomputing/v1alpha1/service.proto b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/proto/google/cloud/confidentialcomputing/v1alpha1/service.proto new file mode 100644 index 000000000000..89b4db4c2c2d --- /dev/null +++ b/java-confidentialcomputing/proto-google-cloud-confidentialcomputing-v1alpha1/src/main/proto/google/cloud/confidentialcomputing/v1alpha1/service.proto @@ -0,0 +1,184 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.confidentialcomputing.v1alpha1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ConfidentialComputing.V1Alpha1"; +option go_package = "cloud.google.com/go/confidentialcomputing/apiv1alpha1/confidentialcomputingpb;confidentialcomputingpb"; +option java_multiple_files = true; +option java_outer_classname = "ServiceProto"; +option java_package = "com.google.cloud.confidentialcomputing.v1alpha1"; +option php_namespace = "Google\\Cloud\\ConfidentialComputing\\V1alpha1"; +option ruby_package = "Google::Cloud::ConfidentialComputing::V1alpha1"; + +// Service describing handlers for resources +service ConfidentialComputing { + option (google.api.default_host) = "confidentialcomputing.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new Challenge in a given project and location. + rpc CreateChallenge(CreateChallengeRequest) returns (Challenge) { + option (google.api.http) = { + post: "/v1alpha1/{parent=projects/*/locations/*}/challenges" + body: "challenge" + }; + option (google.api.method_signature) = "parent,challenge"; + } + + // Verifies the provided attestation info, returning a signed OIDC token. + rpc VerifyAttestation(VerifyAttestationRequest) + returns (VerifyAttestationResponse) { + option (google.api.http) = { + post: "/v1alpha1/{challenge=projects/*/locations/*/challenges/*}:verifyAttestation" + body: "*" + }; + } +} + +// A Challenge from the server used to guarantee freshness of attestations +message Challenge { + option (google.api.resource) = { + type: "confidentialcomputing.googleapis.com/Challenge" + pattern: "projects/{project}/locations/{location}/challenges/{uuid}" + }; + + // Output only. The resource name for this Challenge in the format + // `projects/*/locations/*/challenges/*` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this Challenge was created + google.protobuf.Timestamp create_time = 2 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this Challenge will no longer be usable. It + // is also the expiration time for any tokens generated from this Challenge. + google.protobuf.Timestamp expire_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Indicates if this challenge has been used to generate a token. + bool used = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Random data which should be used when calling TPM2_Quote. + // -- + bytes nonce = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Message for creating a Challenge +message CreateChallengeRequest { + // Required. The resource name of the location where the Challenge will be + // used, in the format `projects/*/locations/*`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The Challenge to be created. Currently this field can be empty as + // all the Challenge fields are set by the server. + Challenge challenge = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// A request for an OIDC token, providing all the necessary information needed +// for this service to verify the plaform state of the requestor. +message VerifyAttestationRequest { + // Required. The name of the Challenge whose nonce was used to generate the + // attestation, in the format `projects/*/locations/*/challenges/*`. The + // provided Challenge will be consumed, and cannot be used again. + string challenge = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "confidentialcomputing.googleapis.com/Challenge" + } + ]; + + // Optional. Credentials used to populate the "emails" claim in the + // claims_token. + GcpCredentials gcp_credentials = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Required. The TPM-specific data provided by the attesting platform, used to + // populate any of the claims regarding platform state. + TpmAttestation tpm_attestation = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// A response once an attestation has been successfully verified, containing a +// signed OIDC token. +message VerifyAttestationResponse { + // Output only. The OIDC token issued by this service. It contains specific + // platform claims based on the contents of the provided attestation. + // -- + bytes claims_token = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Credentials issued by GCP which are linked to the platform attestation. These +// will be verified server-side as part of attestaion verification. +message GcpCredentials { + // A list of service account OpenID Connect ID tokens identifying which + // service account identities should be included in the claims_token. These + // can be generated by calling `serviceAccounts.generateIdToken`. The + // Challenge.name must be used as the `audience` parameter, and the + // `includeEmail` parameter must be `true`. + // -- + repeated bytes id_tokens = 1; +} + +// TPM2 data containing everything necessary to validate any platform state +// measured into the TPM. +message TpmAttestation { + // Information about Platform Control Registers (PCRs) including a signature + // over their values, which can be used for remote validation. + message Quote { + // The hash algorithm of the PCR bank being quoted, encoded as a TPM_ALG_ID + int32 hash_algo = 1; + + // Raw binary values of each PCRs being quoted. + map pcr_values = 2; + + // TPM2 quote, encoded as a TPMS_ATTEST + bytes raw_quote = 3; + + // TPM2 signature, encoded as a TPMT_SIGNATURE + bytes raw_signature = 4; + } + + // TPM2 PCR Quotes generated by calling TPM2_Quote on each PCR bank. + repeated Quote quotes = 1; + + // The binary TCG Event Log containing events measured into the TPM by the + // platform firmware and operating system. Formatted as described in the + // "TCG PC Client Platform Firmware Profile Specification". + bytes tcg_event_log = 2; + + // An Event Log containing additional events measured into the TPM that are + // not already present in the tcg_event_log. Formatted as described in the + // "Canonical Event Log Format" TCG Specification. + bytes canonical_event_log = 3; + + // DER-encoded X.509 certificate of the Attestation Key (otherwise known as + // an AK or a TPM restricted signing key) used to generate the quotes. + bytes ak_cert = 4; + + // List of DER-encoded X.509 certificates which, together with the ak_cert, + // chain back to a trusted Root Certificate. + repeated bytes cert_chain = 5; +} diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/create/SyncCreateSetCredentialsProvider.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..1e5c081b1bee --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_Create_SetCredentialsProvider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingSettings; +import com.google.cloud.confidentialcomputing.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + ConfidentialComputingSettings confidentialComputingSettings = + ConfidentialComputingSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create(confidentialComputingSettings); + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_Create_SetCredentialsProvider_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/create/SyncCreateSetCredentialsProvider1.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..25bceedf066c --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_Create_SetCredentialsProvider1_sync] +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + ConfidentialComputingSettings confidentialComputingSettings = + ConfidentialComputingSettings.newHttpJsonBuilder().build(); + ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create(confidentialComputingSettings); + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_Create_SetCredentialsProvider1_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/create/SyncCreateSetEndpoint.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..db06433f522f --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/create/SyncCreateSetEndpoint.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_Create_SetEndpoint_sync] +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingSettings; +import com.google.cloud.confidentialcomputing.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + ConfidentialComputingSettings confidentialComputingSettings = + ConfidentialComputingSettings.newBuilder().setEndpoint(myEndpoint).build(); + ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create(confidentialComputingSettings); + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_Create_SetEndpoint_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/createchallenge/AsyncCreateChallenge.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/createchallenge/AsyncCreateChallenge.java new file mode 100644 index 000000000000..520b84606b5a --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/createchallenge/AsyncCreateChallenge.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_CreateChallenge_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.confidentialcomputing.v1.Challenge; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest; +import com.google.cloud.confidentialcomputing.v1.LocationName; + +public class AsyncCreateChallenge { + + public static void main(String[] args) throws Exception { + asyncCreateChallenge(); + } + + public static void asyncCreateChallenge() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + CreateChallengeRequest request = + CreateChallengeRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setChallenge(Challenge.newBuilder().build()) + .build(); + ApiFuture future = + confidentialComputingClient.createChallengeCallable().futureCall(request); + // Do something. + Challenge response = future.get(); + } + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_CreateChallenge_async] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/createchallenge/SyncCreateChallenge.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/createchallenge/SyncCreateChallenge.java new file mode 100644 index 000000000000..d2a44ac641ca --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/createchallenge/SyncCreateChallenge.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_CreateChallenge_sync] +import com.google.cloud.confidentialcomputing.v1.Challenge; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1.CreateChallengeRequest; +import com.google.cloud.confidentialcomputing.v1.LocationName; + +public class SyncCreateChallenge { + + public static void main(String[] args) throws Exception { + syncCreateChallenge(); + } + + public static void syncCreateChallenge() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + CreateChallengeRequest request = + CreateChallengeRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setChallenge(Challenge.newBuilder().build()) + .build(); + Challenge response = confidentialComputingClient.createChallenge(request); + } + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_CreateChallenge_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/createchallenge/SyncCreateChallengeLocationnameChallenge.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/createchallenge/SyncCreateChallengeLocationnameChallenge.java new file mode 100644 index 000000000000..7ed762227e9a --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/createchallenge/SyncCreateChallengeLocationnameChallenge.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_CreateChallenge_LocationnameChallenge_sync] +import com.google.cloud.confidentialcomputing.v1.Challenge; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1.LocationName; + +public class SyncCreateChallengeLocationnameChallenge { + + public static void main(String[] args) throws Exception { + syncCreateChallengeLocationnameChallenge(); + } + + public static void syncCreateChallengeLocationnameChallenge() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Challenge challenge = Challenge.newBuilder().build(); + Challenge response = confidentialComputingClient.createChallenge(parent, challenge); + } + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_CreateChallenge_LocationnameChallenge_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/createchallenge/SyncCreateChallengeStringChallenge.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/createchallenge/SyncCreateChallengeStringChallenge.java new file mode 100644 index 000000000000..b5aef74df248 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/createchallenge/SyncCreateChallengeStringChallenge.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_CreateChallenge_StringChallenge_sync] +import com.google.cloud.confidentialcomputing.v1.Challenge; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1.LocationName; + +public class SyncCreateChallengeStringChallenge { + + public static void main(String[] args) throws Exception { + syncCreateChallengeStringChallenge(); + } + + public static void syncCreateChallengeStringChallenge() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Challenge challenge = Challenge.newBuilder().build(); + Challenge response = confidentialComputingClient.createChallenge(parent, challenge); + } + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_CreateChallenge_StringChallenge_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/getlocation/AsyncGetLocation.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/getlocation/AsyncGetLocation.java new file mode 100644 index 000000000000..6df910a145b5 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/getlocation/AsyncGetLocation.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_GetLocation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.Location; + +public class AsyncGetLocation { + + public static void main(String[] args) throws Exception { + asyncGetLocation(); + } + + public static void asyncGetLocation() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + confidentialComputingClient.getLocationCallable().futureCall(request); + // Do something. + Location response = future.get(); + } + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_GetLocation_async] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/getlocation/SyncGetLocation.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/getlocation/SyncGetLocation.java new file mode 100644 index 000000000000..f42613f3571e --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/getlocation/SyncGetLocation.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_GetLocation_sync] +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.Location; + +public class SyncGetLocation { + + public static void main(String[] args) throws Exception { + syncGetLocation(); + } + + public static void syncGetLocation() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + Location response = confidentialComputingClient.getLocation(request); + } + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_GetLocation_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/listlocations/AsyncListLocations.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/listlocations/AsyncListLocations.java new file mode 100644 index 000000000000..3e72eb22b9fc --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/listlocations/AsyncListLocations.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_ListLocations_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.Location; + +public class AsyncListLocations { + + public static void main(String[] args) throws Exception { + asyncListLocations(); + } + + public static void asyncListLocations() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + confidentialComputingClient.listLocationsPagedCallable().futureCall(request); + // Do something. + for (Location element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_ListLocations_async] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/listlocations/AsyncListLocationsPaged.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/listlocations/AsyncListLocationsPaged.java new file mode 100644 index 000000000000..e5cd88de1dde --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/listlocations/AsyncListLocationsPaged.java @@ -0,0 +1,63 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_ListLocations_Paged_async] +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.base.Strings; + +public class AsyncListLocationsPaged { + + public static void main(String[] args) throws Exception { + asyncListLocationsPaged(); + } + + public static void asyncListLocationsPaged() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListLocationsResponse response = + confidentialComputingClient.listLocationsCallable().call(request); + for (Location element : response.getLocationsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_ListLocations_Paged_async] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/listlocations/SyncListLocations.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/listlocations/SyncListLocations.java new file mode 100644 index 000000000000..3f84e7fef908 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/listlocations/SyncListLocations.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_ListLocations_sync] +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.Location; + +public class SyncListLocations { + + public static void main(String[] args) throws Exception { + syncListLocations(); + } + + public static void syncListLocations() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Location element : confidentialComputingClient.listLocations(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_ListLocations_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/verifyattestation/AsyncVerifyAttestation.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/verifyattestation/AsyncVerifyAttestation.java new file mode 100644 index 000000000000..8755b8acb324 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/verifyattestation/AsyncVerifyAttestation.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_VerifyAttestation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.confidentialcomputing.v1.ChallengeName; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1.GcpCredentials; +import com.google.cloud.confidentialcomputing.v1.TpmAttestation; +import com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest; +import com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse; + +public class AsyncVerifyAttestation { + + public static void main(String[] args) throws Exception { + asyncVerifyAttestation(); + } + + public static void asyncVerifyAttestation() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + VerifyAttestationRequest request = + VerifyAttestationRequest.newBuilder() + .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setGcpCredentials(GcpCredentials.newBuilder().build()) + .setTpmAttestation(TpmAttestation.newBuilder().build()) + .build(); + ApiFuture future = + confidentialComputingClient.verifyAttestationCallable().futureCall(request); + // Do something. + VerifyAttestationResponse response = future.get(); + } + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_VerifyAttestation_async] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/verifyattestation/SyncVerifyAttestation.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/verifyattestation/SyncVerifyAttestation.java new file mode 100644 index 000000000000..e0809ca3a166 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputing/verifyattestation/SyncVerifyAttestation.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputing_VerifyAttestation_sync] +import com.google.cloud.confidentialcomputing.v1.ChallengeName; +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1.GcpCredentials; +import com.google.cloud.confidentialcomputing.v1.TpmAttestation; +import com.google.cloud.confidentialcomputing.v1.VerifyAttestationRequest; +import com.google.cloud.confidentialcomputing.v1.VerifyAttestationResponse; + +public class SyncVerifyAttestation { + + public static void main(String[] args) throws Exception { + syncVerifyAttestation(); + } + + public static void syncVerifyAttestation() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + VerifyAttestationRequest request = + VerifyAttestationRequest.newBuilder() + .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setGcpCredentials(GcpCredentials.newBuilder().build()) + .setTpmAttestation(TpmAttestation.newBuilder().build()) + .build(); + VerifyAttestationResponse response = confidentialComputingClient.verifyAttestation(request); + } + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputing_VerifyAttestation_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputingsettings/createchallenge/SyncCreateChallenge.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputingsettings/createchallenge/SyncCreateChallenge.java new file mode 100644 index 000000000000..c0add37a7278 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/confidentialcomputingsettings/createchallenge/SyncCreateChallenge.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputingSettings_CreateChallenge_sync] +import com.google.cloud.confidentialcomputing.v1.ConfidentialComputingSettings; +import java.time.Duration; + +public class SyncCreateChallenge { + + public static void main(String[] args) throws Exception { + syncCreateChallenge(); + } + + public static void syncCreateChallenge() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + ConfidentialComputingSettings.Builder confidentialComputingSettingsBuilder = + ConfidentialComputingSettings.newBuilder(); + confidentialComputingSettingsBuilder + .createChallengeSettings() + .setRetrySettings( + confidentialComputingSettingsBuilder + .createChallengeSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConfidentialComputingSettings confidentialComputingSettings = + confidentialComputingSettingsBuilder.build(); + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputingSettings_CreateChallenge_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/stub/confidentialcomputingstubsettings/createchallenge/SyncCreateChallenge.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/stub/confidentialcomputingstubsettings/createchallenge/SyncCreateChallenge.java new file mode 100644 index 000000000000..98ec722a3236 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1/stub/confidentialcomputingstubsettings/createchallenge/SyncCreateChallenge.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1.stub.samples; + +// [START confidentialcomputing_v1_generated_ConfidentialComputingStubSettings_CreateChallenge_sync] +import com.google.cloud.confidentialcomputing.v1.stub.ConfidentialComputingStubSettings; +import java.time.Duration; + +public class SyncCreateChallenge { + + public static void main(String[] args) throws Exception { + syncCreateChallenge(); + } + + public static void syncCreateChallenge() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + ConfidentialComputingStubSettings.Builder confidentialComputingSettingsBuilder = + ConfidentialComputingStubSettings.newBuilder(); + confidentialComputingSettingsBuilder + .createChallengeSettings() + .setRetrySettings( + confidentialComputingSettingsBuilder + .createChallengeSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConfidentialComputingStubSettings confidentialComputingSettings = + confidentialComputingSettingsBuilder.build(); + } +} +// [END confidentialcomputing_v1_generated_ConfidentialComputingStubSettings_CreateChallenge_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/create/SyncCreateSetCredentialsProvider.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..5597d41be373 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_Create_SetCredentialsProvider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingSettings; +import com.google.cloud.confidentialcomputing.v1alpha1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + ConfidentialComputingSettings confidentialComputingSettings = + ConfidentialComputingSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create(confidentialComputingSettings); + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_Create_SetCredentialsProvider_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/create/SyncCreateSetCredentialsProvider1.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..84ac20a16e07 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_Create_SetCredentialsProvider1_sync] +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + ConfidentialComputingSettings confidentialComputingSettings = + ConfidentialComputingSettings.newHttpJsonBuilder().build(); + ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create(confidentialComputingSettings); + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_Create_SetCredentialsProvider1_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/create/SyncCreateSetEndpoint.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..02d15de6bcd2 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/create/SyncCreateSetEndpoint.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_Create_SetEndpoint_sync] +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingSettings; +import com.google.cloud.confidentialcomputing.v1alpha1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + ConfidentialComputingSettings confidentialComputingSettings = + ConfidentialComputingSettings.newBuilder().setEndpoint(myEndpoint).build(); + ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create(confidentialComputingSettings); + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_Create_SetEndpoint_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/createchallenge/AsyncCreateChallenge.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/createchallenge/AsyncCreateChallenge.java new file mode 100644 index 000000000000..09b53feefc2c --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/createchallenge/AsyncCreateChallenge.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_CreateChallenge_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.confidentialcomputing.v1alpha1.Challenge; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest; +import com.google.cloud.confidentialcomputing.v1alpha1.LocationName; + +public class AsyncCreateChallenge { + + public static void main(String[] args) throws Exception { + asyncCreateChallenge(); + } + + public static void asyncCreateChallenge() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + CreateChallengeRequest request = + CreateChallengeRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setChallenge(Challenge.newBuilder().build()) + .build(); + ApiFuture future = + confidentialComputingClient.createChallengeCallable().futureCall(request); + // Do something. + Challenge response = future.get(); + } + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_CreateChallenge_async] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/createchallenge/SyncCreateChallenge.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/createchallenge/SyncCreateChallenge.java new file mode 100644 index 000000000000..0cd89d3c2dd0 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/createchallenge/SyncCreateChallenge.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_CreateChallenge_sync] +import com.google.cloud.confidentialcomputing.v1alpha1.Challenge; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1alpha1.CreateChallengeRequest; +import com.google.cloud.confidentialcomputing.v1alpha1.LocationName; + +public class SyncCreateChallenge { + + public static void main(String[] args) throws Exception { + syncCreateChallenge(); + } + + public static void syncCreateChallenge() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + CreateChallengeRequest request = + CreateChallengeRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setChallenge(Challenge.newBuilder().build()) + .build(); + Challenge response = confidentialComputingClient.createChallenge(request); + } + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_CreateChallenge_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/createchallenge/SyncCreateChallengeLocationnameChallenge.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/createchallenge/SyncCreateChallengeLocationnameChallenge.java new file mode 100644 index 000000000000..3b74fdc187be --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/createchallenge/SyncCreateChallengeLocationnameChallenge.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_CreateChallenge_LocationnameChallenge_sync] +import com.google.cloud.confidentialcomputing.v1alpha1.Challenge; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1alpha1.LocationName; + +public class SyncCreateChallengeLocationnameChallenge { + + public static void main(String[] args) throws Exception { + syncCreateChallengeLocationnameChallenge(); + } + + public static void syncCreateChallengeLocationnameChallenge() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Challenge challenge = Challenge.newBuilder().build(); + Challenge response = confidentialComputingClient.createChallenge(parent, challenge); + } + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_CreateChallenge_LocationnameChallenge_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/createchallenge/SyncCreateChallengeStringChallenge.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/createchallenge/SyncCreateChallengeStringChallenge.java new file mode 100644 index 000000000000..8af6390b01c5 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/createchallenge/SyncCreateChallengeStringChallenge.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_CreateChallenge_StringChallenge_sync] +import com.google.cloud.confidentialcomputing.v1alpha1.Challenge; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1alpha1.LocationName; + +public class SyncCreateChallengeStringChallenge { + + public static void main(String[] args) throws Exception { + syncCreateChallengeStringChallenge(); + } + + public static void syncCreateChallengeStringChallenge() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Challenge challenge = Challenge.newBuilder().build(); + Challenge response = confidentialComputingClient.createChallenge(parent, challenge); + } + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_CreateChallenge_StringChallenge_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/getlocation/AsyncGetLocation.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/getlocation/AsyncGetLocation.java new file mode 100644 index 000000000000..7354a10aa9c7 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/getlocation/AsyncGetLocation.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_GetLocation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.Location; + +public class AsyncGetLocation { + + public static void main(String[] args) throws Exception { + asyncGetLocation(); + } + + public static void asyncGetLocation() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + confidentialComputingClient.getLocationCallable().futureCall(request); + // Do something. + Location response = future.get(); + } + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_GetLocation_async] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/getlocation/SyncGetLocation.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/getlocation/SyncGetLocation.java new file mode 100644 index 000000000000..cda52747a436 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/getlocation/SyncGetLocation.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_GetLocation_sync] +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.Location; + +public class SyncGetLocation { + + public static void main(String[] args) throws Exception { + syncGetLocation(); + } + + public static void syncGetLocation() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + Location response = confidentialComputingClient.getLocation(request); + } + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_GetLocation_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/listlocations/AsyncListLocations.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/listlocations/AsyncListLocations.java new file mode 100644 index 000000000000..ed244a213442 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/listlocations/AsyncListLocations.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_ListLocations_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.Location; + +public class AsyncListLocations { + + public static void main(String[] args) throws Exception { + asyncListLocations(); + } + + public static void asyncListLocations() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + confidentialComputingClient.listLocationsPagedCallable().futureCall(request); + // Do something. + for (Location element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_ListLocations_async] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/listlocations/AsyncListLocationsPaged.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/listlocations/AsyncListLocationsPaged.java new file mode 100644 index 000000000000..cfc6a92dd8fa --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/listlocations/AsyncListLocationsPaged.java @@ -0,0 +1,63 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_ListLocations_Paged_async] +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.base.Strings; + +public class AsyncListLocationsPaged { + + public static void main(String[] args) throws Exception { + asyncListLocationsPaged(); + } + + public static void asyncListLocationsPaged() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListLocationsResponse response = + confidentialComputingClient.listLocationsCallable().call(request); + for (Location element : response.getLocationsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_ListLocations_Paged_async] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/listlocations/SyncListLocations.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/listlocations/SyncListLocations.java new file mode 100644 index 000000000000..4de321af7669 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/listlocations/SyncListLocations.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_ListLocations_sync] +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.Location; + +public class SyncListLocations { + + public static void main(String[] args) throws Exception { + syncListLocations(); + } + + public static void syncListLocations() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Location element : confidentialComputingClient.listLocations(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_ListLocations_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/verifyattestation/AsyncVerifyAttestation.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/verifyattestation/AsyncVerifyAttestation.java new file mode 100644 index 000000000000..f323ba82b2b8 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/verifyattestation/AsyncVerifyAttestation.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_VerifyAttestation_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.confidentialcomputing.v1alpha1.ChallengeName; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials; +import com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation; +import com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest; +import com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse; + +public class AsyncVerifyAttestation { + + public static void main(String[] args) throws Exception { + asyncVerifyAttestation(); + } + + public static void asyncVerifyAttestation() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + VerifyAttestationRequest request = + VerifyAttestationRequest.newBuilder() + .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setGcpCredentials(GcpCredentials.newBuilder().build()) + .setTpmAttestation(TpmAttestation.newBuilder().build()) + .build(); + ApiFuture future = + confidentialComputingClient.verifyAttestationCallable().futureCall(request); + // Do something. + VerifyAttestationResponse response = future.get(); + } + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_VerifyAttestation_async] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/verifyattestation/SyncVerifyAttestation.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/verifyattestation/SyncVerifyAttestation.java new file mode 100644 index 000000000000..a71c72aa0926 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing/verifyattestation/SyncVerifyAttestation.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputing_VerifyAttestation_sync] +import com.google.cloud.confidentialcomputing.v1alpha1.ChallengeName; +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingClient; +import com.google.cloud.confidentialcomputing.v1alpha1.GcpCredentials; +import com.google.cloud.confidentialcomputing.v1alpha1.TpmAttestation; +import com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationRequest; +import com.google.cloud.confidentialcomputing.v1alpha1.VerifyAttestationResponse; + +public class SyncVerifyAttestation { + + public static void main(String[] args) throws Exception { + syncVerifyAttestation(); + } + + public static void syncVerifyAttestation() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (ConfidentialComputingClient confidentialComputingClient = + ConfidentialComputingClient.create()) { + VerifyAttestationRequest request = + VerifyAttestationRequest.newBuilder() + .setChallenge(ChallengeName.of("[PROJECT]", "[LOCATION]", "[UUID]").toString()) + .setGcpCredentials(GcpCredentials.newBuilder().build()) + .setTpmAttestation(TpmAttestation.newBuilder().build()) + .build(); + VerifyAttestationResponse response = confidentialComputingClient.verifyAttestation(request); + } + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputing_VerifyAttestation_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputingsettings/createchallenge/SyncCreateChallenge.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputingsettings/createchallenge/SyncCreateChallenge.java new file mode 100644 index 000000000000..617c0acfbb17 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputingsettings/createchallenge/SyncCreateChallenge.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputingSettings_CreateChallenge_sync] +import com.google.cloud.confidentialcomputing.v1alpha1.ConfidentialComputingSettings; +import java.time.Duration; + +public class SyncCreateChallenge { + + public static void main(String[] args) throws Exception { + syncCreateChallenge(); + } + + public static void syncCreateChallenge() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + ConfidentialComputingSettings.Builder confidentialComputingSettingsBuilder = + ConfidentialComputingSettings.newBuilder(); + confidentialComputingSettingsBuilder + .createChallengeSettings() + .setRetrySettings( + confidentialComputingSettingsBuilder + .createChallengeSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConfidentialComputingSettings confidentialComputingSettings = + confidentialComputingSettingsBuilder.build(); + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputingSettings_CreateChallenge_sync] diff --git a/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/stub/confidentialcomputingstubsettings/createchallenge/SyncCreateChallenge.java b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/stub/confidentialcomputingstubsettings/createchallenge/SyncCreateChallenge.java new file mode 100644 index 000000000000..3c065e892376 --- /dev/null +++ b/java-confidentialcomputing/samples/snippets/generated/com/google/cloud/confidentialcomputing/v1alpha1/stub/confidentialcomputingstubsettings/createchallenge/SyncCreateChallenge.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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. + */ + +package com.google.cloud.confidentialcomputing.v1alpha1.stub.samples; + +// [START confidentialcomputing_v1alpha1_generated_ConfidentialComputingStubSettings_CreateChallenge_sync] +import com.google.cloud.confidentialcomputing.v1alpha1.stub.ConfidentialComputingStubSettings; +import java.time.Duration; + +public class SyncCreateChallenge { + + public static void main(String[] args) throws Exception { + syncCreateChallenge(); + } + + public static void syncCreateChallenge() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + ConfidentialComputingStubSettings.Builder confidentialComputingSettingsBuilder = + ConfidentialComputingStubSettings.newBuilder(); + confidentialComputingSettingsBuilder + .createChallengeSettings() + .setRetrySettings( + confidentialComputingSettingsBuilder + .createChallengeSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ConfidentialComputingStubSettings confidentialComputingSettings = + confidentialComputingSettingsBuilder.build(); + } +} +// [END confidentialcomputing_v1alpha1_generated_ConfidentialComputingStubSettings_CreateChallenge_sync] diff --git a/pom.xml b/pom.xml index 9f984759787e..28e9012560c8 100644 --- a/pom.xml +++ b/pom.xml @@ -54,6 +54,7 @@ java-cloudbuild java-cloudcommerceconsumerprocurement java-compute + java-confidentialcomputing java-contact-center-insights java-containeranalysis java-container diff --git a/versions.txt b/versions.txt index d107f2608a4a..b8bb2dc9dfda 100644 --- a/versions.txt +++ b/versions.txt @@ -625,3 +625,8 @@ grpc-google-cloud-biglake-v1alpha1:0.2.0:0.3.0-SNAPSHOT google-cloud-workstations:0.2.0:0.3.0-SNAPSHOT proto-google-cloud-workstations-v1beta:0.2.0:0.3.0-SNAPSHOT grpc-google-cloud-workstations-v1beta:0.2.0:0.3.0-SNAPSHOT +google-cloud-confidentialcomputing:0.0.0:0.0.1-SNAPSHOT +proto-google-cloud-confidentialcomputing-v1:0.0.0:0.0.1-SNAPSHOT +proto-google-cloud-confidentialcomputing-v1alpha1:0.0.0:0.0.1-SNAPSHOT +grpc-google-cloud-confidentialcomputing-v1:0.0.0:0.0.1-SNAPSHOT +grpc-google-cloud-confidentialcomputing-v1alpha1:0.0.0:0.0.1-SNAPSHOT