1717package com .example .analytics ;
1818
1919/* This application demonstrates the usage of the Analytics Admin API using
20- service account credentials. For more information on service accounts, see
21- https://cloud.google.com/iam/docs/understanding-service-accounts
20+ service account credentials. For more information on service accounts, see
21+ https://cloud.google.com/iam/docs/understanding-service-accounts
2222
23- The following document provides instructions on setting service account
24- credentials for your application:
25- https://cloud.google.com/docs/authentication/production
23+ The following document provides instructions on setting service account
24+ credentials for your application:
25+ https://cloud.google.com/docs/authentication/production
2626
27- In a nutshell, you need to:
27+ In a nutshell, you need to:
2828
29- 1. Create a service account and download the key JSON file.
30- https://cloud.google.com/docs/authentication/production#creating_a_service_account
29+ 1. Create a service account and download the key JSON file.
30+ https://cloud.google.com/docs/authentication/production#creating_a_service_account
3131
32- 2. Provide service account credentials using one of the following options:
33- - set the GOOGLE_APPLICATION_CREDENTIALS environment variable, the API
34- client will use the value of this variable to find the service account key
35- JSON file.
32+ 2. Provide service account credentials using one of the following options:
33+ - set the GOOGLE_APPLICATION_CREDENTIALS environment variable, the API
34+ client will use the value of this variable to find the service account key
35+ JSON file.
3636
37- https://cloud.google.com/docs/authentication/production#setting_the_environment_variable
37+ https://cloud.google.com/docs/authentication/production#setting_the_environment_variable
3838
39- OR
39+ OR
4040
41- - manually pass the path to the service account key JSON file to the API client
42- by specifying the keyFilename parameter in the constructor.
43- https://cloud.google.com/docs/authentication/production#passing_the_path_to_the_service_account_key_in_code
41+ - manually pass the path to the service account key JSON file to the API client
42+ by specifying the keyFilename parameter in the constructor.
43+ https://cloud.google.com/docs/authentication/production#passing_the_path_to_the_service_account_key_in_code
4444
45- To run this sample using Maven:
46- cd java-analytics-admin/samples/snippets
47- mvn exec:java -Dexec.mainClass="com.example.analytics.QuickstartSample"
48- */
45+ To run this sample using Maven:
46+ cd java-analytics-admin/samples/snippets
47+ mvn exec:java -Dexec.mainClass="com.example.analytics.QuickstartSample"
48+ */
4949
5050// [START analytics_admin_quickstart]
5151
@@ -61,7 +61,6 @@ public static void main(String... args) throws Exception {
6161 listAccounts ();
6262 }
6363
64-
6564 // This is an example snippet that calls the Google Analytics Admin API and lists all Google
6665 // Analytics accounts available to the authenticated user.
6766 static void listAccounts () throws Exception {
@@ -71,8 +70,8 @@ static void listAccounts() throws Exception {
7170 try (AnalyticsAdminServiceClient analyticsAdmin = AnalyticsAdminServiceClient .create ()) {
7271 // Calls listAccounts() method of the Google Analytics Admin API and prints
7372 // the response for each account.
74- ListAccountsPagedResponse response = analyticsAdmin
75- .listAccounts (ListAccountsRequest .newBuilder ().build ());
73+ ListAccountsPagedResponse response =
74+ analyticsAdmin .listAccounts (ListAccountsRequest .newBuilder ().build ());
7675 for (ListAccountsPage page : response .iteratePages ()) {
7776 for (Account account : page .iterateAll ()) {
7877 System .out .printf ("Account name: %s%n" , account .getName ());
0 commit comments