From 6e725ffa4b75175f63158a9426d29f27f3df624e Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 2 Jan 2024 15:09:33 -0500 Subject: [PATCH] feat: [cloudprofiler] add `ListProfiles` RPC to `ExportService` (#10150) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add `ListProfiles` RPC to `ExportService` PiperOrigin-RevId: 590653747 Source-Link: https://github.com/googleapis/googleapis/commit/f8a2933d3589bee919db0b97cccaa85afe1b0c8b Source-Link: https://github.com/googleapis/googleapis-gen/commit/4f504867233bf21c59b6867aa751817f3702629c Copy-Tag: eyJwIjoiamF2YS1wcm9maWxlci8uT3dsQm90LnlhbWwiLCJoIjoiNGY1MDQ4NjcyMzNiZjIxYzU5YjY4NjdhYTc1MTgxN2YzNzAyNjI5YyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot --- java-profiler/README.md | 2 +- .../cloudprofiler/v2/ExportServiceClient.java | 392 ++++++ .../v2/ExportServiceSettings.java | 210 +++ .../cloudprofiler/v2/gapic_metadata.json | 12 + .../cloudprofiler/v2/package-info.java | 26 + .../v2/stub/ExportServiceStub.java | 46 + .../v2/stub/ExportServiceStubSettings.java | 399 ++++++ .../GrpcExportServiceCallableFactory.java | 113 ++ .../v2/stub/GrpcExportServiceStub.java | 172 +++ .../HttpJsonExportServiceCallableFactory.java | 105 ++ .../v2/stub/HttpJsonExportServiceStub.java | 213 +++ .../reflect-config.json | 36 + .../v2/ExportServiceClientHttpJsonTest.java | 137 ++ .../v2/ExportServiceClientTest.java | 136 ++ .../cloudprofiler/v2/MockExportService.java | 59 + .../v2/MockExportServiceImpl.java | 81 ++ .../cloudprofiler/v2/ExportServiceGrpc.java | 390 ++++++ .../cloudprofiler/v2/ListProfilesRequest.java | 945 +++++++++++++ .../v2/ListProfilesRequestOrBuilder.java | 100 ++ .../v2/ListProfilesResponse.java | 1234 +++++++++++++++++ .../v2/ListProfilesResponseOrBuilder.java | 120 ++ .../cloudprofiler/v2/ProfilerProto.java | 98 +- .../devtools/cloudprofiler/v2/profiler.proto | 58 + .../SyncCreateSetCredentialsProvider.java | 44 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 41 + .../listprofiles/AsyncListProfiles.java | 54 + .../listprofiles/AsyncListProfilesPaged.java | 61 + .../listprofiles/SyncListProfiles.java | 50 + .../listprofiles/SyncListProfiles.java | 48 + .../listprofiles/SyncListProfiles.java | 49 + 31 files changed, 5441 insertions(+), 30 deletions(-) create mode 100644 java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/ExportServiceClient.java create mode 100644 java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/ExportServiceSettings.java create mode 100644 java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/ExportServiceStub.java create mode 100644 java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/ExportServiceStubSettings.java create mode 100644 java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/GrpcExportServiceCallableFactory.java create mode 100644 java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/GrpcExportServiceStub.java create mode 100644 java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/HttpJsonExportServiceCallableFactory.java create mode 100644 java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/HttpJsonExportServiceStub.java create mode 100644 java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/ExportServiceClientHttpJsonTest.java create mode 100644 java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/ExportServiceClientTest.java create mode 100644 java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/MockExportService.java create mode 100644 java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/MockExportServiceImpl.java create mode 100644 java-profiler/grpc-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ExportServiceGrpc.java create mode 100644 java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesRequest.java create mode 100644 java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesRequestOrBuilder.java create mode 100644 java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesResponse.java create mode 100644 java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesResponseOrBuilder.java create mode 100644 java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/create/SyncCreateSetEndpoint.java create mode 100644 java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/listprofiles/AsyncListProfiles.java create mode 100644 java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/listprofiles/AsyncListProfilesPaged.java create mode 100644 java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/listprofiles/SyncListProfiles.java create mode 100644 java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservicesettings/listprofiles/SyncListProfiles.java create mode 100644 java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/stub/exportservicestubsettings/listprofiles/SyncListProfiles.java diff --git a/java-profiler/README.md b/java-profiler/README.md index 9a177ac3d2c1..bb9c19639d89 100644 --- a/java-profiler/README.md +++ b/java-profiler/README.md @@ -195,7 +195,7 @@ Java is a registered trademark of Oracle and/or its affiliates. [kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/java11.html [stability-image]: https://img.shields.io/badge/stability-stable-green [maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-profiler.svg -[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-profiler/2.30.0 +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-profiler/2.32.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 diff --git a/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/ExportServiceClient.java b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/ExportServiceClient.java new file mode 100644 index 000000000000..88416631de0a --- /dev/null +++ b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/ExportServiceClient.java @@ -0,0 +1,392 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2; + +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.common.util.concurrent.MoreExecutors; +import com.google.devtools.cloudprofiler.v2.stub.ExportServiceStub; +import com.google.devtools.cloudprofiler.v2.stub.ExportServiceStubSettings; +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 allows existing Cloud Profiler customers to export their profile + * data out of Google Cloud. + * + *

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 (ExportServiceClient exportServiceClient = ExportServiceClient.create()) {
+ *   ListProfilesRequest request =
+ *       ListProfilesRequest.newBuilder()
+ *           .setParent(ProjectName.of("[PROJECT]").toString())
+ *           .setPageSize(883849137)
+ *           .setPageToken("pageToken873572522")
+ *           .build();
+ *   for (Profile element : exportServiceClient.listProfiles(request).iterateAll()) {
+ *     // doThingsWith(element);
+ *   }
+ * }
+ * }
+ * + *

Note: close() needs to be called on the ExportServiceClient 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 ExportServiceSettings 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
+ * ExportServiceSettings exportServiceSettings =
+ *     ExportServiceSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * ExportServiceClient exportServiceClient = ExportServiceClient.create(exportServiceSettings);
+ * }
+ * + *

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
+ * ExportServiceSettings exportServiceSettings =
+ *     ExportServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * ExportServiceClient exportServiceClient = ExportServiceClient.create(exportServiceSettings);
+ * }
+ * + *

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
+ * ExportServiceSettings exportServiceSettings =
+ *     ExportServiceSettings.newHttpJsonBuilder().build();
+ * ExportServiceClient exportServiceClient = ExportServiceClient.create(exportServiceSettings);
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@Generated("by gapic-generator-java") +public class ExportServiceClient implements BackgroundResource { + private final ExportServiceSettings settings; + private final ExportServiceStub stub; + + /** Constructs an instance of ExportServiceClient with default settings. */ + public static final ExportServiceClient create() throws IOException { + return create(ExportServiceSettings.newBuilder().build()); + } + + /** + * Constructs an instance of ExportServiceClient, 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 ExportServiceClient create(ExportServiceSettings settings) + throws IOException { + return new ExportServiceClient(settings); + } + + /** + * Constructs an instance of ExportServiceClient, using the given stub for making calls. This is + * for advanced usage - prefer using create(ExportServiceSettings). + */ + public static final ExportServiceClient create(ExportServiceStub stub) { + return new ExportServiceClient(stub); + } + + /** + * Constructs an instance of ExportServiceClient, 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 ExportServiceClient(ExportServiceSettings settings) throws IOException { + this.settings = settings; + this.stub = ((ExportServiceStubSettings) settings.getStubSettings()).createStub(); + } + + protected ExportServiceClient(ExportServiceStub stub) { + this.settings = null; + this.stub = stub; + } + + public final ExportServiceSettings getSettings() { + return settings; + } + + public ExportServiceStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists profiles which have been collected so far and for which the caller has permission to + * view. + * + *

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 (ExportServiceClient exportServiceClient = ExportServiceClient.create()) {
+   *   ListProfilesRequest request =
+   *       ListProfilesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Profile element : exportServiceClient.listProfiles(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 ListProfilesPagedResponse listProfiles(ListProfilesRequest request) { + return listProfilesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists profiles which have been collected so far and for which the caller has permission to + * view. + * + *

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 (ExportServiceClient exportServiceClient = ExportServiceClient.create()) {
+   *   ListProfilesRequest request =
+   *       ListProfilesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       exportServiceClient.listProfilesPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Profile element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listProfilesPagedCallable() { + return stub.listProfilesPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists profiles which have been collected so far and for which the caller has permission to + * view. + * + *

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 (ExportServiceClient exportServiceClient = ExportServiceClient.create()) {
+   *   ListProfilesRequest request =
+   *       ListProfilesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   while (true) {
+   *     ListProfilesResponse response = exportServiceClient.listProfilesCallable().call(request);
+   *     for (Profile element : response.getProfilesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable listProfilesCallable() { + return stub.listProfilesCallable(); + } + + @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 ListProfilesPagedResponse + extends AbstractPagedListResponse< + ListProfilesRequest, + ListProfilesResponse, + Profile, + ListProfilesPage, + ListProfilesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListProfilesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + input -> new ListProfilesPagedResponse(input), + MoreExecutors.directExecutor()); + } + + private ListProfilesPagedResponse(ListProfilesPage page) { + super(page, ListProfilesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListProfilesPage + extends AbstractPage { + + private ListProfilesPage( + PageContext context, + ListProfilesResponse response) { + super(context, response); + } + + private static ListProfilesPage createEmptyPage() { + return new ListProfilesPage(null, null); + } + + @Override + protected ListProfilesPage createPage( + PageContext context, + ListProfilesResponse response) { + return new ListProfilesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListProfilesFixedSizeCollection + extends AbstractFixedSizeCollection< + ListProfilesRequest, + ListProfilesResponse, + Profile, + ListProfilesPage, + ListProfilesFixedSizeCollection> { + + private ListProfilesFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListProfilesFixedSizeCollection createEmptyCollection() { + return new ListProfilesFixedSizeCollection(null, 0); + } + + @Override + protected ListProfilesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListProfilesFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/ExportServiceSettings.java b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/ExportServiceSettings.java new file mode 100644 index 000000000000..8b98b4423507 --- /dev/null +++ b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/ExportServiceSettings.java @@ -0,0 +1,210 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2; + +import static com.google.devtools.cloudprofiler.v2.ExportServiceClient.ListProfilesPagedResponse; + +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.devtools.cloudprofiler.v2.stub.ExportServiceStubSettings; +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 ExportServiceClient}. + * + *

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

    + *
  • The default service address (cloudprofiler.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 listProfiles 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
+ * ExportServiceSettings.Builder exportServiceSettingsBuilder = ExportServiceSettings.newBuilder();
+ * exportServiceSettingsBuilder
+ *     .listProfilesSettings()
+ *     .setRetrySettings(
+ *         exportServiceSettingsBuilder
+ *             .listProfilesSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * ExportServiceSettings exportServiceSettings = exportServiceSettingsBuilder.build();
+ * }
+ */ +@Generated("by gapic-generator-java") +public class ExportServiceSettings extends ClientSettings { + + /** Returns the object with the settings used for calls to listProfiles. */ + public PagedCallSettings + listProfilesSettings() { + return ((ExportServiceStubSettings) getStubSettings()).listProfilesSettings(); + } + + public static final ExportServiceSettings create(ExportServiceStubSettings stub) + throws IOException { + return new ExportServiceSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return ExportServiceStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return ExportServiceStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return ExportServiceStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return ExportServiceStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return ExportServiceStubSettings.defaultGrpcTransportProviderBuilder(); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ExportServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return ExportServiceStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ExportServiceStubSettings.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 ExportServiceSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for ExportServiceSettings. */ + public static class Builder extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(ExportServiceStubSettings.newBuilder(clientContext)); + } + + protected Builder(ExportServiceSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(ExportServiceStubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(ExportServiceStubSettings.newBuilder()); + } + + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ExportServiceStubSettings.newHttpJsonBuilder()); + } + + public ExportServiceStubSettings.Builder getStubSettingsBuilder() { + return ((ExportServiceStubSettings.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 listProfiles. */ + public PagedCallSettings.Builder< + ListProfilesRequest, ListProfilesResponse, ListProfilesPagedResponse> + listProfilesSettings() { + return getStubSettingsBuilder().listProfilesSettings(); + } + + @Override + public ExportServiceSettings build() throws IOException { + return new ExportServiceSettings(this); + } + } +} diff --git a/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/gapic_metadata.json b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/gapic_metadata.json index e3c8bd8926a9..0a52edd8e697 100644 --- a/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/gapic_metadata.json +++ b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/gapic_metadata.json @@ -22,6 +22,18 @@ } } } + }, + "ExportService": { + "clients": { + "grpc": { + "libraryClient": "ExportServiceClient", + "rpcs": { + "ListProfiles": { + "methods": ["listProfiles", "listProfilesPagedCallable", "listProfilesCallable"] + } + } + } + } } } } \ No newline at end of file diff --git a/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/package-info.java b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/package-info.java index 38c5cfb551ff..157772341f36 100644 --- a/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/package-info.java +++ b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/package-info.java @@ -49,6 +49,32 @@ * Profile response = profilerServiceClient.createProfile(request); * } * } + * + *

