Struct gsuite_api::Client
source · pub struct Client { /* private fields */ }
Expand description
Entrypoint for interacting with the API client.
Implementations§
source§impl Client
impl Client
sourcepub fn new<I, K, R, T, Q>(
client_id: I,
client_secret: K,
redirect_uri: R,
token: T,
refresh_token: Q
) -> Selfwhere
I: ToString,
K: ToString,
R: ToString,
T: ToString,
Q: ToString,
pub fn new<I, K, R, T, Q>( client_id: I, client_secret: K, redirect_uri: R, token: T, refresh_token: Q ) -> Selfwhere I: ToString, K: ToString, R: ToString, T: ToString, Q: ToString,
Create a new Client struct. Requires OAuth2 configuration values as well as an access and refresh token.
Panics
This function will panic if the internal http client fails to create
sourcepub fn set_auto_access_token_refresh(&mut self, enabled: bool) -> &mut Self
pub fn set_auto_access_token_refresh(&mut self, enabled: bool) -> &mut Self
Enables or disables the automatic refreshing of access tokens upon expiration
sourcepub async fn set_expires_at(&self, expires_at: Option<Instant>) -> &Self
pub async fn set_expires_at(&self, expires_at: Option<Instant>) -> &Self
Sets a specific Instant
at which the access token should be considered expired.
The expiration value will only be used when automatic access token refreshing is
also enabled. None
may be passed in if the expiration is unknown. In this case
automatic refreshes will be attempted when encountering an UNAUTHENTICATED status
code on a response.
sourcepub async fn expires_at(&self) -> Option<Instant>
pub async fn expires_at(&self) -> Option<Instant>
Gets the Instant
at which the access token used by this client is set to expire
if one is known
sourcepub async fn set_expires_in(&self, expires_in: i64) -> &Self
pub async fn set_expires_in(&self, expires_in: i64) -> &Self
Sets the number of seconds in which the current access token should be considered expired
sourcepub async fn expires_in(&self) -> Option<Duration>
pub async fn expires_in(&self) -> Option<Duration>
Gets the number of seconds from now in which the current access token will be considered expired if one is known
sourcepub async fn is_expired(&self) -> Option<bool>
pub async fn is_expired(&self) -> Option<bool>
Determines if the access token currently stored in the client is expired. If the expiration can not be determined, None is returned
sourcepub fn with_host_override<H>(&mut self, host: H) -> &mut Selfwhere
H: ToString,
pub fn with_host_override<H>(&mut self, host: H) -> &mut Selfwhere H: ToString,
Override the host for all endpoins in the client.
sourcepub fn remove_host_override(&mut self) -> &mut Self
pub fn remove_host_override(&mut self) -> &mut Self
Disables the global host override for the client.
pub fn get_host_override(&self) -> Option<&str>
sourcepub async fn new_from_env<T, R>(token: T, refresh_token: R) -> Selfwhere
T: ToString,
R: ToString,
pub async fn new_from_env<T, R>(token: T, refresh_token: R) -> Selfwhere T: ToString, R: ToString,
Create a new Client struct from environment variables. Requires an existing access and refresh token
The following environment variables are expected to be set:
GOOGLE_KEY_ENCODED
- A base64 encoded version of JSON formatted application secret
Panics
This function will panic if an application secret can not be parsed from the encoded key
This function will panic if the internal http client fails to create
sourcepub fn user_consent_url(&self, scopes: &[String]) -> String
pub fn user_consent_url(&self, scopes: &[String]) -> String
Return a user consent url with an optional set of scopes. If no scopes are provided, they will not be passed in the url.
sourcepub async fn refresh_access_token(&self) -> Result<AccessToken, ClientError>
pub async fn refresh_access_token(&self) -> Result<AccessToken, ClientError>
Refresh an access token from a refresh token. Client must have a refresh token for this to work.
sourcepub async fn get_access_token(
&mut self,
code: &str,
state: &str
) -> Result<AccessToken, ClientError>
pub async fn get_access_token( &mut self, code: &str, state: &str ) -> Result<AccessToken, ClientError>
Get an access token from the code returned by the URL paramter sent to the redirect URL.
sourcepub fn asps(&self) -> Asps
pub fn asps(&self) -> Asps
Return a reference to an interface that provides access to asps operations.
sourcepub fn channels(&self) -> Channels
pub fn channels(&self) -> Channels
Return a reference to an interface that provides access to channels operations.
sourcepub fn chromeosdevices(&self) -> Chromeosdevices
pub fn chromeosdevices(&self) -> Chromeosdevices
Return a reference to an interface that provides access to chromeosdevices operations.
sourcepub fn customer(&self) -> Customer
pub fn customer(&self) -> Customer
Return a reference to an interface that provides access to customer operations.
sourcepub fn customers(&self) -> Customers
pub fn customers(&self) -> Customers
Return a reference to an interface that provides access to customers operations.
sourcepub fn domain_aliases(&self) -> DomainAliases
pub fn domain_aliases(&self) -> DomainAliases
Return a reference to an interface that provides access to domainAliases operations.
sourcepub fn domains(&self) -> Domains
pub fn domains(&self) -> Domains
Return a reference to an interface that provides access to domains operations.
sourcepub fn groups(&self) -> Groups
pub fn groups(&self) -> Groups
Return a reference to an interface that provides access to groups operations.
sourcepub fn members(&self) -> Members
pub fn members(&self) -> Members
Return a reference to an interface that provides access to members operations.
sourcepub fn mobiledevices(&self) -> Mobiledevices
pub fn mobiledevices(&self) -> Mobiledevices
Return a reference to an interface that provides access to mobiledevices operations.
sourcepub fn orgunits(&self) -> Orgunits
pub fn orgunits(&self) -> Orgunits
Return a reference to an interface that provides access to orgunits operations.
sourcepub fn privileges(&self) -> Privileges
pub fn privileges(&self) -> Privileges
Return a reference to an interface that provides access to privileges operations.
sourcepub fn resources(&self) -> Resources
pub fn resources(&self) -> Resources
Return a reference to an interface that provides access to resources operations.
sourcepub fn role_assignments(&self) -> RoleAssignments
pub fn role_assignments(&self) -> RoleAssignments
Return a reference to an interface that provides access to roleAssignments operations.
sourcepub fn roles(&self) -> Roles
pub fn roles(&self) -> Roles
Return a reference to an interface that provides access to roles operations.
sourcepub fn schemas(&self) -> Schemas
pub fn schemas(&self) -> Schemas
Return a reference to an interface that provides access to schemas operations.
sourcepub fn tokens(&self) -> Tokens
pub fn tokens(&self) -> Tokens
Return a reference to an interface that provides access to tokens operations.
sourcepub fn two_step_verification(&self) -> TwoStepVerification
pub fn two_step_verification(&self) -> TwoStepVerification
Return a reference to an interface that provides access to twoStepVerification operations.
sourcepub fn users(&self) -> Users
pub fn users(&self) -> Users
Return a reference to an interface that provides access to users operations.
sourcepub fn verification_codes(&self) -> VerificationCodes
pub fn verification_codes(&self) -> VerificationCodes
Return a reference to an interface that provides access to verificationCodes operations.