use of com.google.cloud.bigquery.connection.v1.CloudSqlProperties 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);
}
use of com.google.cloud.bigquery.connection.v1.CloudSqlProperties 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);
}
use of com.google.cloud.bigquery.connection.v1.CloudSqlProperties in project java-bigqueryconnection by googleapis.
the class ITSystemTest method setUp.
@Before
public void setUp() throws IOException {
client = ConnectionServiceClient.create();
// create a temporary connection to be deleted
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();
CreateConnectionRequest request = CreateConnectionRequest.newBuilder().setParent(PARENT).setConnection(Connection.newBuilder().setCloudSql(cloudSqlProperties).build()).setConnectionId(CONNECTION_ID).build();
connection = client.createConnection(request);
}
use of com.google.cloud.bigquery.connection.v1.CloudSqlProperties in project java-bigqueryconnection by googleapis.
the class CreateConnection 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 database = "MY_DATABASE";
String instance = "MY_INSTANCE";
String instanceLocation = "MY_INSTANCE_LOCATION";
String username = "MY_USERNAME";
String password = "MY_PASSWORD";
String instanceId = String.format("%s:%s:%s", projectId, instanceLocation, instance);
CloudSqlCredential cloudSqlCredential = CloudSqlCredential.newBuilder().setUsername(username).setPassword(password).build();
CloudSqlProperties cloudSqlProperties = CloudSqlProperties.newBuilder().setType(CloudSqlProperties.DatabaseType.MYSQL).setDatabase(database).setInstanceId(instanceId).setCredential(cloudSqlCredential).build();
Connection connection = Connection.newBuilder().setCloudSql(cloudSqlProperties).build();
createConnection(projectId, location, connectionId, connection);
}
use of com.google.cloud.bigquery.connection.v1.CloudSqlProperties in project java-bigqueryconnection by googleapis.
the class CreateConnectionIT method testCreateConnection.
@Test
public void testCreateConnection() throws IOException {
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().setFriendlyName(connectionId).setCloudSql(cloudSqlProperties).build();
CreateConnection.createConnection(PROJECT_ID, LOCATION, connectionId, connection);
assertThat(bout.toString()).contains("Connection created successfully :");
}
Aggregations