Struct RolesAPI

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

The Roles API is used to create and manage Datadog roles, what global permissions they grant, and which users belong to them.

Permissions related to specific account assets can be granted to roles in the Datadog application without using this API. For example, granting read access on a specific log index to a role can be done in Datadog from the Pipelines page.

Implementations§

Source§

impl RolesAPI

Source

pub fn new() -> Self

Source

pub fn with_config(config: Configuration) -> Self

Examples found in repository?
examples/v2_roles_ListPermissions.rs (line 8)
6async fn main() {
7    let configuration = datadog::Configuration::new();
8    let api = RolesAPI::with_config(configuration);
9    let resp = api.list_permissions().await;
10    if let Ok(value) = resp {
11        println!("{:#?}", value);
12    } else {
13        println!("{:#?}", resp.unwrap_err());
14    }
15}
More examples
Hide additional examples
examples/v2_roles_GetRole.rs (line 10)
6async fn main() {
7    // there is a valid "role" in the system
8    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
9    let configuration = datadog::Configuration::new();
10    let api = RolesAPI::with_config(configuration);
11    let resp = api.get_role(role_data_id.clone()).await;
12    if let Ok(value) = resp {
13        println!("{:#?}", value);
14    } else {
15        println!("{:#?}", resp.unwrap_err());
16    }
17}
examples/v2_roles_DeleteRole.rs (line 10)
6async fn main() {
7    // there is a valid "role" in the system
8    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
9    let configuration = datadog::Configuration::new();
10    let api = RolesAPI::with_config(configuration);
11    let resp = api.delete_role(role_data_id.clone()).await;
12    if let Ok(value) = resp {
13        println!("{:#?}", value);
14    } else {
15        println!("{:#?}", resp.unwrap_err());
16    }
17}
examples/v2_roles_ListRolePermissions.rs (line 10)
6async fn main() {
7    // there is a valid "role" in the system
8    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
9    let configuration = datadog::Configuration::new();
10    let api = RolesAPI::with_config(configuration);
11    let resp = api.list_role_permissions(role_data_id.clone()).await;
12    if let Ok(value) = resp {
13        println!("{:#?}", value);
14    } else {
15        println!("{:#?}", resp.unwrap_err());
16    }
17}
examples/v2_roles_ListRoleUsers.rs (line 11)
7async fn main() {
8    // there is a valid "role" in the system
9    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
10    let configuration = datadog::Configuration::new();
11    let api = RolesAPI::with_config(configuration);
12    let resp = api
13        .list_role_users(role_data_id.clone(), ListRoleUsersOptionalParams::default())
14        .await;
15    if let Ok(value) = resp {
16        println!("{:#?}", value);
17    } else {
18        println!("{:#?}", resp.unwrap_err());
19    }
20}
examples/v2_roles_ListRoles.rs (line 11)
7async fn main() {
8    // there is a valid "role" in the system
9    let role_data_attributes_name = std::env::var("ROLE_DATA_ATTRIBUTES_NAME").unwrap();
10    let configuration = datadog::Configuration::new();
11    let api = RolesAPI::with_config(configuration);
12    let resp = api
13        .list_roles(ListRolesOptionalParams::default().filter(role_data_attributes_name.clone()))
14        .await;
15    if let Ok(value) = resp {
16        println!("{:#?}", value);
17    } else {
18        println!("{:#?}", resp.unwrap_err());
19    }
20}
Source

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

Source

pub async fn add_permission_to_role( &self, role_id: String, body: RelationshipToPermission, ) -> Result<PermissionsResponse, Error<AddPermissionToRoleError>>

Adds a permission to a role.

Examples found in repository?
examples/v2_roles_AddPermissionToRole.rs (line 22)
9async fn main() {
10    // there is a valid "role" in the system
11    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
12
13    // there is a valid "permission" in the system
14    let permission_id = std::env::var("PERMISSION_ID").unwrap();
15    let body = RelationshipToPermission::new().data(
16        RelationshipToPermissionData::new()
17            .id(permission_id.clone())
18            .type_(PermissionsType::PERMISSIONS),
19    );
20    let configuration = datadog::Configuration::new();
21    let api = RolesAPI::with_config(configuration);
22    let resp = api.add_permission_to_role(role_data_id.clone(), body).await;
23    if let Ok(value) = resp {
24        println!("{:#?}", value);
25    } else {
26        println!("{:#?}", resp.unwrap_err());
27    }
28}
Source

pub async fn add_permission_to_role_with_http_info( &self, role_id: String, body: RelationshipToPermission, ) -> Result<ResponseContent<PermissionsResponse>, Error<AddPermissionToRoleError>>

Adds a permission to a role.

Source

