Struct GraphClient

Source
pub struct GraphClient { /* private fields */ }

Implementations§

Source§

impl GraphClient

Source

pub fn new<AT: ToString>(access_token: AT) -> GraphClient

Source

pub fn from_client_app<CA: ClientApplication + 'static>( client_app: CA, ) -> GraphClient

Source

pub fn v1(&mut self) -> &mut GraphClient

Use the v1 endpoint for the Microsoft Graph API. This is the default endpoint used by the client.

§Example
use graph_rs_sdk::Graph;

let mut client = Graph::new("ACCESS_TOKEN");

client.v1()
    .me()
    .get_user()
    .send()
    .await?;
Source

pub fn use_v1(&mut self)

Use the v1 endpoint for the Microsoft Graph API. Same as calling v1() but takes a mutable reference to self and does not return self.

§Example
use graph_rs_sdk::Graph;

let mut client = Graph::new("ACCESS_TOKEN");
client.use_v1();

assert_eq!(client.url().to_string(), GRAPH_URL.to_string())
Source

pub fn beta(&mut self) -> &mut GraphClient

Use the beta endpoint for the Microsoft Graph API

§Example
use graph_rs_sdk::Graph;

let mut client = Graph::new("ACCESS_TOKEN");

client.beta()
    .me()
    .get_user()
    .send()
    .await?;
Source

pub fn use_beta(&mut self)

Use the beta endpoint for the Microsoft Graph API. Same as calling beta() but takes a mutable reference to self and does not return self.

Example

use graph_rs_sdk::Graph;

let mut client = Graph::new("ACCESS_TOKEN");
client.use_beta();

assert_eq!(client.url().to_string(), GRAPH_URL_BETA.to_string())
Source

pub fn url(&self) -> &Url

Source

pub fn with_force_token_refresh( &mut self, force_token_refresh: ForceTokenRefresh, ) -> &mut Self

Source

pub fn use_force_token_refresh( &mut self, force_token_refresh: ForceTokenRefresh, )

Source

pub fn custom_endpoint(&mut self, url: &Url) -> &mut GraphClient

Set a custom endpoint for the Microsoft Graph API. Provide the scheme and host with an optional path. The path is not set by the sdk when using a custom endpoint.

The scheme must be https:// and any other provided scheme will cause a panic. See Microsoft Graph Service Root Endpoints

Attempting to use an invalid host will cause the client to panic. This is done for increased security.

Do not use a government host endpoint without authorization and any necessary clearances. Using any government host endpoint means you should expect every API call will be monitored and recorded.

You should also assume China’s Graph API operated by 21Vianet is being monitored by the Chinese government who is well known for the control it has over Chinese companies and for its surveillance state of Chinese citizens. And, according to Microsoft, These services are subject to Chinese laws. See Microsoft 365 operated by 21Vianet

Valid Hosts:

  • graph.microsoft.com (Default public endpoint worldwide)
  • graph.microsoft.us (U.S. Government)
  • dod-graph.microsoft.us (U.S. Department Of Defense)
  • graph.microsoft.de
  • microsoftgraph.chinacloudapi.cn (operated by 21Vianet)
  • canary.graph.microsoft.com

Example

use graph_rs_sdk::Graph;

let mut client = Graph::new("ACCESS_TOKEN");

client.custom_endpoint("https://graph.microsoft.com/v1.0")
    .me()
    .get_user()
    .send()
    .await?;
Source

pub fn use_endpoint(&mut self, url: &Url)

Set a custom endpoint for the Microsoft Graph API. Provide the scheme and host with an optional path. The path is not set by the sdk when using a custom endpoint.

The scheme must be https:// and any other provided scheme will cause a panic. See Microsoft Graph Service Root Endpoints

Attempting to use an invalid host will cause the client to panic. This is done for increased security.

Do not use a government host endpoint without authorization and any necessary clearances. Using any government host endpoint means you should expect every API call will be monitored and recorded.

You should also assume China’s Graph API operated by 21Vianet is being monitored by the Chinese government who is well known for the control it has over Chinese companies and for its surveillance state of Chinese citizens. And, according to Microsoft, These services are subject to Chinese laws. See Microsoft 365 operated by 21Vianet

Valid Hosts:

  • graph.microsoft.com (Default public endpoint worldwide)
  • graph.microsoft.us (U.S. Government)
  • dod-graph.microsoft.us (U.S. Department Of Defense)
  • graph.microsoft.de
  • microsoftgraph.chinacloudapi.cn (operated by 21Vianet)
  • canary.graph.microsoft.com

Example

use url::Url;
use graph_rs_sdk::Graph;

let mut client = Graph::new("ACCESS_TOKEN");
client.use_endpoint(&Url::parse("https://graph.microsoft.com/v1.0").unwrap());

assert_eq!(client.url().to_string(), "https://graph.microsoft.com/v1.0".to_string())
Source

pub fn admin(&self) -> AdminApiClient

Source

pub fn app_catalogs(&self) -> AppCatalogsApiClient

Source

