diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/ConnectionServiceClient.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/ConnectionServiceClient.java deleted file mode 100644 index 2979c91f..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/ConnectionServiceClient.java +++ /dev/null @@ -1,1143 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigquery.connection.v1beta1; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.api.resourcenames.ResourceName; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.Connection; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ConnectionCredential; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionCredentialRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.stub.ConnectionServiceStub; -import com.google.cloud.bigquery.connection.v1beta1.stub.ConnectionServiceStubSettings; -import com.google.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.Empty; -import com.google.protobuf.FieldMask; -import com.google.protobuf.UInt32Value; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND SERVICE -/** - * Service Description: Manages external data source connections and credentials. - * - *

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: - * - *

- * 
- * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
- *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
- *   connectionServiceClient.deleteConnection(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the connectionServiceClient 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 ConnectionServiceSettings to - * create(). For example: - * - *

To customize credentials: - * - *

- * 
- * ConnectionServiceSettings connectionServiceSettings =
- *     ConnectionServiceSettings.newBuilder()
- *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
- *         .build();
- * ConnectionServiceClient connectionServiceClient =
- *     ConnectionServiceClient.create(connectionServiceSettings);
- * 
- * 
- * - * To customize the endpoint: - * - *
- * 
- * ConnectionServiceSettings connectionServiceSettings =
- *     ConnectionServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
- * ConnectionServiceClient connectionServiceClient =
- *     ConnectionServiceClient.create(connectionServiceSettings);
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi -public class ConnectionServiceClient implements BackgroundResource { - private final ConnectionServiceSettings settings; - private final ConnectionServiceStub stub; - - /** Constructs an instance of ConnectionServiceClient with default settings. */ - public static final ConnectionServiceClient create() throws IOException { - return create(ConnectionServiceSettings.newBuilder().build()); - } - - /** - * Constructs an instance of ConnectionServiceClient, 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 ConnectionServiceClient create(ConnectionServiceSettings settings) - throws IOException { - return new ConnectionServiceClient(settings); - } - - /** - * Constructs an instance of ConnectionServiceClient, using the given stub for making calls. This - * is for advanced usage - prefer to use ConnectionServiceSettings}. - */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public static final ConnectionServiceClient create(ConnectionServiceStub stub) { - return new ConnectionServiceClient(stub); - } - - /** - * Constructs an instance of ConnectionServiceClient, 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 ConnectionServiceClient(ConnectionServiceSettings settings) throws IOException { - this.settings = settings; - this.stub = ((ConnectionServiceStubSettings) settings.getStubSettings()).createStub(); - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - protected ConnectionServiceClient(ConnectionServiceStub stub) { - this.settings = null; - this.stub = stub; - } - - public final ConnectionServiceSettings getSettings() { - return settings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public ConnectionServiceStub getStub() { - return stub; - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes connection and associated credential. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   connectionServiceClient.deleteConnection(name);
-   * }
-   * 
- * - * @param name Required. Name of the deleted connection, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}` - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteConnection(ConnectionName name) { - DeleteConnectionRequest request = - DeleteConnectionRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - deleteConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes connection and associated credential. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   connectionServiceClient.deleteConnection(name.toString());
-   * }
-   * 
- * - * @param name Required. Name of the deleted connection, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}` - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteConnection(String name) { - DeleteConnectionRequest request = DeleteConnectionRequest.newBuilder().setName(name).build(); - deleteConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes connection and associated credential. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   DeleteConnectionRequest request = DeleteConnectionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   connectionServiceClient.deleteConnection(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteConnection(DeleteConnectionRequest request) { - deleteConnectionCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes connection and associated credential. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   DeleteConnectionRequest request = DeleteConnectionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = connectionServiceClient.deleteConnectionCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable deleteConnectionCallable() { - return stub.deleteConnectionCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   String connectionId = "";
-   *   Connection response = connectionServiceClient.createConnection(parent, connection, connectionId);
-   * }
-   * 
- * - * @param parent Required. Parent resource name. Must be in the format - * `projects/{project_id}/locations/{location_id}` - * @param connection Required. Connection to create. - * @param connectionId Optional. Connection id that should be assigned to the created connection. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection createConnection( - LocationName parent, Connection connection, String connectionId) { - CreateConnectionRequest request = - CreateConnectionRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .setConnection(connection) - .setConnectionId(connectionId) - .build(); - return createConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   String connectionId = "";
-   *   Connection response = connectionServiceClient.createConnection(parent.toString(), connection, connectionId);
-   * }
-   * 
- * - * @param parent Required. Parent resource name. Must be in the format - * `projects/{project_id}/locations/{location_id}` - * @param connection Required. Connection to create. - * @param connectionId Optional. Connection id that should be assigned to the created connection. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection createConnection( - String parent, Connection connection, String connectionId) { - CreateConnectionRequest request = - CreateConnectionRequest.newBuilder() - .setParent(parent) - .setConnection(connection) - .setConnectionId(connectionId) - .build(); - return createConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   CreateConnectionRequest request = CreateConnectionRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setConnection(connection)
-   *     .build();
-   *   Connection response = connectionServiceClient.createConnection(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection createConnection(CreateConnectionRequest request) { - return createConnectionCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   CreateConnectionRequest request = CreateConnectionRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setConnection(connection)
-   *     .build();
-   *   ApiFuture<Connection> future = connectionServiceClient.createConnectionCallable().futureCall(request);
-   *   // Do something
-   *   Connection response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable createConnectionCallable() { - return stub.createConnectionCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns specified connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Connection response = connectionServiceClient.getConnection(name);
-   * }
-   * 
- * - * @param name Required. Name of the requested connection, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}` - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection getConnection(ConnectionName name) { - GetConnectionRequest request = - GetConnectionRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return getConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns specified connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Connection response = connectionServiceClient.getConnection(name.toString());
-   * }
-   * 
- * - * @param name Required. Name of the requested connection, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}` - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection getConnection(String name) { - GetConnectionRequest request = GetConnectionRequest.newBuilder().setName(name).build(); - return getConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns specified connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   GetConnectionRequest request = GetConnectionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   Connection response = connectionServiceClient.getConnection(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection getConnection(GetConnectionRequest request) { - return getConnectionCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns specified connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   GetConnectionRequest request = GetConnectionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Connection> future = connectionServiceClient.getConnectionCallable().futureCall(request);
-   *   // Do something
-   *   Connection response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable getConnectionCallable() { - return stub.getConnectionCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns a list of connections in the given project. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   UInt32Value maxResults = UInt32Value.newBuilder().build();
-   *   ListConnectionsResponse response = connectionServiceClient.listConnections(parent, maxResults);
-   * }
-   * 
- * - * @param parent Required. Parent resource name. Must be in the form: - * `projects/{project_id}/locations/{location_id}` - * @param maxResults Required. Maximum number of results per page. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListConnectionsResponse listConnections( - LocationName parent, UInt32Value maxResults) { - ListConnectionsRequest request = - ListConnectionsRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .setMaxResults(maxResults) - .build(); - return listConnections(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns a list of connections in the given project. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   UInt32Value maxResults = UInt32Value.newBuilder().build();
-   *   ListConnectionsResponse response = connectionServiceClient.listConnections(parent.toString(), maxResults);
-   * }
-   * 
- * - * @param parent Required. Parent resource name. Must be in the form: - * `projects/{project_id}/locations/{location_id}` - * @param maxResults Required. Maximum number of results per page. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListConnectionsResponse listConnections(String parent, UInt32Value maxResults) { - ListConnectionsRequest request = - ListConnectionsRequest.newBuilder().setParent(parent).setMaxResults(maxResults).build(); - return listConnections(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns a list of connections in the given project. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   UInt32Value maxResults = UInt32Value.newBuilder().build();
-   *   ListConnectionsRequest request = ListConnectionsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setMaxResults(maxResults)
-   *     .build();
-   *   ListConnectionsResponse response = connectionServiceClient.listConnections(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListConnectionsResponse listConnections(ListConnectionsRequest request) { - return listConnectionsCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns a list of connections in the given project. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   UInt32Value maxResults = UInt32Value.newBuilder().build();
-   *   ListConnectionsRequest request = ListConnectionsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setMaxResults(maxResults)
-   *     .build();
-   *   ApiFuture<ListConnectionsResponse> future = connectionServiceClient.listConnectionsCallable().futureCall(request);
-   *   // Do something
-   *   ListConnectionsResponse response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - listConnectionsCallable() { - return stub.listConnectionsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates the specified connection. For security reasons, also resets credential if connection - * properties are in the update field mask. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   Connection response = connectionServiceClient.updateConnection(name, connection, updateMask);
-   * }
-   * 
- * - * @param name Required. Name of the connection to update, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}` - * @param connection Required. Connection containing the updated fields. - * @param updateMask Required. Update mask for the connection fields to be updated. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection updateConnection( - ConnectionName name, Connection connection, FieldMask updateMask) { - UpdateConnectionRequest request = - UpdateConnectionRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setConnection(connection) - .setUpdateMask(updateMask) - .build(); - return updateConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates the specified connection. For security reasons, also resets credential if connection - * properties are in the update field mask. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   Connection response = connectionServiceClient.updateConnection(name.toString(), connection, updateMask);
-   * }
-   * 
- * - * @param name Required. Name of the connection to update, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}` - * @param connection Required. Connection containing the updated fields. - * @param updateMask Required. Update mask for the connection fields to be updated. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection updateConnection( - String name, Connection connection, FieldMask updateMask) { - UpdateConnectionRequest request = - UpdateConnectionRequest.newBuilder() - .setName(name) - .setConnection(connection) - .setUpdateMask(updateMask) - .build(); - return updateConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates the specified connection. For security reasons, also resets credential if connection - * properties are in the update field mask. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   UpdateConnectionRequest request = UpdateConnectionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setConnection(connection)
-   *     .setUpdateMask(updateMask)
-   *     .build();
-   *   Connection response = connectionServiceClient.updateConnection(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection updateConnection(UpdateConnectionRequest request) { - return updateConnectionCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates the specified connection. For security reasons, also resets credential if connection - * properties are in the update field mask. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   UpdateConnectionRequest request = UpdateConnectionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setConnection(connection)
-   *     .setUpdateMask(updateMask)
-   *     .build();
-   *   ApiFuture<Connection> future = connectionServiceClient.updateConnectionCallable().futureCall(request);
-   *   // Do something
-   *   Connection response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable updateConnectionCallable() { - return stub.updateConnectionCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Sets the credential for the specified connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   String name = "";
-   *   ConnectionCredential credential = ConnectionCredential.newBuilder().build();
-   *   connectionServiceClient.updateConnectionCredential(name, credential);
-   * }
-   * 
- * - * @param name Required. Name of the connection, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}/credential` - * @param credential Required. Credential to use with the connection. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void updateConnectionCredential(String name, ConnectionCredential credential) { - UpdateConnectionCredentialRequest request = - UpdateConnectionCredentialRequest.newBuilder() - .setName(name) - .setCredential(credential) - .build(); - updateConnectionCredential(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Sets the credential for the specified connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   String name = "";
-   *   ConnectionCredential credential = ConnectionCredential.newBuilder().build();
-   *   UpdateConnectionCredentialRequest request = UpdateConnectionCredentialRequest.newBuilder()
-   *     .setName(name)
-   *     .setCredential(credential)
-   *     .build();
-   *   connectionServiceClient.updateConnectionCredential(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void updateConnectionCredential(UpdateConnectionCredentialRequest request) { - updateConnectionCredentialCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Sets the credential for the specified connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   String name = "";
-   *   ConnectionCredential credential = ConnectionCredential.newBuilder().build();
-   *   UpdateConnectionCredentialRequest request = UpdateConnectionCredentialRequest.newBuilder()
-   *     .setName(name)
-   *     .setCredential(credential)
-   *     .build();
-   *   ApiFuture<Void> future = connectionServiceClient.updateConnectionCredentialCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable - updateConnectionCredentialCallable() { - return stub.updateConnectionCredentialCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets the access control policy for a resource. Returns an empty policy if the resource exists - * and does not have a policy set. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   GetPolicyOptions options = GetPolicyOptions.newBuilder().build();
-   *   Policy response = connectionServiceClient.getIamPolicy(resource, options);
-   * }
-   * 
- * - * @param resource REQUIRED: The resource for which the policy is being requested. See the - * operation documentation for the appropriate value for this field. - * @param options OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`. - * This field is only used by Cloud IAM. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy getIamPolicy(ResourceName resource, GetPolicyOptions options) { - GetIamPolicyRequest request = - GetIamPolicyRequest.newBuilder() - .setResource(resource == null ? null : resource.toString()) - .setOptions(options) - .build(); - return getIamPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets the access control policy for a resource. Returns an empty policy if the resource exists - * and does not have a policy set. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   GetPolicyOptions options = GetPolicyOptions.newBuilder().build();
-   *   Policy response = connectionServiceClient.getIamPolicy(resource.toString(), options);
-   * }
-   * 
- * - * @param resource REQUIRED: The resource for which the policy is being requested. See the - * operation documentation for the appropriate value for this field. - * @param options OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`. - * This field is only used by Cloud IAM. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy getIamPolicy(String resource, GetPolicyOptions options) { - GetIamPolicyRequest request = - GetIamPolicyRequest.newBuilder().setResource(resource).setOptions(options).build(); - return getIamPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets the access control policy for a resource. Returns an empty policy if the resource exists - * and does not have a policy set. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .build();
-   *   Policy response = connectionServiceClient.getIamPolicy(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy getIamPolicy(GetIamPolicyRequest request) { - return getIamPolicyCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets the access control policy for a resource. Returns an empty policy if the resource exists - * and does not have a policy set. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .build();
-   *   ApiFuture<Policy> future = connectionServiceClient.getIamPolicyCallable().futureCall(request);
-   *   // Do something
-   *   Policy response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable getIamPolicyCallable() { - return stub.getIamPolicyCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - *

Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   Policy response = connectionServiceClient.setIamPolicy(resource, policy);
-   * }
-   * 
- * - * @param resource REQUIRED: The resource for which the policy is being specified. See the - * operation documentation for the appropriate value for this field. - * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the - * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud - * Platform services (such as Projects) might reject them. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy setIamPolicy(ResourceName resource, Policy policy) { - SetIamPolicyRequest request = - SetIamPolicyRequest.newBuilder() - .setResource(resource == null ? null : resource.toString()) - .setPolicy(policy) - .build(); - return setIamPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - *

Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   Policy response = connectionServiceClient.setIamPolicy(resource.toString(), policy);
-   * }
-   * 
- * - * @param resource REQUIRED: The resource for which the policy is being specified. See the - * operation documentation for the appropriate value for this field. - * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the - * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud - * Platform services (such as Projects) might reject them. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy setIamPolicy(String resource, Policy policy) { - SetIamPolicyRequest request = - SetIamPolicyRequest.newBuilder().setResource(resource).setPolicy(policy).build(); - return setIamPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - *

Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .setPolicy(policy)
-   *     .build();
-   *   Policy response = connectionServiceClient.setIamPolicy(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy setIamPolicy(SetIamPolicyRequest request) { - return setIamPolicyCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - *

Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .setPolicy(policy)
-   *     .build();
-   *   ApiFuture<Policy> future = connectionServiceClient.setIamPolicyCallable().futureCall(request);
-   *   // Do something
-   *   Policy response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable setIamPolicyCallable() { - return stub.setIamPolicyCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns permissions that a caller has on the specified resource. If the resource does not - * exist, this will return an empty set of permissions, not a NOT_FOUND error. - * - *

Note: This operation is designed to be used for building permission-aware UIs and - * command-line tools, not for authorization checking. This operation may "fail open" without - * warning. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsResponse response = connectionServiceClient.testIamPermissions(resource, permissions);
-   * }
-   * 
- * - * @param resource REQUIRED: The resource for which the policy detail is being requested. See the - * operation documentation for the appropriate value for this field. - * @param permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final TestIamPermissionsResponse testIamPermissions( - ResourceName resource, List permissions) { - TestIamPermissionsRequest request = - TestIamPermissionsRequest.newBuilder() - .setResource(resource == null ? null : resource.toString()) - .addAllPermissions(permissions) - .build(); - return testIamPermissions(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns permissions that a caller has on the specified resource. If the resource does not - * exist, this will return an empty set of permissions, not a NOT_FOUND error. - * - *

Note: This operation is designed to be used for building permission-aware UIs and - * command-line tools, not for authorization checking. This operation may "fail open" without - * warning. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsResponse response = connectionServiceClient.testIamPermissions(resource.toString(), permissions);
-   * }
-   * 
- * - * @param resource REQUIRED: The resource for which the policy detail is being requested. See the - * operation documentation for the appropriate value for this field. - * @param permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final TestIamPermissionsResponse testIamPermissions( - String resource, List permissions) { - TestIamPermissionsRequest request = - TestIamPermissionsRequest.newBuilder() - .setResource(resource) - .addAllPermissions(permissions) - .build(); - return testIamPermissions(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns permissions that a caller has on the specified resource. If the resource does not - * exist, this will return an empty set of permissions, not a NOT_FOUND error. - * - *

Note: This operation is designed to be used for building permission-aware UIs and - * command-line tools, not for authorization checking. This operation may "fail open" without - * warning. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .addAllPermissions(permissions)
-   *     .build();
-   *   TestIamPermissionsResponse response = connectionServiceClient.testIamPermissions(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) { - return testIamPermissionsCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns permissions that a caller has on the specified resource. If the resource does not - * exist, this will return an empty set of permissions, not a NOT_FOUND error. - * - *

Note: This operation is designed to be used for building permission-aware UIs and - * command-line tools, not for authorization checking. This operation may "fail open" without - * warning. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .addAllPermissions(permissions)
-   *     .build();
-   *   ApiFuture<TestIamPermissionsResponse> future = connectionServiceClient.testIamPermissionsCallable().futureCall(request);
-   *   // Do something
-   *   TestIamPermissionsResponse response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - testIamPermissionsCallable() { - return stub.testIamPermissionsCallable(); - } - - @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); - } -} diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/ConnectionServiceSettings.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/ConnectionServiceSettings.java deleted file mode 100644 index 8b1f3731..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/ConnectionServiceSettings.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigquery.connection.v1beta1; - -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.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.Connection; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionCredentialRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.stub.ConnectionServiceStubSettings; -import com.google.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.Empty; -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 ConnectionServiceClient}. - * - *

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

    - *
  • The default service address (bigqueryconnection.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 deleteConnection to 30 seconds: - * - *

- * 
- * ConnectionServiceSettings.Builder connectionServiceSettingsBuilder =
- *     ConnectionServiceSettings.newBuilder();
- * connectionServiceSettingsBuilder
- *     .deleteConnectionSettings()
- *     .setRetrySettings(
- *         connectionServiceSettingsBuilder.deleteConnectionSettings().getRetrySettings().toBuilder()
- *             .setTotalTimeout(Duration.ofSeconds(30))
- *             .build());
- * ConnectionServiceSettings connectionServiceSettings = connectionServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi -public class ConnectionServiceSettings extends ClientSettings { - /** Returns the object with the settings used for calls to deleteConnection. */ - public UnaryCallSettings deleteConnectionSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).deleteConnectionSettings(); - } - - /** Returns the object with the settings used for calls to createConnection. */ - public UnaryCallSettings createConnectionSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).createConnectionSettings(); - } - - /** Returns the object with the settings used for calls to getConnection. */ - public UnaryCallSettings getConnectionSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).getConnectionSettings(); - } - - /** Returns the object with the settings used for calls to listConnections. */ - public UnaryCallSettings - listConnectionsSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).listConnectionsSettings(); - } - - /** Returns the object with the settings used for calls to updateConnection. */ - public UnaryCallSettings updateConnectionSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).updateConnectionSettings(); - } - - /** Returns the object with the settings used for calls to updateConnectionCredential. */ - public UnaryCallSettings - updateConnectionCredentialSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).updateConnectionCredentialSettings(); - } - - /** Returns the object with the settings used for calls to getIamPolicy. */ - public UnaryCallSettings getIamPolicySettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).getIamPolicySettings(); - } - - /** Returns the object with the settings used for calls to setIamPolicy. */ - public UnaryCallSettings setIamPolicySettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).setIamPolicySettings(); - } - - /** Returns the object with the settings used for calls to testIamPermissions. */ - public UnaryCallSettings - testIamPermissionsSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).testIamPermissionsSettings(); - } - - public static final ConnectionServiceSettings create(ConnectionServiceStubSettings stub) - throws IOException { - return new ConnectionServiceSettings.Builder(stub.toBuilder()).build(); - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return ConnectionServiceStubSettings.defaultExecutorProviderBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return ConnectionServiceStubSettings.getDefaultEndpoint(); - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return ConnectionServiceStubSettings.getDefaultServiceScopes(); - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return ConnectionServiceStubSettings.defaultCredentialsProviderBuilder(); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return ConnectionServiceStubSettings.defaultGrpcTransportProviderBuilder(); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return ConnectionServiceStubSettings.defaultTransportChannelProvider(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return ConnectionServiceStubSettings.defaultApiClientHeaderProviderBuilder(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** 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 ConnectionServiceSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - } - - /** Builder for ConnectionServiceSettings. */ - public static class Builder extends ClientSettings.Builder { - protected Builder() throws IOException { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(ConnectionServiceStubSettings.newBuilder(clientContext)); - } - - private static Builder createDefault() { - return new Builder(ConnectionServiceStubSettings.newBuilder()); - } - - protected Builder(ConnectionServiceSettings settings) { - super(settings.getStubSettings().toBuilder()); - } - - protected Builder(ConnectionServiceStubSettings.Builder stubSettings) { - super(stubSettings); - } - - public ConnectionServiceStubSettings.Builder getStubSettingsBuilder() { - return ((ConnectionServiceStubSettings.Builder) getStubSettings()); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * 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) throws Exception { - super.applyToAllUnaryMethods( - getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); - return this; - } - - /** Returns the builder for the settings used for calls to deleteConnection. */ - public UnaryCallSettings.Builder deleteConnectionSettings() { - return getStubSettingsBuilder().deleteConnectionSettings(); - } - - /** Returns the builder for the settings used for calls to createConnection. */ - public UnaryCallSettings.Builder - createConnectionSettings() { - return getStubSettingsBuilder().createConnectionSettings(); - } - - /** Returns the builder for the settings used for calls to getConnection. */ - public UnaryCallSettings.Builder getConnectionSettings() { - return getStubSettingsBuilder().getConnectionSettings(); - } - - /** Returns the builder for the settings used for calls to listConnections. */ - public UnaryCallSettings.Builder - listConnectionsSettings() { - return getStubSettingsBuilder().listConnectionsSettings(); - } - - /** Returns the builder for the settings used for calls to updateConnection. */ - public UnaryCallSettings.Builder - updateConnectionSettings() { - return getStubSettingsBuilder().updateConnectionSettings(); - } - - /** Returns the builder for the settings used for calls to updateConnectionCredential. */ - public UnaryCallSettings.Builder - updateConnectionCredentialSettings() { - return getStubSettingsBuilder().updateConnectionCredentialSettings(); - } - - /** Returns the builder for the settings used for calls to getIamPolicy. */ - public UnaryCallSettings.Builder getIamPolicySettings() { - return getStubSettingsBuilder().getIamPolicySettings(); - } - - /** Returns the builder for the settings used for calls to setIamPolicy. */ - public UnaryCallSettings.Builder setIamPolicySettings() { - return getStubSettingsBuilder().setIamPolicySettings(); - } - - /** Returns the builder for the settings used for calls to testIamPermissions. */ - public UnaryCallSettings.Builder - testIamPermissionsSettings() { - return getStubSettingsBuilder().testIamPermissionsSettings(); - } - - @Override - public ConnectionServiceSettings build() throws IOException { - return new ConnectionServiceSettings(this); - } - } -} diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/package-info.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/package-info.java deleted file mode 100644 index 45bbab0a..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/package-info.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * A client to BigQuery Connection API. - * - *

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

======================= ConnectionServiceClient ======================= - * - *

Service Description: Manages external data source connections and credentials. - * - *

Sample for ConnectionServiceClient: - * - *

- * 
- * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
- *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
- *   connectionServiceClient.deleteConnection(name);
- * }
- * 
- * 
- */ -@Generated("by gapic-generator") -package com.google.cloud.bigquery.connection.v1beta1; - -import javax.annotation.Generated; diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/stub/ConnectionServiceStub.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/stub/ConnectionServiceStub.java deleted file mode 100644 index 2e5f4a0f..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/stub/ConnectionServiceStub.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigquery.connection.v1beta1.stub; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.Connection; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionCredentialRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionRequest; -import com.google.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.Empty; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Base stub class for BigQuery Connection API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public abstract class ConnectionServiceStub implements BackgroundResource { - - public UnaryCallable deleteConnectionCallable() { - throw new UnsupportedOperationException("Not implemented: deleteConnectionCallable()"); - } - - public UnaryCallable createConnectionCallable() { - throw new UnsupportedOperationException("Not implemented: createConnectionCallable()"); - } - - public UnaryCallable getConnectionCallable() { - throw new UnsupportedOperationException("Not implemented: getConnectionCallable()"); - } - - public UnaryCallable listConnectionsCallable() { - throw new UnsupportedOperationException("Not implemented: listConnectionsCallable()"); - } - - public UnaryCallable updateConnectionCallable() { - throw new UnsupportedOperationException("Not implemented: updateConnectionCallable()"); - } - - public UnaryCallable - updateConnectionCredentialCallable() { - throw new UnsupportedOperationException( - "Not implemented: updateConnectionCredentialCallable()"); - } - - public UnaryCallable getIamPolicyCallable() { - throw new UnsupportedOperationException("Not implemented: getIamPolicyCallable()"); - } - - public UnaryCallable setIamPolicyCallable() { - throw new UnsupportedOperationException("Not implemented: setIamPolicyCallable()"); - } - - public UnaryCallable - testIamPermissionsCallable() { - throw new UnsupportedOperationException("Not implemented: testIamPermissionsCallable()"); - } - - @Override - public abstract void close(); -} diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/stub/ConnectionServiceStubSettings.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/stub/ConnectionServiceStubSettings.java deleted file mode 100644 index 778ff4cd..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/stub/ConnectionServiceStubSettings.java +++ /dev/null @@ -1,490 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigquery.connection.v1beta1.stub; - -import com.google.api.core.ApiFunction; -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.retrying.RetrySettings; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -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.cloud.bigquery.connection.v1beta1.ConnectionProto.Connection; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionCredentialRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionRequest; -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.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.Empty; -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 ConnectionServiceStub}. - * - *

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

    - *
  • The default service address (bigqueryconnection.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 deleteConnection to 30 seconds: - * - *

- * 
- * ConnectionServiceStubSettings.Builder connectionServiceSettingsBuilder =
- *     ConnectionServiceStubSettings.newBuilder();
- * connectionServiceSettingsBuilder
- *     .deleteConnectionSettings()
- *     .setRetrySettings(
- *         connectionServiceSettingsBuilder.deleteConnectionSettings().getRetrySettings().toBuilder()
- *             .setTotalTimeout(Duration.ofSeconds(30))
- *             .build());
- * ConnectionServiceStubSettings connectionServiceSettings = connectionServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi -public class ConnectionServiceStubSettings extends StubSettings { - /** The default scopes of the service. */ - private static final ImmutableList DEFAULT_SERVICE_SCOPES = - ImmutableList.builder() - .add("https://www.googleapis.com/auth/bigquery") - .add("https://www.googleapis.com/auth/cloud-platform") - .build(); - - private final UnaryCallSettings deleteConnectionSettings; - private final UnaryCallSettings createConnectionSettings; - private final UnaryCallSettings getConnectionSettings; - private final UnaryCallSettings - listConnectionsSettings; - private final UnaryCallSettings updateConnectionSettings; - private final UnaryCallSettings - updateConnectionCredentialSettings; - private final UnaryCallSettings getIamPolicySettings; - private final UnaryCallSettings setIamPolicySettings; - private final UnaryCallSettings - testIamPermissionsSettings; - - /** Returns the object with the settings used for calls to deleteConnection. */ - public UnaryCallSettings deleteConnectionSettings() { - return deleteConnectionSettings; - } - - /** Returns the object with the settings used for calls to createConnection. */ - public UnaryCallSettings createConnectionSettings() { - return createConnectionSettings; - } - - /** Returns the object with the settings used for calls to getConnection. */ - public UnaryCallSettings getConnectionSettings() { - return getConnectionSettings; - } - - /** Returns the object with the settings used for calls to listConnections. */ - public UnaryCallSettings - listConnectionsSettings() { - return listConnectionsSettings; - } - - /** Returns the object with the settings used for calls to updateConnection. */ - public UnaryCallSettings updateConnectionSettings() { - return updateConnectionSettings; - } - - /** Returns the object with the settings used for calls to updateConnectionCredential. */ - public UnaryCallSettings - updateConnectionCredentialSettings() { - return updateConnectionCredentialSettings; - } - - /** Returns the object with the settings used for calls to getIamPolicy. */ - public UnaryCallSettings getIamPolicySettings() { - return getIamPolicySettings; - } - - /** Returns the object with the settings used for calls to setIamPolicy. */ - public UnaryCallSettings setIamPolicySettings() { - return setIamPolicySettings; - } - - /** Returns the object with the settings used for calls to testIamPermissions. */ - public UnaryCallSettings - testIamPermissionsSettings() { - return testIamPermissionsSettings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public ConnectionServiceStub createStub() throws IOException { - if (getTransportChannelProvider() - .getTransportName() - .equals(GrpcTransportChannel.getGrpcTransportName())) { - return GrpcConnectionServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + 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 "bigqueryconnection.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); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return InstantiatingGrpcChannelProvider.newBuilder() - .setMaxInboundMessageSize(Integer.MAX_VALUE); - } - - 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 defaultApiClientHeaderProviderBuilder() { - return ApiClientHeaderProvider.newBuilder() - .setGeneratedLibToken( - "gapic", GaxProperties.getLibraryVersion(ConnectionServiceStubSettings.class)) - .setTransportToken( - GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** 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 ConnectionServiceStubSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - - deleteConnectionSettings = settingsBuilder.deleteConnectionSettings().build(); - createConnectionSettings = settingsBuilder.createConnectionSettings().build(); - getConnectionSettings = settingsBuilder.getConnectionSettings().build(); - listConnectionsSettings = settingsBuilder.listConnectionsSettings().build(); - updateConnectionSettings = settingsBuilder.updateConnectionSettings().build(); - updateConnectionCredentialSettings = - settingsBuilder.updateConnectionCredentialSettings().build(); - getIamPolicySettings = settingsBuilder.getIamPolicySettings().build(); - setIamPolicySettings = settingsBuilder.setIamPolicySettings().build(); - testIamPermissionsSettings = settingsBuilder.testIamPermissionsSettings().build(); - } - - /** Builder for ConnectionServiceStubSettings. */ - public static class Builder extends StubSettings.Builder { - private final ImmutableList> unaryMethodSettingsBuilders; - - private final UnaryCallSettings.Builder - deleteConnectionSettings; - private final UnaryCallSettings.Builder - createConnectionSettings; - private final UnaryCallSettings.Builder getConnectionSettings; - private final UnaryCallSettings.Builder - listConnectionsSettings; - private final UnaryCallSettings.Builder - updateConnectionSettings; - private final UnaryCallSettings.Builder - updateConnectionCredentialSettings; - private final UnaryCallSettings.Builder getIamPolicySettings; - private final UnaryCallSettings.Builder setIamPolicySettings; - private final UnaryCallSettings.Builder - testIamPermissionsSettings; - - private static final ImmutableMap> - RETRYABLE_CODE_DEFINITIONS; - - static { - ImmutableMap.Builder> definitions = - ImmutableMap.builder(); - definitions.put( - "idempotent", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); - RETRYABLE_CODE_DEFINITIONS = definitions.build(); - } - - private static final ImmutableMap RETRY_PARAM_DEFINITIONS; - - static { - ImmutableMap.Builder definitions = ImmutableMap.builder(); - RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(60000L)) - .setInitialRpcTimeout(Duration.ofMillis(20000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(20000L)) - .setTotalTimeout(Duration.ofMillis(600000L)) - .build(); - definitions.put("default", settings); - RETRY_PARAM_DEFINITIONS = definitions.build(); - } - - protected Builder() { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(clientContext); - - deleteConnectionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - createConnectionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - getConnectionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - listConnectionsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - updateConnectionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - updateConnectionCredentialSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - getIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - setIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - testIamPermissionsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - deleteConnectionSettings, - createConnectionSettings, - getConnectionSettings, - listConnectionsSettings, - updateConnectionSettings, - updateConnectionCredentialSettings, - getIamPolicySettings, - setIamPolicySettings, - testIamPermissionsSettings); - - initDefaults(this); - } - - private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); - builder.setTransportChannelProvider(defaultTransportChannelProvider()); - builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); - builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); - builder.setEndpoint(getDefaultEndpoint()); - return initDefaults(builder); - } - - private static Builder initDefaults(Builder builder) { - - builder - .deleteConnectionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .createConnectionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .getConnectionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .listConnectionsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .updateConnectionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .updateConnectionCredentialSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .getIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .setIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .testIamPermissionsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - return builder; - } - - protected Builder(ConnectionServiceStubSettings settings) { - super(settings); - - deleteConnectionSettings = settings.deleteConnectionSettings.toBuilder(); - createConnectionSettings = settings.createConnectionSettings.toBuilder(); - getConnectionSettings = settings.getConnectionSettings.toBuilder(); - listConnectionsSettings = settings.listConnectionsSettings.toBuilder(); - updateConnectionSettings = settings.updateConnectionSettings.toBuilder(); - updateConnectionCredentialSettings = settings.updateConnectionCredentialSettings.toBuilder(); - getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); - setIamPolicySettings = settings.setIamPolicySettings.toBuilder(); - testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - deleteConnectionSettings, - createConnectionSettings, - getConnectionSettings, - listConnectionsSettings, - updateConnectionSettings, - updateConnectionCredentialSettings, - getIamPolicySettings, - setIamPolicySettings, - testIamPermissionsSettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * 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) throws Exception { - super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); - return this; - } - - public ImmutableList> unaryMethodSettingsBuilders() { - return unaryMethodSettingsBuilders; - } - - /** Returns the builder for the settings used for calls to deleteConnection. */ - public UnaryCallSettings.Builder deleteConnectionSettings() { - return deleteConnectionSettings; - } - - /** Returns the builder for the settings used for calls to createConnection. */ - public UnaryCallSettings.Builder - createConnectionSettings() { - return createConnectionSettings; - } - - /** Returns the builder for the settings used for calls to getConnection. */ - public UnaryCallSettings.Builder getConnectionSettings() { - return getConnectionSettings; - } - - /** Returns the builder for the settings used for calls to listConnections. */ - public UnaryCallSettings.Builder - listConnectionsSettings() { - return listConnectionsSettings; - } - - /** Returns the builder for the settings used for calls to updateConnection. */ - public UnaryCallSettings.Builder - updateConnectionSettings() { - return updateConnectionSettings; - } - - /** Returns the builder for the settings used for calls to updateConnectionCredential. */ - public UnaryCallSettings.Builder - updateConnectionCredentialSettings() { - return updateConnectionCredentialSettings; - } - - /** Returns the builder for the settings used for calls to getIamPolicy. */ - public UnaryCallSettings.Builder getIamPolicySettings() { - return getIamPolicySettings; - } - - /** Returns the builder for the settings used for calls to setIamPolicy. */ - public UnaryCallSettings.Builder setIamPolicySettings() { - return setIamPolicySettings; - } - - /** Returns the builder for the settings used for calls to testIamPermissions. */ - public UnaryCallSettings.Builder - testIamPermissionsSettings() { - return testIamPermissionsSettings; - } - - @Override - public ConnectionServiceStubSettings build() throws IOException { - return new ConnectionServiceStubSettings(this); - } - } -} diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/stub/GrpcConnectionServiceCallableFactory.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/stub/GrpcConnectionServiceCallableFactory.java deleted file mode 100644 index 83d3a15f..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/stub/GrpcConnectionServiceCallableFactory.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigquery.connection.v1beta1.stub; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcCallableFactory; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.BatchingCallSettings; -import com.google.api.gax.rpc.BidiStreamingCallable; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientStreamingCallable; -import com.google.api.gax.rpc.OperationCallSettings; -import com.google.api.gax.rpc.OperationCallable; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallable; -import com.google.api.gax.rpc.StreamingCallSettings; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.longrunning.stub.OperationsStub; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for BigQuery Connection API. - * - *

This class is for advanced usage. - */ -@Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -public class GrpcConnectionServiceCallableFactory 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 pagedCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); - } - - @Override - public UnaryCallable createBatchingCallable( - GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); - } - - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - @Override - public - OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, - ClientContext clientContext, - OperationsStub operationsStub) { - return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); - } - - @Override - public - BidiStreamingCallable createBidiStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ServerStreamingCallable createServerStreamingCallable( - GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ClientStreamingCallable createClientStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } -} diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/stub/GrpcConnectionServiceStub.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/stub/GrpcConnectionServiceStub.java deleted file mode 100644 index 6f5bb611..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigquery/connection/v1beta1/stub/GrpcConnectionServiceStub.java +++ /dev/null @@ -1,427 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigquery.connection.v1beta1.stub; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.core.BackgroundResourceAggregation; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.Connection; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionCredentialRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionRequest; -import com.google.common.collect.ImmutableMap; -import com.google.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.Empty; -import io.grpc.MethodDescriptor; -import io.grpc.protobuf.ProtoUtils; -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC stub implementation for BigQuery Connection API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public class GrpcConnectionServiceStub extends ConnectionServiceStub { - - private static final MethodDescriptor - deleteConnectionMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1beta1.ConnectionService/DeleteConnection") - .setRequestMarshaller( - ProtoUtils.marshaller(DeleteConnectionRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - private static final MethodDescriptor - createConnectionMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1beta1.ConnectionService/CreateConnection") - .setRequestMarshaller( - ProtoUtils.marshaller(CreateConnectionRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Connection.getDefaultInstance())) - .build(); - private static final MethodDescriptor - getConnectionMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1beta1.ConnectionService/GetConnection") - .setRequestMarshaller( - ProtoUtils.marshaller(GetConnectionRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Connection.getDefaultInstance())) - .build(); - private static final MethodDescriptor - listConnectionsMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1beta1.ConnectionService/ListConnections") - .setRequestMarshaller( - ProtoUtils.marshaller(ListConnectionsRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListConnectionsResponse.getDefaultInstance())) - .build(); - private static final MethodDescriptor - updateConnectionMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1beta1.ConnectionService/UpdateConnection") - .setRequestMarshaller( - ProtoUtils.marshaller(UpdateConnectionRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Connection.getDefaultInstance())) - .build(); - private static final MethodDescriptor - updateConnectionCredentialMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1beta1.ConnectionService/UpdateConnectionCredential") - .setRequestMarshaller( - ProtoUtils.marshaller(UpdateConnectionCredentialRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - private static final MethodDescriptor getIamPolicyMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1beta1.ConnectionService/GetIamPolicy") - .setRequestMarshaller(ProtoUtils.marshaller(GetIamPolicyRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) - .build(); - private static final MethodDescriptor setIamPolicyMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1beta1.ConnectionService/SetIamPolicy") - .setRequestMarshaller(ProtoUtils.marshaller(SetIamPolicyRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) - .build(); - private static final MethodDescriptor - testIamPermissionsMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1beta1.ConnectionService/TestIamPermissions") - .setRequestMarshaller( - ProtoUtils.marshaller(TestIamPermissionsRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance())) - .build(); - - private final BackgroundResource backgroundResources; - - private final UnaryCallable deleteConnectionCallable; - private final UnaryCallable createConnectionCallable; - private final UnaryCallable getConnectionCallable; - private final UnaryCallable - listConnectionsCallable; - private final UnaryCallable updateConnectionCallable; - private final UnaryCallable - updateConnectionCredentialCallable; - private final UnaryCallable getIamPolicyCallable; - private final UnaryCallable setIamPolicyCallable; - private final UnaryCallable - testIamPermissionsCallable; - - private final GrpcStubCallableFactory callableFactory; - - public static final GrpcConnectionServiceStub create(ConnectionServiceStubSettings settings) - throws IOException { - return new GrpcConnectionServiceStub(settings, ClientContext.create(settings)); - } - - public static final GrpcConnectionServiceStub create(ClientContext clientContext) - throws IOException { - return new GrpcConnectionServiceStub( - ConnectionServiceStubSettings.newBuilder().build(), clientContext); - } - - public static final GrpcConnectionServiceStub create( - ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { - return new GrpcConnectionServiceStub( - ConnectionServiceStubSettings.newBuilder().build(), clientContext, callableFactory); - } - - /** - * Constructs an instance of GrpcConnectionServiceStub, 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 GrpcConnectionServiceStub( - ConnectionServiceStubSettings settings, ClientContext clientContext) throws IOException { - this(settings, clientContext, new GrpcConnectionServiceCallableFactory()); - } - - /** - * Constructs an instance of GrpcConnectionServiceStub, 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 GrpcConnectionServiceStub( - ConnectionServiceStubSettings settings, - ClientContext clientContext, - GrpcStubCallableFactory callableFactory) - throws IOException { - this.callableFactory = callableFactory; - - GrpcCallSettings deleteConnectionTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(deleteConnectionMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteConnectionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings createConnectionTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createConnectionMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateConnectionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } - }) - .build(); - GrpcCallSettings getConnectionTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getConnectionMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetConnectionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - listConnectionsTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(listConnectionsMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListConnectionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } - }) - .build(); - GrpcCallSettings updateConnectionTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateConnectionMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateConnectionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - updateConnectionCredentialTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateConnectionCredentialMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract( - UpdateConnectionCredentialRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings getIamPolicyTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getIamPolicyMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } - }) - .build(); - GrpcCallSettings setIamPolicyTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(setIamPolicyMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - testIamPermissionsTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(testIamPermissionsMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(TestIamPermissionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } - }) - .build(); - - this.deleteConnectionCallable = - callableFactory.createUnaryCallable( - deleteConnectionTransportSettings, settings.deleteConnectionSettings(), clientContext); - this.createConnectionCallable = - callableFactory.createUnaryCallable( - createConnectionTransportSettings, settings.createConnectionSettings(), clientContext); - this.getConnectionCallable = - callableFactory.createUnaryCallable( - getConnectionTransportSettings, settings.getConnectionSettings(), clientContext); - this.listConnectionsCallable = - callableFactory.createUnaryCallable( - listConnectionsTransportSettings, settings.listConnectionsSettings(), clientContext); - this.updateConnectionCallable = - callableFactory.createUnaryCallable( - updateConnectionTransportSettings, settings.updateConnectionSettings(), clientContext); - this.updateConnectionCredentialCallable = - callableFactory.createUnaryCallable( - updateConnectionCredentialTransportSettings, - settings.updateConnectionCredentialSettings(), - clientContext); - this.getIamPolicyCallable = - callableFactory.createUnaryCallable( - getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); - this.setIamPolicyCallable = - callableFactory.createUnaryCallable( - setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); - this.testIamPermissionsCallable = - callableFactory.createUnaryCallable( - testIamPermissionsTransportSettings, - settings.testIamPermissionsSettings(), - clientContext); - - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); - } - - public UnaryCallable deleteConnectionCallable() { - return deleteConnectionCallable; - } - - public UnaryCallable createConnectionCallable() { - return createConnectionCallable; - } - - public UnaryCallable getConnectionCallable() { - return getConnectionCallable; - } - - public UnaryCallable listConnectionsCallable() { - return listConnectionsCallable; - } - - public UnaryCallable updateConnectionCallable() { - return updateConnectionCallable; - } - - public UnaryCallable - updateConnectionCredentialCallable() { - return updateConnectionCredentialCallable; - } - - public UnaryCallable getIamPolicyCallable() { - return getIamPolicyCallable; - } - - public UnaryCallable setIamPolicyCallable() { - return setIamPolicyCallable; - } - - public UnaryCallable - testIamPermissionsCallable() { - return testIamPermissionsCallable; - } - - @Override - public final void close() { - shutdown(); - } - - @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/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/ConnectionServiceClient.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/ConnectionServiceClient.java deleted file mode 100644 index a27004c1..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/ConnectionServiceClient.java +++ /dev/null @@ -1,1140 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigqueryconnection.v1; - -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.paging.AbstractFixedSizeCollection; -import com.google.api.gax.paging.AbstractPage; -import com.google.api.gax.paging.AbstractPagedListResponse; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.api.resourcenames.ResourceName; -import com.google.cloud.bigquery.connection.v1.Connection; -import com.google.cloud.bigquery.connection.v1.ConnectionName; -import com.google.cloud.bigquery.connection.v1.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1.LocationName; -import com.google.cloud.bigquery.connection.v1.UpdateConnectionRequest; -import com.google.cloud.bigqueryconnection.v1.stub.ConnectionServiceStub; -import com.google.cloud.bigqueryconnection.v1.stub.ConnectionServiceStubSettings; -import com.google.common.util.concurrent.MoreExecutors; -import com.google.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.Empty; -import com.google.protobuf.FieldMask; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND SERVICE -/** - * Service Description: Manages external data source connections and credentials. - * - *

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: - * - *

- * 
- * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
- *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
- *   Connection connection = Connection.newBuilder().build();
- *   String connectionId = "";
- *   Connection response = connectionServiceClient.createConnection(parent, connection, connectionId);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the connectionServiceClient 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 ConnectionServiceSettings to - * create(). For example: - * - *

To customize credentials: - * - *

- * 
- * ConnectionServiceSettings connectionServiceSettings =
- *     ConnectionServiceSettings.newBuilder()
- *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
- *         .build();
- * ConnectionServiceClient connectionServiceClient =
- *     ConnectionServiceClient.create(connectionServiceSettings);
- * 
- * 
- * - * To customize the endpoint: - * - *
- * 
- * ConnectionServiceSettings connectionServiceSettings =
- *     ConnectionServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
- * ConnectionServiceClient connectionServiceClient =
- *     ConnectionServiceClient.create(connectionServiceSettings);
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi -public class ConnectionServiceClient implements BackgroundResource { - private final ConnectionServiceSettings settings; - private final ConnectionServiceStub stub; - - /** Constructs an instance of ConnectionServiceClient with default settings. */ - public static final ConnectionServiceClient create() throws IOException { - return create(ConnectionServiceSettings.newBuilder().build()); - } - - /** - * Constructs an instance of ConnectionServiceClient, 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 ConnectionServiceClient create(ConnectionServiceSettings settings) - throws IOException { - return new ConnectionServiceClient(settings); - } - - /** - * Constructs an instance of ConnectionServiceClient, using the given stub for making calls. This - * is for advanced usage - prefer to use ConnectionServiceSettings}. - */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public static final ConnectionServiceClient create(ConnectionServiceStub stub) { - return new ConnectionServiceClient(stub); - } - - /** - * Constructs an instance of ConnectionServiceClient, 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 ConnectionServiceClient(ConnectionServiceSettings settings) throws IOException { - this.settings = settings; - this.stub = ((ConnectionServiceStubSettings) settings.getStubSettings()).createStub(); - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - protected ConnectionServiceClient(ConnectionServiceStub stub) { - this.settings = null; - this.stub = stub; - } - - public final ConnectionServiceSettings getSettings() { - return settings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public ConnectionServiceStub getStub() { - return stub; - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   String connectionId = "";
-   *   Connection response = connectionServiceClient.createConnection(parent, connection, connectionId);
-   * }
-   * 
- * - * @param parent Required. Parent resource name. Must be in the format - * `projects/{project_id}/locations/{location_id}` - * @param connection Required. Connection to create. - * @param connectionId Optional. Connection id that should be assigned to the created connection. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection createConnection( - LocationName parent, Connection connection, String connectionId) { - CreateConnectionRequest request = - CreateConnectionRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) - .setConnection(connection) - .setConnectionId(connectionId) - .build(); - return createConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   String connectionId = "";
-   *   Connection response = connectionServiceClient.createConnection(parent.toString(), connection, connectionId);
-   * }
-   * 
- * - * @param parent Required. Parent resource name. Must be in the format - * `projects/{project_id}/locations/{location_id}` - * @param connection Required. Connection to create. - * @param connectionId Optional. Connection id that should be assigned to the created connection. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection createConnection( - String parent, Connection connection, String connectionId) { - CreateConnectionRequest request = - CreateConnectionRequest.newBuilder() - .setParent(parent) - .setConnection(connection) - .setConnectionId(connectionId) - .build(); - return createConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   CreateConnectionRequest request = CreateConnectionRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setConnection(connection)
-   *     .build();
-   *   Connection response = connectionServiceClient.createConnection(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection createConnection(CreateConnectionRequest request) { - return createConnectionCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   CreateConnectionRequest request = CreateConnectionRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setConnection(connection)
-   *     .build();
-   *   ApiFuture<Connection> future = connectionServiceClient.createConnectionCallable().futureCall(request);
-   *   // Do something
-   *   Connection response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable createConnectionCallable() { - return stub.createConnectionCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns specified connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Connection response = connectionServiceClient.getConnection(name);
-   * }
-   * 
- * - * @param name Required. Name of the requested connection, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}` - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection getConnection(ConnectionName name) { - GetConnectionRequest request = - GetConnectionRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return getConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns specified connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Connection response = connectionServiceClient.getConnection(name.toString());
-   * }
-   * 
- * - * @param name Required. Name of the requested connection, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}` - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection getConnection(String name) { - GetConnectionRequest request = GetConnectionRequest.newBuilder().setName(name).build(); - return getConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns specified connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   GetConnectionRequest request = GetConnectionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   Connection response = connectionServiceClient.getConnection(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection getConnection(GetConnectionRequest request) { - return getConnectionCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns specified connection. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   GetConnectionRequest request = GetConnectionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Connection> future = connectionServiceClient.getConnectionCallable().futureCall(request);
-   *   // Do something
-   *   Connection response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable getConnectionCallable() { - return stub.getConnectionCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns a list of connections in the given project. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   int pageSize = 0;
-   *   ListConnectionsRequest request = ListConnectionsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setPageSize(pageSize)
-   *     .build();
-   *   for (Connection element : connectionServiceClient.listConnections(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 ListConnectionsPagedResponse listConnections(ListConnectionsRequest request) { - return listConnectionsPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns a list of connections in the given project. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   int pageSize = 0;
-   *   ListConnectionsRequest request = ListConnectionsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setPageSize(pageSize)
-   *     .build();
-   *   ApiFuture<ListConnectionsPagedResponse> future = connectionServiceClient.listConnectionsPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (Connection element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listConnectionsPagedCallable() { - return stub.listConnectionsPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns a list of connections in the given project. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   int pageSize = 0;
-   *   ListConnectionsRequest request = ListConnectionsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setPageSize(pageSize)
-   *     .build();
-   *   while (true) {
-   *     ListConnectionsResponse response = connectionServiceClient.listConnectionsCallable().call(request);
-   *     for (Connection element : response.getConnectionsList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listConnectionsCallable() { - return stub.listConnectionsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates the specified connection. For security reasons, also resets credential if connection - * properties are in the update field mask. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   Connection response = connectionServiceClient.updateConnection(name, connection, updateMask);
-   * }
-   * 
- * - * @param name Required. Name of the connection to update, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}` - * @param connection Required. Connection containing the updated fields. - * @param updateMask Required. Update mask for the connection fields to be updated. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection updateConnection( - ConnectionName name, Connection connection, FieldMask updateMask) { - UpdateConnectionRequest request = - UpdateConnectionRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setConnection(connection) - .setUpdateMask(updateMask) - .build(); - return updateConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates the specified connection. For security reasons, also resets credential if connection - * properties are in the update field mask. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   Connection response = connectionServiceClient.updateConnection(name.toString(), connection, updateMask);
-   * }
-   * 
- * - * @param name Required. Name of the connection to update, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}` - * @param connection Required. Connection containing the updated fields. - * @param updateMask Required. Update mask for the connection fields to be updated. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection updateConnection( - String name, Connection connection, FieldMask updateMask) { - UpdateConnectionRequest request = - UpdateConnectionRequest.newBuilder() - .setName(name) - .setConnection(connection) - .setUpdateMask(updateMask) - .build(); - return updateConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates the specified connection. For security reasons, also resets credential if connection - * properties are in the update field mask. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   UpdateConnectionRequest request = UpdateConnectionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setConnection(connection)
-   *     .setUpdateMask(updateMask)
-   *     .build();
-   *   Connection response = connectionServiceClient.updateConnection(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Connection updateConnection(UpdateConnectionRequest request) { - return updateConnectionCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates the specified connection. For security reasons, also resets credential if connection - * properties are in the update field mask. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Connection connection = Connection.newBuilder().build();
-   *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   UpdateConnectionRequest request = UpdateConnectionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setConnection(connection)
-   *     .setUpdateMask(updateMask)
-   *     .build();
-   *   ApiFuture<Connection> future = connectionServiceClient.updateConnectionCallable().futureCall(request);
-   *   // Do something
-   *   Connection response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable updateConnectionCallable() { - return stub.updateConnectionCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes connection and associated credential. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   connectionServiceClient.deleteConnection(name);
-   * }
-   * 
- * - * @param name Required. Name of the deleted connection, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}` - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteConnection(ConnectionName name) { - DeleteConnectionRequest request = - DeleteConnectionRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - deleteConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes connection and associated credential. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   connectionServiceClient.deleteConnection(name.toString());
-   * }
-   * 
- * - * @param name Required. Name of the deleted connection, for example: - * `projects/{project_id}/locations/{location_id}/connections/{connection_id}` - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteConnection(String name) { - DeleteConnectionRequest request = DeleteConnectionRequest.newBuilder().setName(name).build(); - deleteConnection(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes connection and associated credential. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   DeleteConnectionRequest request = DeleteConnectionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   connectionServiceClient.deleteConnection(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteConnection(DeleteConnectionRequest request) { - deleteConnectionCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes connection and associated credential. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   DeleteConnectionRequest request = DeleteConnectionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = connectionServiceClient.deleteConnectionCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable deleteConnectionCallable() { - return stub.deleteConnectionCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets the access control policy for a resource. Returns an empty policy if the resource exists - * and does not have a policy set. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   GetPolicyOptions options = GetPolicyOptions.newBuilder().build();
-   *   Policy response = connectionServiceClient.getIamPolicy(resource, options);
-   * }
-   * 
- * - * @param resource REQUIRED: The resource for which the policy is being requested. See the - * operation documentation for the appropriate value for this field. - * @param options OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`. - * This field is only used by Cloud IAM. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy getIamPolicy(ResourceName resource, GetPolicyOptions options) { - GetIamPolicyRequest request = - GetIamPolicyRequest.newBuilder() - .setResource(resource == null ? null : resource.toString()) - .setOptions(options) - .build(); - return getIamPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets the access control policy for a resource. Returns an empty policy if the resource exists - * and does not have a policy set. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   GetPolicyOptions options = GetPolicyOptions.newBuilder().build();
-   *   Policy response = connectionServiceClient.getIamPolicy(resource.toString(), options);
-   * }
-   * 
- * - * @param resource REQUIRED: The resource for which the policy is being requested. See the - * operation documentation for the appropriate value for this field. - * @param options OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`. - * This field is only used by Cloud IAM. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy getIamPolicy(String resource, GetPolicyOptions options) { - GetIamPolicyRequest request = - GetIamPolicyRequest.newBuilder().setResource(resource).setOptions(options).build(); - return getIamPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets the access control policy for a resource. Returns an empty policy if the resource exists - * and does not have a policy set. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .build();
-   *   Policy response = connectionServiceClient.getIamPolicy(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy getIamPolicy(GetIamPolicyRequest request) { - return getIamPolicyCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets the access control policy for a resource. Returns an empty policy if the resource exists - * and does not have a policy set. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .build();
-   *   ApiFuture<Policy> future = connectionServiceClient.getIamPolicyCallable().futureCall(request);
-   *   // Do something
-   *   Policy response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable getIamPolicyCallable() { - return stub.getIamPolicyCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - *

Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   Policy response = connectionServiceClient.setIamPolicy(resource, policy);
-   * }
-   * 
- * - * @param resource REQUIRED: The resource for which the policy is being specified. See the - * operation documentation for the appropriate value for this field. - * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the - * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud - * Platform services (such as Projects) might reject them. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy setIamPolicy(ResourceName resource, Policy policy) { - SetIamPolicyRequest request = - SetIamPolicyRequest.newBuilder() - .setResource(resource == null ? null : resource.toString()) - .setPolicy(policy) - .build(); - return setIamPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - *

Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   Policy response = connectionServiceClient.setIamPolicy(resource.toString(), policy);
-   * }
-   * 
- * - * @param resource REQUIRED: The resource for which the policy is being specified. See the - * operation documentation for the appropriate value for this field. - * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the - * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud - * Platform services (such as Projects) might reject them. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy setIamPolicy(String resource, Policy policy) { - SetIamPolicyRequest request = - SetIamPolicyRequest.newBuilder().setResource(resource).setPolicy(policy).build(); - return setIamPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - *

Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .setPolicy(policy)
-   *     .build();
-   *   Policy response = connectionServiceClient.setIamPolicy(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Policy setIamPolicy(SetIamPolicyRequest request) { - return setIamPolicyCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Sets the access control policy on the specified resource. Replaces any existing policy. - * - *

Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and PERMISSION_DENIED - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .setPolicy(policy)
-   *     .build();
-   *   ApiFuture<Policy> future = connectionServiceClient.setIamPolicyCallable().futureCall(request);
-   *   // Do something
-   *   Policy response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable setIamPolicyCallable() { - return stub.setIamPolicyCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns permissions that a caller has on the specified resource. If the resource does not - * exist, this will return an empty set of permissions, not a NOT_FOUND error. - * - *

Note: This operation is designed to be used for building permission-aware UIs and - * command-line tools, not for authorization checking. This operation may "fail open" without - * warning. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsResponse response = connectionServiceClient.testIamPermissions(resource, permissions);
-   * }
-   * 
- * - * @param resource REQUIRED: The resource for which the policy detail is being requested. See the - * operation documentation for the appropriate value for this field. - * @param permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final TestIamPermissionsResponse testIamPermissions( - ResourceName resource, List permissions) { - TestIamPermissionsRequest request = - TestIamPermissionsRequest.newBuilder() - .setResource(resource == null ? null : resource.toString()) - .addAllPermissions(permissions) - .build(); - return testIamPermissions(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns permissions that a caller has on the specified resource. If the resource does not - * exist, this will return an empty set of permissions, not a NOT_FOUND error. - * - *

Note: This operation is designed to be used for building permission-aware UIs and - * command-line tools, not for authorization checking. This operation may "fail open" without - * warning. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsResponse response = connectionServiceClient.testIamPermissions(resource.toString(), permissions);
-   * }
-   * 
- * - * @param resource REQUIRED: The resource for which the policy detail is being requested. See the - * operation documentation for the appropriate value for this field. - * @param permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final TestIamPermissionsResponse testIamPermissions( - String resource, List permissions) { - TestIamPermissionsRequest request = - TestIamPermissionsRequest.newBuilder() - .setResource(resource) - .addAllPermissions(permissions) - .build(); - return testIamPermissions(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns permissions that a caller has on the specified resource. If the resource does not - * exist, this will return an empty set of permissions, not a NOT_FOUND error. - * - *

Note: This operation is designed to be used for building permission-aware UIs and - * command-line tools, not for authorization checking. This operation may "fail open" without - * warning. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .addAllPermissions(permissions)
-   *     .build();
-   *   TestIamPermissionsResponse response = connectionServiceClient.testIamPermissions(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) { - return testIamPermissionsCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns permissions that a caller has on the specified resource. If the resource does not - * exist, this will return an empty set of permissions, not a NOT_FOUND error. - * - *

Note: This operation is designed to be used for building permission-aware UIs and - * command-line tools, not for authorization checking. This operation may "fail open" without - * warning. - * - *

Sample code: - * - *


-   * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
-   *   ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .addAllPermissions(permissions)
-   *     .build();
-   *   ApiFuture<TestIamPermissionsResponse> future = connectionServiceClient.testIamPermissionsCallable().futureCall(request);
-   *   // Do something
-   *   TestIamPermissionsResponse response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - testIamPermissionsCallable() { - return stub.testIamPermissionsCallable(); - } - - @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 ListConnectionsPagedResponse - extends AbstractPagedListResponse< - ListConnectionsRequest, - ListConnectionsResponse, - Connection, - ListConnectionsPage, - ListConnectionsFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListConnectionsPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListConnectionsPagedResponse apply(ListConnectionsPage input) { - return new ListConnectionsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private ListConnectionsPagedResponse(ListConnectionsPage page) { - super(page, ListConnectionsFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListConnectionsPage - extends AbstractPage< - ListConnectionsRequest, ListConnectionsResponse, Connection, ListConnectionsPage> { - - private ListConnectionsPage( - PageContext context, - ListConnectionsResponse response) { - super(context, response); - } - - private static ListConnectionsPage createEmptyPage() { - return new ListConnectionsPage(null, null); - } - - @Override - protected ListConnectionsPage createPage( - PageContext context, - ListConnectionsResponse response) { - return new ListConnectionsPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListConnectionsFixedSizeCollection - extends AbstractFixedSizeCollection< - ListConnectionsRequest, - ListConnectionsResponse, - Connection, - ListConnectionsPage, - ListConnectionsFixedSizeCollection> { - - private ListConnectionsFixedSizeCollection( - List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListConnectionsFixedSizeCollection createEmptyCollection() { - return new ListConnectionsFixedSizeCollection(null, 0); - } - - @Override - protected ListConnectionsFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListConnectionsFixedSizeCollection(pages, collectionSize); - } - } -} diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/ConnectionServiceSettings.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/ConnectionServiceSettings.java deleted file mode 100644 index 5938f308..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/ConnectionServiceSettings.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigqueryconnection.v1; - -import static com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient.ListConnectionsPagedResponse; - -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.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientSettings; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.cloud.bigquery.connection.v1.Connection; -import com.google.cloud.bigquery.connection.v1.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1.UpdateConnectionRequest; -import com.google.cloud.bigqueryconnection.v1.stub.ConnectionServiceStubSettings; -import com.google.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.Empty; -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 ConnectionServiceClient}. - * - *

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

    - *
  • The default service address (bigqueryconnection.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 createConnection to 30 seconds: - * - *

- * 
- * ConnectionServiceSettings.Builder connectionServiceSettingsBuilder =
- *     ConnectionServiceSettings.newBuilder();
- * connectionServiceSettingsBuilder
- *     .createConnectionSettings()
- *     .setRetrySettings(
- *         connectionServiceSettingsBuilder.createConnectionSettings().getRetrySettings().toBuilder()
- *             .setTotalTimeout(Duration.ofSeconds(30))
- *             .build());
- * ConnectionServiceSettings connectionServiceSettings = connectionServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi -public class ConnectionServiceSettings extends ClientSettings { - /** Returns the object with the settings used for calls to createConnection. */ - public UnaryCallSettings createConnectionSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).createConnectionSettings(); - } - - /** Returns the object with the settings used for calls to getConnection. */ - public UnaryCallSettings getConnectionSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).getConnectionSettings(); - } - - /** Returns the object with the settings used for calls to listConnections. */ - public PagedCallSettings< - ListConnectionsRequest, ListConnectionsResponse, ListConnectionsPagedResponse> - listConnectionsSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).listConnectionsSettings(); - } - - /** Returns the object with the settings used for calls to updateConnection. */ - public UnaryCallSettings updateConnectionSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).updateConnectionSettings(); - } - - /** Returns the object with the settings used for calls to deleteConnection. */ - public UnaryCallSettings deleteConnectionSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).deleteConnectionSettings(); - } - - /** Returns the object with the settings used for calls to getIamPolicy. */ - public UnaryCallSettings getIamPolicySettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).getIamPolicySettings(); - } - - /** Returns the object with the settings used for calls to setIamPolicy. */ - public UnaryCallSettings setIamPolicySettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).setIamPolicySettings(); - } - - /** Returns the object with the settings used for calls to testIamPermissions. */ - public UnaryCallSettings - testIamPermissionsSettings() { - return ((ConnectionServiceStubSettings) getStubSettings()).testIamPermissionsSettings(); - } - - public static final ConnectionServiceSettings create(ConnectionServiceStubSettings stub) - throws IOException { - return new ConnectionServiceSettings.Builder(stub.toBuilder()).build(); - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return ConnectionServiceStubSettings.defaultExecutorProviderBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return ConnectionServiceStubSettings.getDefaultEndpoint(); - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return ConnectionServiceStubSettings.getDefaultServiceScopes(); - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return ConnectionServiceStubSettings.defaultCredentialsProviderBuilder(); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return ConnectionServiceStubSettings.defaultGrpcTransportProviderBuilder(); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return ConnectionServiceStubSettings.defaultTransportChannelProvider(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return ConnectionServiceStubSettings.defaultApiClientHeaderProviderBuilder(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** 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 ConnectionServiceSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - } - - /** Builder for ConnectionServiceSettings. */ - public static class Builder extends ClientSettings.Builder { - protected Builder() throws IOException { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(ConnectionServiceStubSettings.newBuilder(clientContext)); - } - - private static Builder createDefault() { - return new Builder(ConnectionServiceStubSettings.newBuilder()); - } - - protected Builder(ConnectionServiceSettings settings) { - super(settings.getStubSettings().toBuilder()); - } - - protected Builder(ConnectionServiceStubSettings.Builder stubSettings) { - super(stubSettings); - } - - public ConnectionServiceStubSettings.Builder getStubSettingsBuilder() { - return ((ConnectionServiceStubSettings.Builder) getStubSettings()); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * 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) throws Exception { - super.applyToAllUnaryMethods( - getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); - return this; - } - - /** Returns the builder for the settings used for calls to createConnection. */ - public UnaryCallSettings.Builder - createConnectionSettings() { - return getStubSettingsBuilder().createConnectionSettings(); - } - - /** Returns the builder for the settings used for calls to getConnection. */ - public UnaryCallSettings.Builder getConnectionSettings() { - return getStubSettingsBuilder().getConnectionSettings(); - } - - /** Returns the builder for the settings used for calls to listConnections. */ - public PagedCallSettings.Builder< - ListConnectionsRequest, ListConnectionsResponse, ListConnectionsPagedResponse> - listConnectionsSettings() { - return getStubSettingsBuilder().listConnectionsSettings(); - } - - /** Returns the builder for the settings used for calls to updateConnection. */ - public UnaryCallSettings.Builder - updateConnectionSettings() { - return getStubSettingsBuilder().updateConnectionSettings(); - } - - /** Returns the builder for the settings used for calls to deleteConnection. */ - public UnaryCallSettings.Builder deleteConnectionSettings() { - return getStubSettingsBuilder().deleteConnectionSettings(); - } - - /** Returns the builder for the settings used for calls to getIamPolicy. */ - public UnaryCallSettings.Builder getIamPolicySettings() { - return getStubSettingsBuilder().getIamPolicySettings(); - } - - /** Returns the builder for the settings used for calls to setIamPolicy. */ - public UnaryCallSettings.Builder setIamPolicySettings() { - return getStubSettingsBuilder().setIamPolicySettings(); - } - - /** Returns the builder for the settings used for calls to testIamPermissions. */ - public UnaryCallSettings.Builder - testIamPermissionsSettings() { - return getStubSettingsBuilder().testIamPermissionsSettings(); - } - - @Override - public ConnectionServiceSettings build() throws IOException { - return new ConnectionServiceSettings(this); - } - } -} diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/package-info.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/package-info.java deleted file mode 100644 index 254d8027..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/package-info.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * A client to BigQuery Connection API. - * - *

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

======================= ConnectionServiceClient ======================= - * - *

Service Description: Manages external data source connections and credentials. - * - *

Sample for ConnectionServiceClient: - * - *

- * 
- * try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
- *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
- *   Connection connection = Connection.newBuilder().build();
- *   String connectionId = "";
- *   Connection response = connectionServiceClient.createConnection(parent, connection, connectionId);
- * }
- * 
- * 
- */ -@Generated("by gapic-generator") -package com.google.cloud.bigqueryconnection.v1; - -import javax.annotation.Generated; diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/stub/ConnectionServiceStub.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/stub/ConnectionServiceStub.java deleted file mode 100644 index 94190eff..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/stub/ConnectionServiceStub.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigqueryconnection.v1.stub; - -import static com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient.ListConnectionsPagedResponse; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.bigquery.connection.v1.Connection; -import com.google.cloud.bigquery.connection.v1.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1.UpdateConnectionRequest; -import com.google.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.Empty; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Base stub class for BigQuery Connection API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public abstract class ConnectionServiceStub implements BackgroundResource { - - public UnaryCallable createConnectionCallable() { - throw new UnsupportedOperationException("Not implemented: createConnectionCallable()"); - } - - public UnaryCallable getConnectionCallable() { - throw new UnsupportedOperationException("Not implemented: getConnectionCallable()"); - } - - public UnaryCallable - listConnectionsPagedCallable() { - throw new UnsupportedOperationException("Not implemented: listConnectionsPagedCallable()"); - } - - public UnaryCallable listConnectionsCallable() { - throw new UnsupportedOperationException("Not implemented: listConnectionsCallable()"); - } - - public UnaryCallable updateConnectionCallable() { - throw new UnsupportedOperationException("Not implemented: updateConnectionCallable()"); - } - - public UnaryCallable deleteConnectionCallable() { - throw new UnsupportedOperationException("Not implemented: deleteConnectionCallable()"); - } - - public UnaryCallable getIamPolicyCallable() { - throw new UnsupportedOperationException("Not implemented: getIamPolicyCallable()"); - } - - public UnaryCallable setIamPolicyCallable() { - throw new UnsupportedOperationException("Not implemented: setIamPolicyCallable()"); - } - - public UnaryCallable - testIamPermissionsCallable() { - throw new UnsupportedOperationException("Not implemented: testIamPermissionsCallable()"); - } - - @Override - public abstract void close(); -} diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/stub/ConnectionServiceStubSettings.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/stub/ConnectionServiceStubSettings.java deleted file mode 100644 index 89ceaa72..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/stub/ConnectionServiceStubSettings.java +++ /dev/null @@ -1,530 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigqueryconnection.v1.stub; - -import static com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient.ListConnectionsPagedResponse; - -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.retrying.RetrySettings; -import com.google.api.gax.rpc.ApiCallContext; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.PagedListDescriptor; -import com.google.api.gax.rpc.PagedListResponseFactory; -import com.google.api.gax.rpc.StatusCode; -import com.google.api.gax.rpc.StubSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.bigquery.connection.v1.Connection; -import com.google.cloud.bigquery.connection.v1.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1.UpdateConnectionRequest; -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.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.Empty; -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 ConnectionServiceStub}. - * - *

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

    - *
  • The default service address (bigqueryconnection.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 createConnection to 30 seconds: - * - *

- * 
- * ConnectionServiceStubSettings.Builder connectionServiceSettingsBuilder =
- *     ConnectionServiceStubSettings.newBuilder();
- * connectionServiceSettingsBuilder
- *     .createConnectionSettings()
- *     .setRetrySettings(
- *         connectionServiceSettingsBuilder.createConnectionSettings().getRetrySettings().toBuilder()
- *             .setTotalTimeout(Duration.ofSeconds(30))
- *             .build());
- * ConnectionServiceStubSettings connectionServiceSettings = connectionServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -@BetaApi -public class ConnectionServiceStubSettings extends StubSettings { - /** The default scopes of the service. */ - private static final ImmutableList DEFAULT_SERVICE_SCOPES = - ImmutableList.builder() - .add("https://www.googleapis.com/auth/bigquery") - .add("https://www.googleapis.com/auth/cloud-platform") - .build(); - - private final UnaryCallSettings createConnectionSettings; - private final UnaryCallSettings getConnectionSettings; - private final PagedCallSettings< - ListConnectionsRequest, ListConnectionsResponse, ListConnectionsPagedResponse> - listConnectionsSettings; - private final UnaryCallSettings updateConnectionSettings; - private final UnaryCallSettings deleteConnectionSettings; - private final UnaryCallSettings getIamPolicySettings; - private final UnaryCallSettings setIamPolicySettings; - private final UnaryCallSettings - testIamPermissionsSettings; - - /** Returns the object with the settings used for calls to createConnection. */ - public UnaryCallSettings createConnectionSettings() { - return createConnectionSettings; - } - - /** Returns the object with the settings used for calls to getConnection. */ - public UnaryCallSettings getConnectionSettings() { - return getConnectionSettings; - } - - /** Returns the object with the settings used for calls to listConnections. */ - public PagedCallSettings< - ListConnectionsRequest, ListConnectionsResponse, ListConnectionsPagedResponse> - listConnectionsSettings() { - return listConnectionsSettings; - } - - /** Returns the object with the settings used for calls to updateConnection. */ - public UnaryCallSettings updateConnectionSettings() { - return updateConnectionSettings; - } - - /** Returns the object with the settings used for calls to deleteConnection. */ - public UnaryCallSettings deleteConnectionSettings() { - return deleteConnectionSettings; - } - - /** Returns the object with the settings used for calls to getIamPolicy. */ - public UnaryCallSettings getIamPolicySettings() { - return getIamPolicySettings; - } - - /** Returns the object with the settings used for calls to setIamPolicy. */ - public UnaryCallSettings setIamPolicySettings() { - return setIamPolicySettings; - } - - /** Returns the object with the settings used for calls to testIamPermissions. */ - public UnaryCallSettings - testIamPermissionsSettings() { - return testIamPermissionsSettings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public ConnectionServiceStub createStub() throws IOException { - if (getTransportChannelProvider() - .getTransportName() - .equals(GrpcTransportChannel.getGrpcTransportName())) { - return GrpcConnectionServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + 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 "bigqueryconnection.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); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return InstantiatingGrpcChannelProvider.newBuilder() - .setMaxInboundMessageSize(Integer.MAX_VALUE); - } - - 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 defaultApiClientHeaderProviderBuilder() { - return ApiClientHeaderProvider.newBuilder() - .setGeneratedLibToken( - "gapic", GaxProperties.getLibraryVersion(ConnectionServiceStubSettings.class)) - .setTransportToken( - GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** 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 ConnectionServiceStubSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - - createConnectionSettings = settingsBuilder.createConnectionSettings().build(); - getConnectionSettings = settingsBuilder.getConnectionSettings().build(); - listConnectionsSettings = settingsBuilder.listConnectionsSettings().build(); - updateConnectionSettings = settingsBuilder.updateConnectionSettings().build(); - deleteConnectionSettings = settingsBuilder.deleteConnectionSettings().build(); - getIamPolicySettings = settingsBuilder.getIamPolicySettings().build(); - setIamPolicySettings = settingsBuilder.setIamPolicySettings().build(); - testIamPermissionsSettings = settingsBuilder.testIamPermissionsSettings().build(); - } - - private static final PagedListDescriptor< - ListConnectionsRequest, ListConnectionsResponse, Connection> - LIST_CONNECTIONS_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListConnectionsRequest injectToken( - ListConnectionsRequest payload, String token) { - return ListConnectionsRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListConnectionsRequest injectPageSize( - ListConnectionsRequest payload, int pageSize) { - return ListConnectionsRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListConnectionsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListConnectionsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListConnectionsResponse payload) { - return payload.getConnectionsList() != null - ? payload.getConnectionsList() - : ImmutableList.of(); - } - }; - - private static final PagedListResponseFactory< - ListConnectionsRequest, ListConnectionsResponse, ListConnectionsPagedResponse> - LIST_CONNECTIONS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListConnectionsRequest, ListConnectionsResponse, ListConnectionsPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListConnectionsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, LIST_CONNECTIONS_PAGE_STR_DESC, request, context); - return ListConnectionsPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - /** Builder for ConnectionServiceStubSettings. */ - public static class Builder extends StubSettings.Builder { - private final ImmutableList> unaryMethodSettingsBuilders; - - private final UnaryCallSettings.Builder - createConnectionSettings; - private final UnaryCallSettings.Builder getConnectionSettings; - private final PagedCallSettings.Builder< - ListConnectionsRequest, ListConnectionsResponse, ListConnectionsPagedResponse> - listConnectionsSettings; - private final UnaryCallSettings.Builder - updateConnectionSettings; - private final UnaryCallSettings.Builder - deleteConnectionSettings; - private final UnaryCallSettings.Builder getIamPolicySettings; - private final UnaryCallSettings.Builder setIamPolicySettings; - private final UnaryCallSettings.Builder - testIamPermissionsSettings; - - private static final ImmutableMap> - RETRYABLE_CODE_DEFINITIONS; - - static { - ImmutableMap.Builder> definitions = - ImmutableMap.builder(); - definitions.put( - "idempotent", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); - RETRYABLE_CODE_DEFINITIONS = definitions.build(); - } - - private static final ImmutableMap RETRY_PARAM_DEFINITIONS; - - static { - ImmutableMap.Builder definitions = ImmutableMap.builder(); - RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(60000L)) - .setInitialRpcTimeout(Duration.ofMillis(20000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(20000L)) - .setTotalTimeout(Duration.ofMillis(600000L)) - .build(); - definitions.put("default", settings); - RETRY_PARAM_DEFINITIONS = definitions.build(); - } - - protected Builder() { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(clientContext); - - createConnectionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - getConnectionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - listConnectionsSettings = PagedCallSettings.newBuilder(LIST_CONNECTIONS_PAGE_STR_FACT); - - updateConnectionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - deleteConnectionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - getIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - setIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - testIamPermissionsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - createConnectionSettings, - getConnectionSettings, - listConnectionsSettings, - updateConnectionSettings, - deleteConnectionSettings, - getIamPolicySettings, - setIamPolicySettings, - testIamPermissionsSettings); - - initDefaults(this); - } - - private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); - builder.setTransportChannelProvider(defaultTransportChannelProvider()); - builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); - builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); - builder.setEndpoint(getDefaultEndpoint()); - return initDefaults(builder); - } - - private static Builder initDefaults(Builder builder) { - - builder - .createConnectionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .getConnectionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .listConnectionsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .updateConnectionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .deleteConnectionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .getIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .setIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .testIamPermissionsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - return builder; - } - - protected Builder(ConnectionServiceStubSettings settings) { - super(settings); - - createConnectionSettings = settings.createConnectionSettings.toBuilder(); - getConnectionSettings = settings.getConnectionSettings.toBuilder(); - listConnectionsSettings = settings.listConnectionsSettings.toBuilder(); - updateConnectionSettings = settings.updateConnectionSettings.toBuilder(); - deleteConnectionSettings = settings.deleteConnectionSettings.toBuilder(); - getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); - setIamPolicySettings = settings.setIamPolicySettings.toBuilder(); - testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - createConnectionSettings, - getConnectionSettings, - listConnectionsSettings, - updateConnectionSettings, - deleteConnectionSettings, - getIamPolicySettings, - setIamPolicySettings, - testIamPermissionsSettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * 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) throws Exception { - super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); - return this; - } - - public ImmutableList> unaryMethodSettingsBuilders() { - return unaryMethodSettingsBuilders; - } - - /** Returns the builder for the settings used for calls to createConnection. */ - public UnaryCallSettings.Builder - createConnectionSettings() { - return createConnectionSettings; - } - - /** Returns the builder for the settings used for calls to getConnection. */ - public UnaryCallSettings.Builder getConnectionSettings() { - return getConnectionSettings; - } - - /** Returns the builder for the settings used for calls to listConnections. */ - public PagedCallSettings.Builder< - ListConnectionsRequest, ListConnectionsResponse, ListConnectionsPagedResponse> - listConnectionsSettings() { - return listConnectionsSettings; - } - - /** Returns the builder for the settings used for calls to updateConnection. */ - public UnaryCallSettings.Builder - updateConnectionSettings() { - return updateConnectionSettings; - } - - /** Returns the builder for the settings used for calls to deleteConnection. */ - public UnaryCallSettings.Builder deleteConnectionSettings() { - return deleteConnectionSettings; - } - - /** Returns the builder for the settings used for calls to getIamPolicy. */ - public UnaryCallSettings.Builder getIamPolicySettings() { - return getIamPolicySettings; - } - - /** Returns the builder for the settings used for calls to setIamPolicy. */ - public UnaryCallSettings.Builder setIamPolicySettings() { - return setIamPolicySettings; - } - - /** Returns the builder for the settings used for calls to testIamPermissions. */ - public UnaryCallSettings.Builder - testIamPermissionsSettings() { - return testIamPermissionsSettings; - } - - @Override - public ConnectionServiceStubSettings build() throws IOException { - return new ConnectionServiceStubSettings(this); - } - } -} diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/stub/GrpcConnectionServiceCallableFactory.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/stub/GrpcConnectionServiceCallableFactory.java deleted file mode 100644 index 361af2a7..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/stub/GrpcConnectionServiceCallableFactory.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigqueryconnection.v1.stub; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcCallableFactory; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.BatchingCallSettings; -import com.google.api.gax.rpc.BidiStreamingCallable; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientStreamingCallable; -import com.google.api.gax.rpc.OperationCallSettings; -import com.google.api.gax.rpc.OperationCallable; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallable; -import com.google.api.gax.rpc.StreamingCallSettings; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.longrunning.stub.OperationsStub; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for BigQuery Connection API. - * - *

This class is for advanced usage. - */ -@Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -public class GrpcConnectionServiceCallableFactory 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 pagedCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); - } - - @Override - public UnaryCallable createBatchingCallable( - GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); - } - - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - @Override - public - OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, - ClientContext clientContext, - OperationsStub operationsStub) { - return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); - } - - @Override - public - BidiStreamingCallable createBidiStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ServerStreamingCallable createServerStreamingCallable( - GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ClientStreamingCallable createClientStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } -} diff --git a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/stub/GrpcConnectionServiceStub.java b/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/stub/GrpcConnectionServiceStub.java deleted file mode 100644 index f29e9d55..00000000 --- a/google-cloud-bigquery-connection/src/main/java/com/google/cloud/bigqueryconnection/v1/stub/GrpcConnectionServiceStub.java +++ /dev/null @@ -1,399 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigqueryconnection.v1.stub; - -import static com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient.ListConnectionsPagedResponse; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.core.BackgroundResourceAggregation; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.bigquery.connection.v1.Connection; -import com.google.cloud.bigquery.connection.v1.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1.UpdateConnectionRequest; -import com.google.common.collect.ImmutableMap; -import com.google.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.Empty; -import io.grpc.MethodDescriptor; -import io.grpc.protobuf.ProtoUtils; -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC stub implementation for BigQuery Connection API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public class GrpcConnectionServiceStub extends ConnectionServiceStub { - - private static final MethodDescriptor - createConnectionMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1.ConnectionService/CreateConnection") - .setRequestMarshaller( - ProtoUtils.marshaller(CreateConnectionRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Connection.getDefaultInstance())) - .build(); - private static final MethodDescriptor - getConnectionMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1.ConnectionService/GetConnection") - .setRequestMarshaller( - ProtoUtils.marshaller(GetConnectionRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Connection.getDefaultInstance())) - .build(); - private static final MethodDescriptor - listConnectionsMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1.ConnectionService/ListConnections") - .setRequestMarshaller( - ProtoUtils.marshaller(ListConnectionsRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListConnectionsResponse.getDefaultInstance())) - .build(); - private static final MethodDescriptor - updateConnectionMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1.ConnectionService/UpdateConnection") - .setRequestMarshaller( - ProtoUtils.marshaller(UpdateConnectionRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Connection.getDefaultInstance())) - .build(); - private static final MethodDescriptor - deleteConnectionMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1.ConnectionService/DeleteConnection") - .setRequestMarshaller( - ProtoUtils.marshaller(DeleteConnectionRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - private static final MethodDescriptor getIamPolicyMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.bigquery.connection.v1.ConnectionService/GetIamPolicy") - .setRequestMarshaller(ProtoUtils.marshaller(GetIamPolicyRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) - .build(); - private static final MethodDescriptor setIamPolicyMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.bigquery.connection.v1.ConnectionService/SetIamPolicy") - .setRequestMarshaller(ProtoUtils.marshaller(SetIamPolicyRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) - .build(); - private static final MethodDescriptor - testIamPermissionsMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.cloud.bigquery.connection.v1.ConnectionService/TestIamPermissions") - .setRequestMarshaller( - ProtoUtils.marshaller(TestIamPermissionsRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance())) - .build(); - - private final BackgroundResource backgroundResources; - - private final UnaryCallable createConnectionCallable; - private final UnaryCallable getConnectionCallable; - private final UnaryCallable - listConnectionsCallable; - private final UnaryCallable - listConnectionsPagedCallable; - private final UnaryCallable updateConnectionCallable; - private final UnaryCallable deleteConnectionCallable; - private final UnaryCallable getIamPolicyCallable; - private final UnaryCallable setIamPolicyCallable; - private final UnaryCallable - testIamPermissionsCallable; - - private final GrpcStubCallableFactory callableFactory; - - public static final GrpcConnectionServiceStub create(ConnectionServiceStubSettings settings) - throws IOException { - return new GrpcConnectionServiceStub(settings, ClientContext.create(settings)); - } - - public static final GrpcConnectionServiceStub create(ClientContext clientContext) - throws IOException { - return new GrpcConnectionServiceStub( - ConnectionServiceStubSettings.newBuilder().build(), clientContext); - } - - public static final GrpcConnectionServiceStub create( - ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { - return new GrpcConnectionServiceStub( - ConnectionServiceStubSettings.newBuilder().build(), clientContext, callableFactory); - } - - /** - * Constructs an instance of GrpcConnectionServiceStub, 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 GrpcConnectionServiceStub( - ConnectionServiceStubSettings settings, ClientContext clientContext) throws IOException { - this(settings, clientContext, new GrpcConnectionServiceCallableFactory()); - } - - /** - * Constructs an instance of GrpcConnectionServiceStub, 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 GrpcConnectionServiceStub( - ConnectionServiceStubSettings settings, - ClientContext clientContext, - GrpcStubCallableFactory callableFactory) - throws IOException { - this.callableFactory = callableFactory; - - GrpcCallSettings createConnectionTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createConnectionMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateConnectionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } - }) - .build(); - GrpcCallSettings getConnectionTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getConnectionMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetConnectionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - listConnectionsTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(listConnectionsMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListConnectionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } - }) - .build(); - GrpcCallSettings updateConnectionTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateConnectionMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateConnectionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings deleteConnectionTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(deleteConnectionMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteConnectionRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings getIamPolicyTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getIamPolicyMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } - }) - .build(); - GrpcCallSettings setIamPolicyTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(setIamPolicyMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SetIamPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - testIamPermissionsTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(testIamPermissionsMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(TestIamPermissionsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("resource", String.valueOf(request.getResource())); - return params.build(); - } - }) - .build(); - - this.createConnectionCallable = - callableFactory.createUnaryCallable( - createConnectionTransportSettings, settings.createConnectionSettings(), clientContext); - this.getConnectionCallable = - callableFactory.createUnaryCallable( - getConnectionTransportSettings, settings.getConnectionSettings(), clientContext); - this.listConnectionsCallable = - callableFactory.createUnaryCallable( - listConnectionsTransportSettings, settings.listConnectionsSettings(), clientContext); - this.listConnectionsPagedCallable = - callableFactory.createPagedCallable( - listConnectionsTransportSettings, settings.listConnectionsSettings(), clientContext); - this.updateConnectionCallable = - callableFactory.createUnaryCallable( - updateConnectionTransportSettings, settings.updateConnectionSettings(), clientContext); - this.deleteConnectionCallable = - callableFactory.createUnaryCallable( - deleteConnectionTransportSettings, settings.deleteConnectionSettings(), clientContext); - this.getIamPolicyCallable = - callableFactory.createUnaryCallable( - getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); - this.setIamPolicyCallable = - callableFactory.createUnaryCallable( - setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); - this.testIamPermissionsCallable = - callableFactory.createUnaryCallable( - testIamPermissionsTransportSettings, - settings.testIamPermissionsSettings(), - clientContext); - - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); - } - - public UnaryCallable createConnectionCallable() { - return createConnectionCallable; - } - - public UnaryCallable getConnectionCallable() { - return getConnectionCallable; - } - - public UnaryCallable - listConnectionsPagedCallable() { - return listConnectionsPagedCallable; - } - - public UnaryCallable listConnectionsCallable() { - return listConnectionsCallable; - } - - public UnaryCallable updateConnectionCallable() { - return updateConnectionCallable; - } - - public UnaryCallable deleteConnectionCallable() { - return deleteConnectionCallable; - } - - public UnaryCallable getIamPolicyCallable() { - return getIamPolicyCallable; - } - - public UnaryCallable setIamPolicyCallable() { - return setIamPolicyCallable; - } - - public UnaryCallable - testIamPermissionsCallable() { - return testIamPermissionsCallable; - } - - @Override - public final void close() { - shutdown(); - } - - @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/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigquery/connection/v1beta1/ConnectionServiceClientTest.java b/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigquery/connection/v1beta1/ConnectionServiceClientTest.java deleted file mode 100644 index a8755208..00000000 --- a/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigquery/connection/v1beta1/ConnectionServiceClientTest.java +++ /dev/null @@ -1,514 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigquery.connection.v1beta1; - -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.api.resourcenames.ResourceName; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.Connection; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ConnectionCredential; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionCredentialRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionRequest; -import com.google.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.ByteString; -import com.google.protobuf.Empty; -import com.google.protobuf.FieldMask; -import com.google.protobuf.UInt32Value; -import io.grpc.Status; -import io.grpc.StatusRuntimeException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.UUID; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -@javax.annotation.Generated("by GAPIC") -public class ConnectionServiceClientTest { - private static MockConnectionService mockConnectionService; - private static MockServiceHelper serviceHelper; - private ConnectionServiceClient client; - private LocalChannelProvider channelProvider; - - @BeforeClass - public static void startStaticServer() { - mockConnectionService = new MockConnectionService(); - serviceHelper = - new MockServiceHelper( - UUID.randomUUID().toString(), Arrays.asList(mockConnectionService)); - serviceHelper.start(); - } - - @AfterClass - public static void stopServer() { - serviceHelper.stop(); - } - - @Before - public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); - ConnectionServiceSettings settings = - ConnectionServiceSettings.newBuilder() - .setTransportChannelProvider(channelProvider) - .setCredentialsProvider(NoCredentialsProvider.create()) - .build(); - client = ConnectionServiceClient.create(settings); - } - - @After - public void tearDown() throws Exception { - client.close(); - } - - @Test - @SuppressWarnings("all") - public void deleteConnectionTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockConnectionService.addResponse(expectedResponse); - - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - - client.deleteConnection(name); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteConnectionRequest actualRequest = (DeleteConnectionRequest) actualRequests.get(0); - - Assert.assertEquals(name, ConnectionName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void deleteConnectionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - - client.deleteConnection(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void createConnectionTest() { - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - String friendlyName = "friendlyName1451097503"; - String description = "description-1724546052"; - long creationTime = 1932333101L; - long lastModifiedTime = 671513446L; - boolean hasCredential = true; - Connection expectedResponse = - Connection.newBuilder() - .setName(name.toString()) - .setFriendlyName(friendlyName) - .setDescription(description) - .setCreationTime(creationTime) - .setLastModifiedTime(lastModifiedTime) - .setHasCredential(hasCredential) - .build(); - mockConnectionService.addResponse(expectedResponse); - - LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); - Connection connection = Connection.newBuilder().build(); - String connectionId = "connectionId-513204708"; - - Connection actualResponse = client.createConnection(parent, connection, connectionId); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateConnectionRequest actualRequest = (CreateConnectionRequest) actualRequests.get(0); - - Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); - Assert.assertEquals(connection, actualRequest.getConnection()); - Assert.assertEquals(connectionId, actualRequest.getConnectionId()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void createConnectionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); - Connection connection = Connection.newBuilder().build(); - String connectionId = "connectionId-513204708"; - - client.createConnection(parent, connection, connectionId); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void getConnectionTest() { - ConnectionName name2 = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - String friendlyName = "friendlyName1451097503"; - String description = "description-1724546052"; - long creationTime = 1932333101L; - long lastModifiedTime = 671513446L; - boolean hasCredential = true; - Connection expectedResponse = - Connection.newBuilder() - .setName(name2.toString()) - .setFriendlyName(friendlyName) - .setDescription(description) - .setCreationTime(creationTime) - .setLastModifiedTime(lastModifiedTime) - .setHasCredential(hasCredential) - .build(); - mockConnectionService.addResponse(expectedResponse); - - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - - Connection actualResponse = client.getConnection(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetConnectionRequest actualRequest = (GetConnectionRequest) actualRequests.get(0); - - Assert.assertEquals(name, ConnectionName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void getConnectionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - - client.getConnection(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void listConnectionsTest() { - String nextPageToken = "nextPageToken-1530815211"; - ListConnectionsResponse expectedResponse = - ListConnectionsResponse.newBuilder().setNextPageToken(nextPageToken).build(); - mockConnectionService.addResponse(expectedResponse); - - LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); - UInt32Value maxResults = UInt32Value.newBuilder().build(); - - ListConnectionsResponse actualResponse = client.listConnections(parent, maxResults); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListConnectionsRequest actualRequest = (ListConnectionsRequest) actualRequests.get(0); - - Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); - Assert.assertEquals(maxResults, actualRequest.getMaxResults()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void listConnectionsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); - UInt32Value maxResults = UInt32Value.newBuilder().build(); - - client.listConnections(parent, maxResults); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void updateConnectionTest() { - ConnectionName name2 = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - String friendlyName = "friendlyName1451097503"; - String description = "description-1724546052"; - long creationTime = 1932333101L; - long lastModifiedTime = 671513446L; - boolean hasCredential = true; - Connection expectedResponse = - Connection.newBuilder() - .setName(name2.toString()) - .setFriendlyName(friendlyName) - .setDescription(description) - .setCreationTime(creationTime) - .setLastModifiedTime(lastModifiedTime) - .setHasCredential(hasCredential) - .build(); - mockConnectionService.addResponse(expectedResponse); - - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - Connection connection = Connection.newBuilder().build(); - FieldMask updateMask = FieldMask.newBuilder().build(); - - Connection actualResponse = client.updateConnection(name, connection, updateMask); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - UpdateConnectionRequest actualRequest = (UpdateConnectionRequest) actualRequests.get(0); - - Assert.assertEquals(name, ConnectionName.parse(actualRequest.getName())); - Assert.assertEquals(connection, actualRequest.getConnection()); - Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void updateConnectionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - Connection connection = Connection.newBuilder().build(); - FieldMask updateMask = FieldMask.newBuilder().build(); - - client.updateConnection(name, connection, updateMask); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void updateConnectionCredentialTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockConnectionService.addResponse(expectedResponse); - - String name = "name3373707"; - ConnectionCredential credential = ConnectionCredential.newBuilder().build(); - - client.updateConnectionCredential(name, credential); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - UpdateConnectionCredentialRequest actualRequest = - (UpdateConnectionCredentialRequest) actualRequests.get(0); - - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertEquals(credential, actualRequest.getCredential()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void updateConnectionCredentialExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - String name = "name3373707"; - ConnectionCredential credential = ConnectionCredential.newBuilder().build(); - - client.updateConnectionCredential(name, credential); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void getIamPolicyTest() { - int version = 351608024; - ByteString etag = ByteString.copyFromUtf8("21"); - Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build(); - mockConnectionService.addResponse(expectedResponse); - - ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - GetPolicyOptions options = GetPolicyOptions.newBuilder().build(); - - Policy actualResponse = client.getIamPolicy(resource, options); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetIamPolicyRequest actualRequest = (GetIamPolicyRequest) actualRequests.get(0); - - Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); - Assert.assertEquals(options, actualRequest.getOptions()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void getIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - GetPolicyOptions options = GetPolicyOptions.newBuilder().build(); - - client.getIamPolicy(resource, options); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void setIamPolicyTest() { - int version = 351608024; - ByteString etag = ByteString.copyFromUtf8("21"); - Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build(); - mockConnectionService.addResponse(expectedResponse); - - ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - Policy policy = Policy.newBuilder().build(); - - Policy actualResponse = client.setIamPolicy(resource, policy); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SetIamPolicyRequest actualRequest = (SetIamPolicyRequest) actualRequests.get(0); - - Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); - Assert.assertEquals(policy, actualRequest.getPolicy()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void setIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - Policy policy = Policy.newBuilder().build(); - - client.setIamPolicy(resource, policy); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void testIamPermissionsTest() { - TestIamPermissionsResponse expectedResponse = TestIamPermissionsResponse.newBuilder().build(); - mockConnectionService.addResponse(expectedResponse); - - ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - List permissions = new ArrayList<>(); - - TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - TestIamPermissionsRequest actualRequest = (TestIamPermissionsRequest) actualRequests.get(0); - - Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); - Assert.assertEquals(permissions, actualRequest.getPermissionsList()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void testIamPermissionsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - List permissions = new ArrayList<>(); - - client.testIamPermissions(resource, permissions); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } -} diff --git a/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigquery/connection/v1beta1/MockConnectionService.java b/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigquery/connection/v1beta1/MockConnectionService.java deleted file mode 100644 index 3761e27b..00000000 --- a/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigquery/connection/v1beta1/MockConnectionService.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigquery.connection.v1beta1; - -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; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockConnectionService implements MockGrpcService { - private final MockConnectionServiceImpl serviceImpl; - - public MockConnectionService() { - serviceImpl = new MockConnectionServiceImpl(); - } - - @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/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigquery/connection/v1beta1/MockConnectionServiceImpl.java b/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigquery/connection/v1beta1/MockConnectionServiceImpl.java deleted file mode 100644 index 939a46a0..00000000 --- a/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigquery/connection/v1beta1/MockConnectionServiceImpl.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigquery.connection.v1beta1; - -import com.google.api.core.BetaApi; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.Connection; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionCredentialRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionProto.UpdateConnectionRequest; -import com.google.cloud.bigquery.connection.v1beta1.ConnectionServiceGrpc.ConnectionServiceImplBase; -import com.google.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; -import io.grpc.stub.StreamObserver; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockConnectionServiceImpl extends ConnectionServiceImplBase { - private List requests; - private Queue responses; - - public MockConnectionServiceImpl() { - 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 createConnection( - CreateConnectionRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Connection) { - requests.add(request); - responseObserver.onNext((Connection) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getConnection( - GetConnectionRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Connection) { - requests.add(request); - responseObserver.onNext((Connection) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void listConnections( - ListConnectionsRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListConnectionsResponse) { - requests.add(request); - responseObserver.onNext((ListConnectionsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void updateConnection( - UpdateConnectionRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Connection) { - requests.add(request); - responseObserver.onNext((Connection) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void updateConnectionCredential( - UpdateConnectionCredentialRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext((Empty) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void deleteConnection( - DeleteConnectionRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext((Empty) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getIamPolicy(GetIamPolicyRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Policy) { - requests.add(request); - responseObserver.onNext((Policy) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void setIamPolicy(SetIamPolicyRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Policy) { - requests.add(request); - responseObserver.onNext((Policy) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void testIamPermissions( - TestIamPermissionsRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof TestIamPermissionsResponse) { - requests.add(request); - responseObserver.onNext((TestIamPermissionsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } -} diff --git a/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigqueryconnection/v1/ConnectionServiceClientTest.java b/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigqueryconnection/v1/ConnectionServiceClientTest.java deleted file mode 100644 index 66657fd2..00000000 --- a/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigqueryconnection/v1/ConnectionServiceClientTest.java +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigqueryconnection.v1; - -import static com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient.ListConnectionsPagedResponse; - -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.api.resourcenames.ResourceName; -import com.google.cloud.bigquery.connection.v1.Connection; -import com.google.cloud.bigquery.connection.v1.ConnectionName; -import com.google.cloud.bigquery.connection.v1.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1.LocationName; -import com.google.cloud.bigquery.connection.v1.UpdateConnectionRequest; -import com.google.common.collect.Lists; -import com.google.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.GetPolicyOptions; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.ByteString; -import com.google.protobuf.Empty; -import com.google.protobuf.FieldMask; -import io.grpc.Status; -import io.grpc.StatusRuntimeException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.UUID; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -@javax.annotation.Generated("by GAPIC") -public class ConnectionServiceClientTest { - private static MockConnectionService mockConnectionService; - private static MockServiceHelper serviceHelper; - private ConnectionServiceClient client; - private LocalChannelProvider channelProvider; - - @BeforeClass - public static void startStaticServer() { - mockConnectionService = new MockConnectionService(); - serviceHelper = - new MockServiceHelper( - UUID.randomUUID().toString(), Arrays.asList(mockConnectionService)); - serviceHelper.start(); - } - - @AfterClass - public static void stopServer() { - serviceHelper.stop(); - } - - @Before - public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); - ConnectionServiceSettings settings = - ConnectionServiceSettings.newBuilder() - .setTransportChannelProvider(channelProvider) - .setCredentialsProvider(NoCredentialsProvider.create()) - .build(); - client = ConnectionServiceClient.create(settings); - } - - @After - public void tearDown() throws Exception { - client.close(); - } - - @Test - @SuppressWarnings("all") - public void createConnectionTest() { - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - String friendlyName = "friendlyName1451097503"; - String description = "description-1724546052"; - long creationTime = 1932333101L; - long lastModifiedTime = 671513446L; - boolean hasCredential = true; - Connection expectedResponse = - Connection.newBuilder() - .setName(name.toString()) - .setFriendlyName(friendlyName) - .setDescription(description) - .setCreationTime(creationTime) - .setLastModifiedTime(lastModifiedTime) - .setHasCredential(hasCredential) - .build(); - mockConnectionService.addResponse(expectedResponse); - - LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); - Connection connection = Connection.newBuilder().build(); - String connectionId = "connectionId-513204708"; - - Connection actualResponse = client.createConnection(parent, connection, connectionId); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateConnectionRequest actualRequest = (CreateConnectionRequest) actualRequests.get(0); - - Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); - Assert.assertEquals(connection, actualRequest.getConnection()); - Assert.assertEquals(connectionId, actualRequest.getConnectionId()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void createConnectionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); - Connection connection = Connection.newBuilder().build(); - String connectionId = "connectionId-513204708"; - - client.createConnection(parent, connection, connectionId); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void getConnectionTest() { - ConnectionName name2 = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - String friendlyName = "friendlyName1451097503"; - String description = "description-1724546052"; - long creationTime = 1932333101L; - long lastModifiedTime = 671513446L; - boolean hasCredential = true; - Connection expectedResponse = - Connection.newBuilder() - .setName(name2.toString()) - .setFriendlyName(friendlyName) - .setDescription(description) - .setCreationTime(creationTime) - .setLastModifiedTime(lastModifiedTime) - .setHasCredential(hasCredential) - .build(); - mockConnectionService.addResponse(expectedResponse); - - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - - Connection actualResponse = client.getConnection(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetConnectionRequest actualRequest = (GetConnectionRequest) actualRequests.get(0); - - Assert.assertEquals(name, ConnectionName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void getConnectionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - - client.getConnection(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void listConnectionsTest() { - String nextPageToken = ""; - Connection connectionsElement = Connection.newBuilder().build(); - List connections = Arrays.asList(connectionsElement); - ListConnectionsResponse expectedResponse = - ListConnectionsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllConnections(connections) - .build(); - mockConnectionService.addResponse(expectedResponse); - - LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); - int pageSize = 883849137; - ListConnectionsRequest request = - ListConnectionsRequest.newBuilder() - .setParent(parent.toString()) - .setPageSize(pageSize) - .build(); - - ListConnectionsPagedResponse pagedListResponse = client.listConnections(request); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getConnectionsList().get(0), resources.get(0)); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListConnectionsRequest actualRequest = (ListConnectionsRequest) actualRequests.get(0); - - Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); - Assert.assertEquals(pageSize, actualRequest.getPageSize()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void listConnectionsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); - int pageSize = 883849137; - ListConnectionsRequest request = - ListConnectionsRequest.newBuilder() - .setParent(parent.toString()) - .setPageSize(pageSize) - .build(); - - client.listConnections(request); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void updateConnectionTest() { - ConnectionName name2 = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - String friendlyName = "friendlyName1451097503"; - String description = "description-1724546052"; - long creationTime = 1932333101L; - long lastModifiedTime = 671513446L; - boolean hasCredential = true; - Connection expectedResponse = - Connection.newBuilder() - .setName(name2.toString()) - .setFriendlyName(friendlyName) - .setDescription(description) - .setCreationTime(creationTime) - .setLastModifiedTime(lastModifiedTime) - .setHasCredential(hasCredential) - .build(); - mockConnectionService.addResponse(expectedResponse); - - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - Connection connection = Connection.newBuilder().build(); - FieldMask updateMask = FieldMask.newBuilder().build(); - - Connection actualResponse = client.updateConnection(name, connection, updateMask); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - UpdateConnectionRequest actualRequest = (UpdateConnectionRequest) actualRequests.get(0); - - Assert.assertEquals(name, ConnectionName.parse(actualRequest.getName())); - Assert.assertEquals(connection, actualRequest.getConnection()); - Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void updateConnectionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - Connection connection = Connection.newBuilder().build(); - FieldMask updateMask = FieldMask.newBuilder().build(); - - client.updateConnection(name, connection, updateMask); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void deleteConnectionTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockConnectionService.addResponse(expectedResponse); - - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - - client.deleteConnection(name); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteConnectionRequest actualRequest = (DeleteConnectionRequest) actualRequests.get(0); - - Assert.assertEquals(name, ConnectionName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void deleteConnectionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - - client.deleteConnection(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void getIamPolicyTest() { - int version = 351608024; - ByteString etag = ByteString.copyFromUtf8("21"); - Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build(); - mockConnectionService.addResponse(expectedResponse); - - ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - GetPolicyOptions options = GetPolicyOptions.newBuilder().build(); - - Policy actualResponse = client.getIamPolicy(resource, options); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetIamPolicyRequest actualRequest = (GetIamPolicyRequest) actualRequests.get(0); - - Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); - Assert.assertEquals(options, actualRequest.getOptions()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void getIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - GetPolicyOptions options = GetPolicyOptions.newBuilder().build(); - - client.getIamPolicy(resource, options); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void setIamPolicyTest() { - int version = 351608024; - ByteString etag = ByteString.copyFromUtf8("21"); - Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build(); - mockConnectionService.addResponse(expectedResponse); - - ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - Policy policy = Policy.newBuilder().build(); - - Policy actualResponse = client.setIamPolicy(resource, policy); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SetIamPolicyRequest actualRequest = (SetIamPolicyRequest) actualRequests.get(0); - - Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); - Assert.assertEquals(policy, actualRequest.getPolicy()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void setIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - Policy policy = Policy.newBuilder().build(); - - client.setIamPolicy(resource, policy); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void testIamPermissionsTest() { - TestIamPermissionsResponse expectedResponse = TestIamPermissionsResponse.newBuilder().build(); - mockConnectionService.addResponse(expectedResponse); - - ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - List permissions = new ArrayList<>(); - - TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockConnectionService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - TestIamPermissionsRequest actualRequest = (TestIamPermissionsRequest) actualRequests.get(0); - - Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); - Assert.assertEquals(permissions, actualRequest.getPermissionsList()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void testIamPermissionsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockConnectionService.addException(exception); - - try { - ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]"); - List permissions = new ArrayList<>(); - - client.testIamPermissions(resource, permissions); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } -} diff --git a/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigqueryconnection/v1/MockConnectionService.java b/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigqueryconnection/v1/MockConnectionService.java deleted file mode 100644 index 3ef04b3e..00000000 --- a/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigqueryconnection/v1/MockConnectionService.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigqueryconnection.v1; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.protobuf.AbstractMessage; -import io.grpc.ServerServiceDefinition; -import java.util.List; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockConnectionService implements MockGrpcService { - private final MockConnectionServiceImpl serviceImpl; - - public MockConnectionService() { - serviceImpl = new MockConnectionServiceImpl(); - } - - @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/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigqueryconnection/v1/MockConnectionServiceImpl.java b/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigqueryconnection/v1/MockConnectionServiceImpl.java deleted file mode 100644 index cc8f421e..00000000 --- a/google-cloud-bigquery-connection/src/test/java/com/google/cloud/bigqueryconnection/v1/MockConnectionServiceImpl.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.bigqueryconnection.v1; - -import com.google.api.core.BetaApi; -import com.google.cloud.bigquery.connection.v1.Connection; -import com.google.cloud.bigquery.connection.v1.ConnectionServiceGrpc.ConnectionServiceImplBase; -import com.google.cloud.bigquery.connection.v1.CreateConnectionRequest; -import com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest; -import com.google.cloud.bigquery.connection.v1.GetConnectionRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsRequest; -import com.google.cloud.bigquery.connection.v1.ListConnectionsResponse; -import com.google.cloud.bigquery.connection.v1.UpdateConnectionRequest; -import com.google.iam.v1.GetIamPolicyRequest; -import com.google.iam.v1.Policy; -import com.google.iam.v1.SetIamPolicyRequest; -import com.google.iam.v1.TestIamPermissionsRequest; -import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; -import io.grpc.stub.StreamObserver; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockConnectionServiceImpl extends ConnectionServiceImplBase { - private List requests; - private Queue responses; - - public MockConnectionServiceImpl() { - 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 createConnection( - CreateConnectionRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Connection) { - requests.add(request); - responseObserver.onNext((Connection) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getConnection( - GetConnectionRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Connection) { - requests.add(request); - responseObserver.onNext((Connection) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void listConnections( - ListConnectionsRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListConnectionsResponse) { - requests.add(request); - responseObserver.onNext((ListConnectionsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void updateConnection( - UpdateConnectionRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Connection) { - requests.add(request); - responseObserver.onNext((Connection) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void deleteConnection( - DeleteConnectionRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext((Empty) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getIamPolicy(GetIamPolicyRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Policy) { - requests.add(request); - responseObserver.onNext((Policy) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void setIamPolicy(SetIamPolicyRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Policy) { - requests.add(request); - responseObserver.onNext((Policy) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void testIamPermissions( - TestIamPermissionsRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof TestIamPermissionsResponse) { - requests.add(request); - responseObserver.onNext((TestIamPermissionsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } -}