- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
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.
GET https://api.ap1.datadoghq.com/api/v2/permissionshttps://api.datadoghq.eu/api/v2/permissionshttps://api.ddog-gov.com/api/v2/permissionshttps://api.datadoghq.com/api/v2/permissionshttps://api.us3.datadoghq.com/api/v2/permissionshttps://api.us5.datadoghq.com/api/v2/permissions
Returns a list of all permissions, including name, description, and ID.
This endpoint requires the user_access_read
permission.
OAuth apps require the user_access_read
authorization scope to access this endpoint.
OK
Payload with API-returned permissions.
항목
유형
설명
data
[object]
Array of permissions.
attributes
object
Attributes of a permission.
created
date-time
Creation time of the permission.
description
string
Description of the permission.
display_name
string
Displayed name for the permission.
display_type
string
Display type.
group_name
string
Name of the permission group.
name
string
Name of the permission.
restricted
boolean
Whether or not the permission is restricted.
id
string
ID of the permission.
type [required]
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
{
"data": [
{
"attributes": {
"created": "2019-09-19T10:00:00.000Z",
"description": "string",
"display_name": "string",
"display_type": "string",
"group_name": "string",
"name": "string",
"restricted": false
},
"id": "string",
"type": "permissions"
}
]
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/permissions" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
List permissions returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.list_permissions()
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# List permissions returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
p api_instance.list_permissions()
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// List permissions returns "OK" response
package main
import (
"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"
)
func main() {
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewRolesApi(apiClient)
resp, r, err := api.ListPermissions(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `RolesApi.ListPermissions`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `RolesApi.ListPermissions`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// List permissions returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
import com.datadog.api.client.v2.model.PermissionsResponse;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
try {
PermissionsResponse result = apiInstance.listPermissions();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RolesApi#listPermissions");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// List permissions returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
#[tokio::main]
async fn main() {
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api.list_permissions().await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* List permissions returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
apiInstance
.listPermissions()
.then((data: v2.PermissionsResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
GET https://api.ap1.datadoghq.com/api/v2/roleshttps://api.datadoghq.eu/api/v2/roleshttps://api.ddog-gov.com/api/v2/roleshttps://api.datadoghq.com/api/v2/roleshttps://api.us3.datadoghq.com/api/v2/roleshttps://api.us5.datadoghq.com/api/v2/roles
Returns all roles, including their names and their unique identifiers.
This endpoint requires the user_access_read
permission.
OAuth apps require the user_access_read
authorization scope to access this endpoint.
이름
유형
설명
page[size]
integer
Size for a given page. The maximum allowed value is 100.
page[number]
integer
Specific page number to return.
sort
enum
Sort roles depending on the given field. Sort order is ascending by default.
Sort order is descending if the field is prefixed by a negative sign, for example:
sort=-name
.
Allowed enum values: name, -name, modified_at, -modified_at, user_count, -user_count
filter
string
Filter all roles by the given string.
filter[id]
string
Filter all roles by the given list of role IDs.
OK
Response containing information about multiple roles.
항목
유형
설명
data
[object]
Array of returned roles.
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.
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.
permissions
object
Relationship to multiple permissions objects.
data
[object]
Relationships to permission objects.
id
string
ID of the permission.
type
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
type [required]
enum
Roles type.
Allowed enum values: roles
default: roles
meta
object
Object describing meta attributes of response.
page
object
Pagination object.
total_count
int64
Total count.
total_filtered_count
int64
Total count of elements matched by the filter.
{
"data": [
{
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"modified_at": "2019-09-19T10:00:00.000Z",
"name": "string",
"user_count": "integer"
},
"id": "string",
"relationships": {
"permissions": {
"data": [
{
"id": "string",
"type": "permissions"
}
]
}
},
"type": "roles"
}
],
"meta": {
"page": {
"total_count": "integer",
"total_filtered_count": "integer"
}
}
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/roles" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
List roles returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
# there is a valid "role" in the system
ROLE_DATA_ATTRIBUTES_NAME = environ["ROLE_DATA_ATTRIBUTES_NAME"]
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.list_roles(
filter=ROLE_DATA_ATTRIBUTES_NAME,
)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# List roles returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
# there is a valid "role" in the system
ROLE_DATA_ATTRIBUTES_NAME = ENV["ROLE_DATA_ATTRIBUTES_NAME"]
opts = {
filter: ROLE_DATA_ATTRIBUTES_NAME,
}
p api_instance.list_roles(opts)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// List roles returns "OK" response
package main
import (
"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"
)
func main() {
// there is a valid "role" in the system
RoleDataAttributesName := os.Getenv("ROLE_DATA_ATTRIBUTES_NAME")
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewRolesApi(apiClient)
resp, r, err := api.ListRoles(ctx, *datadogV2.NewListRolesOptionalParameters().WithFilter(RoleDataAttributesName))
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `RolesApi.ListRoles`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `RolesApi.ListRoles`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// List roles returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
import com.datadog.api.client.v2.api.RolesApi.ListRolesOptionalParameters;
import com.datadog.api.client.v2.model.RolesResponse;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
// there is a valid "role" in the system
String ROLE_DATA_ATTRIBUTES_NAME = System.getenv("ROLE_DATA_ATTRIBUTES_NAME");
try {
RolesResponse result =
apiInstance.listRoles(
new ListRolesOptionalParameters().filter(ROLE_DATA_ATTRIBUTES_NAME));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RolesApi#listRoles");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// List roles returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::ListRolesOptionalParams;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
#[tokio::main]
async fn main() {
// there is a valid "role" in the system
let role_data_attributes_name = std::env::var("ROLE_DATA_ATTRIBUTES_NAME").unwrap();
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api
.list_roles(ListRolesOptionalParams::default().filter(role_data_attributes_name.clone()))
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* List roles returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
// there is a valid "role" in the system
const ROLE_DATA_ATTRIBUTES_NAME = process.env
.ROLE_DATA_ATTRIBUTES_NAME as string;
const params: v2.RolesApiListRolesRequest = {
filter: ROLE_DATA_ATTRIBUTES_NAME,
};
apiInstance
.listRoles(params)
.then((data: v2.RolesResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
POST https://api.ap1.datadoghq.com/api/v2/roleshttps://api.datadoghq.eu/api/v2/roleshttps://api.ddog-gov.com/api/v2/roleshttps://api.datadoghq.com/api/v2/roleshttps://api.us3.datadoghq.com/api/v2/roleshttps://api.us5.datadoghq.com/api/v2/roles
Create a new role for your organization.
This endpoint requires the user_access_manage
permission.
OAuth apps require the user_access_manage
authorization scope to access this endpoint.
항목
유형
설명
data [required]
object
Data related to the creation of a role.
attributes [required]
object
Attributes of the created role.
created_at
date-time
Creation time of the role.
modified_at
date-time
Time of last role modification.
name [required]
string
Name of the role.
relationships
object
Relationships of the role object.
permissions
object
Relationship to multiple permissions objects.
data
[object]
Relationships to permission objects.
id
string
ID of the permission.
type
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
type
enum
Roles type.
Allowed enum values: roles
default: roles
{
"data": {
"type": "roles",
"attributes": {
"name": "Example-Role"
},
"relationships": {
"permissions": {
"data": [
{
"id": "string",
"type": "permissions"
}
]
}
}
}
}
OK
Response containing information about a created role.
항목
유형
설명
data
object
Role object returned by the API.
attributes
object
Attributes of the created role.
created_at
date-time
Creation time of the role.
modified_at
date-time
Time of last role modification.
name [required]
string
Name of the role.
id
string
The unique identifier of the role.
relationships
object
Relationships of the role object returned by the API.
permissions
object
Relationship to multiple permissions objects.
data
[object]
Relationships to permission objects.
id
string
ID of the permission.
type
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
type [required]
enum
Roles type.
Allowed enum values: roles
default: roles
{
"data": {
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"modified_at": "2019-09-19T10:00:00.000Z",
"name": "developers"
},
"id": "string",
"relationships": {
"permissions": {
"data": [
{
"id": "string",
"type": "permissions"
}
]
}
},
"type": "roles"
}
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/roles" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"data": {
"type": "roles",
"attributes": {
"name": "Example-Role"
},
"relationships": {
"permissions": {
"data": [
{
"id": "string",
"type": "permissions"
}
]
}
}
}
}
EOF
// Create role with a permission returns "OK" response
package main
import (
"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"
)
func main() {
// there is a valid "permission" in the system
PermissionID := os.Getenv("PERMISSION_ID")
body := datadogV2.RoleCreateRequest{
Data: datadogV2.RoleCreateData{
Type: datadogV2.ROLESTYPE_ROLES.Ptr(),
Attributes: datadogV2.RoleCreateAttributes{
Name: "Example-Role",
},
Relationships: &datadogV2.RoleRelationships{
Permissions: &datadogV2.RelationshipToPermissions{
Data: []datadogV2.RelationshipToPermissionData{
{
Id: datadog.PtrString(PermissionID),
Type: datadogV2.PERMISSIONSTYPE_PERMISSIONS.Ptr(),
},
},
},
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewRolesApi(apiClient)
resp, r, err := api.CreateRole(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `RolesApi.CreateRole`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `RolesApi.CreateRole`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Create role with a permission returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
import com.datadog.api.client.v2.model.PermissionsType;
import com.datadog.api.client.v2.model.RelationshipToPermissionData;
import com.datadog.api.client.v2.model.RelationshipToPermissions;
import com.datadog.api.client.v2.model.RoleCreateAttributes;
import com.datadog.api.client.v2.model.RoleCreateData;
import com.datadog.api.client.v2.model.RoleCreateRequest;
import com.datadog.api.client.v2.model.RoleCreateResponse;
import com.datadog.api.client.v2.model.RoleRelationships;
import com.datadog.api.client.v2.model.RolesType;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
// there is a valid "permission" in the system
String PERMISSION_ID = System.getenv("PERMISSION_ID");
RoleCreateRequest body =
new RoleCreateRequest()
.data(
new RoleCreateData()
.type(RolesType.ROLES)
.attributes(new RoleCreateAttributes().name("Example-Role"))
.relationships(
new RoleRelationships()
.permissions(
new RelationshipToPermissions()
.data(
Collections.singletonList(
new RelationshipToPermissionData()
.id(PERMISSION_ID)
.type(PermissionsType.PERMISSIONS))))));
try {
RoleCreateResponse result = apiInstance.createRole(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RolesApi#createRole");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
"""
Create role with a permission returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
from datadog_api_client.v2.model.permissions_type import PermissionsType
from datadog_api_client.v2.model.relationship_to_permission_data import RelationshipToPermissionData
from datadog_api_client.v2.model.relationship_to_permissions import RelationshipToPermissions
from datadog_api_client.v2.model.role_create_attributes import RoleCreateAttributes
from datadog_api_client.v2.model.role_create_data import RoleCreateData
from datadog_api_client.v2.model.role_create_request import RoleCreateRequest
from datadog_api_client.v2.model.role_relationships import RoleRelationships
from datadog_api_client.v2.model.roles_type import RolesType
# there is a valid "permission" in the system
PERMISSION_ID = environ["PERMISSION_ID"]
body = RoleCreateRequest(
data=RoleCreateData(
type=RolesType.ROLES,
attributes=RoleCreateAttributes(
name="Example-Role",
),
relationships=RoleRelationships(
permissions=RelationshipToPermissions(
data=[
RelationshipToPermissionData(
id=PERMISSION_ID,
type=PermissionsType.PERMISSIONS,
),
],
),
),
),
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.create_role(body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Create role with a permission returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
# there is a valid "permission" in the system
PERMISSION_ID = ENV["PERMISSION_ID"]
body = DatadogAPIClient::V2::RoleCreateRequest.new({
data: DatadogAPIClient::V2::RoleCreateData.new({
type: DatadogAPIClient::V2::RolesType::ROLES,
attributes: DatadogAPIClient::V2::RoleCreateAttributes.new({
name: "Example-Role",
}),
relationships: DatadogAPIClient::V2::RoleRelationships.new({
permissions: DatadogAPIClient::V2::RelationshipToPermissions.new({
data: [
DatadogAPIClient::V2::RelationshipToPermissionData.new({
id: PERMISSION_ID,
type: DatadogAPIClient::V2::PermissionsType::PERMISSIONS,
}),
],
}),
}),
}),
})
p api_instance.create_role(body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Create role with a permission returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
use datadog_api_client::datadogV2::model::PermissionsType;
use datadog_api_client::datadogV2::model::RelationshipToPermissionData;
use datadog_api_client::datadogV2::model::RelationshipToPermissions;
use datadog_api_client::datadogV2::model::RoleCreateAttributes;
use datadog_api_client::datadogV2::model::RoleCreateData;
use datadog_api_client::datadogV2::model::RoleCreateRequest;
use datadog_api_client::datadogV2::model::RoleRelationships;
use datadog_api_client::datadogV2::model::RolesType;
#[tokio::main]
async fn main() {
// there is a valid "permission" in the system
let permission_id = std::env::var("PERMISSION_ID").unwrap();
let body = RoleCreateRequest::new(
RoleCreateData::new(RoleCreateAttributes::new("Example-Role".to_string()))
.relationships(RoleRelationships::new().permissions(
RelationshipToPermissions::new().data(vec![
RelationshipToPermissionData::new()
.id(permission_id.clone())
.type_(PermissionsType::PERMISSIONS)
]),
))
.type_(RolesType::ROLES),
);
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api.create_role(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* Create role with a permission returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
// there is a valid "permission" in the system
const PERMISSION_ID = process.env.PERMISSION_ID as string;
const params: v2.RolesApiCreateRoleRequest = {
body: {
data: {
type: "roles",
attributes: {
name: "Example-Role",
},
relationships: {
permissions: {
data: [
{
id: PERMISSION_ID,
type: "permissions",
},
],
},
},
},
},
};
apiInstance
.createRole(params)
.then((data: v2.RoleCreateResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
GET https://api.ap1.datadoghq.com/api/v2/roles/{role_id}https://api.datadoghq.eu/api/v2/roles/{role_id}https://api.ddog-gov.com/api/v2/roles/{role_id}https://api.datadoghq.com/api/v2/roles/{role_id}https://api.us3.datadoghq.com/api/v2/roles/{role_id}https://api.us5.datadoghq.com/api/v2/roles/{role_id}
Get a role in the organization specified by the role’s role_id
.
OAuth apps require the user_access_read
authorization scope to access this endpoint.
이름
유형
설명
role_id [required]
string
The unique identifier of the role.
OK
Response containing information about a single role.
항목
유형
설명
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.
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.
permissions
object
Relationship to multiple permissions objects.
data
[object]
Relationships to permission objects.
id
string
ID of the permission.
type
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
type [required]
enum
Roles type.
Allowed enum values: roles
default: roles
{
"data": {
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"modified_at": "2019-09-19T10:00:00.000Z",
"name": "string",
"user_count": "integer"
},
"id": "string",
"relationships": {
"permissions": {
"data": [
{
"id": "string",
"type": "permissions"
}
]
}
},
"type": "roles"
}
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Not found
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export role_id="CHANGE_ME"
# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/roles/${role_id}" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get a role returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
# there is a valid "role" in the system
ROLE_DATA_ID = environ["ROLE_DATA_ID"]
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.get_role(
role_id=ROLE_DATA_ID,
)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get a role returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
# there is a valid "role" in the system
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]
p api_instance.get_role(ROLE_DATA_ID)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Get a role returns "OK" response
package main
import (
"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"
)
func main() {
// there is a valid "role" in the system
RoleDataID := os.Getenv("ROLE_DATA_ID")
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewRolesApi(apiClient)
resp, r, err := api.GetRole(ctx, RoleDataID)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `RolesApi.GetRole`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `RolesApi.GetRole`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get a role returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
import com.datadog.api.client.v2.model.RoleResponse;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
// there is a valid "role" in the system
String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");
try {
RoleResponse result = apiInstance.getRole(ROLE_DATA_ID);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RolesApi#getRole");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// Get a role returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
#[tokio::main]
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api.get_role(role_data_id.clone()).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* Get a role returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
// there is a valid "role" in the system
const ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;
const params: v2.RolesApiGetRoleRequest = {
roleId: ROLE_DATA_ID,
};
apiInstance
.getRole(params)
.then((data: v2.RoleResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
PATCH https://api.ap1.datadoghq.com/api/v2/roles/{role_id}https://api.datadoghq.eu/api/v2/roles/{role_id}https://api.ddog-gov.com/api/v2/roles/{role_id}https://api.datadoghq.com/api/v2/roles/{role_id}https://api.us3.datadoghq.com/api/v2/roles/{role_id}https://api.us5.datadoghq.com/api/v2/roles/{role_id}
Edit a role. Can only be used with application keys belonging to administrators.
This endpoint requires the user_access_manage
permission.
OAuth apps require the user_access_manage
authorization scope to access this endpoint.
이름
유형
설명
role_id [required]
string
The unique identifier of the role.
항목
유형
설명
data [required]
object
Data related to the update of a role.
attributes [required]
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
Name of the role.
user_count
int32
The user count.
id [required]
string
The unique identifier of the role.
relationships
object
Relationships of the role object.
permissions
object
Relationship to multiple permissions objects.
data
[object]
Relationships to permission objects.
id
string
ID of the permission.
type
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
type [required]
enum
Roles type.
Allowed enum values: roles
default: roles
{
"data": {
"id": "string",
"type": "roles",
"attributes": {
"name": "developers-updated"
},
"relationships": {
"permissions": {
"data": [
{
"id": "f2a8beb4-91f8-962d-b6d9-60215cda2214",
"type": "permissions"
}
]
}
}
}
}
OK
Response containing information about an updated role.
항목
유형
설명
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
Name of the 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.
permissions
object
Relationship to multiple permissions objects.
data
[object]
Relationships to permission objects.
id
string
ID of the permission.
type
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
type [required]
enum
Roles type.
Allowed enum values: roles
default: roles
{
"data": {
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"modified_at": "2019-09-19T10:00:00.000Z",
"name": "string",
"user_count": "integer"
},
"id": "string",
"relationships": {
"permissions": {
"data": [
{
"id": "string",
"type": "permissions"
}
]
}
},
"type": "roles"
}
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Not found
API error response.
{
"errors": [
"Bad Request"
]
}
Unprocessable Entity
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export role_id="CHANGE_ME"
# Curl command
curl -X PATCH "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/roles/${role_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"data": {
"attributes": {},
"id": "00000000-0000-1111-0000-000000000000",
"type": "roles"
}
}
EOF
"""
Update a role returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
from datadog_api_client.v2.model.permissions_type import PermissionsType
from datadog_api_client.v2.model.relationship_to_permission_data import RelationshipToPermissionData
from datadog_api_client.v2.model.relationship_to_permissions import RelationshipToPermissions
from datadog_api_client.v2.model.role_relationships import RoleRelationships
from datadog_api_client.v2.model.role_update_attributes import RoleUpdateAttributes
from datadog_api_client.v2.model.role_update_data import RoleUpdateData
from datadog_api_client.v2.model.role_update_request import RoleUpdateRequest
from datadog_api_client.v2.model.roles_type import RolesType
# there is a valid "role" in the system
ROLE_DATA_ATTRIBUTES_NAME = environ["ROLE_DATA_ATTRIBUTES_NAME"]
ROLE_DATA_ID = environ["ROLE_DATA_ID"]
# there is a valid "permission" in the system
PERMISSION_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()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.update_role(role_id=ROLE_DATA_ID, body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Update a role returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
# there is a valid "role" in the system
ROLE_DATA_ATTRIBUTES_NAME = ENV["ROLE_DATA_ATTRIBUTES_NAME"]
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]
# there is a valid "permission" in the system
PERMISSION_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,
}),
],
}),
}),
}),
})
p api_instance.update_role(ROLE_DATA_ID, body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Update a role returns "OK" response
package main
import (
"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"
)
func main() {
// there is a valid "role" in the system
RoleDataID := os.Getenv("ROLE_DATA_ID")
// there is a valid "permission" in the system
PermissionID := 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())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewRolesApi(apiClient)
resp, r, err := api.UpdateRole(ctx, RoleDataID, body)
if err != 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)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Update a role returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
import com.datadog.api.client.v2.model.PermissionsType;
import com.datadog.api.client.v2.model.RelationshipToPermissionData;
import com.datadog.api.client.v2.model.RelationshipToPermissions;
import com.datadog.api.client.v2.model.RoleRelationships;
import com.datadog.api.client.v2.model.RoleUpdateAttributes;
import com.datadog.api.client.v2.model.RoleUpdateData;
import com.datadog.api.client.v2.model.RoleUpdateRequest;
import com.datadog.api.client.v2.model.RoleUpdateResponse;
import com.datadog.api.client.v2.model.RolesType;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
// there is a valid "role" in the system
String ROLE_DATA_ATTRIBUTES_NAME = System.getenv("ROLE_DATA_ATTRIBUTES_NAME");
String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");
// there is a valid "permission" in the system
String PERMISSION_ID = System.getenv("PERMISSION_ID");
RoleUpdateRequest body =
new RoleUpdateRequest()
.data(
new RoleUpdateData()
.id(ROLE_DATA_ID)
.type(RolesType.ROLES)
.attributes(new RoleUpdateAttributes().name("developers-updated"))
.relationships(
new RoleRelationships()
.permissions(
new RelationshipToPermissions()
.data(
Collections.singletonList(
new RelationshipToPermissionData()
.id(PERMISSION_ID)
.type(PermissionsType.PERMISSIONS))))));
try {
RoleUpdateResponse result = apiInstance.updateRole(ROLE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// Update a role returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
use datadog_api_client::datadogV2::model::PermissionsType;
use datadog_api_client::datadogV2::model::RelationshipToPermissionData;
use datadog_api_client::datadogV2::model::RelationshipToPermissions;
use datadog_api_client::datadogV2::model::RoleRelationships;
use datadog_api_client::datadogV2::model::RoleUpdateAttributes;
use datadog_api_client::datadogV2::model::RoleUpdateData;
use datadog_api_client::datadogV2::model::RoleUpdateRequest;
use datadog_api_client::datadogV2::model::RolesType;
#[tokio::main]
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
// there is a valid "permission" in the system
let permission_id = std::env::var("PERMISSION_ID").unwrap();
let body = 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)
]),
)),
);
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api.update_role(role_data_id.clone(), body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-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";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
// there is a valid "role" in the system
const ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;
// there is a valid "permission" in the system
const PERMISSION_ID = process.env.PERMISSION_ID as string;
const params: 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));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
DELETE https://api.ap1.datadoghq.com/api/v2/roles/{role_id}https://api.datadoghq.eu/api/v2/roles/{role_id}https://api.ddog-gov.com/api/v2/roles/{role_id}https://api.datadoghq.com/api/v2/roles/{role_id}https://api.us3.datadoghq.com/api/v2/roles/{role_id}https://api.us5.datadoghq.com/api/v2/roles/{role_id}
Disables a role.
OAuth apps require the user_access_manage
authorization scope to access this endpoint.
이름
유형
설명
role_id [required]
string
The unique identifier of the role.
OK
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Not found
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export role_id="CHANGE_ME"
# Curl command
curl -X DELETE "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/roles/${role_id}" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Delete role returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
# there is a valid "role" in the system
ROLE_DATA_ID = environ["ROLE_DATA_ID"]
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
api_instance.delete_role(
role_id=ROLE_DATA_ID,
)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Delete role returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
# there is a valid "role" in the system
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]
api_instance.delete_role(ROLE_DATA_ID)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Delete role returns "OK" response
package main
import (
"context"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
// there is a valid "role" in the system
RoleDataID := os.Getenv("ROLE_DATA_ID")
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewRolesApi(apiClient)
r, err := api.DeleteRole(ctx, RoleDataID)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `RolesApi.DeleteRole`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Delete role returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
// there is a valid "role" in the system
String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");
try {
apiInstance.deleteRole(ROLE_DATA_ID);
} catch (ApiException e) {
System.err.println("Exception when calling RolesApi#deleteRole");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// Delete role returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
#[tokio::main]
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api.delete_role(role_data_id.clone()).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* Delete role returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
// there is a valid "role" in the system
const ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;
const params: v2.RolesApiDeleteRoleRequest = {
roleId: ROLE_DATA_ID,
};
apiInstance
.deleteRole(params)
.then((data: any) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
GET https://api.ap1.datadoghq.com/api/v2/roles/{role_id}/permissionshttps://api.datadoghq.eu/api/v2/roles/{role_id}/permissionshttps://api.ddog-gov.com/api/v2/roles/{role_id}/permissionshttps://api.datadoghq.com/api/v2/roles/{role_id}/permissionshttps://api.us3.datadoghq.com/api/v2/roles/{role_id}/permissionshttps://api.us5.datadoghq.com/api/v2/roles/{role_id}/permissions
Returns a list of all permissions for a single role.
OAuth apps require the user_access_read
authorization scope to access this endpoint.
이름
유형
설명
role_id [required]
string
The unique identifier of the role.
OK
Payload with API-returned permissions.
항목
유형
설명
data
[object]
Array of permissions.
attributes
object
Attributes of a permission.
created
date-time
Creation time of the permission.
description
string
Description of the permission.
display_name
string
Displayed name for the permission.
display_type
string
Display type.
group_name
string
Name of the permission group.
name
string
Name of the permission.
restricted
boolean
Whether or not the permission is restricted.
id
string
ID of the permission.
type [required]
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
{
"data": [
{
"attributes": {
"created": "2019-09-19T10:00:00.000Z",
"description": "string",
"display_name": "string",
"display_type": "string",
"group_name": "string",
"name": "string",
"restricted": false
},
"id": "string",
"type": "permissions"
}
]
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Not found
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export role_id="CHANGE_ME"
# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/roles/${role_id}/permissions" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
List permissions for a role returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
# there is a valid "role" in the system
ROLE_DATA_ID = environ["ROLE_DATA_ID"]
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.list_role_permissions(
role_id=ROLE_DATA_ID,
)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# List permissions for a role returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
# there is a valid "role" in the system
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]
p api_instance.list_role_permissions(ROLE_DATA_ID)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// List permissions for a role returns "OK" response
package main
import (
"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"
)
func main() {
// there is a valid "role" in the system
RoleDataID := os.Getenv("ROLE_DATA_ID")
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewRolesApi(apiClient)
resp, r, err := api.ListRolePermissions(ctx, RoleDataID)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `RolesApi.ListRolePermissions`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `RolesApi.ListRolePermissions`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// List permissions for a role returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
import com.datadog.api.client.v2.model.PermissionsResponse;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
// there is a valid "role" in the system
String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");
try {
PermissionsResponse result = apiInstance.listRolePermissions(ROLE_DATA_ID);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RolesApi#listRolePermissions");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// List permissions for a role returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
#[tokio::main]
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api.list_role_permissions(role_data_id.clone()).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* List permissions for a role returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
// there is a valid "role" in the system
const ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;
const params: v2.RolesApiListRolePermissionsRequest = {
roleId: ROLE_DATA_ID,
};
apiInstance
.listRolePermissions(params)
.then((data: v2.PermissionsResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
POST https://api.ap1.datadoghq.com/api/v2/roles/{role_id}/permissionshttps://api.datadoghq.eu/api/v2/roles/{role_id}/permissionshttps://api.ddog-gov.com/api/v2/roles/{role_id}/permissionshttps://api.datadoghq.com/api/v2/roles/{role_id}/permissionshttps://api.us3.datadoghq.com/api/v2/roles/{role_id}/permissionshttps://api.us5.datadoghq.com/api/v2/roles/{role_id}/permissions
Adds a permission to a role.
This endpoint requires the user_access_manage
permission.
OAuth apps require the user_access_manage
authorization scope to access this endpoint.
이름
유형
설명
role_id [required]
string
The unique identifier of the role.
항목
유형
설명
data
object
Relationship to permission object.
id
string
ID of the permission.
type
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
{
"data": {
"id": "f2a8beb4-91f8-962d-b6d9-60215cda2214",
"type": "permissions"
}
}
OK
Payload with API-returned permissions.
항목
유형
설명
data
[object]
Array of permissions.
attributes
object
Attributes of a permission.
created
date-time
Creation time of the permission.
description
string
Description of the permission.
display_name
string
Displayed name for the permission.
display_type
string
Display type.
group_name
string
Name of the permission group.
name
string
Name of the permission.
restricted
boolean
Whether or not the permission is restricted.
id
string
ID of the permission.
type [required]
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
{
"data": [
{
"attributes": {
"created": "2019-09-19T10:00:00.000Z",
"description": "string",
"display_name": "string",
"display_type": "string",
"group_name": "string",
"name": "string",
"restricted": false
},
"id": "string",
"type": "permissions"
}
]
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Not found
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export role_id="CHANGE_ME"
# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/roles/${role_id}/permissions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"data": {
"id": "f2a8beb4-91f8-962d-b6d9-60215cda2214",
"type": "permissions"
}
}
EOF
// Grant permission to a role returns "OK" response
package main
import (
"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"
)
func main() {
// there is a valid "role" in the system
RoleDataID := os.Getenv("ROLE_DATA_ID")
// there is a valid "permission" in the system
PermissionID := os.Getenv("PERMISSION_ID")
body := datadogV2.RelationshipToPermission{
Data: &datadogV2.RelationshipToPermissionData{
Id: datadog.PtrString(PermissionID),
Type: datadogV2.PERMISSIONSTYPE_PERMISSIONS.Ptr(),
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewRolesApi(apiClient)
resp, r, err := api.AddPermissionToRole(ctx, RoleDataID, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `RolesApi.AddPermissionToRole`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `RolesApi.AddPermissionToRole`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Grant permission to a role returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
import com.datadog.api.client.v2.model.PermissionsResponse;
import com.datadog.api.client.v2.model.PermissionsType;
import com.datadog.api.client.v2.model.RelationshipToPermission;
import com.datadog.api.client.v2.model.RelationshipToPermissionData;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
// there is a valid "role" in the system
String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");
// there is a valid "permission" in the system
String PERMISSION_ID = System.getenv("PERMISSION_ID");
RelationshipToPermission body =
new RelationshipToPermission()
.data(
new RelationshipToPermissionData()
.id(PERMISSION_ID)
.type(PermissionsType.PERMISSIONS));
try {
PermissionsResponse result = apiInstance.addPermissionToRole(ROLE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RolesApi#addPermissionToRole");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
"""
Grant permission to a role returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
from datadog_api_client.v2.model.permissions_type import PermissionsType
from datadog_api_client.v2.model.relationship_to_permission import RelationshipToPermission
from datadog_api_client.v2.model.relationship_to_permission_data import RelationshipToPermissionData
# there is a valid "role" in the system
ROLE_DATA_ID = environ["ROLE_DATA_ID"]
# there is a valid "permission" in the system
PERMISSION_ID = environ["PERMISSION_ID"]
body = RelationshipToPermission(
data=RelationshipToPermissionData(
id=PERMISSION_ID,
type=PermissionsType.PERMISSIONS,
),
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.add_permission_to_role(role_id=ROLE_DATA_ID, body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Grant permission to a role returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
# there is a valid "role" in the system
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]
# there is a valid "permission" in the system
PERMISSION_ID = ENV["PERMISSION_ID"]
body = DatadogAPIClient::V2::RelationshipToPermission.new({
data: DatadogAPIClient::V2::RelationshipToPermissionData.new({
id: PERMISSION_ID,
type: DatadogAPIClient::V2::PermissionsType::PERMISSIONS,
}),
})
p api_instance.add_permission_to_role(ROLE_DATA_ID, body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Grant permission to a role returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
use datadog_api_client::datadogV2::model::PermissionsType;
use datadog_api_client::datadogV2::model::RelationshipToPermission;
use datadog_api_client::datadogV2::model::RelationshipToPermissionData;
#[tokio::main]
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
// there is a valid "permission" in the system
let permission_id = std::env::var("PERMISSION_ID").unwrap();
let body = RelationshipToPermission::new().data(
RelationshipToPermissionData::new()
.id(permission_id.clone())
.type_(PermissionsType::PERMISSIONS),
);
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api.add_permission_to_role(role_data_id.clone(), body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* Grant permission to a role returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
// there is a valid "role" in the system
const ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;
// there is a valid "permission" in the system
const PERMISSION_ID = process.env.PERMISSION_ID as string;
const params: v2.RolesApiAddPermissionToRoleRequest = {
body: {
data: {
id: PERMISSION_ID,
type: "permissions",
},
},
roleId: ROLE_DATA_ID,
};
apiInstance
.addPermissionToRole(params)
.then((data: v2.PermissionsResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
DELETE https://api.ap1.datadoghq.com/api/v2/roles/{role_id}/permissionshttps://api.datadoghq.eu/api/v2/roles/{role_id}/permissionshttps://api.ddog-gov.com/api/v2/roles/{role_id}/permissionshttps://api.datadoghq.com/api/v2/roles/{role_id}/permissionshttps://api.us3.datadoghq.com/api/v2/roles/{role_id}/permissionshttps://api.us5.datadoghq.com/api/v2/roles/{role_id}/permissions
Removes a permission from a role.
This endpoint requires the user_access_manage
permission.
OAuth apps require the user_access_manage
authorization scope to access this endpoint.
이름
유형
설명
role_id [required]
string
The unique identifier of the role.
항목
유형
설명
data
object
Relationship to permission object.
id
string
ID of the permission.
type
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
{
"data": {
"id": "f2a8beb4-91f8-962d-b6d9-60215cda2214",
"type": "permissions"
}
}
OK
Payload with API-returned permissions.
항목
유형
설명
data
[object]
Array of permissions.
attributes
object
Attributes of a permission.
created
date-time
Creation time of the permission.
description
string
Description of the permission.
display_name
string
Displayed name for the permission.
display_type
string
Display type.
group_name
string
Name of the permission group.
name
string
Name of the permission.
restricted
boolean
Whether or not the permission is restricted.
id
string
ID of the permission.
type [required]
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
{
"data": [
{
"attributes": {
"created": "2019-09-19T10:00:00.000Z",
"description": "string",
"display_name": "string",
"display_type": "string",
"group_name": "string",
"name": "string",
"restricted": false
},
"id": "string",
"type": "permissions"
}
]
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Not found
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export role_id="CHANGE_ME"
# Curl command
curl -X DELETE "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/roles/${role_id}/permissions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"data": {
"id": "f2a8beb4-91f8-962d-b6d9-60215cda2214",
"type": "permissions"
}
}
EOF
// Revoke permission returns "OK" response
package main
import (
"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"
)
func main() {
// there is a valid "role" in the system
RoleDataID := os.Getenv("ROLE_DATA_ID")
// there is a valid "permission" in the system
PermissionID := os.Getenv("PERMISSION_ID")
body := datadogV2.RelationshipToPermission{
Data: &datadogV2.RelationshipToPermissionData{
Id: datadog.PtrString(PermissionID),
Type: datadogV2.PERMISSIONSTYPE_PERMISSIONS.Ptr(),
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewRolesApi(apiClient)
resp, r, err := api.RemovePermissionFromRole(ctx, RoleDataID, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `RolesApi.RemovePermissionFromRole`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `RolesApi.RemovePermissionFromRole`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Revoke permission returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
import com.datadog.api.client.v2.model.PermissionsResponse;
import com.datadog.api.client.v2.model.PermissionsType;
import com.datadog.api.client.v2.model.RelationshipToPermission;
import com.datadog.api.client.v2.model.RelationshipToPermissionData;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
// there is a valid "role" in the system
String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");
// there is a valid "permission" in the system
String PERMISSION_ID = System.getenv("PERMISSION_ID");
RelationshipToPermission body =
new RelationshipToPermission()
.data(
new RelationshipToPermissionData()
.id(PERMISSION_ID)
.type(PermissionsType.PERMISSIONS));
try {
PermissionsResponse result = apiInstance.removePermissionFromRole(ROLE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RolesApi#removePermissionFromRole");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
"""
Revoke permission returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
from datadog_api_client.v2.model.permissions_type import PermissionsType
from datadog_api_client.v2.model.relationship_to_permission import RelationshipToPermission
from datadog_api_client.v2.model.relationship_to_permission_data import RelationshipToPermissionData
# there is a valid "role" in the system
ROLE_DATA_ID = environ["ROLE_DATA_ID"]
# there is a valid "permission" in the system
PERMISSION_ID = environ["PERMISSION_ID"]
body = RelationshipToPermission(
data=RelationshipToPermissionData(
id=PERMISSION_ID,
type=PermissionsType.PERMISSIONS,
),
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.remove_permission_from_role(role_id=ROLE_DATA_ID, body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Revoke permission returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
# there is a valid "role" in the system
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]
# there is a valid "permission" in the system
PERMISSION_ID = ENV["PERMISSION_ID"]
body = DatadogAPIClient::V2::RelationshipToPermission.new({
data: DatadogAPIClient::V2::RelationshipToPermissionData.new({
id: PERMISSION_ID,
type: DatadogAPIClient::V2::PermissionsType::PERMISSIONS,
}),
})
p api_instance.remove_permission_from_role(ROLE_DATA_ID, body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Revoke permission returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
use datadog_api_client::datadogV2::model::PermissionsType;
use datadog_api_client::datadogV2::model::RelationshipToPermission;
use datadog_api_client::datadogV2::model::RelationshipToPermissionData;
#[tokio::main]
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
// there is a valid "permission" in the system
let permission_id = std::env::var("PERMISSION_ID").unwrap();
let body = RelationshipToPermission::new().data(
RelationshipToPermissionData::new()
.id(permission_id.clone())
.type_(PermissionsType::PERMISSIONS),
);
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api
.remove_permission_from_role(role_data_id.clone(), body)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* Revoke permission returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
// there is a valid "role" in the system
const ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;
// there is a valid "permission" in the system
const PERMISSION_ID = process.env.PERMISSION_ID as string;
const params: v2.RolesApiRemovePermissionFromRoleRequest = {
body: {
data: {
id: PERMISSION_ID,
type: "permissions",
},
},
roleId: ROLE_DATA_ID,
};
apiInstance
.removePermissionFromRole(params)
.then((data: v2.PermissionsResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
GET https://api.ap1.datadoghq.com/api/v2/roles/{role_id}/usershttps://api.datadoghq.eu/api/v2/roles/{role_id}/usershttps://api.ddog-gov.com/api/v2/roles/{role_id}/usershttps://api.datadoghq.com/api/v2/roles/{role_id}/usershttps://api.us3.datadoghq.com/api/v2/roles/{role_id}/usershttps://api.us5.datadoghq.com/api/v2/roles/{role_id}/users
Gets all users of a role.
OAuth apps require the user_access_read
authorization scope to access this endpoint.
이름
유형
설명
role_id [required]
string
The unique identifier of the role.
이름
유형
설명
page[size]
integer
Size for a given page. The maximum allowed value is 100.
page[number]
integer
Specific page number to return.
sort
string
User attribute to order results by. Sort order is ascending by default.
Sort order is descending if the field is prefixed by a negative sign,
for example sort=-name
. Options: name
, email
, status
.
filter
string
Filter all users by the given string. Defaults to no filtering.
OK
Response containing information about multiple users.
항목
유형
설명
data
[object]
Array of returned users.
attributes
object
Attributes of user object returned by the API.
created_at
date-time
Creation time of the user.
disabled
boolean
Whether the user is disabled.
string
Email of the user.
handle
string
Handle of the user.
icon
string
URL of the user's icon.
mfa_enabled
boolean
If user has MFA enabled.
modified_at
date-time
Time that the user was last modified.
name
string
Name of the user.
service_account
boolean
Whether the user is a service account.
status
string
Status of the user.
title
string
Title of the user.
verified
boolean
Whether the user is verified.
id
string
ID of the user.
relationships
object
Relationships of the user object returned by the API.
org
object
Relationship to an organization.
data [required]
object
Relationship to organization object.
id [required]
string
ID of the organization.
type [required]
enum
Organizations resource type.
Allowed enum values: orgs
default: orgs
other_orgs
object
Relationship to organizations.
data [required]
[object]
Relationships to organization objects.
id [required]
string
ID of the organization.
type [required]
enum
Organizations resource type.
Allowed enum values: orgs
default: orgs
other_users
object
Relationship to users.
data [required]
[object]
Relationships to user objects.
id [required]
string
A unique identifier that represents the user.
type [required]
enum
Users resource type.
Allowed enum values: users
default: users
roles
object
Relationship to roles.
data
[object]
An array containing type and the unique identifier of a role.
id
string
The unique identifier of the role.
type
enum
Roles type.
Allowed enum values: roles
default: roles
type
enum
Users resource type.
Allowed enum values: users
default: users
included
[ <oneOf>]
Array of objects related to the users.
Option 1
object
Organization object.
attributes
object
Attributes of the organization.
created_at
date-time
Creation time of the organization.
description
string
Description of the organization.
disabled
boolean
Whether or not the organization is disabled.
modified_at
date-time
Time of last organization modification.
name
string
Name of the organization.
public_id
string
Public ID of the organization.
sharing
string
Sharing type of the organization.
url
string
URL of the site that this organization exists at.
id
string
ID of the organization.
type [required]
enum
Organizations resource type.
Allowed enum values: orgs
default: orgs
Option 2
object
Permission object.
attributes
object
Attributes of a permission.
created
date-time
Creation time of the permission.
description
string
Description of the permission.
display_name
string
Displayed name for the permission.
display_type
string
Display type.
group_name
string
Name of the permission group.
name
string
Name of the permission.
restricted
boolean
Whether or not the permission is restricted.
id
string
ID of the permission.
type [required]
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
Option 3
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.
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.
permissions
object
Relationship to multiple permissions objects.
data
[object]
Relationships to permission objects.
id
string
ID of the permission.
type
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
type [required]
enum
Roles type.
Allowed enum values: roles
default: roles
meta
object
Object describing meta attributes of response.
page
object
Pagination object.
total_count
int64
Total count.
total_filtered_count
int64
Total count of elements matched by the filter.
{
"data": [
{
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"disabled": false,
"email": "string",
"handle": "string",
"icon": "string",
"mfa_enabled": false,
"modified_at": "2019-09-19T10:00:00.000Z",
"name": "string",
"service_account": false,
"status": "string",
"title": "string",
"verified": false
},
"id": "string",
"relationships": {
"org": {
"data": {
"id": "00000000-0000-beef-0000-000000000000",
"type": "orgs"
}
},
"other_orgs": {
"data": [
{
"id": "00000000-0000-beef-0000-000000000000",
"type": "orgs"
}
]
},
"other_users": {
"data": [
{
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
]
},
"roles": {
"data": [
{
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"type": "roles"
}
]
}
},
"type": "users"
}
],
"included": [
{
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"description": "string",
"disabled": false,
"modified_at": "2019-09-19T10:00:00.000Z",
"name": "string",
"public_id": "string",
"sharing": "string",
"url": "string"
},
"id": "string",
"type": "orgs"
}
],
"meta": {
"page": {
"total_count": "integer",
"total_filtered_count": "integer"
}
}
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Not found
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export role_id="CHANGE_ME"
# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/roles/${role_id}/users" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get all users of a role returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
# there is a valid "role" in the system
ROLE_DATA_ID = environ["ROLE_DATA_ID"]
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.list_role_users(
role_id=ROLE_DATA_ID,
)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get all users of a role returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
# there is a valid "role" in the system
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]
p api_instance.list_role_users(ROLE_DATA_ID)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Get all users of a role returns "OK" response
package main
import (
"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"
)
func main() {
// there is a valid "role" in the system
RoleDataID := os.Getenv("ROLE_DATA_ID")
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewRolesApi(apiClient)
resp, r, err := api.ListRoleUsers(ctx, RoleDataID, *datadogV2.NewListRoleUsersOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `RolesApi.ListRoleUsers`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `RolesApi.ListRoleUsers`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get all users of a role returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
import com.datadog.api.client.v2.model.UsersResponse;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
// there is a valid "role" in the system
String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");
try {
UsersResponse result = apiInstance.listRoleUsers(ROLE_DATA_ID);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RolesApi#listRoleUsers");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// Get all users of a role returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::ListRoleUsersOptionalParams;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
#[tokio::main]
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api
.list_role_users(role_data_id.clone(), ListRoleUsersOptionalParams::default())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* Get all users of a role returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
// there is a valid "role" in the system
const ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;
const params: v2.RolesApiListRoleUsersRequest = {
roleId: ROLE_DATA_ID,
};
apiInstance
.listRoleUsers(params)
.then((data: v2.UsersResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
POST https://api.ap1.datadoghq.com/api/v2/roles/{role_id}/usershttps://api.datadoghq.eu/api/v2/roles/{role_id}/usershttps://api.ddog-gov.com/api/v2/roles/{role_id}/usershttps://api.datadoghq.com/api/v2/roles/{role_id}/usershttps://api.us3.datadoghq.com/api/v2/roles/{role_id}/usershttps://api.us5.datadoghq.com/api/v2/roles/{role_id}/users
Adds a user to a role.
This endpoint requires the user_access_manage
permission.
OAuth apps require the user_access_manage
authorization scope to access this endpoint.
이름
유형
설명
role_id [required]
string
The unique identifier of the role.
항목
유형
설명
data [required]
object
Relationship to user object.
id [required]
string
A unique identifier that represents the user.
type [required]
enum
Users resource type.
Allowed enum values: users
default: users
{
"data": {
"id": "c1d4eb9e-8bb0-974d-85a5-a7dd9db46bee",
"type": "users"
}
}
OK
Response containing information about multiple users.
항목
유형
설명
data
[object]
Array of returned users.
attributes
object
Attributes of user object returned by the API.
created_at
date-time
Creation time of the user.
disabled
boolean
Whether the user is disabled.
string
Email of the user.
handle
string
Handle of the user.
icon
string
URL of the user's icon.
mfa_enabled
boolean
If user has MFA enabled.
modified_at
date-time
Time that the user was last modified.
name
string
Name of the user.
service_account
boolean
Whether the user is a service account.
status
string
Status of the user.
title
string
Title of the user.
verified
boolean
Whether the user is verified.
id
string
ID of the user.
relationships
object
Relationships of the user object returned by the API.
org
object
Relationship to an organization.
data [required]
object
Relationship to organization object.
id [required]
string
ID of the organization.
type [required]
enum
Organizations resource type.
Allowed enum values: orgs
default: orgs
other_orgs
object
Relationship to organizations.
data [required]
[object]
Relationships to organization objects.
id [required]
string
ID of the organization.
type [required]
enum
Organizations resource type.
Allowed enum values: orgs
default: orgs
other_users
object
Relationship to users.
data [required]
[object]
Relationships to user objects.
id [required]
string
A unique identifier that represents the user.
type [required]
enum
Users resource type.
Allowed enum values: users
default: users
roles
object
Relationship to roles.
data
[object]
An array containing type and the unique identifier of a role.
id
string
The unique identifier of the role.
type
enum
Roles type.
Allowed enum values: roles
default: roles
type
enum
Users resource type.
Allowed enum values: users
default: users
included
[ <oneOf>]
Array of objects related to the users.
Option 1
object
Organization object.
attributes
object
Attributes of the organization.
created_at
date-time
Creation time of the organization.
description
string
Description of the organization.
disabled
boolean
Whether or not the organization is disabled.
modified_at
date-time
Time of last organization modification.
name
string
Name of the organization.
public_id
string
Public ID of the organization.
sharing
string
Sharing type of the organization.
url
string
URL of the site that this organization exists at.
id
string
ID of the organization.
type [required]
enum
Organizations resource type.
Allowed enum values: orgs
default: orgs
Option 2
object
Permission object.
attributes
object
Attributes of a permission.
created
date-time
Creation time of the permission.
description
string
Description of the permission.
display_name
string
Displayed name for the permission.
display_type
string
Display type.
group_name
string
Name of the permission group.
name
string
Name of the permission.
restricted
boolean
Whether or not the permission is restricted.
id
string
ID of the permission.
type [required]
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
Option 3
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.
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.
permissions
object
Relationship to multiple permissions objects.
data
[object]
Relationships to permission objects.
id
string
ID of the permission.
type
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
type [required]
enum
Roles type.
Allowed enum values: roles
default: roles
meta
object
Object describing meta attributes of response.
page
object
Pagination object.
total_count
int64
Total count.
total_filtered_count
int64
Total count of elements matched by the filter.
{
"data": [
{
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"disabled": false,
"email": "string",
"handle": "string",
"icon": "string",
"mfa_enabled": false,
"modified_at": "2019-09-19T10:00:00.000Z",
"name": "string",
"service_account": false,
"status": "string",
"title": "string",
"verified": false
},
"id": "string",
"relationships": {
"org": {
"data": {
"id": "00000000-0000-beef-0000-000000000000",
"type": "orgs"
}
},
"other_orgs": {
"data": [
{
"id": "00000000-0000-beef-0000-000000000000",
"type": "orgs"
}
]
},
"other_users": {
"data": [
{
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
]
},
"roles": {
"data": [
{
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"type": "roles"
}
]
}
},
"type": "users"
}
],
"included": [
{
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"description": "string",
"disabled": false,
"modified_at": "2019-09-19T10:00:00.000Z",
"name": "string",
"public_id": "string",
"sharing": "string",
"url": "string"
},
"id": "string",
"type": "orgs"
}
],
"meta": {
"page": {
"total_count": "integer",
"total_filtered_count": "integer"
}
}
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Not found
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export role_id="CHANGE_ME"
# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/roles/${role_id}/users" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"data": {
"id": "c1d4eb9e-8bb0-974d-85a5-a7dd9db46bee",
"type": "users"
}
}
EOF
// Add a user to a role returns "OK" response
package main
import (
"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"
)
func main() {
// there is a valid "role" in the system
RoleDataID := os.Getenv("ROLE_DATA_ID")
// there is a valid "user" in the system
UserDataID := os.Getenv("USER_DATA_ID")
body := datadogV2.RelationshipToUser{
Data: datadogV2.RelationshipToUserData{
Id: UserDataID,
Type: datadogV2.USERSTYPE_USERS,
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewRolesApi(apiClient)
resp, r, err := api.AddUserToRole(ctx, RoleDataID, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `RolesApi.AddUserToRole`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `RolesApi.AddUserToRole`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Add a user to a role returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
import com.datadog.api.client.v2.model.RelationshipToUser;
import com.datadog.api.client.v2.model.RelationshipToUserData;
import com.datadog.api.client.v2.model.UsersResponse;
import com.datadog.api.client.v2.model.UsersType;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
// there is a valid "role" in the system
String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");
// there is a valid "user" in the system
String USER_DATA_ID = System.getenv("USER_DATA_ID");
RelationshipToUser body =
new RelationshipToUser()
.data(new RelationshipToUserData().id(USER_DATA_ID).type(UsersType.USERS));
try {
UsersResponse result = apiInstance.addUserToRole(ROLE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RolesApi#addUserToRole");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
"""
Add a user to a role returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
from datadog_api_client.v2.model.relationship_to_user import RelationshipToUser
from datadog_api_client.v2.model.relationship_to_user_data import RelationshipToUserData
from datadog_api_client.v2.model.users_type import UsersType
# there is a valid "role" in the system
ROLE_DATA_ID = environ["ROLE_DATA_ID"]
# there is a valid "user" in the system
USER_DATA_ID = environ["USER_DATA_ID"]
body = RelationshipToUser(
data=RelationshipToUserData(
id=USER_DATA_ID,
type=UsersType.USERS,
),
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.add_user_to_role(role_id=ROLE_DATA_ID, body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Add a user to a role returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
# there is a valid "role" in the system
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]
# there is a valid "user" in the system
USER_DATA_ID = ENV["USER_DATA_ID"]
body = DatadogAPIClient::V2::RelationshipToUser.new({
data: DatadogAPIClient::V2::RelationshipToUserData.new({
id: USER_DATA_ID,
type: DatadogAPIClient::V2::UsersType::USERS,
}),
})
p api_instance.add_user_to_role(ROLE_DATA_ID, body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Add a user to a role returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
use datadog_api_client::datadogV2::model::RelationshipToUser;
use datadog_api_client::datadogV2::model::RelationshipToUserData;
use datadog_api_client::datadogV2::model::UsersType;
#[tokio::main]
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
// there is a valid "user" in the system
let user_data_id = std::env::var("USER_DATA_ID").unwrap();
let body = RelationshipToUser::new(RelationshipToUserData::new(
user_data_id.clone(),
UsersType::USERS,
));
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api.add_user_to_role(role_data_id.clone(), body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* Add a user to a role returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
// there is a valid "role" in the system
const ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;
// there is a valid "user" in the system
const USER_DATA_ID = process.env.USER_DATA_ID as string;
const params: v2.RolesApiAddUserToRoleRequest = {
body: {
data: {
id: USER_DATA_ID,
type: "users",
},
},
roleId: ROLE_DATA_ID,
};
apiInstance
.addUserToRole(params)
.then((data: v2.UsersResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
DELETE https://api.ap1.datadoghq.com/api/v2/roles/{role_id}/usershttps://api.datadoghq.eu/api/v2/roles/{role_id}/usershttps://api.ddog-gov.com/api/v2/roles/{role_id}/usershttps://api.datadoghq.com/api/v2/roles/{role_id}/usershttps://api.us3.datadoghq.com/api/v2/roles/{role_id}/usershttps://api.us5.datadoghq.com/api/v2/roles/{role_id}/users
Removes a user from a role.
This endpoint requires the user_access_manage
permission.
OAuth apps require the user_access_manage
authorization scope to access this endpoint.
이름
유형
설명
role_id [required]
string
The unique identifier of the role.
항목
유형
설명
data [required]
object
Relationship to user object.
id [required]
string
A unique identifier that represents the user.
type [required]
enum
Users resource type.
Allowed enum values: users
default: users
{
"data": {
"id": "c1d4eb9e-8bb0-974d-85a5-a7dd9db46bee",
"type": "users"
}
}
OK
Response containing information about multiple users.
항목
유형
설명
data
[object]
Array of returned users.
attributes
object
Attributes of user object returned by the API.
created_at
date-time
Creation time of the user.
disabled
boolean
Whether the user is disabled.
string
Email of the user.
handle
string
Handle of the user.
icon
string
URL of the user's icon.
mfa_enabled
boolean
If user has MFA enabled.
modified_at
date-time
Time that the user was last modified.
name
string
Name of the user.
service_account
boolean
Whether the user is a service account.
status
string
Status of the user.
title
string
Title of the user.
verified
boolean
Whether the user is verified.
id
string
ID of the user.
relationships
object
Relationships of the user object returned by the API.
org
object
Relationship to an organization.
data [required]
object
Relationship to organization object.
id [required]
string
ID of the organization.
type [required]
enum
Organizations resource type.
Allowed enum values: orgs
default: orgs
other_orgs
object
Relationship to organizations.
data [required]
[object]
Relationships to organization objects.
id [required]
string
ID of the organization.
type [required]
enum
Organizations resource type.
Allowed enum values: orgs
default: orgs
other_users
object
Relationship to users.
data [required]
[object]
Relationships to user objects.
id [required]
string
A unique identifier that represents the user.
type [required]
enum
Users resource type.
Allowed enum values: users
default: users
roles
object
Relationship to roles.
data
[object]
An array containing type and the unique identifier of a role.
id
string
The unique identifier of the role.
type
enum
Roles type.
Allowed enum values: roles
default: roles
type
enum
Users resource type.
Allowed enum values: users
default: users
included
[ <oneOf>]
Array of objects related to the users.
Option 1
object
Organization object.
attributes
object
Attributes of the organization.
created_at
date-time
Creation time of the organization.
description
string
Description of the organization.
disabled
boolean
Whether or not the organization is disabled.
modified_at
date-time
Time of last organization modification.
name
string
Name of the organization.
public_id
string
Public ID of the organization.
sharing
string
Sharing type of the organization.
url
string
URL of the site that this organization exists at.
id
string
ID of the organization.
type [required]
enum
Organizations resource type.
Allowed enum values: orgs
default: orgs
Option 2
object
Permission object.
attributes
object
Attributes of a permission.
created
date-time
Creation time of the permission.
description
string
Description of the permission.
display_name
string
Displayed name for the permission.
display_type
string
Display type.
group_name
string
Name of the permission group.
name
string
Name of the permission.
restricted
boolean
Whether or not the permission is restricted.
id
string
ID of the permission.
type [required]
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
Option 3
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.
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.
permissions
object
Relationship to multiple permissions objects.
data
[object]
Relationships to permission objects.
id
string
ID of the permission.
type
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
type [required]
enum
Roles type.
Allowed enum values: roles
default: roles
meta
object
Object describing meta attributes of response.
page
object
Pagination object.
total_count
int64
Total count.
total_filtered_count
int64
Total count of elements matched by the filter.
{
"data": [
{
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"disabled": false,
"email": "string",
"handle": "string",
"icon": "string",
"mfa_enabled": false,
"modified_at": "2019-09-19T10:00:00.000Z",
"name": "string",
"service_account": false,
"status": "string",
"title": "string",
"verified": false
},
"id": "string",
"relationships": {
"org": {
"data": {
"id": "00000000-0000-beef-0000-000000000000",
"type": "orgs"
}
},
"other_orgs": {
"data": [
{
"id": "00000000-0000-beef-0000-000000000000",
"type": "orgs"
}
]
},
"other_users": {
"data": [
{
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
]
},
"roles": {
"data": [
{
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"type": "roles"
}
]
}
},
"type": "users"
}
],
"included": [
{
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"description": "string",
"disabled": false,
"modified_at": "2019-09-19T10:00:00.000Z",
"name": "string",
"public_id": "string",
"sharing": "string",
"url": "string"
},
"id": "string",
"type": "orgs"
}
],
"meta": {
"page": {
"total_count": "integer",
"total_filtered_count": "integer"
}
}
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Not found
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export role_id="CHANGE_ME"
# Curl command
curl -X DELETE "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/roles/${role_id}/users" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"data": {
"id": "c1d4eb9e-8bb0-974d-85a5-a7dd9db46bee",
"type": "users"
}
}
EOF
// Remove a user from a role returns "OK" response
package main
import (
"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"
)
func main() {
// there is a valid "role" in the system
RoleDataID := os.Getenv("ROLE_DATA_ID")
// there is a valid "user" in the system
UserDataID := os.Getenv("USER_DATA_ID")
body := datadogV2.RelationshipToUser{
Data: datadogV2.RelationshipToUserData{
Id: UserDataID,
Type: datadogV2.USERSTYPE_USERS,
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewRolesApi(apiClient)
resp, r, err := api.RemoveUserFromRole(ctx, RoleDataID, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `RolesApi.RemoveUserFromRole`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `RolesApi.RemoveUserFromRole`:\n%s\n", responseContent)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Remove a user from a role returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
import com.datadog.api.client.v2.model.RelationshipToUser;
import com.datadog.api.client.v2.model.RelationshipToUserData;
import com.datadog.api.client.v2.model.UsersResponse;
import com.datadog.api.client.v2.model.UsersType;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
// there is a valid "role" in the system
String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");
// there is a valid "user" in the system
String USER_DATA_ID = System.getenv("USER_DATA_ID");
RelationshipToUser body =
new RelationshipToUser()
.data(new RelationshipToUserData().id(USER_DATA_ID).type(UsersType.USERS));
try {
UsersResponse result = apiInstance.removeUserFromRole(ROLE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RolesApi#removeUserFromRole");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
"""
Remove a user from a role returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
from datadog_api_client.v2.model.relationship_to_user import RelationshipToUser
from datadog_api_client.v2.model.relationship_to_user_data import RelationshipToUserData
from datadog_api_client.v2.model.users_type import UsersType
# there is a valid "role" in the system
ROLE_DATA_ID = environ["ROLE_DATA_ID"]
# there is a valid "user" in the system
USER_DATA_ID = environ["USER_DATA_ID"]
body = RelationshipToUser(
data=RelationshipToUserData(
id=USER_DATA_ID,
type=UsersType.USERS,
),
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.remove_user_from_role(role_id=ROLE_DATA_ID, body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Remove a user from a role returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
# there is a valid "role" in the system
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]
# there is a valid "user" in the system
USER_DATA_ID = ENV["USER_DATA_ID"]
body = DatadogAPIClient::V2::RelationshipToUser.new({
data: DatadogAPIClient::V2::RelationshipToUserData.new({
id: USER_DATA_ID,
type: DatadogAPIClient::V2::UsersType::USERS,
}),
})
p api_instance.remove_user_from_role(ROLE_DATA_ID, body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Remove a user from a role returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
use datadog_api_client::datadogV2::model::RelationshipToUser;
use datadog_api_client::datadogV2::model::RelationshipToUserData;
use datadog_api_client::datadogV2::model::UsersType;
#[tokio::main]
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
// there is a valid "user" in the system
let user_data_id = std::env::var("USER_DATA_ID").unwrap();
let body = RelationshipToUser::new(RelationshipToUserData::new(
user_data_id.clone(),
UsersType::USERS,
));
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api.remove_user_from_role(role_data_id.clone(), body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
* Remove a user from a role returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
// there is a valid "role" in the system
const ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;
// there is a valid "user" in the system
const USER_DATA_ID = process.env.USER_DATA_ID as string;
const params: v2.RolesApiRemoveUserFromRoleRequest = {
body: {
data: {
id: USER_DATA_ID,
type: "users",
},
},
roleId: ROLE_DATA_ID,
};
apiInstance
.removeUserFromRole(params)
.then((data: v2.UsersResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
POST https://api.ap1.datadoghq.com/api/v2/roles/{role_id}/clonehttps://api.datadoghq.eu/api/v2/roles/{role_id}/clonehttps://api.ddog-gov.com/api/v2/roles/{role_id}/clonehttps://api.datadoghq.com/api/v2/roles/{role_id}/clonehttps://api.us3.datadoghq.com/api/v2/roles/{role_id}/clonehttps://api.us5.datadoghq.com/api/v2/roles/{role_id}/clone
Clone an existing role
This endpoint requires the user_access_manage
permission.
OAuth apps require the user_access_manage
authorization scope to access this endpoint.
이름
유형
설명
role_id [required]
string
The unique identifier of the role.
항목
유형
설명
data [required]
object
Data for the clone role request.
attributes [required]
object
Attributes required to create a new role by cloning an existing one.
name [required]
string
Name of the new role that is cloned.
type [required]
enum
Roles type.
Allowed enum values: roles
default: roles
{
"data": {
"attributes": {
"name": "Example-Role clone"
},
"type": "roles"
}
}
OK
Response containing information about a single role.
항목
유형
설명
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.
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.
permissions
object
Relationship to multiple permissions objects.
data
[object]
Relationships to permission objects.
id
string
ID of the permission.
type
enum
Permissions resource type.
Allowed enum values: permissions
default: permissions
type [required]
enum
Roles type.
Allowed enum values: roles
default: roles
{
"data": {
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"modified_at": "2019-09-19T10:00:00.000Z",
"name": "string",
"user_count": "integer"
},
"id": "string",
"relationships": {
"permissions": {
"data": [
{
"id": "string",
"type": "permissions"
}
]
}
},
"type": "roles"
}
}
Bad Request
API error response.
{
"errors": [
"Bad Request"
]
}
Authentication error
API error response.
{
"errors": [
"Bad Request"
]
}
Not found
API error response.
{
"errors": [
"Bad Request"
]
}
Conflict
API error response.
{
"errors": [
"Bad Request"
]
}
Too many requests
API error response.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export role_id="CHANGE_ME"
# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/roles/${role_id}/clone" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
"data": {
"attributes": {
"name": "Example-Role clone"
},
"type": "roles"
}
}
EOF
// Create a new role by cloning an existing role returns "OK" response
package main
import (
"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"
)
func main() {
// there is a valid "role" in the system
RoleDataID := 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)
if err != 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)
}
First install the library and its dependencies and then save the example to main.go
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Create a new role by cloning an existing role returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.RolesApi;
import com.datadog.api.client.v2.model.RoleClone;
import com.datadog.api.client.v2.model.RoleCloneAttributes;
import com.datadog.api.client.v2.model.RoleCloneRequest;
import com.datadog.api.client.v2.model.RoleResponse;
import com.datadog.api.client.v2.model.RolesType;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
RolesApi apiInstance = new RolesApi(defaultClient);
// there is a valid "role" in the system
String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");
RoleCloneRequest body =
new RoleCloneRequest()
.data(
new RoleClone()
.attributes(new RoleCloneAttributes().name("Example-Role clone"))
.type(RolesType.ROLES));
try {
RoleResponse result = apiInstance.cloneRole(ROLE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
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();
}
}
}
First install the library and its dependencies and then save the example to Example.java
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
"""
Create a new role by cloning an existing role returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
from datadog_api_client.v2.model.role_clone import RoleClone
from datadog_api_client.v2.model.role_clone_attributes import RoleCloneAttributes
from datadog_api_client.v2.model.role_clone_request import RoleCloneRequest
from datadog_api_client.v2.model.roles_type import RolesType
# there is a valid "role" in the system
ROLE_DATA_ID = environ["ROLE_DATA_ID"]
body = RoleCloneRequest(
data=RoleClone(
attributes=RoleCloneAttributes(
name="Example-Role clone",
),
type=RolesType.ROLES,
),
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.clone_role(role_id=ROLE_DATA_ID, body=body)
print(response)
First install the library and its dependencies and then save the example to example.py
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Create a new role by cloning an existing role returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::RolesAPI.new
# there is a valid "role" in the system
ROLE_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,
}),
})
p api_instance.clone_role(ROLE_DATA_ID, body)
First install the library and its dependencies and then save the example to example.rb
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Create a new role by cloning an existing role returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_roles::RolesAPI;
use datadog_api_client::datadogV2::model::RoleClone;
use datadog_api_client::datadogV2::model::RoleCloneAttributes;
use datadog_api_client::datadogV2::model::RoleCloneRequest;
use datadog_api_client::datadogV2::model::RolesType;
#[tokio::main]
async fn main() {
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
let body = RoleCloneRequest::new(RoleClone::new(
RoleCloneAttributes::new("Example-Role clone".to_string()),
RolesType::ROLES,
));
let configuration = datadog::Configuration::new();
let api = RolesAPI::with_config(configuration);
let resp = api.clone_role(role_data_id.clone(), body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
First install the library and its dependencies and then save the example to src/main.rs
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-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";
const configuration = client.createConfiguration();
const apiInstance = new v2.RolesApi(configuration);
// there is a valid "role" in the system
const ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;
const params: 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));
First install the library and its dependencies and then save the example to example.ts
and run following commands:
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"