diff --git a/jobs/v4/pom.xml b/jobs/v4/pom.xml index d193d2ce329..da9ceaebda9 100644 --- a/jobs/v4/pom.xml +++ b/jobs/v4/pom.xml @@ -24,7 +24,7 @@ - 3.5 + 3.5.4 diff --git a/jobs/v4/src/main/java/com/example/jobs/CommuteSearchJobs.java b/jobs/v4/src/main/java/com/example/jobs/CommuteSearchJobs.java index 2dad6176bcb..e8e8e04b094 100644 --- a/jobs/v4/src/main/java/com/example/jobs/CommuteSearchJobs.java +++ b/jobs/v4/src/main/java/com/example/jobs/CommuteSearchJobs.java @@ -42,6 +42,9 @@ public static void searchJobs() throws IOException { // Search Jobs with histogram queries. public static void searchJobs(String projectId, String tenantId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); String domain = "www.example.com"; @@ -80,11 +83,11 @@ public static void searchJobs(String projectId, String tenantId) throws IOExcept for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) { - System.out.printf("Job summary: %s\n", responseItem.getJobSummary()); - System.out.printf("Job title snippet: %s\n", responseItem.getJobTitleSnippet()); + System.out.format("Job summary: %s%n", responseItem.getJobSummary()); + System.out.format("Job title snippet: %s%n", responseItem.getJobTitleSnippet()); Job job = responseItem.getJob(); - System.out.printf("Job name: %s\n", job.getName()); - System.out.printf("Job title: %s\n", job.getTitle()); + System.out.format("Job name: %s%n", job.getName()); + System.out.format("Job title: %s%n", job.getTitle()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/CustomRankingSearchJobs.java b/jobs/v4/src/main/java/com/example/jobs/CustomRankingSearchJobs.java index dac2f276832..94899b282f4 100644 --- a/jobs/v4/src/main/java/com/example/jobs/CustomRankingSearchJobs.java +++ b/jobs/v4/src/main/java/com/example/jobs/CustomRankingSearchJobs.java @@ -37,6 +37,9 @@ public static void searchCustomRankingJobs() throws IOException { // Search Jobs using custom rankings. public static void searchCustomRankingJobs(String projectId, String tenantId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); String domain = "www.example.com"; @@ -66,11 +69,11 @@ public static void searchCustomRankingJobs(String projectId, String tenantId) th .build(); for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) { - System.out.printf("Job summary: %s\n", responseItem.getJobSummary()); - System.out.printf("Job title snippet: %s\n", responseItem.getJobTitleSnippet()); + System.out.format("Job summary: %s%n", responseItem.getJobSummary()); + System.out.format("Job title snippet: %s%n", responseItem.getJobTitleSnippet()); Job job = responseItem.getJob(); - System.out.printf("Job name: %s\n", job.getName()); - System.out.printf("Job title: %s\n", job.getTitle()); + System.out.format("Job name: %s%n", job.getName()); + System.out.format("Job title: %s%n", job.getTitle()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/HistogramSearchJobs.java b/jobs/v4/src/main/java/com/example/jobs/HistogramSearchJobs.java index 0ec97a2b957..57c34123392 100644 --- a/jobs/v4/src/main/java/com/example/jobs/HistogramSearchJobs.java +++ b/jobs/v4/src/main/java/com/example/jobs/HistogramSearchJobs.java @@ -40,6 +40,9 @@ public static void searchJobs() throws IOException { // Search Jobs with histogram queries. public static void searchJobs(String projectId, String tenantId, String query) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); @@ -63,11 +66,11 @@ public static void searchJobs(String projectId, String tenantId, String query) for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) { - System.out.printf("Job summary: %s\n", responseItem.getJobSummary()); - System.out.printf("Job title snippet: %s\n", responseItem.getJobTitleSnippet()); + System.out.format("Job summary: %s%n", responseItem.getJobSummary()); + System.out.format("Job title snippet: %s%n", responseItem.getJobTitleSnippet()); Job job = responseItem.getJob(); - System.out.printf("Job name: %s\n", job.getName()); - System.out.printf("Job title: %s\n", job.getTitle()); + System.out.format("Job name: %s%n", job.getName()); + System.out.format("Job title: %s%n", job.getTitle()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchAutoCompleteJobTitle.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchAutoCompleteJobTitle.java index 675f32a0002..842d77a05d1 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchAutoCompleteJobTitle.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchAutoCompleteJobTitle.java @@ -37,6 +37,9 @@ public static void completeQuery() throws IOException { // Complete job title given partial text (autocomplete). public static void completeQuery(String projectId, String tenantId, String query) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (CompletionClient completionClient = CompletionClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); CompleteQueryRequest request = @@ -48,9 +51,9 @@ public static void completeQuery(String projectId, String tenantId, String query .build(); CompleteQueryResponse response = completionClient.completeQuery(request); for (CompleteQueryResponse.CompletionResult result : response.getCompletionResultsList()) { - System.out.printf("Suggested title: %s\n", result.getSuggestion()); + System.out.format("Suggested title: %s%n", result.getSuggestion()); // Suggestion type is JOB_TITLE or COMPANY_TITLE - System.out.printf("Suggestion type: %s\n", result.getType()); + System.out.format("Suggestion type: %s%n", result.getType()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateClientEvent.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateClientEvent.java index 5df585cf7e5..d7c835cf147 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateClientEvent.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateClientEvent.java @@ -42,6 +42,9 @@ public static void createClientEvent() throws IOException { // Creates a client event. public static void createClientEvent( String projectId, String tenantId, String requestId, String eventId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (EventServiceClient eventServiceClient = EventServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateCompany.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateCompany.java index f823259e3b9..baa890a51d9 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateCompany.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateCompany.java @@ -38,6 +38,9 @@ public static void createCompany() throws IOException { // Create a company. public static void createCompany( String projectId, String tenantId, String displayName, String externalId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); Company company = @@ -51,9 +54,9 @@ public static void createCompany( Company response = companyServiceClient.createCompany(request); System.out.println("Created Company"); - System.out.printf("Name: %s\n", response.getName()); - System.out.printf("Display Name: %s\n", response.getDisplayName()); - System.out.printf("External ID: %s\n", response.getExternalId()); + System.out.format("Name: %s%n", response.getName()); + System.out.format("Display Name: %s%n", response.getDisplayName()); + System.out.format("External ID: %s%n", response.getExternalId()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java index e7652c5b8ce..ecbc0e9433e 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java @@ -23,8 +23,13 @@ import com.google.cloud.talent.v4beta1.JobServiceClient; import com.google.cloud.talent.v4beta1.TenantName; import java.io.IOException; +import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.Arrays; +import java.util.Calendar; import java.util.List; +import java.util.Locale; public class JobSearchCreateJob { @@ -46,14 +51,21 @@ public static void createJob( String requisitionId, String jobApplicationUrl) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addUris(jobApplicationUrl).build(); - List addresses = Arrays.asList("1600 Amphitheatre Parkway, Mountain View, CA 94043", + List addresses = + Arrays.asList( + "1600 Amphitheatre Parkway, Mountain View, CA 94043", "111 8th Avenue, New York, NY 10011"); + // By default, job will expire in 30 days. + // https://cloud.google.com/talent-solution/job-search/docs/jobs Job job = Job.newBuilder() .setCompany(companyId) @@ -69,7 +81,7 @@ public static void createJob( CreateJobRequest.newBuilder().setParent(parent.toString()).setJob(job).build(); Job response = jobServiceClient.createJob(request); - System.out.printf("Created job: %s\n", response.getName()); + System.out.format("Created job: %s%n", response.getName()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJobCustomAttributes.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJobCustomAttributes.java index 5eeabce8f4e..8c8e1b9dcf5 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJobCustomAttributes.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJobCustomAttributes.java @@ -43,6 +43,9 @@ public static void createJob( String companyId, String requisitionId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateTenant.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateTenant.java index d5389406825..5d9b1a5f46c 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateTenant.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateTenant.java @@ -35,6 +35,9 @@ public static void createTenant() throws IOException { // Create Tenant for scoping resources, e.g. companies and jobs. public static void createTenant(String projectId, String externalId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) { ProjectName parent = ProjectName.of(projectId); Tenant tenant = Tenant.newBuilder().setExternalId(externalId).build(); @@ -44,8 +47,8 @@ public static void createTenant(String projectId, String externalId) throws IOEx Tenant response = tenantServiceClient.createTenant(request); System.out.println("Created Tenant"); - System.out.printf("Name: %s\n", response.getName()); - System.out.printf("External ID: %s\n", response.getExternalId()); + System.out.format("Name: %s%n", response.getName()); + System.out.format("External ID: %s%n", response.getExternalId()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteCompany.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteCompany.java index 18599edc8b6..44d8b33aff6 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteCompany.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteCompany.java @@ -36,6 +36,9 @@ public static void deleteCompany() throws IOException { // Delete Company. public static void deleteCompany(String projectId, String tenantId, String companyId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { CompanyName name = CompanyName.ofProjectTenantCompanyName(projectId, tenantId, companyId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteJob.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteJob.java index 9fc5fd7b32b..82ff8b0a096 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteJob.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteJob.java @@ -35,6 +35,9 @@ public static void deleteJob() throws IOException { // Delete Job. public static void deleteJob(String projectId, String tenantId, String jobId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { JobName name = JobName.ofProjectTenantJobName(projectId, tenantId, jobId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteTenant.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteTenant.java index f984c48d8e6..5d112da04d8 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteTenant.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteTenant.java @@ -34,6 +34,9 @@ public static void deleteTenant() throws IOException { // Delete Tenant. public static void deleteTenant(String projectId, String tenantId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) { TenantName name = TenantName.of(projectId, tenantId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetCompany.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetCompany.java index 6aff009185b..639b15979cc 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetCompany.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetCompany.java @@ -37,14 +37,17 @@ public static void getCompany() throws IOException { // Get Company. public static void getCompany(String projectId, String tenantId, String companyId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { CompanyName name = CompanyName.ofProjectTenantCompanyName(projectId, tenantId, companyId); GetCompanyRequest request = GetCompanyRequest.newBuilder().setName(name.toString()).build(); Company response = companyServiceClient.getCompany(request); - System.out.printf("Company name: %s\n", response.getName()); - System.out.printf("Display name: %s\n", response.getDisplayName()); + System.out.format("Company name: %s%n", response.getName()); + System.out.format("Display name: %s%n", response.getDisplayName()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetJob.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetJob.java index 8d6545a5d94..84a88801792 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetJob.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetJob.java @@ -36,25 +36,28 @@ public static void getJob() throws IOException { // Get Job. public static void getJob(String projectId, String tenantId, String jobId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { JobName name = JobName.ofProjectTenantJobName(projectId, tenantId, jobId); GetJobRequest request = GetJobRequest.newBuilder().setName(name.toString()).build(); Job response = jobServiceClient.getJob(request); - System.out.printf("Job name: %s\n", response.getName()); - System.out.printf("Requisition ID: %s\n", response.getRequisitionId()); - System.out.printf("Title: %s\n", response.getTitle()); - System.out.printf("Description: %s\n", response.getDescription()); - System.out.printf("Posting language: %s\n", response.getLanguageCode()); + System.out.format("Job name: %s%n", response.getName()); + System.out.format("Requisition ID: %s%n", response.getRequisitionId()); + System.out.format("Title: %s%n", response.getTitle()); + System.out.format("Description: %s%n", response.getDescription()); + System.out.format("Posting language: %s%n", response.getLanguageCode()); for (String address : response.getAddressesList()) { - System.out.printf("Address: %s\n", address); + System.out.format("Address: %s%n", address); } for (String email : response.getApplicationInfo().getEmailsList()) { - System.out.printf("Email: %s\n", email); + System.out.format("Email: %s%n", email); } for (String websiteUri : response.getApplicationInfo().getUrisList()) { - System.out.printf("Website: %s\n", websiteUri); + System.out.format("Website: %s%n", websiteUri); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetTenant.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetTenant.java index c59f90e27a8..527ba34d295 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetTenant.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetTenant.java @@ -35,14 +35,17 @@ public static void getTenant() throws IOException { // Get Tenant by name. public static void getTenant(String projectId, String tenantId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) { TenantName name = TenantName.of(projectId, tenantId); GetTenantRequest request = GetTenantRequest.newBuilder().setName(name.toString()).build(); Tenant response = tenantServiceClient.getTenant(request); - System.out.printf("Name: %s\n", response.getName()); - System.out.printf("External ID: %s\n", response.getExternalId()); + System.out.format("Name: %s%n", response.getName()); + System.out.format("External ID: %s%n", response.getExternalId()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchListCompanies.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchListCompanies.java index 4e9878f7d9e..cef24dc2087 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchListCompanies.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchListCompanies.java @@ -35,6 +35,9 @@ public static void listCompanies() throws IOException { // List Companies. public static void listCompanies(String projectId, String tenantId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); @@ -42,9 +45,9 @@ public static void listCompanies(String projectId, String tenantId) throws IOExc ListCompaniesRequest.newBuilder().setParent(parent.toString()).build(); for (Company responseItem : companyServiceClient.listCompanies(request).iterateAll()) { - System.out.printf("Company Name: %s\n", responseItem.getName()); - System.out.printf("Display Name: %s\n", responseItem.getDisplayName()); - System.out.printf("External ID: %s\n", responseItem.getExternalId()); + System.out.format("Company Name: %s%n", responseItem.getName()); + System.out.format("Display Name: %s%n", responseItem.getDisplayName()); + System.out.format("External ID: %s%n", responseItem.getExternalId()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchListJobs.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchListJobs.java index df1342c843c..81f844226ea 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchListJobs.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchListJobs.java @@ -36,15 +36,18 @@ public static void listJobs() throws IOException { // Search Jobs with histogram queries. public static void listJobs(String projectId, String tenantId, String filter) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); ListJobsRequest request = ListJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build(); for (Job responseItem : jobServiceClient.listJobs(request).iterateAll()) { - System.out.printf("Job name: %s\n", responseItem.getName()); - System.out.printf("Job requisition ID: %s\n", responseItem.getRequisitionId()); - System.out.printf("Job title: %s\n", responseItem.getTitle()); - System.out.printf("Job description: %s\n", responseItem.getDescription()); + System.out.format("Job name: %s%n", responseItem.getName()); + System.out.format("Job requisition ID: %s%n", responseItem.getRequisitionId()); + System.out.format("Job title: %s%n", responseItem.getTitle()); + System.out.format("Job description: %s%n", responseItem.getDescription()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchListTenants.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchListTenants.java index 565e75e4714..4b0be36b2cf 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchListTenants.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchListTenants.java @@ -34,6 +34,9 @@ public static void listTenants() throws IOException { // List Tenants. public static void listTenants(String projectId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) { ProjectName parent = ProjectName.of(projectId); @@ -41,8 +44,8 @@ public static void listTenants(String projectId) throws IOException { ListTenantsRequest.newBuilder().setParent(parent.toString()).build(); for (Tenant responseItem : tenantServiceClient.listTenants(request).iterateAll()) { - System.out.printf("Tenant Name: %s\n", responseItem.getName()); - System.out.printf("External ID: %s\n", responseItem.getExternalId()); + System.out.format("Tenant Name: %s%n", responseItem.getName()); + System.out.format("External ID: %s%n", responseItem.getExternalId()); } } }