Class EssentialContactsServiceClient
- All Implemented Interfaces:
BackgroundResource,AutoCloseable
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (EssentialContactsServiceClient essentialContactsServiceClient =
EssentialContactsServiceClient.create()) {
FolderName parent = FolderName.of("[FOLDER]");
Contact contact = Contact.newBuilder().build();
Contact response = essentialContactsServiceClient.createContact(parent, contact);
}
Note: close() needs to be called on the EssentialContactsServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
CreateContact |
Adds a new contact for a resource. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateContact |
Updates a contact. Note: A contact's email address cannot be changed. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListContacts |
Lists the contacts that have been set on a resource. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetContact |
Gets a single contact. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteContact |
Deletes a contact. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ComputeContacts |
Lists all contacts for the resource that are subscribed to the specified notification categories, including contacts inherited from any parent resources. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
SendTestMessage |
Allows a contact admin to send a test message to contact to verify that it has been configured correctly. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of EssentialContactsServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
EssentialContactsServiceSettings essentialContactsServiceSettings =
EssentialContactsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
EssentialContactsServiceClient essentialContactsServiceClient =
EssentialContactsServiceClient.create(essentialContactsServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
EssentialContactsServiceSettings essentialContactsServiceSettings =
EssentialContactsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
EssentialContactsServiceClient essentialContactsServiceClient =
EssentialContactsServiceClient.create(essentialContactsServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
EssentialContactsServiceSettings essentialContactsServiceSettings =
EssentialContactsServiceSettings.newHttpJsonBuilder().build();
EssentialContactsServiceClient essentialContactsServiceClient =
EssentialContactsServiceClient.create(essentialContactsServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an instance of EssentialContactsServiceClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long duration, TimeUnit unit) final voidclose()computeContacts(ComputeContactsRequest request) Lists all contacts for the resource that are subscribed to the specified notification categories, including contacts inherited from any parent resources.Lists all contacts for the resource that are subscribed to the specified notification categories, including contacts inherited from any parent resources.final UnaryCallable<ComputeContactsRequest,EssentialContactsServiceClient.ComputeContactsPagedResponse> Lists all contacts for the resource that are subscribed to the specified notification categories, including contacts inherited from any parent resources.static final EssentialContactsServiceClientcreate()Constructs an instance of EssentialContactsServiceClient with default settings.static final EssentialContactsServiceClientcreate(EssentialContactsServiceSettings settings) Constructs an instance of EssentialContactsServiceClient, using the given settings.static final EssentialContactsServiceClientConstructs an instance of EssentialContactsServiceClient, using the given stub for making calls.final ContactcreateContact(CreateContactRequest request) Adds a new contact for a resource.final ContactcreateContact(FolderName parent, Contact contact) Adds a new contact for a resource.final ContactcreateContact(OrganizationName parent, Contact contact) Adds a new contact for a resource.final ContactcreateContact(ProjectName parent, Contact contact) Adds a new contact for a resource.final ContactcreateContact(String parent, Contact contact) Adds a new contact for a resource.Adds a new contact for a resource.final voiddeleteContact(ContactName name) Deletes a contact.final voiddeleteContact(DeleteContactRequest request) Deletes a contact.final voiddeleteContact(String name) Deletes a contact.final UnaryCallable<DeleteContactRequest,com.google.protobuf.Empty> Deletes a contact.final ContactgetContact(ContactName name) Gets a single contact.final ContactgetContact(GetContactRequest request) Gets a single contact.final ContactgetContact(String name) Gets a single contact.Gets a single contact.getStub()booleanbooleanlistContacts(FolderName parent) Lists the contacts that have been set on a resource.listContacts(ListContactsRequest request) Lists the contacts that have been set on a resource.listContacts(OrganizationName parent) Lists the contacts that have been set on a resource.listContacts(ProjectName parent) Lists the contacts that have been set on a resource.listContacts(String parent) Lists the contacts that have been set on a resource.Lists the contacts that have been set on a resource.Lists the contacts that have been set on a resource.final voidsendTestMessage(SendTestMessageRequest request) Allows a contact admin to send a test message to contact to verify that it has been configured correctly.final UnaryCallable<SendTestMessageRequest,com.google.protobuf.Empty> Allows a contact admin to send a test message to contact to verify that it has been configured correctly.voidshutdown()voidfinal ContactupdateContact(Contact contact, com.google.protobuf.FieldMask updateMask) Updates a contact.final ContactupdateContact(UpdateContactRequest request) Updates a contact.Updates a contact.
-
Constructor Details
-
EssentialContactsServiceClient
protected EssentialContactsServiceClient(EssentialContactsServiceSettings settings) throws IOException Constructs an instance of EssentialContactsServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.- Throws:
IOException
-
EssentialContactsServiceClient
-
-
Method Details
-
create
Constructs an instance of EssentialContactsServiceClient with default settings.- Throws:
IOException
-
create
public static final EssentialContactsServiceClient create(EssentialContactsServiceSettings settings) throws IOException Constructs an instance of EssentialContactsServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.- Throws:
IOException
-
create
Constructs an instance of EssentialContactsServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(EssentialContactsServiceSettings). -
getSettings
-
getStub
-
createContact
Adds a new contact for a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { FolderName parent = FolderName.of("[FOLDER]"); Contact contact = Contact.newBuilder().build(); Contact response = essentialContactsServiceClient.createContact(parent, contact); }- Parameters:
parent- Required. The resource to save this contact for. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id}contact- Required. The contact to create. Must specify an email address and language tag.- Throws:
ApiException- if the remote call fails
-
createContact
Adds a new contact for a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); Contact contact = Contact.newBuilder().build(); Contact response = essentialContactsServiceClient.createContact(parent, contact); }- Parameters:
parent- Required. The resource to save this contact for. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id}contact- Required. The contact to create. Must specify an email address and language tag.- Throws:
ApiException- if the remote call fails
-
createContact
Adds a new contact for a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { ProjectName parent = ProjectName.of("[PROJECT]"); Contact contact = Contact.newBuilder().build(); Contact response = essentialContactsServiceClient.createContact(parent, contact); }- Parameters:
parent- Required. The resource to save this contact for. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id}contact- Required. The contact to create. Must specify an email address and language tag.- Throws:
ApiException- if the remote call fails
-
createContact
Adds a new contact for a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { String parent = ProjectName.of("[PROJECT]").toString(); Contact contact = Contact.newBuilder().build(); Contact response = essentialContactsServiceClient.createContact(parent, contact); }- Parameters:
parent- Required. The resource to save this contact for. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id}contact- Required. The contact to create. Must specify an email address and language tag.- Throws:
ApiException- if the remote call fails
-
createContact
Adds a new contact for a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { CreateContactRequest request = CreateContactRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setContact(Contact.newBuilder().build()) .build(); Contact response = essentialContactsServiceClient.createContact(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
createContactCallable
Adds a new contact for a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { CreateContactRequest request = CreateContactRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setContact(Contact.newBuilder().build()) .build(); ApiFuture<Contact> future = essentialContactsServiceClient.createContactCallable().futureCall(request); // Do something. Contact response = future.get(); } -
updateContact
Updates a contact. Note: A contact's email address cannot be changed.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { Contact contact = Contact.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); Contact response = essentialContactsServiceClient.updateContact(contact, updateMask); }- Parameters:
contact- Required. The contact resource to replace the existing saved contact. Note: the email address of the contact cannot be modified.updateMask- Optional. The update mask applied to the resource. For the `FieldMask` definition, see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask- Throws:
ApiException- if the remote call fails
-
updateContact
Updates a contact. Note: A contact's email address cannot be changed.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { UpdateContactRequest request = UpdateContactRequest.newBuilder() .setContact(Contact.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); Contact response = essentialContactsServiceClient.updateContact(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
updateContactCallable
Updates a contact. Note: A contact's email address cannot be changed.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { UpdateContactRequest request = UpdateContactRequest.newBuilder() .setContact(Contact.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); ApiFuture<Contact> future = essentialContactsServiceClient.updateContactCallable().futureCall(request); // Do something. Contact response = future.get(); } -
listContacts
public final EssentialContactsServiceClient.ListContactsPagedResponse listContacts(FolderName parent) Lists the contacts that have been set on a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { FolderName parent = FolderName.of("[FOLDER]"); for (Contact element : essentialContactsServiceClient.listContacts(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The parent resource name. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id}- Throws:
ApiException- if the remote call fails
-
listContacts
public final EssentialContactsServiceClient.ListContactsPagedResponse listContacts(OrganizationName parent) Lists the contacts that have been set on a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); for (Contact element : essentialContactsServiceClient.listContacts(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The parent resource name. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id}- Throws:
ApiException- if the remote call fails
-
listContacts
public final EssentialContactsServiceClient.ListContactsPagedResponse listContacts(ProjectName parent) Lists the contacts that have been set on a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { ProjectName parent = ProjectName.of("[PROJECT]"); for (Contact element : essentialContactsServiceClient.listContacts(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The parent resource name. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id}- Throws:
ApiException- if the remote call fails
-
listContacts
Lists the contacts that have been set on a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { String parent = ProjectName.of("[PROJECT]").toString(); for (Contact element : essentialContactsServiceClient.listContacts(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The parent resource name. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id}- Throws:
ApiException- if the remote call fails
-
listContacts
public final EssentialContactsServiceClient.ListContactsPagedResponse listContacts(ListContactsRequest request) Lists the contacts that have been set on a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { ListContactsRequest request = ListContactsRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (Contact element : essentialContactsServiceClient.listContacts(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listContactsPagedCallable
public final UnaryCallable<ListContactsRequest,EssentialContactsServiceClient.ListContactsPagedResponse> listContactsPagedCallable()Lists the contacts that have been set on a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { ListContactsRequest request = ListContactsRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<Contact> future = essentialContactsServiceClient.listContactsPagedCallable().futureCall(request); // Do something. for (Contact element : future.get().iterateAll()) { // doThingsWith(element); } } -
listContactsCallable
Lists the contacts that have been set on a resource.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { ListContactsRequest request = ListContactsRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ListContactsResponse response = essentialContactsServiceClient.listContactsCallable().call(request); for (Contact element : response.getContactsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
getContact
Gets a single contact.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { ContactName name = ContactName.ofProjectContactName("[PROJECT]", "[CONTACT]"); Contact response = essentialContactsServiceClient.getContact(name); }- Parameters:
name- Required. The name of the contact to retrieve. Format: organizations/{organization_id}/contacts/{contact_id}, folders/{folder_id}/contacts/{contact_id} or projects/{project_id}/contacts/{contact_id}- Throws:
ApiException- if the remote call fails
-
getContact
Gets a single contact.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { String name = ContactName.ofProjectContactName("[PROJECT]", "[CONTACT]").toString(); Contact response = essentialContactsServiceClient.getContact(name); }- Parameters:
name- Required. The name of the contact to retrieve. Format: organizations/{organization_id}/contacts/{contact_id}, folders/{folder_id}/contacts/{contact_id} or projects/{project_id}/contacts/{contact_id}- Throws:
ApiException- if the remote call fails
-
getContact
Gets a single contact.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { GetContactRequest request = GetContactRequest.newBuilder() .setName(ContactName.ofProjectContactName("[PROJECT]", "[CONTACT]").toString()) .build(); Contact response = essentialContactsServiceClient.getContact(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getContactCallable
Gets a single contact.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { GetContactRequest request = GetContactRequest.newBuilder() .setName(ContactName.ofProjectContactName("[PROJECT]", "[CONTACT]").toString()) .build(); ApiFuture<Contact> future = essentialContactsServiceClient.getContactCallable().futureCall(request); // Do something. Contact response = future.get(); } -
deleteContact
Deletes a contact.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { ContactName name = ContactName.ofProjectContactName("[PROJECT]", "[CONTACT]"); essentialContactsServiceClient.deleteContact(name); }- Parameters:
name- Required. The name of the contact to delete. Format: organizations/{organization_id}/contacts/{contact_id}, folders/{folder_id}/contacts/{contact_id} or projects/{project_id}/contacts/{contact_id}- Throws:
ApiException- if the remote call fails
-
deleteContact
Deletes a contact.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { String name = ContactName.ofProjectContactName("[PROJECT]", "[CONTACT]").toString(); essentialContactsServiceClient.deleteContact(name); }- Parameters:
name- Required. The name of the contact to delete. Format: organizations/{organization_id}/contacts/{contact_id}, folders/{folder_id}/contacts/{contact_id} or projects/{project_id}/contacts/{contact_id}- Throws:
ApiException- if the remote call fails
-
deleteContact
Deletes a contact.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { DeleteContactRequest request = DeleteContactRequest.newBuilder() .setName(ContactName.ofProjectContactName("[PROJECT]", "[CONTACT]").toString()) .build(); essentialContactsServiceClient.deleteContact(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
deleteContactCallable
Deletes a contact.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { DeleteContactRequest request = DeleteContactRequest.newBuilder() .setName(ContactName.ofProjectContactName("[PROJECT]", "[CONTACT]").toString()) .build(); ApiFuture<Empty> future = essentialContactsServiceClient.deleteContactCallable().futureCall(request); // Do something. future.get(); } -
computeContacts
public final EssentialContactsServiceClient.ComputeContactsPagedResponse computeContacts(ComputeContactsRequest request) Lists all contacts for the resource that are subscribed to the specified notification categories, including contacts inherited from any parent resources.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { ComputeContactsRequest request = ComputeContactsRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .addAllNotificationCategories(new ArrayList<NotificationCategory>()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); for (Contact element : essentialContactsServiceClient.computeContacts(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
computeContactsPagedCallable
public final UnaryCallable<ComputeContactsRequest,EssentialContactsServiceClient.ComputeContactsPagedResponse> computeContactsPagedCallable()Lists all contacts for the resource that are subscribed to the specified notification categories, including contacts inherited from any parent resources.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { ComputeContactsRequest request = ComputeContactsRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .addAllNotificationCategories(new ArrayList<NotificationCategory>()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); ApiFuture<Contact> future = essentialContactsServiceClient.computeContactsPagedCallable().futureCall(request); // Do something. for (Contact element : future.get().iterateAll()) { // doThingsWith(element); } } -
computeContactsCallable
public final UnaryCallable<ComputeContactsRequest,ComputeContactsResponse> computeContactsCallable()Lists all contacts for the resource that are subscribed to the specified notification categories, including contacts inherited from any parent resources.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { ComputeContactsRequest request = ComputeContactsRequest.newBuilder() .setParent(ProjectName.of("[PROJECT]").toString()) .addAllNotificationCategories(new ArrayList<NotificationCategory>()) .setPageSize(883849137) .setPageToken("pageToken873572522") .build(); while (true) { ComputeContactsResponse response = essentialContactsServiceClient.computeContactsCallable().call(request); for (Contact element : response.getContactsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
sendTestMessage
Allows a contact admin to send a test message to contact to verify that it has been configured correctly.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { SendTestMessageRequest request = SendTestMessageRequest.newBuilder() .addAllContacts(new ArrayList<String>()) .setResource(ProjectName.of("[PROJECT]").toString()) .setNotificationCategory(NotificationCategory.forNumber(0)) .build(); essentialContactsServiceClient.sendTestMessage(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
sendTestMessageCallable
public final UnaryCallable<SendTestMessageRequest,com.google.protobuf.Empty> sendTestMessageCallable()Allows a contact admin to send a test message to contact to verify that it has been configured correctly.Sample code:
// This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library try (EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.create()) { SendTestMessageRequest request = SendTestMessageRequest.newBuilder() .addAllContacts(new ArrayList<String>()) .setResource(ProjectName.of("[PROJECT]").toString()) .setNotificationCategory(NotificationCategory.forNumber(0)) .build(); ApiFuture<Empty> future = essentialContactsServiceClient.sendTestMessageCallable().futureCall(request); // Do something. future.get(); } -
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceBackgroundResource
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceBackgroundResource
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceBackgroundResource
-
shutdownNow
public void shutdownNow()- Specified by:
shutdownNowin interfaceBackgroundResource
-
awaitTermination
- Specified by:
awaitTerminationin interfaceBackgroundResource- Throws:
InterruptedException
-