Edit a role. Can only be used with application keys belonging to administrators.
Restricted permissions,
such as Dashboards Read and Monitors Read, remain on the role by default, even if they are omitted from
the request. To exclude them, set default_permissions_opt_out to true.
This endpoint requires the user_access_manage permission.
OAuth apps require the user_access_manage authorization scope to access this endpoint.
Whether to exclude restricted default permissions from this role.
Restricted default permissions are automatically assigned to every role by default. Set this field to true to exclude them.
Some of these permissions can only be excluded after Minimal Access Roles is enabled for the organization.
modified_at
date-time
Time of last role modification.
name
string
Name of the role.
receives_permissions_from
[string]
The managed role from which this role automatically inherits new permissions.
Specify one of the following: "Datadog Admin Role", "Datadog Standard Role", or "Datadog Read Only Role".
If empty or not specified, the role does not automatically inherit permissions from any managed role.
Response containing information about an updated role.
Expand All
Field
Type
Description
data
object
Role object returned by the API.
attributes
object
Attributes of the role.
created_at
date-time
Creation time of the role.
default_permissions_opt_out
boolean
Whether to exclude restricted default permissions from this role.
Restricted default permissions are automatically assigned to every role by default. Set this field to true to exclude them.
Some of these permissions can only be excluded after Minimal Access Roles is enabled for the organization.
modified_at
date-time
Time of last role modification.
name
string
Name of the role.
receives_permissions_from
[string]
The managed role from which this role automatically inherits new permissions.
Specify one of the following: "Datadog Admin Role", "Datadog Standard Role", or "Datadog Read Only Role".
If empty or not specified, the role does not automatically inherit permissions from any managed role.
user_count
int32
The user count.
id
string
The unique identifier of the role.
relationships
object
Relationships of the role object returned by the API.
## default
#
# Path parameters exportrole_id="CHANGE_ME" # Use a Personal Access Token or Service Access Token exportDD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
"""
Update a role returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.roles_apiimportRolesApifromdatadog_api_client.v2.model.permissions_typeimportPermissionsTypefromdatadog_api_client.v2.model.relationship_to_permission_dataimportRelationshipToPermissionDatafromdatadog_api_client.v2.model.relationship_to_permissionsimportRelationshipToPermissionsfromdatadog_api_client.v2.model.role_relationshipsimportRoleRelationshipsfromdatadog_api_client.v2.model.role_update_attributesimportRoleUpdateAttributesfromdatadog_api_client.v2.model.role_update_dataimportRoleUpdateDatafromdatadog_api_client.v2.model.role_update_requestimportRoleUpdateRequestfromdatadog_api_client.v2.model.roles_typeimportRolesType# there is a valid "role" in the systemROLE_DATA_ATTRIBUTES_NAME=environ["ROLE_DATA_ATTRIBUTES_NAME"]ROLE_DATA_ID=environ["ROLE_DATA_ID"]# there is a valid "permission" in the systemPERMISSION_ID=environ["PERMISSION_ID"]body=RoleUpdateRequest(data=RoleUpdateData(id=ROLE_DATA_ID,type=RolesType.ROLES,attributes=RoleUpdateAttributes(name="developers-updated",),relationships=RoleRelationships(permissions=RelationshipToPermissions(data=[RelationshipToPermissionData(id=PERMISSION_ID,type=PermissionsType.PERMISSIONS,),],),),),)configuration=Configuration()configuration.access_token=environ["DD_BEARER_TOKEN"]withApiClient(configuration)asapi_client:api_instance=RolesApi(api_client)response=api_instance.update_role(role_id=ROLE_DATA_ID,body=body)print(response)
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"python3"example.py"
# Update a role returns "OK" responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.access_token=ENV["DD_BEARER_TOKEN"]endapi_instance=DatadogAPIClient::V2::RolesAPI.new# there is a valid "role" in the systemROLE_DATA_ATTRIBUTES_NAME=ENV["ROLE_DATA_ATTRIBUTES_NAME"]ROLE_DATA_ID=ENV["ROLE_DATA_ID"]# there is a valid "permission" in the systemPERMISSION_ID=ENV["PERMISSION_ID"]body=DatadogAPIClient::V2::RoleUpdateRequest.new({data:DatadogAPIClient::V2::RoleUpdateData.new({id:ROLE_DATA_ID,type:DatadogAPIClient::V2::RolesType::ROLES,attributes:DatadogAPIClient::V2::RoleUpdateAttributes.new({name:"developers-updated",}),relationships:DatadogAPIClient::V2::RoleRelationships.new({permissions:DatadogAPIClient::V2::RelationshipToPermissions.new({data:[DatadogAPIClient::V2::RelationshipToPermissionData.new({id:PERMISSION_ID,type:DatadogAPIClient::V2::PermissionsType::PERMISSIONS,}),],}),}),}),})papi_instance.update_role(ROLE_DATA_ID,body)
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"rb"example.rb"
// Update a role returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.RolesApi;importcom.datadog.api.client.v2.model.PermissionsType;importcom.datadog.api.client.v2.model.RelationshipToPermissionData;importcom.datadog.api.client.v2.model.RelationshipToPermissions;importcom.datadog.api.client.v2.model.RoleRelationships;importcom.datadog.api.client.v2.model.RoleUpdateAttributes;importcom.datadog.api.client.v2.model.RoleUpdateData;importcom.datadog.api.client.v2.model.RoleUpdateRequest;importcom.datadog.api.client.v2.model.RoleUpdateResponse;importcom.datadog.api.client.v2.model.RolesType;importjava.util.Collections;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));RolesApiapiInstance=newRolesApi(defaultClient);// there is a valid "role" in the systemStringROLE_DATA_ATTRIBUTES_NAME=System.getenv("ROLE_DATA_ATTRIBUTES_NAME");StringROLE_DATA_ID=System.getenv("ROLE_DATA_ID");// there is a valid "permission" in the systemStringPERMISSION_ID=System.getenv("PERMISSION_ID");RoleUpdateRequestbody=newRoleUpdateRequest().data(newRoleUpdateData().id(ROLE_DATA_ID).type(RolesType.ROLES).attributes(newRoleUpdateAttributes().name("developers-updated")).relationships(newRoleRelationships().permissions(newRelationshipToPermissions().data(Collections.singletonList(newRelationshipToPermissionData().id(PERMISSION_ID).type(PermissionsType.PERMISSIONS))))));try{RoleUpdateResponseresult=apiInstance.updateRole(ROLE_DATA_ID,body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling RolesApi#updateRole");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"java"Example.java"
// Update a role returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_roles::RolesAPI;usedatadog_api_client::datadogV2::model::PermissionsType;usedatadog_api_client::datadogV2::model::RelationshipToPermissionData;usedatadog_api_client::datadogV2::model::RelationshipToPermissions;usedatadog_api_client::datadogV2::model::RoleRelationships;usedatadog_api_client::datadogV2::model::RoleUpdateAttributes;usedatadog_api_client::datadogV2::model::RoleUpdateData;usedatadog_api_client::datadogV2::model::RoleUpdateRequest;usedatadog_api_client::datadogV2::model::RolesType;#[tokio::main]asyncfnmain(){// there is a valid "role" in the system
letrole_data_id=std::env::var("ROLE_DATA_ID").unwrap();// there is a valid "permission" in the system
letpermission_id=std::env::var("PERMISSION_ID").unwrap();letbody=RoleUpdateRequest::new(RoleUpdateData::new(RoleUpdateAttributes::new().name("developers-updated".to_string()),role_data_id.clone(),RolesType::ROLES,).relationships(RoleRelationships::new().permissions(RelationshipToPermissions::new().data(vec![RelationshipToPermissionData::new().id(permission_id.clone()).type_(PermissionsType::PERMISSIONS)]),)),);letconfiguration=datadog::Configuration::new();letapi=RolesAPI::with_config(configuration);letresp=api.update_role(role_data_id.clone(),body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Update a role returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration({authMethods:{AuthZ:{accessToken: process.env.DD_BEARER_TOKENasstring,},},});constapiInstance=newv2.RolesApi(configuration);// there is a valid "role" in the system
constROLE_DATA_ID=process.env.ROLE_DATA_IDasstring;// there is a valid "permission" in the system
constPERMISSION_ID=process.env.PERMISSION_IDasstring;constparams: v2.RolesApiUpdateRoleRequest={body:{data:{id: ROLE_DATA_ID,type:"roles",attributes:{name:"developers-updated",},relationships:{permissions:{data:[{id: PERMISSION_ID,type:"permissions",},],},},},},roleId: ROLE_DATA_ID,};apiInstance.updateRole(params).then((data: v2.RoleUpdateResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"tsc"example.ts"
// Update a role returns "OK" responsepackagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "role" in the systemRoleDataID:=os.Getenv("ROLE_DATA_ID")// there is a valid "permission" in the systemPermissionID:=os.Getenv("PERMISSION_ID")body:=datadogV2.RoleUpdateRequest{Data:datadogV2.RoleUpdateData{Id:RoleDataID,Type:datadogV2.ROLESTYPE_ROLES,Attributes:datadogV2.RoleUpdateAttributes{Name:datadog.PtrString("developers-updated"),},Relationships:&datadogV2.RoleRelationships{Permissions:&datadogV2.RelationshipToPermissions{Data:[]datadogV2.RelationshipToPermissionData{{Id:datadog.PtrString(PermissionID),Type:datadogV2.PERMISSIONSTYPE_PERMISSIONS.Ptr(),},},},},},}ctx:=datadog.NewDefaultContext(context.Background())ctx=context.WithValue(ctx,datadog.ContextAccessToken,os.Getenv("DD_BEARER_TOKEN"))configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewRolesApi(apiClient)resp,r,err:=api.UpdateRole(ctx,RoleDataID,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `RolesApi.UpdateRole`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `RolesApi.UpdateRole`:\n%s\n",responseContent)}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"go run"main.go"
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.