Struct ServiceAccountsAPI

Source
pub struct ServiceAccountsAPI { /* private fields */ }
Expand description

Create, edit, and disable service accounts. See the Service Accounts page for more information.

Implementations§

Source§

impl ServiceAccountsAPI

Source

pub fn new() -> Self

Source

pub fn with_config(config: Configuration) -> Self

Examples found in repository?
examples/v2_service-accounts_ListServiceAccountApplicationKeys.rs (line 11)
7async fn main() {
8    // there is a valid "service_account_user" in the system
9    let service_account_user_data_id = std::env::var("SERVICE_ACCOUNT_USER_DATA_ID").unwrap();
10    let configuration = datadog::Configuration::new();
11    let api = ServiceAccountsAPI::with_config(configuration);
12    let resp = api
13        .list_service_account_application_keys(
14            service_account_user_data_id.clone(),
15            ListServiceAccountApplicationKeysOptionalParams::default(),
16        )
17        .await;
18    if let Ok(value) = resp {
19        println!("{:#?}", value);
20    } else {
21        println!("{:#?}", resp.unwrap_err());
22    }
23}
More examples
Hide additional examples
examples/v2_service-accounts_CreateServiceAccountApplicationKey.rs (line 18)
10async fn main() {
11    // there is a valid "service_account_user" in the system
12    let service_account_user_data_id = std::env::var("SERVICE_ACCOUNT_USER_DATA_ID").unwrap();
13    let body = ApplicationKeyCreateRequest::new(ApplicationKeyCreateData::new(
14        ApplicationKeyCreateAttributes::new("Example-Service-Account".to_string()),
15        ApplicationKeysType::APPLICATION_KEYS,
16    ));
17    let configuration = datadog::Configuration::new();
18    let api = ServiceAccountsAPI::with_config(configuration);
19    let resp = api
20        .create_service_account_application_key(service_account_user_data_id.clone(), body)
21        .await;
22    if let Ok(value) = resp {
23        println!("{:#?}", value);
24    } else {
25        println!("{:#?}", resp.unwrap_err());
26    }
27}
examples/v2_service-accounts_GetServiceAccountApplicationKey.rs (line 14)
6async fn main() {
7    // there is a valid "service_account_user" in the system
8    let service_account_user_data_id = std::env::var("SERVICE_ACCOUNT_USER_DATA_ID").unwrap();
9
10    // there is a valid "service_account_application_key" for "service_account_user"
11    let service_account_application_key_data_id =
12        std::env::var("SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID").unwrap();
13    let configuration = datadog::Configuration::new();
14    let api = ServiceAccountsAPI::with_config(configuration);
15    let resp = api
16        .get_service_account_application_key(
17            service_account_user_data_id.clone(),
18            service_account_application_key_data_id.clone(),
19        )
20        .await;
21    if let Ok(value) = resp {
22        println!("{:#?}", value);
23    } else {
24        println!("{:#?}", resp.unwrap_err());
25    }
26}
examples/v2_service-accounts_DeleteServiceAccountApplicationKey.rs (line 14)
6async fn main() {
7    // there is a valid "service_account_user" in the system
8    let service_account_user_data_id = std::env::var("SERVICE_ACCOUNT_USER_DATA_ID").unwrap();
9
10    // there is a valid "service_account_application_key" for "service_account_user"
11    let service_account_application_key_data_id =
12        std::env::var("SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID").unwrap();
13    let configuration = datadog::Configuration::new();
14    let api = ServiceAccountsAPI::with_config(configuration);
15    let resp = api
16        .delete_service_account_application_key(
17            service_account_user_data_id.clone(),
18            service_account_application_key_data_id.clone(),
19        )
20        .await;
21    if let Ok(value) = resp {
22        println!("{:#?}", value);
23    } else {
24        println!("{:#?}", resp.unwrap_err());
25    }
26}
examples/v2_service-accounts_CreateServiceAccountApplicationKey_3480494373.rs (line 25)
11async fn main() {
12    // there is a valid "service_account_user" in the system
13    let service_account_user_data_id = std::env::var("SERVICE_ACCOUNT_USER_DATA_ID").unwrap();
14    let body = ApplicationKeyCreateRequest::new(ApplicationKeyCreateData::new(
15        ApplicationKeyCreateAttributes::new("Example-Service-Account".to_string()).scopes(Some(
16            vec![
17                "dashboards_read".to_string(),
18                "dashboards_write".to_string(),
19                "dashboards_public_share".to_string(),
20            ],
21        )),
22        ApplicationKeysType::APPLICATION_KEYS,
23    ));
24    let configuration = datadog::Configuration::new();
25    let api = ServiceAccountsAPI::with_config(configuration);
26    let resp = api
27        .create_service_account_application_key(service_account_user_data_id.clone(), body)
28        .await;
29    if let Ok(value) = resp {
30        println!("{:#?}", value);
31    } else {
32        println!("{:#?}", resp.unwrap_err());
33    }
34}
examples/v2_service-accounts_CreateServiceAccount.rs (line 34)
14async fn main() {
15    // there is a valid "role" in the system
16    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
17    let body =
18        ServiceAccountCreateRequest::new(
19            ServiceAccountCreateData::new(
20                ServiceAccountCreateAttributes::new(
21                    "Example-Service-Account@datadoghq.com".to_string(),
22                    true,
23                )
24                .name("Test API Client".to_string()),
25                UsersType::USERS,
26            )
27            .relationships(UserRelationships::new().roles(
28                RelationshipToRoles::new().data(vec![RelationshipToRoleData::new()
29                    .id(role_data_id.clone())
30                    .type_(RolesType::ROLES)]),
31            )),
32        );
33    let configuration = datadog::Configuration::new();
34    let api = ServiceAccountsAPI::with_config(configuration);
35    let resp = api.create_service_account(body).await;
36    if let Ok(value) = resp {
37        println!("{:#?}", value);
38    } else {
39        println!("{:#?}", resp.unwrap_err());
40    }
41}
Source

