Skip to content

Commit 4d6a3b1

Browse files
authored
chore: delint/reformat files (googleworkspace#258)
chore: delint/reformat files
1 parent 6b09f7c commit 4d6a3b1

File tree

232 files changed

+7451
-7657
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+7451
-7657
lines changed

Diff for: .github/pull_request_template.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Description
22

3-
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
3+
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
4+
List any dependencies that are required for this change.
45

56
Fixes # (issue)
67

78
## Is it been tested?
9+
810
- [ ] Development testing done
911

1012
## Checklist

Diff for: .github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
name: Lint
15-
on: [push, pull_request, workflow_dispatch]
15+
on: [ push, pull_request, workflow_dispatch ]
1616

1717
jobs:
1818
lint:

Diff for: .github/workflows/test.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
name: Test
1616

17-
on: [push, pull_request, workflow_dispatch]
17+
on: [ push, pull_request, workflow_dispatch ]
1818

1919
jobs:
2020
matrix:
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
matrix:
2929
# TODO - expand matrix once stable
30-
java-version: [11]
30+
java-version: [ 11 ]
3131
steps:
3232
- uses: actions/checkout@v3
3333
- name: Fetch and Diff PR with base from which it was cloned
@@ -59,7 +59,7 @@ jobs:
5959
- name: Run tests
6060
run: ./.github/scripts/test.sh
6161
test:
62-
needs: [matrix]
62+
needs: [ matrix ]
6363
runs-on: ubuntu-latest
6464
steps:
65-
- run: echo "Test matrix finished"
65+
- run: echo "Test matrix finished"

Diff for: CONTRIBUTING.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ Please fill out either the individual or corporate Contributor License
1111
Agreement.
1212

1313
* If you are an individual writing original source code and you're sure you
14-
own the intellectual property, then sign an [individual CLA](https://developers.google.com/open-source/cla/individual).
14+
own the intellectual property, then sign an [individual CLA](https://developers.google.com/open-source/cla/individual)
15+
.
1516
* If you work for a company that wants to allow you to contribute your work,
16-
then sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate).
17+
then sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate).
1718

1819
Follow either of the two links above to access the appropriate CLA and
1920
instructions for how to sign and return it.

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Google Workspace Java Samples
2+
13
A collection of samples that demonstrate how to call Google Workspace APIs in Java.
24

35
## APIs

Diff for: SECURITY.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Report a security issue
22

3-
To report a security issue, please use https://g.co/vulnz. We use
4-
https://g.co/vulnz for our intake, and do coordination and disclosure here on
3+
To report a security issue, please use [https://g.co/vulnz](https://g.co/vulnz). We use
4+
[https://g.co/vulnz](https://g.co/vulnz) for our intake, and do coordination and disclosure here on
55
GitHub (including using GitHub Security Advisory). The Google Security Team will
6-
respond within 5 working days of your report on g.co/vulnz.
6+
respond within 5 working days of your report on [https://g.co/vulnz](https://g.co/vulnz).

Diff for: adminSDK/alertcenter/quickstart/src/main/java/AdminSDKAlertCenterQuickstart.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@
3535
import java.util.List;
3636

3737
public class AdminSDKAlertCenterQuickstart {
38-
/** Application name. */
39-
private static final String APPLICATION_NAME = "Google Admin SDK Alert Center API Java Quickstart";
40-
/** Global instance of the JSON factory. */
38+
/**
39+
* Application name.
40+
*/
41+
private static final String APPLICATION_NAME =
42+
"Google Admin SDK Alert Center API Java Quickstart";
43+
/**
44+
* Global instance of the JSON factory.
45+
*/
4146
private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
4247

4348
/**

Diff for: adminSDK/directory/quickstart/src/main/java/AdminSDKDirectoryQuickstart.java

+67-56
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
// [START admin_sdk_directory_quickstart]
16+
1617
import com.google.api.client.auth.oauth2.Credential;
1718
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
1819
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
@@ -27,7 +28,6 @@
2728
import com.google.api.services.admin.directory.DirectoryScopes;
2829
import com.google.api.services.admin.directory.model.User;
2930
import com.google.api.services.admin.directory.model.Users;
30-
3131
import java.io.FileNotFoundException;
3232
import java.io.IOException;
3333
import java.io.InputStream;
@@ -37,66 +37,77 @@
3737
import java.util.List;
3838

3939
public class AdminSDKDirectoryQuickstart {
40-
/** Application name. */
41-
private static final String APPLICATION_NAME = "Google Admin SDK Directory API Java Quickstart";
42-
/** Global instance of the JSON factory. */
43-
private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
44-
/** Directory to store authorization tokens for this application. */
45-
private static final String TOKENS_DIRECTORY_PATH = "tokens";
40+
/**
41+
* Application name.
42+
*/
43+
private static final String APPLICATION_NAME = "Google Admin SDK Directory API Java Quickstart";
44+
/**
45+
* Global instance of the JSON factory.
46+
*/
47+
private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
48+
/**
49+
* Directory to store authorization tokens for this application.
50+
*/
51+
private static final String TOKENS_DIRECTORY_PATH = "tokens";
4652

47-
/**
48-
* Global instance of the scopes required by this quickstart.
49-
* If modifying these scopes, delete your previously saved tokens/ folder.
50-
*/
51-
private static final List<String> SCOPES = Collections.singletonList(DirectoryScopes.ADMIN_DIRECTORY_USER_READONLY);
52-
private static final String CREDENTIALS_FILE_PATH = "/credentials.json";
53+
/**
54+
* Global instance of the scopes required by this quickstart.
55+
* If modifying these scopes, delete your previously saved tokens/ folder.
56+
*/
57+
private static final List<String> SCOPES =
58+
Collections.singletonList(DirectoryScopes.ADMIN_DIRECTORY_USER_READONLY);
59+
private static final String CREDENTIALS_FILE_PATH = "/credentials.json";
5360

54-
/**
55-
* Creates an authorized Credential object.
56-
* @param HTTP_TRANSPORT The network HTTP Transport.
57-
* @return An authorized Credential object.
58-
* @throws IOException If the credentials.json file cannot be found.
59-
*/
60-
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException {
61-
// Load client secrets.
62-
InputStream in = AdminSDKDirectoryQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
63-
if (in == null) {
64-
throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH);
65-
}
66-
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
67-
68-
// Build flow and trigger user authorization request.
69-
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
70-
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
71-
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
72-
.setAccessType("offline")
73-
.build();
74-
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();
75-
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
61+
/**
62+
* Creates an authorized Credential object.
63+
*
64+
* @param HTTP_TRANSPORT The network HTTP Transport.
65+
* @return An authorized Credential object.
66+
* @throws IOException If the credentials.json file cannot be found.
67+
*/
68+
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT)
69+
throws IOException {
70+
// Load client secrets.
71+
InputStream in = AdminSDKDirectoryQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
72+
if (in == null) {
73+
throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH);
7674
}
75+
GoogleClientSecrets clientSecrets =
76+
GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
77+
78+
// Build flow and trigger user authorization request.
79+
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
80+
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
81+
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
82+
.setAccessType("offline")
83+
.build();
84+
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();
85+
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
86+
}
7787

78-
public static void main(String... args) throws IOException, GeneralSecurityException {
79-
// Build a new authorized API client service.
80-
final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
81-
Directory service = new Directory.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
82-
.setApplicationName(APPLICATION_NAME)
83-
.build();
88+
public static void main(String... args) throws IOException, GeneralSecurityException {
89+
// Build a new authorized API client service.
90+
final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
91+
Directory service =
92+
new Directory.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
93+
.setApplicationName(APPLICATION_NAME)
94+
.build();
8495

85-
// Print the first 10 users in the domain.
86-
Users result = service.users().list()
87-
.setCustomer("my_customer")
88-
.setMaxResults(10)
89-
.setOrderBy("email")
90-
.execute();
91-
List<User> users = result.getUsers();
92-
if (users == null || users.size() == 0) {
93-
System.out.println("No users found.");
94-
} else {
95-
System.out.println("Users:");
96-
for (User user : users) {
97-
System.out.println(user.getName().getFullName());
98-
}
99-
}
96+
// Print the first 10 users in the domain.
97+
Users result = service.users().list()
98+
.setCustomer("my_customer")
99+
.setMaxResults(10)
100+
.setOrderBy("email")
101+
.execute();
102+
List<User> users = result.getUsers();
103+
if (users == null || users.size() == 0) {
104+
System.out.println("No users found.");
105+
} else {
106+
System.out.println("Users:");
107+
for (User user : users) {
108+
System.out.println(user.getName().getFullName());
109+
}
100110
}
111+
}
101112
}
102113
// [END admin_sdk_directory_quickstart]

Diff for: adminSDK/groups-settings/quickstart/src/main/java/GroupsSettingsQuickstart.java

+57-51
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
// [START admin_sdk_groups_settings_quickstart]
16+
1617
import com.google.api.client.auth.oauth2.Credential;
1718
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
1819
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
@@ -35,63 +36,68 @@
3536
import java.util.List;
3637

3738
public class GroupsSettingsQuickstart {
38-
private static final String APPLICATION_NAME = "Google Admin SDK Group Settings API Java Quickstart";
39-
private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
40-
private static final String TOKENS_DIRECTORY_PATH = "tokens";
41-
42-
/**
43-
* Global instance of the scopes required by this quickstart.
44-
* If modifying these scopes, delete your previously saved tokens/ folder.
45-
*/
46-
private static final List<String> SCOPES = Collections.singletonList(
47-
"https://www.googleapis.com/auth/apps.groups.settings");
48-
private static final String CREDENTIALS_FILE_PATH = "/credentials.json";
39+
private static final String APPLICATION_NAME =
40+
"Google Admin SDK Group Settings API Java Quickstart";
41+
private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
42+
private static final String TOKENS_DIRECTORY_PATH = "tokens";
4943

50-
/**
51-
* Creates an authorized Credential object.
52-
* @param HTTP_TRANSPORT The network HTTP Transport.
53-
* @return An authorized Credential object.
54-
* @throws IOException If the credentials.json file cannot be found.
55-
*/
56-
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException {
57-
// Load client secrets.
58-
InputStream in = GroupsSettingsQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
59-
if (in == null) {
60-
throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH);
61-
}
62-
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
44+
/**
45+
* Global instance of the scopes required by this quickstart.
46+
* If modifying these scopes, delete your previously saved tokens/ folder.
47+
*/
48+
private static final List<String> SCOPES = Collections.singletonList(
49+
"https://www.googleapis.com/auth/apps.groups.settings");
50+
private static final String CREDENTIALS_FILE_PATH = "/credentials.json";
6351

64-
// Build flow and trigger user authorization request.
65-
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
66-
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
67-
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
68-
.setAccessType("offline")
69-
.build();
70-
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();
71-
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
52+
/**
53+
* Creates an authorized Credential object.
54+
*
55+
* @param HTTP_TRANSPORT The network HTTP Transport.
56+
* @return An authorized Credential object.
57+
* @throws IOException If the credentials.json file cannot be found.
58+
*/
59+
private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT)
60+
throws IOException {
61+
// Load client secrets.
62+
InputStream in = GroupsSettingsQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
63+
if (in == null) {
64+
throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH);
7265
}
66+
GoogleClientSecrets clientSecrets =
67+
GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
7368

74-
public static void main(String... args) throws IOException, GeneralSecurityException {
75-
// Build a new authorized API client service.
76-
final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
77-
Groupssettings service = new Groupssettings.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
78-
.setApplicationName(APPLICATION_NAME)
79-
.build();
69+
// Build flow and trigger user authorization request.
70+
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
71+
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
72+
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
73+
.setAccessType("offline")
74+
.build();
75+
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();
76+
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
77+
}
8078

81-
// API is ready to use
79+
public static void main(String... args) throws IOException, GeneralSecurityException {
80+
// Build a new authorized API client service.
81+
final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
82+
Groupssettings service =
83+
new Groupssettings.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
84+
.setApplicationName(APPLICATION_NAME)
85+
.build();
8286

83-
if (args.length == 0) {
84-
System.out.println("No group email specified.");
85-
return;
86-
}
87-
try {
88-
String groupEmail = args[0];
89-
Groups settings = service.groups().get(groupEmail).execute();
90-
System.out.println(String.format("Description: %s", settings.getDescription()));
91-
} catch (Exception e) {
92-
// TODO(developer) - Handle errors
93-
e.printStackTrace();
94-
}
87+
// API is ready to use
88+
89+
if (args.length == 0) {
90+
System.out.println("No group email specified.");
91+
return;
92+
}
93+
try {
94+
String groupEmail = args[0];
95+
Groups settings = service.groups().get(groupEmail).execute();
96+
System.out.println(String.format("Description: %s", settings.getDescription()));
97+
} catch (Exception e) {
98+
// TODO(developer) - Handle errors
99+
e.printStackTrace();
95100
}
101+
}
96102
}
97103
// [END admin_sdk_groups_settings_quickstart]

0 commit comments

Comments
 (0)