Skip to content

Commit 71dbda6

Browse files
committed
fix sample indentations
1 parent 7483a57 commit 71dbda6

File tree

2 files changed

+56
-59
lines changed

2 files changed

+56
-59
lines changed

samples/snippets/src/main/java/com/example/spanner/ListRolesSample.java

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,32 @@
2626
import java.util.concurrent.ExecutionException;
2727

2828
public class ListRolesSample {
29-
static void listRoles() throws InterruptedException, ExecutionException {
30-
// TODO(developer): Replace these variables before running the sample.
31-
String projectId = "my-project";
32-
String instanceId = "my-instance";
33-
String databaseId = "my-database";
34-
listRoles(projectId, instanceId, databaseId);
35-
}
29+
static void listRoles() throws InterruptedException, ExecutionException {
30+
// TODO(developer): Replace these variables before running the sample.
31+
String projectId = "my-project";
32+
String instanceId = "my-instance";
33+
String databaseId = "my-database";
34+
listRoles(projectId, instanceId, databaseId);
35+
}
3636

37-
static void listRoles(String projectId, String instanceId, String databaseId) {
38-
try (Spanner spanner =
39-
SpannerOptions.newBuilder()
40-
.setProjectId(projectId)
41-
.build()
42-
.getService()) {
43-
final DatabaseAdminClient adminClient = spanner.getDatabaseAdminClient();
44-
String databasePath = DatabaseId.of(projectId, instanceId, databaseId).getName();
45-
for (DatabaseRole role : adminClient.listDatabaseRoles(instanceId, databaseId).iterateAll()) {
46-
if (!role.getName().startsWith(databasePath + "/databaseRoles/")) {
47-
throw new RuntimeException(
48-
"Role +"
49-
+ role.getName()
50-
+ "does not have prefix ["
51-
+ databasePath
52-
+ "/databaseRoles/"
53-
+ "]");
54-
}
55-
System.out.printf("%s%n", role.getName());
56-
}
37+
static void listRoles(String projectId, String instanceId, String databaseId) {
38+
try (Spanner spanner =
39+
SpannerOptions.newBuilder().setProjectId(projectId).build().getService()) {
40+
final DatabaseAdminClient adminClient = spanner.getDatabaseAdminClient();
41+
String databasePath = DatabaseId.of(projectId, instanceId, databaseId).getName();
42+
for (DatabaseRole role : adminClient.listDatabaseRoles(instanceId, databaseId).iterateAll()) {
43+
if (!role.getName().startsWith(databasePath + "/databaseRoles/")) {
44+
throw new RuntimeException(
45+
"Role +"
46+
+ role.getName()
47+
+ "does not have prefix ["
48+
+ databasePath
49+
+ "/databaseRoles/"
50+
+ "]");
5751
}
52+
System.out.printf("%s%n", role.getName());
53+
}
5854
}
55+
}
5956
}
60-
// [END spanner_list_database_roles]
57+
// [END spanner_list_database_roles]

samples/snippets/src/main/java/com/example/spanner/ReadDataWithRoleSample.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,38 +28,38 @@
2828
import java.util.concurrent.ExecutionException;
2929

3030
public class ReadDataWithRoleSample {
31-
static void readDataWithRole() throws InterruptedException, ExecutionException {
32-
// TODO(developer): Replace these variables before running the sample.
33-
String projectId = "my-project";
34-
String instanceId = "my-instance";
35-
String databaseId = "my-database";
36-
String role = "my-role";
37-
readDataWithRole(projectId, instanceId, databaseId, role);
38-
}
31+
static void readDataWithRole() throws InterruptedException, ExecutionException {
32+
// TODO(developer): Replace these variables before running the sample.
33+
String projectId = "my-project";
34+
String instanceId = "my-instance";
35+
String databaseId = "my-database";
36+
String role = "my-role";
37+
readDataWithRole(projectId, instanceId, databaseId, role);
38+
}
3939

40-
static void readDataWithRole(String projectId, String instanceId, String databaseId, String role)
41-
throws InterruptedException, ExecutionException {
42-
try (Spanner spanner =
43-
SpannerOptions.newBuilder()
44-
.setProjectId(projectId)
45-
.setDatabaseRole(role)
46-
.build()
47-
.getService()) {
48-
final DatabaseClient dbClient =
49-
spanner.getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId));
50-
try (ResultSet resultSet =
51-
dbClient
52-
.singleUse()
53-
.read(
54-
"Albums",
55-
KeySet.all(), // Read all rows in a table.
56-
Arrays.asList("SingerId", "AlbumId", "AlbumTitle"))) {
57-
while (resultSet.next()) {
58-
System.out.printf(
59-
"%d %d %s\n", resultSet.getLong(0), resultSet.getLong(1), resultSet.getString(2));
60-
}
61-
}
40+
static void readDataWithRole(String projectId, String instanceId, String databaseId, String role)
41+
throws InterruptedException, ExecutionException {
42+
try (Spanner spanner =
43+
SpannerOptions.newBuilder()
44+
.setProjectId(projectId)
45+
.setDatabaseRole(role)
46+
.build()
47+
.getService()) {
48+
final DatabaseClient dbClient =
49+
spanner.getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId));
50+
try (ResultSet resultSet =
51+
dbClient
52+
.singleUse()
53+
.read(
54+
"Albums",
55+
KeySet.all(), // Read all rows in a table.
56+
Arrays.asList("SingerId", "AlbumId", "AlbumTitle"))) {
57+
while (resultSet.next()) {
58+
System.out.printf(
59+
"%d %d %s\n", resultSet.getLong(0), resultSet.getLong(1), resultSet.getString(2));
6260
}
61+
}
6362
}
63+
}
6464
}
65-
// [END spanner_read_data_with_database_role]
65+
// [END spanner_read_data_with_database_role]

0 commit comments

Comments
 (0)