Créer un mappage d'authentification
https://api.datadoghq.com/api/v2/authn_mappingshttps://api.us3.datadoghq.com/api/v2/authn_mappingshttps://api.us5.datadoghq.com/api/v2/authn_mappingshttps://api.datadoghq.eu/api/v2/authn_mappingshttps://api.ap1.datadoghq.com/api/v2/authn_mappingshttps://api.ap2.datadoghq.com/api/v2/authn_mappingshttps://api.uk1.datadoghq.com/api/v2/authn_mappingshttps://api.ddog-gov.com/api/v2/authn_mappingshttps://api.us2.ddog-gov.com/api/v2/authn_mappingsPrésentation
Créez un mappage d'authentification.
Requête
Body Data (required)
data [required]La requête de création d'un mappage d'authentification.
attributesKey/Value pair of attributes used for create request.
attribute_keyKey portion of a key/value pair of the attribute sent from the Identity Provider.
attribute_valueValue portion of a key/value pair of the attribute sent from the Identity Provider.
relationshipsRelationship of AuthN Mapping create object to a Role or Team.
Object 1Relationship of AuthN Mapping to a Role.
role [required]Relationship to role.
dataRelationship to role object.
idThe unique identifier of the role.
typeRoles type.
rolesrolesObject 2Relationship of AuthN Mapping to a Team.
team [required]Relationship to team.
dataRelationship to Team object.
idThe unique identifier of the team.
typeTeam type
teamteamtype [required]AuthN Mappings resource type.
authn_mappingsauthn_mappings{
"data": {
"attributes": {
"attribute_key": "exampleauthnmapping",
"attribute_value": "Example-AuthN-Mapping"
},
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}Réponse
OK
AuthN Mapping response from the API.
dataThe AuthN Mapping object returned by API.
attributesAttributes of AuthN Mapping.
attribute_keyKey portion of a key/value pair of the attribute sent from the Identity Provider.
attribute_valueValue portion of a key/value pair of the attribute sent from the Identity Provider.
created_atCreation time of the AuthN Mapping.
modified_atTime of last AuthN Mapping modification.
saml_assertion_attribute_idThe ID of the SAML assertion attribute.
id [required]ID of the AuthN Mapping.
relationshipsAll relationships associated with AuthN Mapping.
roleRelationship to role.
dataRelationship to role object.
idThe unique identifier of the role.
typeRoles type.
rolesrolessaml_assertion_attributeAuthN Mapping relationship to SAML Assertion Attribute.
data [required]Data of AuthN Mapping relationship to SAML Assertion Attribute.
id [required]The ID of the SAML assertion attribute.
type [required]SAML assertion attributes resource type.
saml_assertion_attributessaml_assertion_attributesteamRelationship to team.
dataRelationship to Team object.
idThe unique identifier of the team.
typeTeam type
teamteamtype [required]AuthN Mappings resource type.
authn_mappingsauthn_mappingsincludedIncluded data in the AuthN Mapping response.
<type=saml_assertion_attributes>SAML assertion attribute.
attributesKey/Value pair of attributes used in SAML assertion attributes.
attribute_keyKey portion of a key/value pair of the attribute sent from the Identity Provider.
attribute_valueValue portion of a key/value pair of the attribute sent from the Identity Provider.
id [required]The ID of the SAML assertion attribute.
type [required]SAML assertion attributes resource type.
saml_assertion_attributessaml_assertion_attributes<type=roles>Role object returned by the API.
attributesAttributes of the role.
created_atCreation time of the role.
modified_atTime of last role modification.
nameThe name of the role. The name is neither unique nor a stable identifier of the role.
receives_permissions_fromThe managed role from which this role automatically inherits new permissions. Specify one of the following: "Datadog Admin Role", "Datadog Standard Role", or "Datadog Read Only Role". If empty or not specified, the role does not automatically inherit permissions from any managed role.
user_countNumber of users with that role.
idThe unique identifier of the role.
relationshipsRelationships of the role object returned by the API.
permissionsRelationship to multiple permissions objects.
dataRelationships to permission objects.
idID of the permission.
typePermissions resource type.
permissionspermissionstype [required]Roles type.
rolesroles<type=team>Team.
attributesTeam attributes.
avatarUnicode representation of the avatar for the team, limited to a single grapheme
bannerBanner selection for the team
handleThe team's identifier
link_countThe number of links belonging to the team
nameThe name of the team
summaryA brief summary of the team, derived from the description
user_countThe number of users belonging to the team
idThe ID of the Team.
typeTeam type
teamteam{
"data": {
"attributes": {
"attribute_key": "member-of",
"attribute_value": "Development",
"created_at": "2019-09-19T10:00:00.000Z",
"modified_at": "2019-09-19T10:00:00.000Z",
"saml_assertion_attribute_id": "0"
},
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"relationships": {
"role": {
"data": {
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"type": "roles"
}
},
"saml_assertion_attribute": {
"data": {
"id": "0",
"type": "saml_assertion_attributes"
}
},
"team": {
"data": {
"id": "f9bb8444-af7f-11ec-ac2c-da7ad0900001",
"type": "team"
}
}
},
"type": "authn_mappings"
},
"included": [
{
"attributes": {
"attribute_key": "member-of",
"attribute_value": "Development"
},
"id": "0",
"type": "saml_assertion_attributes"
}
]
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Authentication Error
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Not Found
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Exemple de code
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/authn_mappings" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "exampleauthnmapping",
"attribute_value": "Example-AuthN-Mapping"
},
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/authn_mappings" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "exampleauthnmapping",
"attribute_value": "Example-AuthN-Mapping"
},
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/authn_mappings" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "exampleauthnmapping",
"attribute_value": "Example-AuthN-Mapping"
},
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/authn_mappings" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "exampleauthnmapping",
"attribute_value": "Example-AuthN-Mapping"
},
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/authn_mappings" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "exampleauthnmapping",
"attribute_value": "Example-AuthN-Mapping"
},
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/authn_mappings" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "exampleauthnmapping",
"attribute_value": "Example-AuthN-Mapping"
},
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/authn_mappings" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "exampleauthnmapping",
"attribute_value": "Example-AuthN-Mapping"
},
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/authn_mappings" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "exampleauthnmapping",
"attribute_value": "Example-AuthN-Mapping"
},
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/authn_mappings" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "exampleauthnmapping",
"attribute_value": "Example-AuthN-Mapping"
},
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF// Create an AuthN Mapping 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.AuthNMappingCreateRequest{
Data: datadogV2.AuthNMappingCreateData{
Attributes: &datadogV2.AuthNMappingCreateAttributes{
AttributeKey: datadog.PtrString("exampleauthnmapping"),
AttributeValue: datadog.PtrString("Example-AuthN-Mapping"),
},
Relationships: &datadogV2.AuthNMappingCreateRelationships{
AuthNMappingRelationshipToRole: &datadogV2.AuthNMappingRelationshipToRole{
Role: datadogV2.RelationshipToRole{
Data: &datadogV2.RelationshipToRoleData{
Id: datadog.PtrString(RoleDataID),
Type: datadogV2.ROLESTYPE_ROLES.Ptr(),
},
},
}},
Type: datadogV2.AUTHNMAPPINGSTYPE_AUTHN_MAPPINGS,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewAuthNMappingsApi(apiClient)
resp, r, err := api.CreateAuthNMapping(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AuthNMappingsApi.CreateAuthNMapping`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `AuthNMappingsApi.CreateAuthNMapping`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Create an AuthN Mapping returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.AuthNMappingsApi;
import com.datadog.api.client.v2.model.AuthNMappingCreateAttributes;
import com.datadog.api.client.v2.model.AuthNMappingCreateData;
import com.datadog.api.client.v2.model.AuthNMappingCreateRelationships;
import com.datadog.api.client.v2.model.AuthNMappingCreateRequest;
import com.datadog.api.client.v2.model.AuthNMappingRelationshipToRole;
import com.datadog.api.client.v2.model.AuthNMappingResponse;
import com.datadog.api.client.v2.model.AuthNMappingsType;
import com.datadog.api.client.v2.model.RelationshipToRole;
import com.datadog.api.client.v2.model.RelationshipToRoleData;
import com.datadog.api.client.v2.model.RolesType;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
AuthNMappingsApi apiInstance = new AuthNMappingsApi(defaultClient);
// there is a valid "role" in the system
String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");
AuthNMappingCreateRequest body =
new AuthNMappingCreateRequest()
.data(
new AuthNMappingCreateData()
.attributes(
new AuthNMappingCreateAttributes()
.attributeKey("exampleauthnmapping")
.attributeValue("Example-AuthN-Mapping"))
.relationships(
new AuthNMappingCreateRelationships(
new AuthNMappingRelationshipToRole()
.role(
new RelationshipToRole()
.data(
new RelationshipToRoleData()
.id(ROLE_DATA_ID)
.type(RolesType.ROLES)))))
.type(AuthNMappingsType.AUTHN_MAPPINGS));
try {
AuthNMappingResponse result = apiInstance.createAuthNMapping(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AuthNMappingsApi#createAuthNMapping");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Create an AuthN Mapping returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.authn_mappings_api import AuthNMappingsApi
from datadog_api_client.v2.model.authn_mapping_create_attributes import AuthNMappingCreateAttributes
from datadog_api_client.v2.model.authn_mapping_create_data import AuthNMappingCreateData
from datadog_api_client.v2.model.authn_mapping_create_request import AuthNMappingCreateRequest
from datadog_api_client.v2.model.authn_mapping_relationship_to_role import AuthNMappingRelationshipToRole
from datadog_api_client.v2.model.authn_mappings_type import AuthNMappingsType
from datadog_api_client.v2.model.relationship_to_role import RelationshipToRole
from datadog_api_client.v2.model.relationship_to_role_data import RelationshipToRoleData
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 = AuthNMappingCreateRequest(
data=AuthNMappingCreateData(
attributes=AuthNMappingCreateAttributes(
attribute_key="exampleauthnmapping",
attribute_value="Example-AuthN-Mapping",
),
relationships=AuthNMappingRelationshipToRole(
role=RelationshipToRole(
data=RelationshipToRoleData(
id=ROLE_DATA_ID,
type=RolesType.ROLES,
),
),
),
type=AuthNMappingsType.AUTHN_MAPPINGS,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = AuthNMappingsApi(api_client)
response = api_instance.create_authn_mapping(body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create an AuthN Mapping returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::AuthNMappingsAPI.new
# there is a valid "role" in the system
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]
body = DatadogAPIClient::V2::AuthNMappingCreateRequest.new({
data: DatadogAPIClient::V2::AuthNMappingCreateData.new({
attributes: DatadogAPIClient::V2::AuthNMappingCreateAttributes.new({
attribute_key: "exampleauthnmapping",
attribute_value: "Example-AuthN-Mapping",
}),
relationships: DatadogAPIClient::V2::AuthNMappingRelationshipToRole.new({
role: DatadogAPIClient::V2::RelationshipToRole.new({
data: DatadogAPIClient::V2::RelationshipToRoleData.new({
id: ROLE_DATA_ID,
type: DatadogAPIClient::V2::RolesType::ROLES,
}),
}),
}),
type: DatadogAPIClient::V2::AuthNMappingsType::AUTHN_MAPPINGS,
}),
})
p api_instance.create_authn_mapping(body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Create an AuthN Mapping returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_authn_mappings::AuthNMappingsAPI;
use datadog_api_client::datadogV2::model::AuthNMappingCreateAttributes;
use datadog_api_client::datadogV2::model::AuthNMappingCreateData;
use datadog_api_client::datadogV2::model::AuthNMappingCreateRelationships;
use datadog_api_client::datadogV2::model::AuthNMappingCreateRequest;
use datadog_api_client::datadogV2::model::AuthNMappingRelationshipToRole;
use datadog_api_client::datadogV2::model::AuthNMappingsType;
use datadog_api_client::datadogV2::model::RelationshipToRole;
use datadog_api_client::datadogV2::model::RelationshipToRoleData;
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 = AuthNMappingCreateRequest::new(
AuthNMappingCreateData::new(AuthNMappingsType::AUTHN_MAPPINGS)
.attributes(
AuthNMappingCreateAttributes::new()
.attribute_key("exampleauthnmapping".to_string())
.attribute_value("Example-AuthN-Mapping".to_string()),
)
.relationships(
AuthNMappingCreateRelationships::AuthNMappingRelationshipToRole(Box::new(
AuthNMappingRelationshipToRole::new(
RelationshipToRole::new().data(
RelationshipToRoleData::new()
.id(role_data_id.clone())
.type_(RolesType::ROLES),
),
),
)),
),
);
let configuration = datadog::Configuration::new();
let api = AuthNMappingsAPI::with_config(configuration);
let resp = api.create_authn_mapping(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Create an AuthN Mapping returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.AuthNMappingsApi(configuration);
// there is a valid "role" in the system
const ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;
const params: v2.AuthNMappingsApiCreateAuthNMappingRequest = {
body: {
data: {
attributes: {
attributeKey: "exampleauthnmapping",
attributeValue: "Example-AuthN-Mapping",
},
relationships: {
role: {
data: {
id: ROLE_DATA_ID,
type: "roles",
},
},
},
type: "authn_mappings",
},
},
};
apiInstance
.createAuthNMapping(params)
.then((data: v2.AuthNMappingResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"