pub fn with_client_and_config( config: Configuration, client: ClientWithMiddleware, ) -> Self

Source

pub async fn create_service_account( &self, body: ServiceAccountCreateRequest, ) -> Result<UserResponse, Error<CreateServiceAccountError>>

Create a service account for your organization.

Examples found in repository?
examples/v2_service-accounts_CreateServiceAccount.rs (line 35)
14async fn main() {
15    // there is a valid "role" in the system
16    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
17    let body =
18        ServiceAccountCreateRequest::new(
19            ServiceAccountCreateData::new(
20                ServiceAccountCreateAttributes::new(
21                    "Example-Service-Account@datadoghq.com".to_string(),
22                    true,
23                )
24                .name("Test API Client".to_string()),
25                UsersType::USERS,
26            )
27            .relationships(UserRelationships::new().roles(
28                RelationshipToRoles::new().data(vec![RelationshipToRoleData::new()
29                    .id(role_data_id.clone())
30                    .type_(RolesType::ROLES)]),
31            )),
32        );
33    let configuration = datadog::Configuration::new();
34    let api = ServiceAccountsAPI::with_config(configuration);
35    let resp = api.create_service_account(body).await;
36    if let Ok(value) = resp {
37        println!("{:#?}", value);
38    } else {
39        println!("{:#?}", resp.unwrap_err());
40    }
41}
Source

pub async fn create_service_account_with_http_info( &self, body: ServiceAccountCreateRequest, ) -> Result<ResponseContent<UserResponse>, Error<CreateServiceAccountError>>

Create a service account for your organization.

Source

pub async fn create_service_account_application_key( &self, service_account_id: String, body: ApplicationKeyCreateRequest, ) -> Result<ApplicationKeyResponse, Error<CreateServiceAccountApplicationKeyError>>

Create an application key for this service account.