pub async fn add_user_to_role( &self, role_id: String, body: RelationshipToUser, ) -> Result<UsersResponse, Error<AddUserToRoleError>>

Adds a user to a role.

Examples found in repository?
examples/v2_roles_AddUserToRole.rs (line 21)
9async fn main() {
10    // there is a valid "role" in the system
11    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
12
13    // there is a valid "user" in the system
14    let user_data_id = std::env::var("USER_DATA_ID").unwrap();
15    let body = RelationshipToUser::new(RelationshipToUserData::new(
16        user_data_id.clone(),
17        UsersType::USERS,
18    ));
19    let configuration = datadog::Configuration::new();
20    let api = RolesAPI::with_config(configuration);
21    let resp = api.add_user_to_role(role_data_id.clone(), body).await;
22    if let Ok(value) = resp {
23        println!("{:#?}", value);
24    } else {
25        println!("{:#?}", resp.unwrap_err());
26    }
27}
Source

pub async fn add_user_to_role_with_http_info( &self, role_id: String, body: RelationshipToUser, ) -> Result<ResponseContent<UsersResponse>, Error<AddUserToRoleError>>

Adds a user to a role.

Source

pub async fn clone_role( &self, role_id: String, body: RoleCloneRequest, ) -> Result<RoleResponse, Error<CloneRoleError>>

Clone an existing role

Examples found in repository?
examples/v2_roles_CloneRole.rs (line 19)
10async fn main() {
11    // there is a valid "role" in the system
12    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
13    let body = RoleCloneRequest::new(RoleClone::new(
14        RoleCloneAttributes::new("Example-Role clone".to_string()),
15        RolesType::ROLES,
16    ));
17    let configuration = datadog::Configuration::new();
18    let api = RolesAPI::with_config(configuration);
19    let resp = api.clone_role(role_data_id.clone(), body).await;
20    if let Ok(value) = resp {
21        println!("{:#?}", value);
22    } else {
23        println!("{:#?}", resp.unwrap_err());
24    }
25}
Source

pub async fn clone_role_with_http_info( &self, role_id: String, body: RoleCloneRequest, ) -> Result<ResponseContent<RoleResponse>, Error<CloneRoleError>>

Clone an existing role

Source

pub async fn create_role( &self, body: RoleCreateRequest, ) -> Result<RoleCreateResponse, Error<CreateRoleError>>

Create a new role for your organization.

Examples found in repository?
examples/v2_roles_CreateRole.rs (line 26)
14async fn main() {
15    let body = RoleCreateRequest::new(
16        RoleCreateData::new(RoleCreateAttributes::new("developers".to_string()))
17            .relationships(RoleRelationships::new().permissions(
18                RelationshipToPermissions::new().data(vec![
19                    RelationshipToPermissionData::new().type_(PermissionsType::PERMISSIONS),
20                ]),
21            ))
22            .type_(RolesType::ROLES),
23    );
24    let configuration = datadog::Configuration::new();
25    let api = RolesAPI::with_config(configuration);
26    let resp = api.create_role(body).await;
27    if let Ok(value) = resp {
28        println!("{:#?}", value);
29    } else {
30        println!("{:#?}", resp.unwrap_err());
31    }
32}
More examples
Hide additional examples
examples/v2_roles_CreateRole_3862893229.rs (line 30)
14async fn main() {
15    // there is a valid "permission" in the system
16    let permission_id = std::env::var("PERMISSION_ID").unwrap();
17    let body = RoleCreateRequest::new(
18        RoleCreateData::new(RoleCreateAttributes::new("Example-Role".to_string()))
19            .relationships(RoleRelationships::new().permissions(
20                RelationshipToPermissions::new().data(vec![
21                                RelationshipToPermissionData::new()
22                                    .id(permission_id.clone())
23                                    .type_(PermissionsType::PERMISSIONS)
24                            ]),
25            ))
26            .type_(RolesType::ROLES),
27    );
28    let configuration = datadog::Configuration::new();
29    let api = RolesAPI::with_config(configuration);
30    let resp = api.create_role(body).await;
31    if let Ok(value) = resp {
32        println!("{:#?}", value);
33    } else {
34        println!("{:#?}", resp.unwrap_err());
35    }
36}
Source

pub async fn create_role_with_http_info( &self, body: RoleCreateRequest, ) -> Result<ResponseContent<RoleCreateResponse>, Error<CreateRoleError>>

Create a new role for your organization.

Source

pub async fn delete_role( &self, role_id: String, ) -> Result<(), Error<DeleteRoleError>>

Disables a role.