pub fn agreement_acceptances(&self) -> AgreementAcceptancesApiClient

Source

pub fn agreement_acceptance<S: AsRef<str>>( &self, id: S, ) -> AgreementAcceptancesIdApiClient

Source

pub fn agreements(&self) -> AgreementsApiClient

Source

pub fn agreement<S: AsRef<str>>(&self, id: S) -> AgreementsIdApiClient

Source

pub fn applications(&self) -> ApplicationsApiClient

Source

pub fn application<S: AsRef<str>>(&self, id: S) -> ApplicationsIdApiClient

Source

pub fn audit_logs(&self) -> AuditLogsApiClient

Source

pub fn authentication_method_configurations( &self, ) -> AuthenticationMethodConfigurationsApiClient

Source

pub fn authentication_method_configuration<S: AsRef<str>>( &self, id: S, ) -> AuthenticationMethodConfigurationsIdApiClient

Source

pub fn authentication_methods_policy( &self, ) -> AuthenticationMethodsPolicyApiClient

Source

pub fn branding(&self) -> BrandingApiClient

Source

pub fn certificate_based_auth_configurations( &self, ) -> CertificateBasedAuthConfigurationApiClient

Source

pub fn certificate_based_auth_configuration<S: AsRef<str>>( &self, id: S, ) -> CertificateBasedAuthConfigurationIdApiClient

Source

pub fn chats(&self) -> ChatsApiClient

Source

pub fn chat<S: AsRef<str>>(&self, id: S) -> ChatsIdApiClient

Source

pub fn communications(&self) -> CommunicationsApiClient

Source

pub fn contracts(&self) -> ContractsApiClient

Source

pub fn contract<S: AsRef<str>>(&self, id: S) -> ContractsIdApiClient

Source

pub fn data_policy_operations(&self) -> DataPolicyOperationsApiClient

Source

pub fn device_app_management(&self) -> DeviceAppManagementApiClient

Source

pub fn device_management(&self) -> DeviceManagementApiClient

Source

pub fn devices(&self) -> DevicesApiClient

Source

pub fn device<S: AsRef<str>>(&self, id: S) -> DevicesIdApiClient

Source

pub fn directory(&self) -> DirectoryApiClient

Source

pub fn directory_objects(&self) -> DirectoryObjectsApiClient

Source

pub fn directory_object<S: AsRef<str>>( &self, id: S, ) -> DirectoryObjectsIdApiClient

Source

pub fn directory_role_templates(&self) -> DirectoryRoleTemplatesApiClient

Source

pub fn directory_role_template<S: AsRef<str>>( &self, id: S, ) -> DirectoryRoleTemplatesIdApiClient

Source

pub fn directory_roles(&self) -> DirectoryRolesApiClient

Source

pub fn directory_role<S: AsRef<str>>(&self, id: S) -> DirectoryRolesIdApiClient

Source

pub fn domain_dns_records(&self) -> DomainDnsRecordsApiClient

Source

pub fn domain_dns_record<S: AsRef<str>>( &self, id: S, ) -> DomainDnsRecordsIdApiClient

Source

pub fn domains(&self) -> DomainsApiClient

Source

pub fn domain<S: AsRef<str>>(&self, id: S) -> DomainsIdApiClient

Source

pub fn drives(&self) -> DrivesApiClient

Source

pub fn drive<S: AsRef<str>>(&self, id: S) -> DrivesIdApiClient

Source

pub fn default_drive(&self) -> DefaultDriveApiClient

Source

pub fn education(&self) -> EducationApiClient

Source

pub fn groups(&self) -> GroupsApiClient

Source

pub fn group<S: AsRef<str>>(&self, id: S) -> GroupsIdApiClient

Source

pub fn group_lifecycle_policies(&self) -> GroupLifecyclePoliciesApiClient

Source

pub fn group_lifecycle_policy<S: AsRef<str>>( &self, id: S, ) -> GroupLifecyclePoliciesIdApiClient

Source

pub fn identity(&self) -> IdentityApiClient

Source

pub fn identity_governance(&self) -> IdentityGovernanceApiClient

Source

pub fn identity_providers(&self) -> IdentityProvidersApiClient

Source

pub fn identity_provider<S: AsRef<str>>( &self, id: S, ) -> IdentityProvidersIdApiClient

Source

pub fn invitations(&self) -> InvitationsApiClient

Source

pub fn me(&self) -> MeApiClient

Source

pub fn oauth2_permission_grants(&self) -> Oauth2PermissionGrantsApiClient

Source

pub fn oauth2_permission_grant<S: AsRef<str>>( &self, id: S, ) -> Oauth2PermissionGrantsIdApiClient

Source

pub fn organizations(&self) -> OrganizationApiClient

Source

pub fn organization<S: AsRef<str>>(&self, id: S) -> OrganizationIdApiClient

Source

pub fn places(&self) -> PlacesApiClient

Source

pub fn permission_grants(&self) -> PermissionGrantsApiClient

Source