======================= ExportServiceClient ======================= + * + *

Service Description: Service allows existing Cloud Profiler customers to export their profile + * data out of Google Cloud. + * + *

Sample for ExportServiceClient: + * + *

{@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 (ExportServiceClient exportServiceClient = ExportServiceClient.create()) {
+ *   ListProfilesRequest request =
+ *       ListProfilesRequest.newBuilder()
+ *           .setParent(ProjectName.of("[PROJECT]").toString())
+ *           .setPageSize(883849137)
+ *           .setPageToken("pageToken873572522")
+ *           .build();
+ *   for (Profile element : exportServiceClient.listProfiles(request).iterateAll()) {
+ *     // doThingsWith(element);
+ *   }
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package com.google.devtools.cloudprofiler.v2; diff --git a/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/ExportServiceStub.java b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/ExportServiceStub.java new file mode 100644 index 000000000000..e46d52074f78 --- /dev/null +++ b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/ExportServiceStub.java @@ -0,0 +1,46 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.stub; + +import static com.google.devtools.cloudprofiler.v2.ExportServiceClient.ListProfilesPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.devtools.cloudprofiler.v2.ListProfilesRequest; +import com.google.devtools.cloudprofiler.v2.ListProfilesResponse; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Base stub class for the ExportService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public abstract class ExportServiceStub implements BackgroundResource { + + public UnaryCallable listProfilesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listProfilesPagedCallable()"); + } + + public UnaryCallable listProfilesCallable() { + throw new UnsupportedOperationException("Not implemented: listProfilesCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/ExportServiceStubSettings.java b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/ExportServiceStubSettings.java new file mode 100644 index 000000000000..302a927b4f9a --- /dev/null +++ b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/ExportServiceStubSettings.java @@ -0,0 +1,399 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.stub; + +import static com.google.devtools.cloudprofiler.v2.ExportServiceClient.ListProfilesPagedResponse; + +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.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.devtools.cloudprofiler.v2.ListProfilesRequest; +import com.google.devtools.cloudprofiler.v2.ListProfilesResponse; +import com.google.devtools.cloudprofiler.v2.Profile; +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 ExportServiceStub}. + * + *

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

    + *
  • The default service address (cloudprofiler.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 listProfiles 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
+ * ExportServiceStubSettings.Builder exportServiceSettingsBuilder =
+ *     ExportServiceStubSettings.newBuilder();
+ * exportServiceSettingsBuilder
+ *     .listProfilesSettings()
+ *     .setRetrySettings(
+ *         exportServiceSettingsBuilder
+ *             .listProfilesSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * ExportServiceStubSettings exportServiceSettings = exportServiceSettingsBuilder.build();
+ * }
+ */ +@Generated("by gapic-generator-java") +public class ExportServiceStubSettings 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") + .add("https://www.googleapis.com/auth/monitoring") + .add("https://www.googleapis.com/auth/monitoring.write") + .build(); + + private final PagedCallSettings< + ListProfilesRequest, ListProfilesResponse, ListProfilesPagedResponse> + listProfilesSettings; + + private static final PagedListDescriptor + LIST_PROFILES_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListProfilesRequest injectToken(ListProfilesRequest payload, String token) { + return ListProfilesRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListProfilesRequest injectPageSize(ListProfilesRequest payload, int pageSize) { + return ListProfilesRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListProfilesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListProfilesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListProfilesResponse payload) { + return payload.getProfilesList() == null + ? ImmutableList.of() + : payload.getProfilesList(); + } + }; + + private static final PagedListResponseFactory< + ListProfilesRequest, ListProfilesResponse, ListProfilesPagedResponse> + LIST_PROFILES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListProfilesRequest, ListProfilesResponse, ListProfilesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListProfilesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_PROFILES_PAGE_STR_DESC, request, context); + return ListProfilesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Returns the object with the settings used for calls to listProfiles. */ + public PagedCallSettings + listProfilesSettings() { + return listProfilesSettings; + } + + public ExportServiceStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcExportServiceStub.create(this); + } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonExportServiceStub.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 "cloudprofiler.googleapis.com:443"; + } + + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "cloudprofiler.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(ExportServiceStubSettings.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(ExportServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ExportServiceStubSettings.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 ExportServiceStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + listProfilesSettings = settingsBuilder.listProfilesSettings().build(); + } + + /** Builder for ExportServiceStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final PagedCallSettings.Builder< + ListProfilesRequest, ListProfilesResponse, ListProfilesPagedResponse> + listProfilesSettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "retry_policy_1_codes", + ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.UNAVAILABLE))); + 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(10000L)) + .setInitialRpcTimeout(Duration.ofMillis(130000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(130000L)) + .setTotalTimeout(Duration.ofMillis(130000L)) + .build(); + definitions.put("retry_policy_1_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + listProfilesSettings = PagedCallSettings.newBuilder(LIST_PROFILES_PAGE_STR_FACT); + + unaryMethodSettingsBuilders = + ImmutableList.>of(listProfilesSettings); + initDefaults(this); + } + + protected Builder(ExportServiceStubSettings settings) { + super(settings); + + listProfilesSettings = settings.listProfilesSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of(listProfilesSettings); + } + + 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 + .listProfilesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_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 listProfiles. */ + public PagedCallSettings.Builder< + ListProfilesRequest, ListProfilesResponse, ListProfilesPagedResponse> + listProfilesSettings() { + return listProfilesSettings; + } + + @Override + public ExportServiceStubSettings build() throws IOException { + return new ExportServiceStubSettings(this); + } + } +} diff --git a/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/GrpcExportServiceCallableFactory.java b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/GrpcExportServiceCallableFactory.java new file mode 100644 index 000000000000..fc69b26e07c6 --- /dev/null +++ b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/GrpcExportServiceCallableFactory.java @@ -0,0 +1,113 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.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 ExportService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +public class GrpcExportServiceCallableFactory 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-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/GrpcExportServiceStub.java b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/GrpcExportServiceStub.java new file mode 100644 index 000000000000..5af2faff2dae --- /dev/null +++ b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/GrpcExportServiceStub.java @@ -0,0 +1,172 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.stub; + +import static com.google.devtools.cloudprofiler.v2.ExportServiceClient.ListProfilesPagedResponse; + +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.RequestParamsBuilder; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.devtools.cloudprofiler.v2.ListProfilesRequest; +import com.google.devtools.cloudprofiler.v2.ListProfilesResponse; +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 ExportService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class GrpcExportServiceStub extends ExportServiceStub { + private static final MethodDescriptor + listProfilesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.devtools.cloudprofiler.v2.ExportService/ListProfiles") + .setRequestMarshaller(ProtoUtils.marshaller(ListProfilesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListProfilesResponse.getDefaultInstance())) + .build(); + + private final UnaryCallable listProfilesCallable; + private final UnaryCallable + listProfilesPagedCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcExportServiceStub create(ExportServiceStubSettings settings) + throws IOException { + return new GrpcExportServiceStub(settings, ClientContext.create(settings)); + } + + public static final GrpcExportServiceStub create(ClientContext clientContext) throws IOException { + return new GrpcExportServiceStub(ExportServiceStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcExportServiceStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcExportServiceStub( + ExportServiceStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcExportServiceStub, 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 GrpcExportServiceStub(ExportServiceStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcExportServiceCallableFactory()); + } + + /** + * Constructs an instance of GrpcExportServiceStub, 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 GrpcExportServiceStub( + ExportServiceStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings listProfilesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listProfilesMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + + this.listProfilesCallable = + callableFactory.createUnaryCallable( + listProfilesTransportSettings, settings.listProfilesSettings(), clientContext); + this.listProfilesPagedCallable = + callableFactory.createPagedCallable( + listProfilesTransportSettings, settings.listProfilesSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + @Override + public UnaryCallable listProfilesCallable() { + return listProfilesCallable; + } + + @Override + public UnaryCallable listProfilesPagedCallable() { + return listProfilesPagedCallable; + } + + @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-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/HttpJsonExportServiceCallableFactory.java b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/HttpJsonExportServiceCallableFactory.java new file mode 100644 index 000000000000..10ca0a2c89cb --- /dev/null +++ b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/HttpJsonExportServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.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 ExportService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonExportServiceCallableFactory + 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-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/HttpJsonExportServiceStub.java b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/HttpJsonExportServiceStub.java new file mode 100644 index 000000000000..050523ea26bc --- /dev/null +++ b/java-profiler/google-cloud-profiler/src/main/java/com/google/devtools/cloudprofiler/v2/stub/HttpJsonExportServiceStub.java @@ -0,0 +1,213 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.stub; + +import static com.google.devtools.cloudprofiler.v2.ExportServiceClient.ListProfilesPagedResponse; + +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.RequestParamsBuilder; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.devtools.cloudprofiler.v2.ListProfilesRequest; +import com.google.devtools.cloudprofiler.v2.ListProfilesResponse; +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 ExportService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonExportServiceStub extends ExportServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listProfilesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.devtools.cloudprofiler.v2.ExportService/ListProfiles") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=projects/*}/profiles", + 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, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListProfilesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listProfilesCallable; + private final UnaryCallable + listProfilesPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonExportServiceStub create(ExportServiceStubSettings settings) + throws IOException { + return new HttpJsonExportServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonExportServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonExportServiceStub( + ExportServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonExportServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonExportServiceStub( + ExportServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonExportServiceStub, 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 HttpJsonExportServiceStub( + ExportServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonExportServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonExportServiceStub, 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 HttpJsonExportServiceStub( + ExportServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listProfilesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listProfilesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + + this.listProfilesCallable = + callableFactory.createUnaryCallable( + listProfilesTransportSettings, settings.listProfilesSettings(), clientContext); + this.listProfilesPagedCallable = + callableFactory.createPagedCallable( + listProfilesTransportSettings, settings.listProfilesSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listProfilesMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listProfilesCallable() { + return listProfilesCallable; + } + + @Override + public UnaryCallable listProfilesPagedCallable() { + return listProfilesPagedCallable; + } + + @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-profiler/google-cloud-profiler/src/main/resources/META-INF/native-image/com.google.devtools.cloudprofiler.v2/reflect-config.json b/java-profiler/google-cloud-profiler/src/main/resources/META-INF/native-image/com.google.devtools.cloudprofiler.v2/reflect-config.json index cb9cccbb0d39..150fde5a53f7 100644 --- a/java-profiler/google-cloud-profiler/src/main/resources/META-INF/native-image/com.google.devtools.cloudprofiler.v2/reflect-config.json +++ b/java-profiler/google-cloud-profiler/src/main/resources/META-INF/native-image/com.google.devtools.cloudprofiler.v2/reflect-config.json @@ -431,6 +431,42 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.devtools.cloudprofiler.v2.ListProfilesRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.devtools.cloudprofiler.v2.ListProfilesRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.devtools.cloudprofiler.v2.ListProfilesResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.devtools.cloudprofiler.v2.ListProfilesResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.devtools.cloudprofiler.v2.Profile", "queryAllDeclaredConstructors": true, diff --git a/java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/ExportServiceClientHttpJsonTest.java b/java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/ExportServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..703f738e511c --- /dev/null +++ b/java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/ExportServiceClientHttpJsonTest.java @@ -0,0 +1,137 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2; + +import static com.google.devtools.cloudprofiler.v2.ExportServiceClient.ListProfilesPagedResponse; + +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.common.collect.Lists; +import com.google.devtools.cloudprofiler.v2.stub.HttpJsonExportServiceStub; +import java.io.IOException; +import java.util.Arrays; +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 ExportServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ExportServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonExportServiceStub.getMethodDescriptors(), + ExportServiceSettings.getDefaultEndpoint()); + ExportServiceSettings settings = + ExportServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ExportServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ExportServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listProfilesTest() throws Exception { + Profile responsesElement = Profile.newBuilder().build(); + ListProfilesResponse expectedResponse = + ListProfilesResponse.newBuilder() + .setNextPageToken("") + .addAllProfiles(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListProfilesRequest request = + ListProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListProfilesPagedResponse pagedListResponse = client.listProfiles(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProfilesList().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 listProfilesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListProfilesRequest request = + ListProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listProfiles(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/ExportServiceClientTest.java b/java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/ExportServiceClientTest.java new file mode 100644 index 000000000000..c47efbe41ff2 --- /dev/null +++ b/java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/ExportServiceClientTest.java @@ -0,0 +1,136 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2; + +import static com.google.devtools.cloudprofiler.v2.ExportServiceClient.ListProfilesPagedResponse; + +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.common.collect.Lists; +import com.google.protobuf.AbstractMessage; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.Arrays; +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 ExportServiceClientTest { + private static MockExportService mockExportService; + private static MockServiceHelper mockServiceHelper; + private LocalChannelProvider channelProvider; + private ExportServiceClient client; + + @BeforeClass + public static void startStaticServer() { + mockExportService = new MockExportService(); + mockServiceHelper = + new MockServiceHelper( + UUID.randomUUID().toString(), Arrays.asList(mockExportService)); + mockServiceHelper.start(); + } + + @AfterClass + public static void stopServer() { + mockServiceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); + ExportServiceSettings settings = + ExportServiceSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ExportServiceClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + public void listProfilesTest() throws Exception { + Profile responsesElement = Profile.newBuilder().build(); + ListProfilesResponse expectedResponse = + ListProfilesResponse.newBuilder() + .setNextPageToken("") + .addAllProfiles(Arrays.asList(responsesElement)) + .build(); + mockExportService.addResponse(expectedResponse); + + ListProfilesRequest request = + ListProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListProfilesPagedResponse pagedListResponse = client.listProfiles(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getProfilesList().get(0), resources.get(0)); + + List actualRequests = mockExportService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListProfilesRequest actualRequest = ((ListProfilesRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getParent(), actualRequest.getParent()); + Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize()); + Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listProfilesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockExportService.addException(exception); + + try { + ListProfilesRequest request = + ListProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listProfiles(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/MockExportService.java b/java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/MockExportService.java new file mode 100644 index 000000000000..03db182122c7 --- /dev/null +++ b/java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/MockExportService.java @@ -0,0 +1,59 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2; + +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 MockExportService implements MockGrpcService { + private final MockExportServiceImpl serviceImpl; + + public MockExportService() { + serviceImpl = new MockExportServiceImpl(); + } + + @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-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/MockExportServiceImpl.java b/java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/MockExportServiceImpl.java new file mode 100644 index 000000000000..f184dfabfe1e --- /dev/null +++ b/java-profiler/google-cloud-profiler/src/test/java/com/google/devtools/cloudprofiler/v2/MockExportServiceImpl.java @@ -0,0 +1,81 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2; + +import com.google.api.core.BetaApi; +import com.google.devtools.cloudprofiler.v2.ExportServiceGrpc.ExportServiceImplBase; +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 MockExportServiceImpl extends ExportServiceImplBase { + private List requests; + private Queue responses; + + public MockExportServiceImpl() { + 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 listProfiles( + ListProfilesRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListProfilesResponse) { + requests.add(request); + responseObserver.onNext(((ListProfilesResponse) 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 ListProfiles, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListProfilesResponse.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/java-profiler/grpc-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ExportServiceGrpc.java b/java-profiler/grpc-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ExportServiceGrpc.java new file mode 100644 index 000000000000..04ca605fee2b --- /dev/null +++ b/java-profiler/grpc-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ExportServiceGrpc.java @@ -0,0 +1,390 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2; + +import static io.grpc.MethodDescriptor.generateFullMethodName; + +/** + * + * + *
+ * Service allows existing Cloud Profiler customers to export their profile data
+ * out of Google Cloud.
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler", + comments = "Source: google/devtools/cloudprofiler/v2/profiler.proto") +@io.grpc.stub.annotations.GrpcGenerated +public final class ExportServiceGrpc { + + private ExportServiceGrpc() {} + + public static final java.lang.String SERVICE_NAME = + "google.devtools.cloudprofiler.v2.ExportService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor< + com.google.devtools.cloudprofiler.v2.ListProfilesRequest, + com.google.devtools.cloudprofiler.v2.ListProfilesResponse> + getListProfilesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListProfiles", + requestType = com.google.devtools.cloudprofiler.v2.ListProfilesRequest.class, + responseType = com.google.devtools.cloudprofiler.v2.ListProfilesResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.devtools.cloudprofiler.v2.ListProfilesRequest, + com.google.devtools.cloudprofiler.v2.ListProfilesResponse> + getListProfilesMethod() { + io.grpc.MethodDescriptor< + com.google.devtools.cloudprofiler.v2.ListProfilesRequest, + com.google.devtools.cloudprofiler.v2.ListProfilesResponse> + getListProfilesMethod; + if ((getListProfilesMethod = ExportServiceGrpc.getListProfilesMethod) == null) { + synchronized (ExportServiceGrpc.class) { + if ((getListProfilesMethod = ExportServiceGrpc.getListProfilesMethod) == null) { + ExportServiceGrpc.getListProfilesMethod = + getListProfilesMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListProfiles")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.devtools.cloudprofiler.v2.ListProfilesRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.devtools.cloudprofiler.v2.ListProfilesResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new ExportServiceMethodDescriptorSupplier("ListProfiles")) + .build(); + } + } + } + return getListProfilesMethod; + } + + /** Creates a new async stub that supports all call types for the service */ + public static ExportServiceStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public ExportServiceStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ExportServiceStub(channel, callOptions); + } + }; + return ExportServiceStub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static ExportServiceBlockingStub newBlockingStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public ExportServiceBlockingStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ExportServiceBlockingStub(channel, callOptions); + } + }; + return ExportServiceBlockingStub.newStub(factory, channel); + } + + /** Creates a new ListenableFuture-style stub that supports unary calls on the service */ + public static ExportServiceFutureStub newFutureStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public ExportServiceFutureStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ExportServiceFutureStub(channel, callOptions); + } + }; + return ExportServiceFutureStub.newStub(factory, channel); + } + + /** + * + * + *
+   * Service allows existing Cloud Profiler customers to export their profile data
+   * out of Google Cloud.
+   * 
+ */ + public interface AsyncService { + + /** + * + * + *
+     * Lists profiles which have been collected so far and for which the caller
+     * has permission to view.
+     * 
+ */ + default void listProfiles( + com.google.devtools.cloudprofiler.v2.ListProfilesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListProfilesMethod(), responseObserver); + } + } + + /** + * Base class for the server implementation of the service ExportService. + * + *
+   * Service allows existing Cloud Profiler customers to export their profile data
+   * out of Google Cloud.
+   * 
+ */ + public abstract static class ExportServiceImplBase + implements io.grpc.BindableService, AsyncService { + + @java.lang.Override + public final io.grpc.ServerServiceDefinition bindService() { + return ExportServiceGrpc.bindService(this); + } + } + + /** + * A stub to allow clients to do asynchronous rpc calls to service ExportService. + * + *
+   * Service allows existing Cloud Profiler customers to export their profile data
+   * out of Google Cloud.
+   * 
+ */ + public static final class ExportServiceStub + extends io.grpc.stub.AbstractAsyncStub { + private ExportServiceStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ExportServiceStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ExportServiceStub(channel, callOptions); + } + + /** + * + * + *
+     * Lists profiles which have been collected so far and for which the caller
+     * has permission to view.
+     * 
+ */ + public void listProfiles( + com.google.devtools.cloudprofiler.v2.ListProfilesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListProfilesMethod(), getCallOptions()), + request, + responseObserver); + } + } + + /** + * A stub to allow clients to do synchronous rpc calls to service ExportService. + * + *
+   * Service allows existing Cloud Profiler customers to export their profile data
+   * out of Google Cloud.
+   * 
+ */ + public static final class ExportServiceBlockingStub + extends io.grpc.stub.AbstractBlockingStub { + private ExportServiceBlockingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ExportServiceBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ExportServiceBlockingStub(channel, callOptions); + } + + /** + * + * + *
+     * Lists profiles which have been collected so far and for which the caller
+     * has permission to view.
+     * 
+ */ + public com.google.devtools.cloudprofiler.v2.ListProfilesResponse listProfiles( + com.google.devtools.cloudprofiler.v2.ListProfilesRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListProfilesMethod(), getCallOptions(), request); + } + } + + /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service ExportService. + * + *
+   * Service allows existing Cloud Profiler customers to export their profile data
+   * out of Google Cloud.
+   * 
+ */ + public static final class ExportServiceFutureStub + extends io.grpc.stub.AbstractFutureStub { + private ExportServiceFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ExportServiceFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ExportServiceFutureStub(channel, callOptions); + } + + /** + * + * + *
+     * Lists profiles which have been collected so far and for which the caller
+     * has permission to view.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.devtools.cloudprofiler.v2.ListProfilesResponse> + listProfiles(com.google.devtools.cloudprofiler.v2.ListProfilesRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListProfilesMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_LIST_PROFILES = 0; + + 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_LIST_PROFILES: + serviceImpl.listProfiles( + (com.google.devtools.cloudprofiler.v2.ListProfilesRequest) request, + (io.grpc.stub.StreamObserver< + com.google.devtools.cloudprofiler.v2.ListProfilesResponse>) + 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( + getListProfilesMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.devtools.cloudprofiler.v2.ListProfilesRequest, + com.google.devtools.cloudprofiler.v2.ListProfilesResponse>( + service, METHODID_LIST_PROFILES))) + .build(); + } + + private abstract static class ExportServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, + io.grpc.protobuf.ProtoServiceDescriptorSupplier { + ExportServiceBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return com.google.devtools.cloudprofiler.v2.ProfilerProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("ExportService"); + } + } + + private static final class ExportServiceFileDescriptorSupplier + extends ExportServiceBaseDescriptorSupplier { + ExportServiceFileDescriptorSupplier() {} + } + + private static final class ExportServiceMethodDescriptorSupplier + extends ExportServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final java.lang.String methodName; + + ExportServiceMethodDescriptorSupplier(java.lang.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 (ExportServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = + result = + io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new ExportServiceFileDescriptorSupplier()) + .addMethod(getListProfilesMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesRequest.java b/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesRequest.java new file mode 100644 index 000000000000..a6b6cbf2144d --- /dev/null +++ b/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesRequest.java @@ -0,0 +1,945 @@ +/* + * 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 + * + * 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/devtools/cloudprofiler/v2/profiler.proto + +package com.google.devtools.cloudprofiler.v2; + +/** + * + * + *
+ * ListProfilesRequest contains request parameters for listing profiles for
+ * deployments in projects which the user has permissions to view.
+ * 
+ * + * Protobuf type {@code google.devtools.cloudprofiler.v2.ListProfilesRequest} + */ +public final class ListProfilesRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.devtools.cloudprofiler.v2.ListProfilesRequest) + ListProfilesRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListProfilesRequest.newBuilder() to construct. + private ListProfilesRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListProfilesRequest() { + parent_ = ""; + pageToken_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListProfilesRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.devtools.cloudprofiler.v2.ProfilerProto + .internal_static_google_devtools_cloudprofiler_v2_ListProfilesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.devtools.cloudprofiler.v2.ProfilerProto + .internal_static_google_devtools_cloudprofiler_v2_ListProfilesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.devtools.cloudprofiler.v2.ListProfilesRequest.class, + com.google.devtools.cloudprofiler.v2.ListProfilesRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + /** + * + * + *
+   * Required. The parent, which owns this collection of profiles.
+   * Format: projects/{user_project_id}
+   * 
+ * + * + * 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 parent, which owns this collection of profiles.
+   * Format: projects/{user_project_id}
+   * 
+ * + * + * 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 PAGE_SIZE_FIELD_NUMBER = 2; + private int pageSize_ = 0; + /** + * + * + *
+   * The maximum number of items to return.
+   * Default page_size is 1000.
+   * Max limit is 10000.
+   * 
+ * + * int32 page_size = 2; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object pageToken_ = ""; + /** + * + * + *
+   * The token to continue pagination and get profiles from a particular page.
+   * When paginating, all other parameters provided to `ListProfiles` must match
+   * the call that provided the page token.
+   * 
+ * + * string page_token = 3; + * + * @return The pageToken. + */ + @java.lang.Override + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + 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(); + pageToken_ = s; + return s; + } + } + /** + * + * + *
+   * The token to continue pagination and get profiles from a particular page.
+   * When paginating, all other parameters provided to `ListProfiles` must match
+   * the call that provided the page token.
+   * 
+ * + * string page_token = 3; + * + * @return The bytes for pageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = 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(parent_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + if (pageSize_ != 0) { + output.writeInt32(2, pageSize_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, pageToken_); + } + 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 (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, pageSize_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, pageToken_); + } + 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.devtools.cloudprofiler.v2.ListProfilesRequest)) { + return super.equals(obj); + } + com.google.devtools.cloudprofiler.v2.ListProfilesRequest other = + (com.google.devtools.cloudprofiler.v2.ListProfilesRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (getPageSize() != other.getPageSize()) return false; + if (!getPageToken().equals(other.getPageToken())) 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(); + hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER; + hash = (53 * hash) + getPageSize(); + hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getPageToken().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesRequest 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.devtools.cloudprofiler.v2.ListProfilesRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesRequest 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.devtools.cloudprofiler.v2.ListProfilesRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesRequest 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.devtools.cloudprofiler.v2.ListProfilesRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesRequest 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.devtools.cloudprofiler.v2.ListProfilesRequest 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; + } + /** + * + * + *
+   * ListProfilesRequest contains request parameters for listing profiles for
+   * deployments in projects which the user has permissions to view.
+   * 
+ * + * Protobuf type {@code google.devtools.cloudprofiler.v2.ListProfilesRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.devtools.cloudprofiler.v2.ListProfilesRequest) + com.google.devtools.cloudprofiler.v2.ListProfilesRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.devtools.cloudprofiler.v2.ProfilerProto + .internal_static_google_devtools_cloudprofiler_v2_ListProfilesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.devtools.cloudprofiler.v2.ProfilerProto + .internal_static_google_devtools_cloudprofiler_v2_ListProfilesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.devtools.cloudprofiler.v2.ListProfilesRequest.class, + com.google.devtools.cloudprofiler.v2.ListProfilesRequest.Builder.class); + } + + // Construct using com.google.devtools.cloudprofiler.v2.ListProfilesRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + pageSize_ = 0; + pageToken_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.devtools.cloudprofiler.v2.ProfilerProto + .internal_static_google_devtools_cloudprofiler_v2_ListProfilesRequest_descriptor; + } + + @java.lang.Override + public com.google.devtools.cloudprofiler.v2.ListProfilesRequest getDefaultInstanceForType() { + return com.google.devtools.cloudprofiler.v2.ListProfilesRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.devtools.cloudprofiler.v2.ListProfilesRequest build() { + com.google.devtools.cloudprofiler.v2.ListProfilesRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.devtools.cloudprofiler.v2.ListProfilesRequest buildPartial() { + com.google.devtools.cloudprofiler.v2.ListProfilesRequest result = + new com.google.devtools.cloudprofiler.v2.ListProfilesRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.devtools.cloudprofiler.v2.ListProfilesRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.pageSize_ = pageSize_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.pageToken_ = pageToken_; + } + } + + @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.devtools.cloudprofiler.v2.ListProfilesRequest) { + return mergeFrom((com.google.devtools.cloudprofiler.v2.ListProfilesRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.devtools.cloudprofiler.v2.ListProfilesRequest other) { + if (other == com.google.devtools.cloudprofiler.v2.ListProfilesRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + bitField0_ |= 0x00000004; + 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: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + pageSize_ = input.readInt32(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 26: + { + pageToken_ = input.readStringRequireUtf8(); + 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 parent_ = ""; + /** + * + * + *
+     * Required. The parent, which owns this collection of profiles.
+     * Format: projects/{user_project_id}
+     * 
+ * + * + * 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 parent, which owns this collection of profiles.
+     * Format: projects/{user_project_id}
+     * 
+ * + * + * 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 parent, which owns this collection of profiles.
+     * Format: projects/{user_project_id}
+     * 
+ * + * + * 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 parent, which owns this collection of profiles.
+     * Format: projects/{user_project_id}
+     * 
+ * + * + * 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 parent, which owns this collection of profiles.
+     * Format: projects/{user_project_id}
+     * 
+ * + * + * 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 int pageSize_; + /** + * + * + *
+     * The maximum number of items to return.
+     * Default page_size is 1000.
+     * Max limit is 10000.
+     * 
+ * + * int32 page_size = 2; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + /** + * + * + *
+     * The maximum number of items to return.
+     * Default page_size is 1000.
+     * Max limit is 10000.
+     * 
+ * + * int32 page_size = 2; + * + * @param value The pageSize to set. + * @return This builder for chaining. + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * The maximum number of items to return.
+     * Default page_size is 1000.
+     * Max limit is 10000.
+     * 
+ * + * int32 page_size = 2; + * + * @return This builder for chaining. + */ + public Builder clearPageSize() { + bitField0_ = (bitField0_ & ~0x00000002); + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + /** + * + * + *
+     * The token to continue pagination and get profiles from a particular page.
+     * When paginating, all other parameters provided to `ListProfiles` must match
+     * the call that provided the page token.
+     * 
+ * + * string page_token = 3; + * + * @return The pageToken. + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * The token to continue pagination and get profiles from a particular page.
+     * When paginating, all other parameters provided to `ListProfiles` must match
+     * the call that provided the page token.
+     * 
+ * + * string page_token = 3; + * + * @return The bytes for pageToken. + */ + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * The token to continue pagination and get profiles from a particular page.
+     * When paginating, all other parameters provided to `ListProfiles` must match
+     * the call that provided the page token.
+     * 
+ * + * string page_token = 3; + * + * @param value The pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + pageToken_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * The token to continue pagination and get profiles from a particular page.
+     * When paginating, all other parameters provided to `ListProfiles` must match
+     * the call that provided the page token.
+     * 
+ * + * string page_token = 3; + * + * @return This builder for chaining. + */ + public Builder clearPageToken() { + pageToken_ = getDefaultInstance().getPageToken(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + /** + * + * + *
+     * The token to continue pagination and get profiles from a particular page.
+     * When paginating, all other parameters provided to `ListProfiles` must match
+     * the call that provided the page token.
+     * 
+ * + * string page_token = 3; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + pageToken_ = value; + bitField0_ |= 0x00000004; + 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.devtools.cloudprofiler.v2.ListProfilesRequest) + } + + // @@protoc_insertion_point(class_scope:google.devtools.cloudprofiler.v2.ListProfilesRequest) + private static final com.google.devtools.cloudprofiler.v2.ListProfilesRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.devtools.cloudprofiler.v2.ListProfilesRequest(); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListProfilesRequest 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.devtools.cloudprofiler.v2.ListProfilesRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesRequestOrBuilder.java b/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesRequestOrBuilder.java new file mode 100644 index 000000000000..ee6c12bb410e --- /dev/null +++ b/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesRequestOrBuilder.java @@ -0,0 +1,100 @@ +/* + * 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 + * + * 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/devtools/cloudprofiler/v2/profiler.proto + +package com.google.devtools.cloudprofiler.v2; + +public interface ListProfilesRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.devtools.cloudprofiler.v2.ListProfilesRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The parent, which owns this collection of profiles.
+   * Format: projects/{user_project_id}
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. The parent, which owns this collection of profiles.
+   * Format: projects/{user_project_id}
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * The maximum number of items to return.
+   * Default page_size is 1000.
+   * Max limit is 10000.
+   * 
+ * + * int32 page_size = 2; + * + * @return The pageSize. + */ + int getPageSize(); + + /** + * + * + *
+   * The token to continue pagination and get profiles from a particular page.
+   * When paginating, all other parameters provided to `ListProfiles` must match
+   * the call that provided the page token.
+   * 
+ * + * string page_token = 3; + * + * @return The pageToken. + */ + java.lang.String getPageToken(); + /** + * + * + *
+   * The token to continue pagination and get profiles from a particular page.
+   * When paginating, all other parameters provided to `ListProfiles` must match
+   * the call that provided the page token.
+   * 
+ * + * string page_token = 3; + * + * @return The bytes for pageToken. + */ + com.google.protobuf.ByteString getPageTokenBytes(); +} diff --git a/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesResponse.java b/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesResponse.java new file mode 100644 index 000000000000..e03ce003ad14 --- /dev/null +++ b/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesResponse.java @@ -0,0 +1,1234 @@ +/* + * 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 + * + * 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/devtools/cloudprofiler/v2/profiler.proto + +package com.google.devtools.cloudprofiler.v2; + +/** + * + * + *
+ * ListProfileResponse contains the list of collected profiles for deployments
+ * in projects which the user has permissions to view.
+ * 
+ * + * Protobuf type {@code google.devtools.cloudprofiler.v2.ListProfilesResponse} + */ +public final class ListProfilesResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.devtools.cloudprofiler.v2.ListProfilesResponse) + ListProfilesResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListProfilesResponse.newBuilder() to construct. + private ListProfilesResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListProfilesResponse() { + profiles_ = java.util.Collections.emptyList(); + nextPageToken_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListProfilesResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.devtools.cloudprofiler.v2.ProfilerProto + .internal_static_google_devtools_cloudprofiler_v2_ListProfilesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.devtools.cloudprofiler.v2.ProfilerProto + .internal_static_google_devtools_cloudprofiler_v2_ListProfilesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.devtools.cloudprofiler.v2.ListProfilesResponse.class, + com.google.devtools.cloudprofiler.v2.ListProfilesResponse.Builder.class); + } + + public static final int PROFILES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List profiles_; + /** + * + * + *
+   * List of profiles fetched.
+   * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + @java.lang.Override + public java.util.List getProfilesList() { + return profiles_; + } + /** + * + * + *
+   * List of profiles fetched.
+   * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + @java.lang.Override + public java.util.List + getProfilesOrBuilderList() { + return profiles_; + } + /** + * + * + *
+   * List of profiles fetched.
+   * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + @java.lang.Override + public int getProfilesCount() { + return profiles_.size(); + } + /** + * + * + *
+   * List of profiles fetched.
+   * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + @java.lang.Override + public com.google.devtools.cloudprofiler.v2.Profile getProfiles(int index) { + return profiles_.get(index); + } + /** + * + * + *
+   * List of profiles fetched.
+   * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + @java.lang.Override + public com.google.devtools.cloudprofiler.v2.ProfileOrBuilder getProfilesOrBuilder(int index) { + return profiles_.get(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object nextPageToken_ = ""; + /** + * + * + *
+   * Token to receive the next page of results.
+   * This field maybe empty if there are no more profiles to fetch.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + @java.lang.Override + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + 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(); + nextPageToken_ = s; + return s; + } + } + /** + * + * + *
+   * Token to receive the next page of results.
+   * This field maybe empty if there are no more profiles to fetch.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SKIPPED_PROFILES_FIELD_NUMBER = 3; + private int skippedProfiles_ = 0; + /** + * + * + *
+   * Number of profiles that were skipped in the current page since they were
+   * not able to be fetched successfully. This should typically be zero. A
+   * non-zero value may indicate a transient failure, in which case if the
+   * number is too high for your use case, the call may be retried.
+   * 
+ * + * int32 skipped_profiles = 3; + * + * @return The skippedProfiles. + */ + @java.lang.Override + public int getSkippedProfiles() { + return skippedProfiles_; + } + + 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 < profiles_.size(); i++) { + output.writeMessage(1, profiles_.get(i)); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nextPageToken_); + } + if (skippedProfiles_ != 0) { + output.writeInt32(3, skippedProfiles_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < profiles_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, profiles_.get(i)); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(nextPageToken_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nextPageToken_); + } + if (skippedProfiles_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(3, skippedProfiles_); + } + 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.devtools.cloudprofiler.v2.ListProfilesResponse)) { + return super.equals(obj); + } + com.google.devtools.cloudprofiler.v2.ListProfilesResponse other = + (com.google.devtools.cloudprofiler.v2.ListProfilesResponse) obj; + + if (!getProfilesList().equals(other.getProfilesList())) return false; + if (!getNextPageToken().equals(other.getNextPageToken())) return false; + if (getSkippedProfiles() != other.getSkippedProfiles()) 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 (getProfilesCount() > 0) { + hash = (37 * hash) + PROFILES_FIELD_NUMBER; + hash = (53 * hash) + getProfilesList().hashCode(); + } + hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getNextPageToken().hashCode(); + hash = (37 * hash) + SKIPPED_PROFILES_FIELD_NUMBER; + hash = (53 * hash) + getSkippedProfiles(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesResponse 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.devtools.cloudprofiler.v2.ListProfilesResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesResponse 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.devtools.cloudprofiler.v2.ListProfilesResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesResponse 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.devtools.cloudprofiler.v2.ListProfilesResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesResponse 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.devtools.cloudprofiler.v2.ListProfilesResponse 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; + } + /** + * + * + *
+   * ListProfileResponse contains the list of collected profiles for deployments
+   * in projects which the user has permissions to view.
+   * 
+ * + * Protobuf type {@code google.devtools.cloudprofiler.v2.ListProfilesResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.devtools.cloudprofiler.v2.ListProfilesResponse) + com.google.devtools.cloudprofiler.v2.ListProfilesResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.devtools.cloudprofiler.v2.ProfilerProto + .internal_static_google_devtools_cloudprofiler_v2_ListProfilesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.devtools.cloudprofiler.v2.ProfilerProto + .internal_static_google_devtools_cloudprofiler_v2_ListProfilesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.devtools.cloudprofiler.v2.ListProfilesResponse.class, + com.google.devtools.cloudprofiler.v2.ListProfilesResponse.Builder.class); + } + + // Construct using com.google.devtools.cloudprofiler.v2.ListProfilesResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (profilesBuilder_ == null) { + profiles_ = java.util.Collections.emptyList(); + } else { + profiles_ = null; + profilesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + nextPageToken_ = ""; + skippedProfiles_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.devtools.cloudprofiler.v2.ProfilerProto + .internal_static_google_devtools_cloudprofiler_v2_ListProfilesResponse_descriptor; + } + + @java.lang.Override + public com.google.devtools.cloudprofiler.v2.ListProfilesResponse getDefaultInstanceForType() { + return com.google.devtools.cloudprofiler.v2.ListProfilesResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.devtools.cloudprofiler.v2.ListProfilesResponse build() { + com.google.devtools.cloudprofiler.v2.ListProfilesResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.devtools.cloudprofiler.v2.ListProfilesResponse buildPartial() { + com.google.devtools.cloudprofiler.v2.ListProfilesResponse result = + new com.google.devtools.cloudprofiler.v2.ListProfilesResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.devtools.cloudprofiler.v2.ListProfilesResponse result) { + if (profilesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + profiles_ = java.util.Collections.unmodifiableList(profiles_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.profiles_ = profiles_; + } else { + result.profiles_ = profilesBuilder_.build(); + } + } + + private void buildPartial0(com.google.devtools.cloudprofiler.v2.ListProfilesResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.nextPageToken_ = nextPageToken_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.skippedProfiles_ = skippedProfiles_; + } + } + + @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.devtools.cloudprofiler.v2.ListProfilesResponse) { + return mergeFrom((com.google.devtools.cloudprofiler.v2.ListProfilesResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.devtools.cloudprofiler.v2.ListProfilesResponse other) { + if (other == com.google.devtools.cloudprofiler.v2.ListProfilesResponse.getDefaultInstance()) + return this; + if (profilesBuilder_ == null) { + if (!other.profiles_.isEmpty()) { + if (profiles_.isEmpty()) { + profiles_ = other.profiles_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureProfilesIsMutable(); + profiles_.addAll(other.profiles_); + } + onChanged(); + } + } else { + if (!other.profiles_.isEmpty()) { + if (profilesBuilder_.isEmpty()) { + profilesBuilder_.dispose(); + profilesBuilder_ = null; + profiles_ = other.profiles_; + bitField0_ = (bitField0_ & ~0x00000001); + profilesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getProfilesFieldBuilder() + : null; + } else { + profilesBuilder_.addAllMessages(other.profiles_); + } + } + } + if (!other.getNextPageToken().isEmpty()) { + nextPageToken_ = other.nextPageToken_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.getSkippedProfiles() != 0) { + setSkippedProfiles(other.getSkippedProfiles()); + } + 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.devtools.cloudprofiler.v2.Profile m = + input.readMessage( + com.google.devtools.cloudprofiler.v2.Profile.parser(), extensionRegistry); + if (profilesBuilder_ == null) { + ensureProfilesIsMutable(); + profiles_.add(m); + } else { + profilesBuilder_.addMessage(m); + } + break; + } // case 10 + case 18: + { + nextPageToken_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + skippedProfiles_ = input.readInt32(); + bitField0_ |= 0x00000004; + break; + } // case 24 + 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 profiles_ = + java.util.Collections.emptyList(); + + private void ensureProfilesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + profiles_ = + new java.util.ArrayList(profiles_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.devtools.cloudprofiler.v2.Profile, + com.google.devtools.cloudprofiler.v2.Profile.Builder, + com.google.devtools.cloudprofiler.v2.ProfileOrBuilder> + profilesBuilder_; + + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public java.util.List getProfilesList() { + if (profilesBuilder_ == null) { + return java.util.Collections.unmodifiableList(profiles_); + } else { + return profilesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public int getProfilesCount() { + if (profilesBuilder_ == null) { + return profiles_.size(); + } else { + return profilesBuilder_.getCount(); + } + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public com.google.devtools.cloudprofiler.v2.Profile getProfiles(int index) { + if (profilesBuilder_ == null) { + return profiles_.get(index); + } else { + return profilesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public Builder setProfiles(int index, com.google.devtools.cloudprofiler.v2.Profile value) { + if (profilesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProfilesIsMutable(); + profiles_.set(index, value); + onChanged(); + } else { + profilesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public Builder setProfiles( + int index, com.google.devtools.cloudprofiler.v2.Profile.Builder builderForValue) { + if (profilesBuilder_ == null) { + ensureProfilesIsMutable(); + profiles_.set(index, builderForValue.build()); + onChanged(); + } else { + profilesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public Builder addProfiles(com.google.devtools.cloudprofiler.v2.Profile value) { + if (profilesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProfilesIsMutable(); + profiles_.add(value); + onChanged(); + } else { + profilesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public Builder addProfiles(int index, com.google.devtools.cloudprofiler.v2.Profile value) { + if (profilesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProfilesIsMutable(); + profiles_.add(index, value); + onChanged(); + } else { + profilesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public Builder addProfiles( + com.google.devtools.cloudprofiler.v2.Profile.Builder builderForValue) { + if (profilesBuilder_ == null) { + ensureProfilesIsMutable(); + profiles_.add(builderForValue.build()); + onChanged(); + } else { + profilesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public Builder addProfiles( + int index, com.google.devtools.cloudprofiler.v2.Profile.Builder builderForValue) { + if (profilesBuilder_ == null) { + ensureProfilesIsMutable(); + profiles_.add(index, builderForValue.build()); + onChanged(); + } else { + profilesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public Builder addAllProfiles( + java.lang.Iterable values) { + if (profilesBuilder_ == null) { + ensureProfilesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, profiles_); + onChanged(); + } else { + profilesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public Builder clearProfiles() { + if (profilesBuilder_ == null) { + profiles_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + profilesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public Builder removeProfiles(int index) { + if (profilesBuilder_ == null) { + ensureProfilesIsMutable(); + profiles_.remove(index); + onChanged(); + } else { + profilesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public com.google.devtools.cloudprofiler.v2.Profile.Builder getProfilesBuilder(int index) { + return getProfilesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public com.google.devtools.cloudprofiler.v2.ProfileOrBuilder getProfilesOrBuilder(int index) { + if (profilesBuilder_ == null) { + return profiles_.get(index); + } else { + return profilesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public java.util.List + getProfilesOrBuilderList() { + if (profilesBuilder_ != null) { + return profilesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(profiles_); + } + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public com.google.devtools.cloudprofiler.v2.Profile.Builder addProfilesBuilder() { + return getProfilesFieldBuilder() + .addBuilder(com.google.devtools.cloudprofiler.v2.Profile.getDefaultInstance()); + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public com.google.devtools.cloudprofiler.v2.Profile.Builder addProfilesBuilder(int index) { + return getProfilesFieldBuilder() + .addBuilder(index, com.google.devtools.cloudprofiler.v2.Profile.getDefaultInstance()); + } + /** + * + * + *
+     * List of profiles fetched.
+     * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + public java.util.List + getProfilesBuilderList() { + return getProfilesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.devtools.cloudprofiler.v2.Profile, + com.google.devtools.cloudprofiler.v2.Profile.Builder, + com.google.devtools.cloudprofiler.v2.ProfileOrBuilder> + getProfilesFieldBuilder() { + if (profilesBuilder_ == null) { + profilesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.devtools.cloudprofiler.v2.Profile, + com.google.devtools.cloudprofiler.v2.Profile.Builder, + com.google.devtools.cloudprofiler.v2.ProfileOrBuilder>( + profiles_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + profiles_ = null; + } + return profilesBuilder_; + } + + private java.lang.Object nextPageToken_ = ""; + /** + * + * + *
+     * Token to receive the next page of results.
+     * This field maybe empty if there are no more profiles to fetch.
+     * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Token to receive the next page of results.
+     * This field maybe empty if there are no more profiles to fetch.
+     * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Token to receive the next page of results.
+     * This field maybe empty if there are no more profiles to fetch.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + nextPageToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Token to receive the next page of results.
+     * This field maybe empty if there are no more profiles to fetch.
+     * 
+ * + * string next_page_token = 2; + * + * @return This builder for chaining. + */ + public Builder clearNextPageToken() { + nextPageToken_ = getDefaultInstance().getNextPageToken(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * + * + *
+     * Token to receive the next page of results.
+     * This field maybe empty if there are no more profiles to fetch.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The bytes for nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + nextPageToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private int skippedProfiles_; + /** + * + * + *
+     * Number of profiles that were skipped in the current page since they were
+     * not able to be fetched successfully. This should typically be zero. A
+     * non-zero value may indicate a transient failure, in which case if the
+     * number is too high for your use case, the call may be retried.
+     * 
+ * + * int32 skipped_profiles = 3; + * + * @return The skippedProfiles. + */ + @java.lang.Override + public int getSkippedProfiles() { + return skippedProfiles_; + } + /** + * + * + *
+     * Number of profiles that were skipped in the current page since they were
+     * not able to be fetched successfully. This should typically be zero. A
+     * non-zero value may indicate a transient failure, in which case if the
+     * number is too high for your use case, the call may be retried.
+     * 
+ * + * int32 skipped_profiles = 3; + * + * @param value The skippedProfiles to set. + * @return This builder for chaining. + */ + public Builder setSkippedProfiles(int value) { + + skippedProfiles_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Number of profiles that were skipped in the current page since they were
+     * not able to be fetched successfully. This should typically be zero. A
+     * non-zero value may indicate a transient failure, in which case if the
+     * number is too high for your use case, the call may be retried.
+     * 
+ * + * int32 skipped_profiles = 3; + * + * @return This builder for chaining. + */ + public Builder clearSkippedProfiles() { + bitField0_ = (bitField0_ & ~0x00000004); + skippedProfiles_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.devtools.cloudprofiler.v2.ListProfilesResponse) + } + + // @@protoc_insertion_point(class_scope:google.devtools.cloudprofiler.v2.ListProfilesResponse) + private static final com.google.devtools.cloudprofiler.v2.ListProfilesResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.devtools.cloudprofiler.v2.ListProfilesResponse(); + } + + public static com.google.devtools.cloudprofiler.v2.ListProfilesResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListProfilesResponse 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.devtools.cloudprofiler.v2.ListProfilesResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesResponseOrBuilder.java b/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesResponseOrBuilder.java new file mode 100644 index 000000000000..a7f913e4efb6 --- /dev/null +++ b/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ListProfilesResponseOrBuilder.java @@ -0,0 +1,120 @@ +/* + * 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 + * + * 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/devtools/cloudprofiler/v2/profiler.proto + +package com.google.devtools.cloudprofiler.v2; + +public interface ListProfilesResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.devtools.cloudprofiler.v2.ListProfilesResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * List of profiles fetched.
+   * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + java.util.List getProfilesList(); + /** + * + * + *
+   * List of profiles fetched.
+   * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + com.google.devtools.cloudprofiler.v2.Profile getProfiles(int index); + /** + * + * + *
+   * List of profiles fetched.
+   * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + int getProfilesCount(); + /** + * + * + *
+   * List of profiles fetched.
+   * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + java.util.List + getProfilesOrBuilderList(); + /** + * + * + *
+   * List of profiles fetched.
+   * 
+ * + * repeated .google.devtools.cloudprofiler.v2.Profile profiles = 1; + */ + com.google.devtools.cloudprofiler.v2.ProfileOrBuilder getProfilesOrBuilder(int index); + + /** + * + * + *
+   * Token to receive the next page of results.
+   * This field maybe empty if there are no more profiles to fetch.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + java.lang.String getNextPageToken(); + /** + * + * + *
+   * Token to receive the next page of results.
+   * This field maybe empty if there are no more profiles to fetch.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + com.google.protobuf.ByteString getNextPageTokenBytes(); + + /** + * + * + *
+   * Number of profiles that were skipped in the current page since they were
+   * not able to be fetched successfully. This should typically be zero. A
+   * non-zero value may indicate a transient failure, in which case if the
+   * number is too high for your use case, the call may be retried.
+   * 
+ * + * int32 skipped_profiles = 3; + * + * @return The skippedProfiles. + */ + int getSkippedProfiles(); +} diff --git a/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ProfilerProto.java b/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ProfilerProto.java index d0fe4724cb45..02d23a348fb3 100644 --- a/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ProfilerProto.java +++ b/java-profiler/proto-google-cloud-profiler-v2/src/main/java/com/google/devtools/cloudprofiler/v2/ProfilerProto.java @@ -55,6 +55,14 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_devtools_cloudprofiler_v2_Deployment_LabelsEntry_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_devtools_cloudprofiler_v2_Deployment_LabelsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_devtools_cloudprofiler_v2_ListProfilesRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_devtools_cloudprofiler_v2_ListProfilesRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_devtools_cloudprofiler_v2_ListProfilesResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_devtools_cloudprofiler_v2_ListProfilesResponse_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { return descriptor; @@ -99,35 +107,51 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "\022H\n\006labels\030\003 \003(\01328.google.devtools.cloud" + "profiler.v2.Deployment.LabelsEntry\032-\n\013La" + "belsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028" - + "\001*\204\001\n\013ProfileType\022\034\n\030PROFILE_TYPE_UNSPEC" - + "IFIED\020\000\022\007\n\003CPU\020\001\022\010\n\004WALL\020\002\022\010\n\004HEAP\020\003\022\013\n\007" - + "THREADS\020\004\022\016\n\nCONTENTION\020\005\022\r\n\tPEAK_HEAP\020\006" - + "\022\016\n\nHEAP_ALLOC\020\0072\376\005\n\017ProfilerService\022\237\001\n" - + "\rCreateProfile\0226.google.devtools.cloudpr" - + "ofiler.v2.CreateProfileRequest\032).google." - + "devtools.cloudprofiler.v2.Profile\"+\202\323\344\223\002" - + "%\" /v2/{parent=projects/*}/profiles:\001*\022\322" - + "\001\n\024CreateOfflineProfile\022=.google.devtool" - + "s.cloudprofiler.v2.CreateOfflineProfileR" - + "equest\032).google.devtools.cloudprofiler.v" - + "2.Profile\"P\332A\016parent,profile\202\323\344\223\0029\"./v2/" - + "{parent=projects/*}/profiles:createOffli" - + "ne:\007profile\022\303\001\n\rUpdateProfile\0226.google.d" - + "evtools.cloudprofiler.v2.UpdateProfileRe" - + "quest\032).google.devtools.cloudprofiler.v2" - + ".Profile\"O\332A\023profile,update_mask\202\323\344\223\00232(" - + "/v2/{profile.name=projects/*/profiles/*}" - + ":\007profile\032\255\001\312A\034cloudprofiler.googleapis." - + "com\322A\212\001https://www.googleapis.com/auth/c" - + "loud-platform,https://www.googleapis.com" - + "/auth/monitoring,https://www.googleapis." - + "com/auth/monitoring.writeB\324\001\n$com.google" - + ".devtools.cloudprofiler.v2B\rProfilerProt" - + "oP\001ZGcloud.google.com/go/cloudprofiler/a" - + "piv2/cloudprofilerpb;cloudprofilerpb\252\002\030G" - + "oogle.Cloud.Profiler.V2\312\002\030Google\\Cloud\\P" - + "rofiler\\V2\352\002\033Google::Cloud::Profiler::V2" - + "b\006proto3" + + "\001\"\202\001\n\023ListProfilesRequest\022D\n\006parent\030\001 \001(" + + "\tB4\342A\001\002\372A-\n+cloudresourcemanager.googlea" + + "pis.com/Project\022\021\n\tpage_size\030\002 \001(\005\022\022\n\npa" + + "ge_token\030\003 \001(\t\"\206\001\n\024ListProfilesResponse\022" + + ";\n\010profiles\030\001 \003(\0132).google.devtools.clou" + + "dprofiler.v2.Profile\022\027\n\017next_page_token\030" + + "\002 \001(\t\022\030\n\020skipped_profiles\030\003 \001(\005*\204\001\n\013Prof" + + "ileType\022\034\n\030PROFILE_TYPE_UNSPECIFIED\020\000\022\007\n" + + "\003CPU\020\001\022\010\n\004WALL\020\002\022\010\n\004HEAP\020\003\022\013\n\007THREADS\020\004\022" + + "\016\n\nCONTENTION\020\005\022\r\n\tPEAK_HEAP\020\006\022\016\n\nHEAP_A" + + "LLOC\020\0072\376\005\n\017ProfilerService\022\237\001\n\rCreatePro" + + "file\0226.google.devtools.cloudprofiler.v2." + + "CreateProfileRequest\032).google.devtools.c" + + "loudprofiler.v2.Profile\"+\202\323\344\223\002%\" /v2/{pa" + + "rent=projects/*}/profiles:\001*\022\322\001\n\024CreateO" + + "fflineProfile\022=.google.devtools.cloudpro" + + "filer.v2.CreateOfflineProfileRequest\032).g" + + "oogle.devtools.cloudprofiler.v2.Profile\"" + + "P\332A\016parent,profile\202\323\344\223\0029\"./v2/{parent=pr" + + "ojects/*}/profiles:createOffline:\007profil" + + "e\022\303\001\n\rUpdateProfile\0226.google.devtools.cl" + + "oudprofiler.v2.UpdateProfileRequest\032).go" + + "ogle.devtools.cloudprofiler.v2.Profile\"O" + + "\332A\023profile,update_mask\202\323\344\223\00232(/v2/{profi" + + "le.name=projects/*/profiles/*}:\007profile\032" + + "\255\001\312A\034cloudprofiler.googleapis.com\322A\212\001htt" + + "ps://www.googleapis.com/auth/cloud-platf" + + "orm,https://www.googleapis.com/auth/moni" + + "toring,https://www.googleapis.com/auth/m" + + "onitoring.write2\351\002\n\rExportService\022\247\001\n\014Li" + + "stProfiles\0225.google.devtools.cloudprofil" + + "er.v2.ListProfilesRequest\0326.google.devto" + + "ols.cloudprofiler.v2.ListProfilesRespons" + + "e\"(\202\323\344\223\002\"\022 /v2/{parent=projects/*}/profi" + + "les\032\255\001\312A\034cloudprofiler.googleapis.com\322A\212" + + "\001https://www.googleapis.com/auth/cloud-p" + + "latform,https://www.googleapis.com/auth/" + + "monitoring,https://www.googleapis.com/au" + + "th/monitoring.writeB\324\001\n$com.google.devto" + + "ols.cloudprofiler.v2B\rProfilerProtoP\001ZGc" + + "loud.google.com/go/cloudprofiler/apiv2/c" + + "loudprofilerpb;cloudprofilerpb\252\002\030Google." + + "Cloud.Profiler.V2\312\002\030Google\\Cloud\\Profile" + + "r\\V2\352\002\033Google::Cloud::Profiler::V2b\006prot" + + "o3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -198,6 +222,22 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new java.lang.String[] { "Key", "Value", }); + internal_static_google_devtools_cloudprofiler_v2_ListProfilesRequest_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_google_devtools_cloudprofiler_v2_ListProfilesRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_devtools_cloudprofiler_v2_ListProfilesRequest_descriptor, + new java.lang.String[] { + "Parent", "PageSize", "PageToken", + }); + internal_static_google_devtools_cloudprofiler_v2_ListProfilesResponse_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_google_devtools_cloudprofiler_v2_ListProfilesResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_devtools_cloudprofiler_v2_ListProfilesResponse_descriptor, + new java.lang.String[] { + "Profiles", "NextPageToken", "SkippedProfiles", + }); com.google.protobuf.ExtensionRegistry registry = com.google.protobuf.ExtensionRegistry.newInstance(); registry.add(com.google.api.ClientProto.defaultHost); diff --git a/java-profiler/proto-google-cloud-profiler-v2/src/main/proto/google/devtools/cloudprofiler/v2/profiler.proto b/java-profiler/proto-google-cloud-profiler-v2/src/main/proto/google/devtools/cloudprofiler/v2/profiler.proto index b86164cb2ace..0962c2ae7027 100644 --- a/java-profiler/proto-google-cloud-profiler-v2/src/main/proto/google/devtools/cloudprofiler/v2/profiler.proto +++ b/java-profiler/proto-google-cloud-profiler-v2/src/main/proto/google/devtools/cloudprofiler/v2/profiler.proto @@ -89,6 +89,24 @@ service ProfilerService { } } +// Service allows existing Cloud Profiler customers to export their profile data +// out of Google Cloud. +service ExportService { + option (google.api.default_host) = "cloudprofiler.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/monitoring," + "https://www.googleapis.com/auth/monitoring.write"; + + // Lists profiles which have been collected so far and for which the caller + // has permission to view. + rpc ListProfiles(ListProfilesRequest) returns (ListProfilesResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*}/profiles" + }; + } +} + // CreateProfileRequest describes a profile resource online creation request. // The deployment field must be populated. The profile_type specifies the list // of profile types supported by the agent. The creation call will hang until a @@ -231,3 +249,43 @@ enum ProfileType { // collection pressure to see if those can be optimized. HEAP_ALLOC = 7; } + +// ListProfilesRequest contains request parameters for listing profiles for +// deployments in projects which the user has permissions to view. +message ListProfilesRequest { + // Required. The parent, which owns this collection of profiles. + // Format: projects/{user_project_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // The maximum number of items to return. + // Default page_size is 1000. + // Max limit is 10000. + int32 page_size = 2; + + // The token to continue pagination and get profiles from a particular page. + // When paginating, all other parameters provided to `ListProfiles` must match + // the call that provided the page token. + string page_token = 3; +} + +// ListProfileResponse contains the list of collected profiles for deployments +// in projects which the user has permissions to view. +message ListProfilesResponse { + // List of profiles fetched. + repeated Profile profiles = 1; + + // Token to receive the next page of results. + // This field maybe empty if there are no more profiles to fetch. + string next_page_token = 2; + + // Number of profiles that were skipped in the current page since they were + // not able to be fetched successfully. This should typically be zero. A + // non-zero value may indicate a transient failure, in which case if the + // number is too high for your use case, the call may be retried. + int32 skipped_profiles = 3; +} diff --git a/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/create/SyncCreateSetCredentialsProvider.java b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..7f035fae57e0 --- /dev/null +++ b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,44 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.samples; + +// [START cloudprofiler_v2_generated_ExportService_Create_SetCredentialsProvider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.devtools.cloudprofiler.v2.ExportServiceClient; +import com.google.devtools.cloudprofiler.v2.ExportServiceSettings; +import com.google.devtools.cloudprofiler.v2.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 + ExportServiceSettings exportServiceSettings = + ExportServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ExportServiceClient exportServiceClient = ExportServiceClient.create(exportServiceSettings); + } +} +// [END cloudprofiler_v2_generated_ExportService_Create_SetCredentialsProvider_sync] diff --git a/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/create/SyncCreateSetCredentialsProvider1.java b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..2e10eb4157a8 --- /dev/null +++ b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.samples; + +// [START cloudprofiler_v2_generated_ExportService_Create_SetCredentialsProvider1_sync] +import com.google.devtools.cloudprofiler.v2.ExportServiceClient; +import com.google.devtools.cloudprofiler.v2.ExportServiceSettings; + +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 + ExportServiceSettings exportServiceSettings = + ExportServiceSettings.newHttpJsonBuilder().build(); + ExportServiceClient exportServiceClient = ExportServiceClient.create(exportServiceSettings); + } +} +// [END cloudprofiler_v2_generated_ExportService_Create_SetCredentialsProvider1_sync] diff --git a/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/create/SyncCreateSetEndpoint.java b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..3dde01d3e0b1 --- /dev/null +++ b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/create/SyncCreateSetEndpoint.java @@ -0,0 +1,41 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.samples; + +// [START cloudprofiler_v2_generated_ExportService_Create_SetEndpoint_sync] +import com.google.devtools.cloudprofiler.v2.ExportServiceClient; +import com.google.devtools.cloudprofiler.v2.ExportServiceSettings; +import com.google.devtools.cloudprofiler.v2.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 + ExportServiceSettings exportServiceSettings = + ExportServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ExportServiceClient exportServiceClient = ExportServiceClient.create(exportServiceSettings); + } +} +// [END cloudprofiler_v2_generated_ExportService_Create_SetEndpoint_sync] diff --git a/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/listprofiles/AsyncListProfiles.java b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/listprofiles/AsyncListProfiles.java new file mode 100644 index 000000000000..7d4e2b49b30e --- /dev/null +++ b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/listprofiles/AsyncListProfiles.java @@ -0,0 +1,54 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.samples; + +// [START cloudprofiler_v2_generated_ExportService_ListProfiles_async] +import com.google.api.core.ApiFuture; +import com.google.devtools.cloudprofiler.v2.ExportServiceClient; +import com.google.devtools.cloudprofiler.v2.ListProfilesRequest; +import com.google.devtools.cloudprofiler.v2.Profile; +import com.google.devtools.cloudprofiler.v2.ProjectName; + +public class AsyncListProfiles { + + public static void main(String[] args) throws Exception { + asyncListProfiles(); + } + + public static void asyncListProfiles() 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 (ExportServiceClient exportServiceClient = ExportServiceClient.create()) { + ListProfilesRequest request = + ListProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + exportServiceClient.listProfilesPagedCallable().futureCall(request); + // Do something. + for (Profile element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END cloudprofiler_v2_generated_ExportService_ListProfiles_async] diff --git a/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/listprofiles/AsyncListProfilesPaged.java b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/listprofiles/AsyncListProfilesPaged.java new file mode 100644 index 000000000000..a4cf06691afc --- /dev/null +++ b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/listprofiles/AsyncListProfilesPaged.java @@ -0,0 +1,61 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.samples; + +// [START cloudprofiler_v2_generated_ExportService_ListProfiles_Paged_async] +import com.google.common.base.Strings; +import com.google.devtools.cloudprofiler.v2.ExportServiceClient; +import com.google.devtools.cloudprofiler.v2.ListProfilesRequest; +import com.google.devtools.cloudprofiler.v2.ListProfilesResponse; +import com.google.devtools.cloudprofiler.v2.Profile; +import com.google.devtools.cloudprofiler.v2.ProjectName; + +public class AsyncListProfilesPaged { + + public static void main(String[] args) throws Exception { + asyncListProfilesPaged(); + } + + public static void asyncListProfilesPaged() 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 (ExportServiceClient exportServiceClient = ExportServiceClient.create()) { + ListProfilesRequest request = + ListProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListProfilesResponse response = exportServiceClient.listProfilesCallable().call(request); + for (Profile element : response.getProfilesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END cloudprofiler_v2_generated_ExportService_ListProfiles_Paged_async] diff --git a/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/listprofiles/SyncListProfiles.java b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/listprofiles/SyncListProfiles.java new file mode 100644 index 000000000000..58b20b8e8c1c --- /dev/null +++ b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservice/listprofiles/SyncListProfiles.java @@ -0,0 +1,50 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.samples; + +// [START cloudprofiler_v2_generated_ExportService_ListProfiles_sync] +import com.google.devtools.cloudprofiler.v2.ExportServiceClient; +import com.google.devtools.cloudprofiler.v2.ListProfilesRequest; +import com.google.devtools.cloudprofiler.v2.Profile; +import com.google.devtools.cloudprofiler.v2.ProjectName; + +public class SyncListProfiles { + + public static void main(String[] args) throws Exception { + syncListProfiles(); + } + + public static void syncListProfiles() 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 (ExportServiceClient exportServiceClient = ExportServiceClient.create()) { + ListProfilesRequest request = + ListProfilesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Profile element : exportServiceClient.listProfiles(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END cloudprofiler_v2_generated_ExportService_ListProfiles_sync] diff --git a/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservicesettings/listprofiles/SyncListProfiles.java b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservicesettings/listprofiles/SyncListProfiles.java new file mode 100644 index 000000000000..bf3bbc1d244d --- /dev/null +++ b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/exportservicesettings/listprofiles/SyncListProfiles.java @@ -0,0 +1,48 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.samples; + +// [START cloudprofiler_v2_generated_ExportServiceSettings_ListProfiles_sync] +import com.google.devtools.cloudprofiler.v2.ExportServiceSettings; +import java.time.Duration; + +public class SyncListProfiles { + + public static void main(String[] args) throws Exception { + syncListProfiles(); + } + + public static void syncListProfiles() 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 + ExportServiceSettings.Builder exportServiceSettingsBuilder = ExportServiceSettings.newBuilder(); + exportServiceSettingsBuilder + .listProfilesSettings() + .setRetrySettings( + exportServiceSettingsBuilder + .listProfilesSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ExportServiceSettings exportServiceSettings = exportServiceSettingsBuilder.build(); + } +} +// [END cloudprofiler_v2_generated_ExportServiceSettings_ListProfiles_sync] diff --git a/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/stub/exportservicestubsettings/listprofiles/SyncListProfiles.java b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/stub/exportservicestubsettings/listprofiles/SyncListProfiles.java new file mode 100644 index 000000000000..aa76eb027282 --- /dev/null +++ b/java-profiler/samples/snippets/generated/com/google/devtools/cloudprofiler/v2/stub/exportservicestubsettings/listprofiles/SyncListProfiles.java @@ -0,0 +1,49 @@ +/* + * 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 + * + * 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.devtools.cloudprofiler.v2.stub.samples; + +// [START cloudprofiler_v2_generated_ExportServiceStubSettings_ListProfiles_sync] +import com.google.devtools.cloudprofiler.v2.stub.ExportServiceStubSettings; +import java.time.Duration; + +public class SyncListProfiles { + + public static void main(String[] args) throws Exception { + syncListProfiles(); + } + + public static void syncListProfiles() 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 + ExportServiceStubSettings.Builder exportServiceSettingsBuilder = + ExportServiceStubSettings.newBuilder(); + exportServiceSettingsBuilder + .listProfilesSettings() + .setRetrySettings( + exportServiceSettingsBuilder + .listProfilesSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ExportServiceStubSettings exportServiceSettings = exportServiceSettingsBuilder.build(); + } +} +// [END cloudprofiler_v2_generated_ExportServiceStubSettings_ListProfiles_sync]