Examples found in repository?
examples/v2_roles_DeleteRole.rs (line 11)
6async fn main() {
7    // there is a valid "role" in the system
8    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
9    let configuration = datadog::Configuration::new();
10    let api = RolesAPI::with_config(configuration);
11    let resp = api.delete_role(role_data_id.clone()).await;
12    if let Ok(value) = resp {
13        println!("{:#?}", value);
14    } else {
15        println!("{:#?}", resp.unwrap_err());
16    }
17}
Source

pub async fn delete_role_with_http_info( &self, role_id: String, ) -> Result<ResponseContent<()>, Error<DeleteRoleError>>

Disables a role.

Source

pub async fn get_role( &self, role_id: String, ) -> Result<RoleResponse, Error<GetRoleError>>

Get a role in the organization specified by the role’s role_id.

Examples found in repository?
examples/v2_roles_GetRole.rs (line 11)
6async fn main() {
7    // there is a valid "role" in the system
8    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
9    let configuration = datadog::Configuration::new();
10    let api = RolesAPI::with_config(configuration);
11    let resp = api.get_role(role_data_id.clone()).await;
12    if let Ok(value) = resp {
13        println!("{:#?}", value);
14    } else {
15        println!("{:#?}", resp.unwrap_err());
16    }
17}
Source

pub async fn get_role_with_http_info( &self, role_id: String, ) -> Result<ResponseContent<RoleResponse>, Error<GetRoleError>>

Get a role in the organization specified by the role’s role_id.

Source

pub async fn list_permissions( &self, ) -> Result<PermissionsResponse, Error<ListPermissionsError>>

Returns a list of all permissions, including name, description, and ID.

Examples found in repository?
examples/v2_roles_ListPermissions.rs (line 9)
6async fn main() {
7    let configuration = datadog::Configuration::new();
8    let api = RolesAPI::with_config(configuration);
9    let resp = api.list_permissions().await;
10    if let Ok(value) = resp {
11        println!("{:#?}", value);
12    } else {
13        println!("{:#?}", resp.unwrap_err());
14    }
15}
Source

pub async fn list_permissions_with_http_info( &self, ) -> Result<ResponseContent<PermissionsResponse>, Error<ListPermissionsError>>

Returns a list of all permissions, including name, description, and ID.

Source

pub async fn list_role_permissions( &self, role_id: String, ) -> Result<PermissionsResponse, Error<ListRolePermissionsError>>

Returns a list of all permissions for a single role.

Examples found in repository?
examples/v2_roles_ListRolePermissions.rs (line 11)
6async fn main() {
7    // there is a valid "role" in the system
8    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
9    let configuration = datadog::Configuration::new();
10    let api = RolesAPI::with_config(configuration);
11    let resp = api.list_role_permissions(role_data_id.clone()).await;
12    if let Ok(value) = resp {
13        println!("{:#?}", value);
14    } else {
15        println!("{:#?}", resp.unwrap_err());
16    }
17}
Source

pub async fn list_role_permissions_with_http_info( &self, role_id: String, ) -> Result<ResponseContent<PermissionsResponse>, Error<ListRolePermissionsError>>

Returns a list of all permissions for a single role.

Source

pub async fn list_role_users( &self, role_id: String, params: ListRoleUsersOptionalParams, ) -> Result<UsersResponse, Error<ListRoleUsersError>>

Gets all users of a role.

Examples found in repository?
examples/v2_roles_ListRoleUsers.rs (line 13)
7async fn main() {
8    // there is a valid "role" in the system
9    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
10    let configuration = datadog::Configuration::new();
11    let api = RolesAPI::with_config(configuration);
12    let resp = api
13        .list_role_users(role_data_id.clone(), ListRoleUsersOptionalParams::default())
14        .await;
15    if let Ok(value) = resp {
16        println!("{:#?}", value);
17    } else {
18        println!("{:#?}", resp.unwrap_err());
19    }
20}
Source

pub async fn list_role_users_with_http_info( &self, role_id: String, params: ListRoleUsersOptionalParams, ) -> Result<ResponseContent<UsersResponse>, Error<ListRoleUsersError>>

Gets all users of a role.

Source

pub async fn list_roles( &self, params: ListRolesOptionalParams, ) -> Result<RolesResponse, Error<ListRolesError>>

Returns all roles, including their names and their unique identifiers.

Examples found in repository?
examples/v2_roles_ListRoles.rs (line 13)
7async fn main() {
8    // there is a valid "role" in the system
9    let role_data_attributes_name = std::env::var("ROLE_DATA_ATTRIBUTES_NAME").unwrap();
10    let configuration = datadog::Configuration::new();
11    let api = RolesAPI::with_config(configuration);
12    let resp = api
13        .list_roles(ListRolesOptionalParams::default().filter(role_data_attributes_name.clone()))
14        .await;
15    if let Ok(value) = resp {
16        println!("{:#?}", value);
17    } else {
18        println!("{:#?}", resp.unwrap_err());
19    }
20}
Source