pub fn permission_grant<S: AsRef<str>>( &self, id: S, ) -> PermissionGrantsIdApiClient

Source

pub fn planner(&self) -> PlannerApiClient

Source

pub fn policies(&self) -> PoliciesApiClient

Source

pub fn reports(&self) -> ReportsApiClient

Source

pub fn schema_extensions(&self) -> SchemaExtensionsApiClient

Source

pub fn schema_extension<S: AsRef<str>>( &self, id: S, ) -> SchemaExtensionsIdApiClient

Source

pub fn service_principals(&self) -> ServicePrincipalsApiClient

Source

pub fn service_principal<S: AsRef<str>>( &self, id: S, ) -> ServicePrincipalsIdApiClient

Source

pub fn sites(&self) -> SitesApiClient

Source

pub fn site<S: AsRef<str>>(&self, id: S) -> SitesIdApiClient

Source

pub fn solutions(&self) -> SolutionsApiClient

Source

pub fn subscribed_skus(&self) -> SubscribedSkusApiClient

Source

pub fn subscribed_sku<S: AsRef<str>>(&self, id: S) -> SubscriptionsIdApiClient

Source

pub fn subscriptions(&self) -> SubscriptionsApiClient

Source

pub fn subscription<S: AsRef<str>>(&self, id: S) -> SubscriptionsIdApiClient

Source

pub fn teams(&self) -> TeamsApiClient

Source

pub fn team<S: AsRef<str>>(&self, id: S) -> TeamsIdApiClient

Source

pub fn teams_templates(&self) -> TeamsTemplatesApiClient

Source

pub fn teams_template<S: AsRef<str>>(&self, id: S) -> TeamsTemplatesIdApiClient

Source

pub fn teamwork(&self) -> TeamworkApiClient

Source

pub fn users(&self) -> UsersApiClient

Source

pub fn user<S: AsRef<str>>(&self, id: S) -> UsersIdApiClient

Source

pub fn custom(&self, method: Method, body: Option<BodyRead>) -> RequestHandler

Source

pub fn batch<B: Serialize>(&self, batch: &B) -> RequestHandler

Trait Implementations§

Source§

impl Clone for GraphClient

Source§

fn clone(&self) -> GraphClient

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GraphClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&ConfidentialClientApplication<AuthorizationCodeAssertionCredential>> for GraphClient

Source§

fn from( value: &ConfidentialClientApplication<AuthorizationCodeAssertionCredential>, ) -> Self

Converts to this type from the input type.
Source§

impl From<&ConfidentialClientApplication<AuthorizationCodeCertificateCredential>> for GraphClient

Source§

fn from( value: &ConfidentialClientApplication<AuthorizationCodeCertificateCredential>, ) -> Self

Converts to this type from the input type.
Source§

impl From<&ConfidentialClientApplication<AuthorizationCodeCredential>> for GraphClient

Source§

fn from( value: &ConfidentialClientApplication<AuthorizationCodeCredential>, ) -> Self

Converts to this type from the input type.
Source§

impl From<&ConfidentialClientApplication<ClientAssertionCredential>> for GraphClient

Source§

fn from( value: &ConfidentialClientApplication<ClientAssertionCredential>, ) -> Self

Converts to this type from the input type.
Source§

impl From<&ConfidentialClientApplication<ClientCertificateCredential>> for GraphClient

Source§

fn from( value: &ConfidentialClientApplication<ClientCertificateCredential>, ) -> Self

Converts to this type from the input type.
Source§

impl From<&ConfidentialClientApplication<ClientSecretCredential>> for GraphClient

Source§

fn from(value: &ConfidentialClientApplication<ClientSecretCredential>) -> Self

Converts to this type from the input type.
Source§

impl From<&ConfidentialClientApplication<OpenIdCredential>> for GraphClient

Source§

fn from(value: &ConfidentialClientApplication<OpenIdCredential>) -> Self

Converts to this type from the input type.
Source§

impl From<&PublicClientApplication<AuthorizationCodeSpaCredential>> for GraphClient

Source§

fn from(value: &PublicClientApplication<AuthorizationCodeSpaCredential>) -> Self

Converts to this type from the input type.
Source§

impl From<&PublicClientApplication<DeviceCodeCredential>> for GraphClient

Source§

fn from(value: &PublicClientApplication<DeviceCodeCredential>) -> Self

Converts to this type from the input type.
Source§

impl From<&PublicClientApplication<ResourceOwnerPasswordCredential>> for GraphClient

Source§

fn from( value: &PublicClientApplication<ResourceOwnerPasswordCredential>, ) -> Self

Converts to this type from the input type.
Source§

impl From<&Token> for GraphClient

Source§

fn from(token: &Token) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for GraphClient

Source§

fn from(token: &str) -> Self

Converts to this type from the input type.
Source§

impl From<GraphClientConfiguration> for GraphClient

Source§

fn from(graph_client_builder: GraphClientConfiguration) -> Self

Converts to this type from the input type.
Source§

impl From<String> for GraphClient

Source§

fn from(token: String) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more