Attributes required to create a new role by cloning an existing one.
name [required]
string
Name of the new role that is cloned.
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 a single 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.
modified_at
date-time
Time of last role modification.
name
string
The name of the role. The name is neither unique nor a stable identifier 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
int64
Number of users with that role.
id
string
The unique identifier of the role.
relationships
object
Relationships of the role object returned by the API.
// Create a new role by cloning an existing 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")body:=datadogV2.RoleCloneRequest{Data:datadogV2.RoleClone{Attributes:datadogV2.RoleCloneAttributes{Name:"Example-Role clone",},Type:datadogV2.ROLESTYPE_ROLES,},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewRolesApi(apiClient)resp,r,err:=api.CloneRole(ctx,RoleDataID,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `RolesApi.CloneRole`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `RolesApi.CloneRole`:\n%s\n",responseContent)}
// Create a new role by cloning an existing 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.RoleClone;importcom.datadog.api.client.v2.model.RoleCloneAttributes;importcom.datadog.api.client.v2.model.RoleCloneRequest;importcom.datadog.api.client.v2.model.RoleResponse;importcom.datadog.api.client.v2.model.RolesType;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();RolesApiapiInstance=newRolesApi(defaultClient);// there is a valid "role" in the systemStringROLE_DATA_ID=System.getenv("ROLE_DATA_ID");RoleCloneRequestbody=newRoleCloneRequest().data(newRoleClone().attributes(newRoleCloneAttributes().name("Example-Role clone")).type(RolesType.ROLES));try{RoleResponseresult=apiInstance.cloneRole(ROLE_DATA_ID,body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling RolesApi#cloneRole");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
"""
Create a new role by cloning an existing role returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.roles_apiimportRolesApifromdatadog_api_client.v2.model.role_cloneimportRoleClonefromdatadog_api_client.v2.model.role_clone_attributesimportRoleCloneAttributesfromdatadog_api_client.v2.model.role_clone_requestimportRoleCloneRequestfromdatadog_api_client.v2.model.roles_typeimportRolesType# there is a valid "role" in the systemROLE_DATA_ID=environ["ROLE_DATA_ID"]body=RoleCloneRequest(data=RoleClone(attributes=RoleCloneAttributes(name="Example-Role clone",),type=RolesType.ROLES,),)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=RolesApi(api_client)response=api_instance.clone_role(role_id=ROLE_DATA_ID,body=body)print(response)
# Create a new role by cloning an existing role returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::RolesAPI.new# there is a valid "role" in the systemROLE_DATA_ID=ENV["ROLE_DATA_ID"]body=DatadogAPIClient::V2::RoleCloneRequest.new({data:DatadogAPIClient::V2::RoleClone.new({attributes:DatadogAPIClient::V2::RoleCloneAttributes.new({name:"Example-Role clone",}),type:DatadogAPIClient::V2::RolesType::ROLES,}),})papi_instance.clone_role(ROLE_DATA_ID,body)
// Create a new role by cloning an existing role returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_roles::RolesAPI;usedatadog_api_client::datadogV2::model::RoleClone;usedatadog_api_client::datadogV2::model::RoleCloneAttributes;usedatadog_api_client::datadogV2::model::RoleCloneRequest;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();letbody=RoleCloneRequest::new(RoleClone::new(RoleCloneAttributes::new("Example-Role clone".to_string()),RolesType::ROLES,));letconfiguration=datadog::Configuration::new();letapi=RolesAPI::with_config(configuration);letresp=api.clone_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.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Create a new role by cloning an existing role returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.RolesApi(configuration);// there is a valid "role" in the system
constROLE_DATA_ID=process.env.ROLE_DATA_IDasstring;constparams: v2.RolesApiCloneRoleRequest={body:{data:{attributes:{name:"Example-Role clone",},type:"roles",},},roleId: ROLE_DATA_ID,};apiInstance.cloneRole(params).then((data: v2.RoleResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));