pub async fn list_roles_with_http_info( &self, params: ListRolesOptionalParams, ) -> Result<ResponseContent<RolesResponse>, Error<ListRolesError>>

Returns all roles, including their names and their unique identifiers.

Source

pub async fn remove_permission_from_role( &self, role_id: String, body: RelationshipToPermission, ) -> Result<PermissionsResponse, Error<RemovePermissionFromRoleError>>

Removes a permission from a role.

Examples found in repository?
examples/v2_roles_RemovePermissionFromRole.rs (line 23)
9async fn main() {
10    // there is a valid "role" in the system
11    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
12
13    // there is a valid "permission" in the system
14    let permission_id = std::env::var("PERMISSION_ID").unwrap();
15    let body = RelationshipToPermission::new().data(
16        RelationshipToPermissionData::new()
17            .id(permission_id.clone())
18            .type_(PermissionsType::PERMISSIONS),
19    );
20    let configuration = datadog::Configuration::new();
21    let api = RolesAPI::with_config(configuration);
22    let resp = api
23        .remove_permission_from_role(role_data_id.clone(), body)
24        .await;
25    if let Ok(value) = resp {
26        println!("{:#?}", value);
27    } else {
28        println!("{:#?}", resp.unwrap_err());
29    }
30}
Source

pub async fn remove_permission_from_role_with_http_info( &self, role_id: String, body: RelationshipToPermission, ) -> Result<ResponseContent<PermissionsResponse>, Error<RemovePermissionFromRoleError>>

Removes a permission from a role.

Source

pub async fn remove_user_from_role( &self, role_id: String, body: RelationshipToUser, ) -> Result<UsersResponse, Error<RemoveUserFromRoleError>>

Removes a user from a role.

Examples found in repository?
examples/v2_roles_RemoveUserFromRole.rs (line 21)
9async fn main() {
10    // there is a valid "role" in the system
11    let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
12
13    // there is a valid "user" in the system
14    let user_data_id = std::env::var("USER_DATA_ID").unwrap();
15    let body = RelationshipToUser::new(RelationshipToUserData::new(
16        user_data_id.clone(),
17        UsersType::USERS,
18    ));
19    let configuration = datadog::Configuration::new();
20    let api = RolesAPI::with_config(configuration);
21    let resp = api.remove_user_from_role(role_data_id.clone(), body).await;
22    if let Ok(value) = resp {
23        println!("{:#?}", value);
24    } else {
25        println!("{:#?}", resp.unwrap_err());
26    }
27}
Source

pub async fn remove_user_from_role_with_http_info( &self, role_id: String, body: RelationshipToUser, ) -> Result<ResponseContent<UsersResponse>, Error<RemoveUserFromRoleError>>

Removes a user from a role.

Source

pub async fn update_role( &self, role_id: String, body: RoleUpdateRequest, ) -> Result<RoleUpdateResponse, Error<UpdateRoleError>>

Edit a role. Can only be used with application keys belonging to administrators.

Examples found in repository?
examples/v2_roles_UpdateRole.rs (line 36)
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
18    // there is a valid "permission" in the system
19    let permission_id = std::env::var("PERMISSION_ID").unwrap();
20    let body = RoleUpdateRequest::new(
21        RoleUpdateData::new(
22            RoleUpdateAttributes::new().name("developers-updated".to_string()),
23            role_data_id.clone(),
24            RolesType::ROLES,
25        )
26        .relationships(RoleRelationships::new().permissions(
27            RelationshipToPermissions::new().data(vec![
28                            RelationshipToPermissionData::new()
29                                .id(permission_id.clone())
30                                .type_(PermissionsType::PERMISSIONS)
31                        ]),
32        )),
33    );
34    let configuration = datadog::Configuration::new();
35    let api = RolesAPI::with_config(configuration);
36    let resp = api.update_role(role_data_id.clone(), body).await;
37    if let Ok(value) = resp {
38        println!("{:#?}", value);
39    } else {
40        println!("{:#?}", resp.unwrap_err());
41    }
42}
Source

pub async fn update_role_with_http_info( &self, role_id: String, body: RoleUpdateRequest, ) -> Result<ResponseContent<RoleUpdateResponse>, Error<UpdateRoleError>>

Edit a role. Can only be used with application keys belonging to administrators.

Trait Implementations§

Source§

impl Clone for RolesAPI

Source§

fn clone(&self) -> RolesAPI

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 RolesAPI

Source§

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

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

impl Default for RolesAPI

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,