Examples found in repository?
examples/v2_service-accounts_CreateServiceAccountApplicationKey.rs (line 20)
10async fn main() {
11    // there is a valid "service_account_user" in the system
12    let service_account_user_data_id = std::env::var("SERVICE_ACCOUNT_USER_DATA_ID").unwrap();
13    let body = ApplicationKeyCreateRequest::new(ApplicationKeyCreateData::new(
14        ApplicationKeyCreateAttributes::new("Example-Service-Account".to_string()),
15        ApplicationKeysType::APPLICATION_KEYS,
16    ));
17    let configuration = datadog::Configuration::new();
18    let api = ServiceAccountsAPI::with_config(configuration);
19    let resp = api
20        .create_service_account_application_key(service_account_user_data_id.clone(), body)
21        .await;
22    if let Ok(value) = resp {
23        println!("{:#?}", value);
24    } else {
25        println!("{:#?}", resp.unwrap_err());
26    }
27}
More examples
Hide additional examples
examples/v2_service-accounts_CreateServiceAccountApplicationKey_3480494373.rs (line 27)
11async fn main() {
12    // there is a valid "service_account_user" in the system
13    let service_account_user_data_id = std::env::var("SERVICE_ACCOUNT_USER_DATA_ID").unwrap();
14    let body = ApplicationKeyCreateRequest::new(ApplicationKeyCreateData::new(
15        ApplicationKeyCreateAttributes::new("Example-Service-Account".to_string()).scopes(Some(
16            vec![
17                "dashboards_read".to_string(),
18                "dashboards_write".to_string(),
19                "dashboards_public_share".to_string(),
20            ],
21        )),
22        ApplicationKeysType::APPLICATION_KEYS,
23    ));
24    let configuration = datadog::Configuration::new();
25    let api = ServiceAccountsAPI::with_config(configuration);
26    let resp = api
27        .create_service_account_application_key(service_account_user_data_id.clone(), body)
28        .await;
29    if let Ok(value) = resp {
30        println!("{:#?}", value);
31    } else {
32        println!("{:#?}", resp.unwrap_err());
33    }
34}
Source

pub async fn create_service_account_application_key_with_http_info( &self, service_account_id: String, body: ApplicationKeyCreateRequest, ) -> Result<ResponseContent<ApplicationKeyResponse>, Error<CreateServiceAccountApplicationKeyError>>

Create an application key for this service account.

Source

pub async fn delete_service_account_application_key( &self, service_account_id: String, app_key_id: String, ) -> Result<(), Error<DeleteServiceAccountApplicationKeyError>>

Delete an application key owned by this service account.

Examples found in repository?
examples/v2_service-accounts_DeleteServiceAccountApplicationKey.rs (lines 16-19)
6async fn main() {
7    // there is a valid "service_account_user" in the system
8    let service_account_user_data_id = std::env::var("SERVICE_ACCOUNT_USER_DATA_ID").unwrap();
9
10    // there is a valid "service_account_application_key" for "service_account_user"
11    let service_account_application_key_data_id =
12        std::env::var("SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID").unwrap();
13    let configuration = datadog::Configuration::new();
14    let api = ServiceAccountsAPI::with_config(configuration);
15    let resp = api
16        .delete_service_account_application_key(
17            service_account_user_data_id.clone(),
18            service_account_application_key_data_id.clone(),
19        )
20        .await;
21    if let Ok(value) = resp {
22        println!("{:#?}", value);
23    } else {
24        println!("{:#?}", resp.unwrap_err());
25    }
26}
Source

pub async fn delete_service_account_application_key_with_http_info( &self, service_account_id: String, app_key_id: String, ) -> Result<ResponseContent<()>, Error<DeleteServiceAccountApplicationKeyError>>

Delete an application key owned by this service account.

Source

pub async fn get_service_account_application_key( &self, service_account_id: String, app_key_id: String, ) -> Result<PartialApplicationKeyResponse, Error<GetServiceAccountApplicationKeyError>>

Get an application key owned by this service account.

Examples found in repository?
examples/v2_service-accounts_GetServiceAccountApplicationKey.rs (lines 16-19)
6async fn main() {
7    // there is a valid "service_account_user" in the system
8    let service_account_user_data_id = std::env::var("SERVICE_ACCOUNT_USER_DATA_ID").unwrap();
9
10    // there is a valid "service_account_application_key" for "service_account_user"
11    let service_account_application_key_data_id =
12        std::env::var("SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID").unwrap();
13    let configuration = datadog::Configuration::new();
14    let api = ServiceAccountsAPI::with_config(configuration);
15    let resp = api
16        .get_service_account_application_key(
17            service_account_user_data_id.clone(),
18            service_account_application_key_data_id.clone(),
19        )
20        .await;
21    if let Ok(value) = resp {
22        println!("{:#?}", value);
23    } else {
24        println!("{:#?}", resp.unwrap_err());
25    }
26}
Source

