Search in sources :

Example 71 with Connection

use of org.geotoolkit.sml.xml.v100.Connection in project java-bigqueryconnection by googleapis.

the class UpdateConnection method main.

public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "MY_PROJECT_ID";
    String location = "MY_LOCATION";
    String connectionId = "MY_CONNECTION_ID";
    String description = "MY_DESCRIPTION";
    Connection connection = Connection.newBuilder().setDescription(description).build();
    updateConnection(projectId, location, connectionId, connection);
}
Also used : Connection(com.google.cloud.bigquery.connection.v1.Connection)

Example 72 with Connection

use of org.geotoolkit.sml.xml.v100.Connection in project java-bigqueryconnection by googleapis.

the class UpdateConnection method updateConnection.

public static void updateConnection(String projectId, String location, String connectionId, Connection connection) throws IOException {
    try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
        ConnectionName name = ConnectionName.of(projectId, location, connectionId);
        FieldMask updateMask = FieldMaskUtil.fromString("description");
        UpdateConnectionRequest request = UpdateConnectionRequest.newBuilder().setName(name.toString()).setConnection(connection).setUpdateMask(updateMask).build();
        Connection response = client.updateConnection(request);
        System.out.println("Connection updated successfully :" + response.getDescription());
    }
}
Also used : ConnectionName(com.google.cloud.bigquery.connection.v1.ConnectionName) ConnectionServiceClient(com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient) UpdateConnectionRequest(com.google.cloud.bigquery.connection.v1.UpdateConnectionRequest) Connection(com.google.cloud.bigquery.connection.v1.Connection) FieldMask(com.google.protobuf.FieldMask)

Example 73 with Connection

use of org.geotoolkit.sml.xml.v100.Connection in project java-bigqueryconnection by googleapis.

the class CreateAwsConnectionIT method testCreateAwsConnection.

@Test
public void testCreateAwsConnection() throws IOException {
    String iamRoleId = String.format("arn:aws:iam::%s:role/%s", AWS_ACCOUNT_ID, AWS_ROLE_ID);
    AwsAccessRole awsRole = AwsAccessRole.newBuilder().setIamRoleId(iamRoleId).build();
    AwsProperties awsProperties = AwsProperties.newBuilder().setAccessRole(awsRole).build();
    Connection connection = Connection.newBuilder().setAws(awsProperties).build();
    CreateAwsConnection.createAwsConnection(PROJECT_ID, LOCATION, connectionId, connection);
    assertThat(bout.toString()).contains("Aws connection created successfully :");
}
Also used : AwsAccessRole(com.google.cloud.bigquery.connection.v1.AwsAccessRole) AwsProperties(com.google.cloud.bigquery.connection.v1.AwsProperties) Connection(com.google.cloud.bigquery.connection.v1.Connection) Test(org.junit.Test)

Example 74 with Connection

use of org.geotoolkit.sml.xml.v100.Connection in project java-bigqueryconnection by googleapis.

the class ListConnectionsIT method setUp.

@Before
public void setUp() throws IOException {
    bout = new ByteArrayOutputStream();
    out = new PrintStream(bout);
    originalPrintStream = System.out;
    System.setOut(out);
    // create a temporary connection
    connectionId = "LIST_CONNECTIONS_TEST_" + UUID.randomUUID().toString().substring(0, 8);
    String instanceId = String.format("%s:%s:%s", PROJECT_ID, REGION, MY_SQL_INSTANCE);
    CloudSqlCredential cloudSqlCredential = CloudSqlCredential.newBuilder().setUsername(DB_USER).setPassword(DB_PWD).build();
    CloudSqlProperties cloudSqlProperties = CloudSqlProperties.newBuilder().setType(CloudSqlProperties.DatabaseType.MYSQL).setDatabase(MY_SQL_DATABASE).setInstanceId(instanceId).setCredential(cloudSqlCredential).build();
    Connection connection = Connection.newBuilder().setCloudSql(cloudSqlProperties).build();
    CreateConnection.createConnection(PROJECT_ID, LOCATION, connectionId, connection);
}
Also used : PrintStream(java.io.PrintStream) CloudSqlCredential(com.google.cloud.bigquery.connection.v1.CloudSqlCredential) Connection(com.google.cloud.bigquery.connection.v1.Connection) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CloudSqlProperties(com.google.cloud.bigquery.connection.v1.CloudSqlProperties) Before(org.junit.Before)

Example 75 with Connection

use of org.geotoolkit.sml.xml.v100.Connection in project java-bigqueryconnection by googleapis.

the class UpdateConnectionIT method setUp.

@Before
public void setUp() throws IOException {
    bout = new ByteArrayOutputStream();
    out = new PrintStream(bout);
    originalPrintStream = System.out;
    System.setOut(out);
    // create a temporary connection
    connectionId = "UPDATE_CONNECTION_TEST_" + UUID.randomUUID().toString().substring(0, 8);
    String instanceId = String.format("%s:%s:%s", PROJECT_ID, REGION, MY_SQL_INSTANCE);
    CloudSqlCredential cloudSqlCredential = CloudSqlCredential.newBuilder().setUsername(DB_USER).setPassword(DB_PWD).build();
    CloudSqlProperties cloudSqlProperties = CloudSqlProperties.newBuilder().setType(CloudSqlProperties.DatabaseType.MYSQL).setDatabase(MY_SQL_DATABASE).setInstanceId(instanceId).setCredential(cloudSqlCredential).build();
    Connection connection = Connection.newBuilder().setCloudSql(cloudSqlProperties).build();
    CreateConnection.createConnection(PROJECT_ID, LOCATION, connectionId, connection);
}
Also used : PrintStream(java.io.PrintStream) CloudSqlCredential(com.google.cloud.bigquery.connection.v1.CloudSqlCredential) Connection(com.google.cloud.bigquery.connection.v1.Connection) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CloudSqlProperties(com.google.cloud.bigquery.connection.v1.CloudSqlProperties) Before(org.junit.Before)

Aggregations

IOException (java.io.IOException)68 Connection (org.ovirt.engine.sdk4.Connection)64 Connection (com.trilead.ssh2.Connection)61 Connection (org.osate.aadl2.Connection)57 Session (com.trilead.ssh2.Session)33 Connection (org.jboss.remoting3.Connection)33 Connection (com.google.cloud.bigquery.connection.v1.Connection)31 Test (org.junit.Test)30 VmsService (org.ovirt.engine.sdk4.services.VmsService)30 Vm (org.ovirt.engine.sdk4.types.Vm)30 InputStream (java.io.InputStream)29 Connection (okhttp3.Connection)28 Connection (ch.ethz.ssh2.Connection)24 Request (okhttp3.Request)20 Subcomponent (org.osate.aadl2.Subcomponent)19 FeatureGroupConnection (org.osate.aadl2.FeatureGroupConnection)18 PortConnection (org.osate.aadl2.PortConnection)18 VmService (org.ovirt.engine.sdk4.services.VmService)18 ArrayList (java.util.ArrayList)17 Response (okhttp3.Response)17