Search in sources :

Example 6 with CloudSqlCredential

use of com.google.cloud.bigquery.connection.v1.CloudSqlCredential in project java-bigqueryconnection by googleapis.

the class DeleteConnectionIT 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 = "DELETE_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)

Example 7 with CloudSqlCredential

use of com.google.cloud.bigquery.connection.v1.CloudSqlCredential in project java-bigqueryconnection by googleapis.

the class GetConnectionIT 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 = "GET_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)

Example 8 with CloudSqlCredential

use of com.google.cloud.bigquery.connection.v1.CloudSqlCredential in project java-bigqueryconnection by googleapis.

the class ShareConnectionIT 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 = "SHARE_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

CloudSqlCredential (com.google.cloud.bigquery.connection.v1.CloudSqlCredential)8 CloudSqlProperties (com.google.cloud.bigquery.connection.v1.CloudSqlProperties)8 Connection (com.google.cloud.bigquery.connection.v1.Connection)7 Before (org.junit.Before)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 PrintStream (java.io.PrintStream)5 CreateConnectionRequest (com.google.cloud.bigquery.connection.v1.CreateConnectionRequest)1 Test (org.junit.Test)1