pub async fn get_service_account_application_key_with_http_info( &self, service_account_id: String, app_key_id: String, ) -> Result<ResponseContent<PartialApplicationKeyResponse>, Error<GetServiceAccountApplicationKeyError>>

Get an application key owned by this service account.

Source

pub async fn list_service_account_application_keys( &self, service_account_id: String, params: ListServiceAccountApplicationKeysOptionalParams, ) -> Result<ListApplicationKeysResponse, Error<ListServiceAccountApplicationKeysError>>

List all application keys available for this service account.

Examples found in repository?
examples/v2_service-accounts_ListServiceAccountApplicationKeys.rs (lines 13-16)
7async fn main() {
8    // there is a valid "service_account_user" in the system
9    let service_account_user_data_id = std::env::var("SERVICE_ACCOUNT_USER_DATA_ID").unwrap();
10    let configuration = datadog::Configuration::new();
11    let api = ServiceAccountsAPI::with_config(configuration);
12    let resp = api
13        .list_service_account_application_keys(
14            service_account_user_data_id.clone(),
15            ListServiceAccountApplicationKeysOptionalParams::default(),
16        )
17        .await;
18    if let Ok(value) = resp {
19        println!("{:#?}", value);
20    } else {
21        println!("{:#?}", resp.unwrap_err());
22    }
23}
Source

pub async fn list_service_account_application_keys_with_http_info( &self, service_account_id: String, params: ListServiceAccountApplicationKeysOptionalParams, ) -> Result<ResponseContent<ListApplicationKeysResponse>, Error<ListServiceAccountApplicationKeysError>>

List all application keys available for this service account.

Source

pub async fn update_service_account_application_key( &self, service_account_id: String, app_key_id: String, body: ApplicationKeyUpdateRequest, ) -> Result<PartialApplicationKeyResponse, Error<UpdateServiceAccountApplicationKeyError>>

Edit an application key owned by this service account.

Examples found in repository?
examples/v2_service-accounts_UpdateServiceAccountApplicationKey.rs (lines 26-30)
10async fn main() {
11    // there is a valid "service_account_user" in the system
12    let service_account_user_data_id = std::env::var("SERVICE_ACCOUNT_USER_DATA_ID").unwrap();
13
14    // there is a valid "service_account_application_key" for "service_account_user"
15    let service_account_application_key_data_id =
16        std::env::var("SERVICE_ACCOUNT_APPLICATION_KEY_DATA_ID").unwrap();
17    let body = ApplicationKeyUpdateRequest::new(ApplicationKeyUpdateData::new(
18        ApplicationKeyUpdateAttributes::new()
19            .name("Application Key for managing dashboards-updated".to_string()),
20        service_account_application_key_data_id.clone(),
21        ApplicationKeysType::APPLICATION_KEYS,
22    ));
23    let configuration = datadog::Configuration::new();
24    let api = ServiceAccountsAPI::with_config(configuration);
25    let resp = api
26        .update_service_account_application_key(
27            service_account_user_data_id.clone(),
28            service_account_application_key_data_id.clone(),
29            body,
30        )
31        .await;
32    if let Ok(value) = resp {
33        println!("{:#?}", value);
34    } else {
35        println!("{:#?}", resp.unwrap_err());
36    }
37}
Source

pub async fn update_service_account_application_key_with_http_info( &self, service_account_id: String, app_key_id: String, body: ApplicationKeyUpdateRequest, ) -> Result<ResponseContent<PartialApplicationKeyResponse>, Error<UpdateServiceAccountApplicationKeyError>>

Edit an application key owned by this service account.

Trait Implementations§

Source§

impl Clone for ServiceAccountsAPI

Source§

fn clone(&self) -> ServiceAccountsAPI

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ServiceAccountsAPI

Source§

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

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

impl Default for ServiceAccountsAPI

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,