pub struct EssentialContactsService { /* private fields */ }Expand description
Implements a client for the Essential Contacts API.
§Example
use google_cloud_gax::paginator::ItemPaginator as _;
async fn sample(
project_id: &str,
) -> anyhow::Result<()> {
let client = EssentialContactsService::builder().build().await?;
let mut list = client.list_contacts()
.set_parent(format!("projects/{project_id}"))
.by_item();
while let Some(item) = list.next().await.transpose()? {
println!("{:?}", item);
}
Ok(())
}§Service Description
Manages contacts for important Google Cloud notifications.
§Configuration
To configure EssentialContactsService use the with_* methods in the type returned
by builder(). The default configuration should
work for most applications. Common configuration changes include
- with_endpoint(): by default this client uses the global default endpoint
(
https://essentialcontacts.googleapis.com). Applications using regional endpoints or running in restricted networks (e.g. a network configured with Private Google Access with VPC Service Controls) may want to override this default. - with_credentials(): by default this client uses Application Default Credentials. Applications using custom authentication may need to override this default.
§Pooling and Cloning
EssentialContactsService holds a connection pool internally, it is advised to
create one and reuse it. You do not need to wrap EssentialContactsService in
an Rc or Arc to reuse it, because it
already uses an Arc internally.
Implementations§
Source§impl EssentialContactsService
impl EssentialContactsService
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a builder for EssentialContactsService.
let client = EssentialContactsService::builder().build().await?;Sourcepub fn from_stub<T>(stub: impl Into<Arc<T>>) -> Selfwhere
T: EssentialContactsService + 'static,
pub fn from_stub<T>(stub: impl Into<Arc<T>>) -> Selfwhere
T: EssentialContactsService + 'static,
Creates a new client from the provided stub.
The most common case for calling this function is in tests mocking the client’s behavior.
Sourcepub fn create_contact(&self) -> CreateContact
pub fn create_contact(&self) -> CreateContact
Adds a new contact for a resource.
§Example
use google_cloud_essentialcontacts_v1::model::Contact;
use google_cloud_essentialcontacts_v1::Result;
async fn sample(
client: &EssentialContactsService, project_id: &str
) -> Result<()> {
let response = client.create_contact()
.set_parent(format!("projects/{project_id}"))
.set_contact(
Contact::new()/* set fields */
)
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn update_contact(&self) -> UpdateContact
pub fn update_contact(&self) -> UpdateContact
Updates a contact. Note: A contact’s email address cannot be changed.
§Example
use google_cloud_wkt::FieldMask;
use google_cloud_essentialcontacts_v1::model::Contact;
use google_cloud_essentialcontacts_v1::Result;
async fn sample(
client: &EssentialContactsService, project_id: &str, contact_id: &str
) -> Result<()> {
let response = client.update_contact()
.set_contact(
Contact::new().set_name(format!("projects/{project_id}/contacts/{contact_id}"))/* set fields */
)
.set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn list_contacts(&self) -> ListContacts
pub fn list_contacts(&self) -> ListContacts
Lists the contacts that have been set on a resource.
§Example
use google_cloud_gax::paginator::ItemPaginator as _;
use google_cloud_essentialcontacts_v1::Result;
async fn sample(
client: &EssentialContactsService, project_id: &str
) -> Result<()> {
let mut list = client.list_contacts()
.set_parent(format!("projects/{project_id}"))
.by_item();
while let Some(item) = list.next().await.transpose()? {
println!("{:?}", item);
}
Ok(())
}Sourcepub fn get_contact(&self) -> GetContact
pub fn get_contact(&self) -> GetContact
Gets a single contact.
§Example
use google_cloud_essentialcontacts_v1::Result;
async fn sample(
client: &EssentialContactsService, project_id: &str, contact_id: &str
) -> Result<()> {
let response = client.get_contact()
.set_name(format!("projects/{project_id}/contacts/{contact_id}"))
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn delete_contact(&self) -> DeleteContact
pub fn delete_contact(&self) -> DeleteContact
Deletes a contact.
§Example
use google_cloud_essentialcontacts_v1::Result;
async fn sample(
client: &EssentialContactsService, project_id: &str, contact_id: &str
) -> Result<()> {
client.delete_contact()
.set_name(format!("projects/{project_id}/contacts/{contact_id}"))
.send().await?;
Ok(())
}Sourcepub fn compute_contacts(&self) -> ComputeContacts
pub fn compute_contacts(&self) -> ComputeContacts
Lists all contacts for the resource that are subscribed to the specified notification categories, including contacts inherited from any parent resources.
§Example
use google_cloud_gax::paginator::ItemPaginator as _;
use google_cloud_essentialcontacts_v1::Result;
async fn sample(
client: &EssentialContactsService
) -> Result<()> {
let mut list = client.compute_contacts()
/* set fields */
.by_item();
while let Some(item) = list.next().await.transpose()? {
println!("{:?}", item);
}
Ok(())
}Sourcepub fn send_test_message(&self) -> SendTestMessage
pub fn send_test_message(&self) -> SendTestMessage
Allows a contact admin to send a test message to contact to verify that it has been configured correctly.
§Example
use google_cloud_essentialcontacts_v1::Result;
async fn sample(
client: &EssentialContactsService
) -> Result<()> {
client.send_test_message()
/* set fields */
.send().await?;
Ok(())
}Trait Implementations§
Source§impl Clone for EssentialContactsService
impl Clone for EssentialContactsService
Source§fn clone(&self) -> EssentialContactsService
fn clone(&self) -> EssentialContactsService
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more