Edit an AuthN Mapping
https://api.datadoghq.com/api/v2/authn_mappings/{authn_mapping_id}https://api.us3.datadoghq.com/api/v2/authn_mappings/{authn_mapping_id}https://api.us5.datadoghq.com/api/v2/authn_mappings/{authn_mapping_id}https://api.datadoghq.eu/api/v2/authn_mappings/{authn_mapping_id}https://api.ap1.datadoghq.com/api/v2/authn_mappings/{authn_mapping_id}https://api.ap2.datadoghq.com/api/v2/authn_mappings/{authn_mapping_id}https://api.uk1.datadoghq.com/api/v2/authn_mappings/{authn_mapping_id}https://api.ddog-gov.com/api/v2/authn_mappings/{authn_mapping_id}https://api.us2.ddog-gov.com/api/v2/authn_mappings/{authn_mapping_id}Overview
Edit an AuthN Mapping.
Arguments
Path Parameters
authn_mapping_id [required]The UUID of the AuthN Mapping.
Request
Body Data (required)
data [required]Data for updating an AuthN Mapping.
attributesKey/Value pair of attributes used for update 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.
id [required]ID of the AuthN Mapping.
relationshipsRelationship of AuthN Mapping update 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": "member-of",
"attribute_value": "Development"
},
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}Response
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"
]
}Conflict
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Unprocessable Entity
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"
]
}Code Example
# Path parameters
export authn_mapping_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/authn_mappings/${authn_mapping_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "member-of",
"attribute_value": "Development"
},
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Path parameters
export authn_mapping_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/authn_mappings/${authn_mapping_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "member-of",
"attribute_value": "Development"
},
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Path parameters
export authn_mapping_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/authn_mappings/${authn_mapping_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "member-of",
"attribute_value": "Development"
},
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Path parameters
export authn_mapping_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/authn_mappings/${authn_mapping_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "member-of",
"attribute_value": "Development"
},
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Path parameters
export authn_mapping_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/authn_mappings/${authn_mapping_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "member-of",
"attribute_value": "Development"
},
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Path parameters
export authn_mapping_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/authn_mappings/${authn_mapping_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "member-of",
"attribute_value": "Development"
},
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Path parameters
export authn_mapping_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/authn_mappings/${authn_mapping_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "member-of",
"attribute_value": "Development"
},
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Path parameters
export authn_mapping_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/authn_mappings/${authn_mapping_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "member-of",
"attribute_value": "Development"
},
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF# Path parameters
export authn_mapping_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/authn_mappings/${authn_mapping_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attribute_key": "member-of",
"attribute_value": "Development"
},
"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
"relationships": {
"role": {
"data": {
"id": "string",
"type": "roles"
}
}
},
"type": "authn_mappings"
}
}
EOF// Edit 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 "authn_mapping" in the system
AuthnMappingDataID := os.Getenv("AUTHN_MAPPING_DATA_ID")
// there is a valid "role" in the system
RoleDataID := os.Getenv("ROLE_DATA_ID")
body := datadogV2.AuthNMappingUpdateRequest{
Data: datadogV2.AuthNMappingUpdateData{
Attributes: &datadogV2.AuthNMappingUpdateAttributes{
AttributeKey: datadog.PtrString("member-of"),
AttributeValue: datadog.PtrString("Development"),
},
Id: AuthnMappingDataID,
Relationships: &datadogV2.AuthNMappingUpdateRelationships{
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.UpdateAuthNMapping(ctx, AuthnMappingDataID, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AuthNMappingsApi.UpdateAuthNMapping`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `AuthNMappingsApi.UpdateAuthNMapping`:\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"// Edit 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.AuthNMappingRelationshipToRole;
import com.datadog.api.client.v2.model.AuthNMappingResponse;
import com.datadog.api.client.v2.model.AuthNMappingUpdateAttributes;
import com.datadog.api.client.v2.model.AuthNMappingUpdateData;
import com.datadog.api.client.v2.model.AuthNMappingUpdateRelationships;
import com.datadog.api.client.v2.model.AuthNMappingUpdateRequest;
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 "authn_mapping" in the system
String AUTHN_MAPPING_DATA_ID = System.getenv("AUTHN_MAPPING_DATA_ID");
// there is a valid "role" in the system
String ROLE_DATA_ID = System.getenv("ROLE_DATA_ID");
AuthNMappingUpdateRequest body =
new AuthNMappingUpdateRequest()
.data(
new AuthNMappingUpdateData()
.attributes(
new AuthNMappingUpdateAttributes()
.attributeKey("member-of")
.attributeValue("Development"))
.id(AUTHN_MAPPING_DATA_ID)
.relationships(
new AuthNMappingUpdateRelationships(
new AuthNMappingRelationshipToRole()
.role(
new RelationshipToRole()
.data(
new RelationshipToRoleData()
.id(ROLE_DATA_ID)
.type(RolesType.ROLES)))))
.type(AuthNMappingsType.AUTHN_MAPPINGS));
try {
AuthNMappingResponse result = apiInstance.updateAuthNMapping(AUTHN_MAPPING_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AuthNMappingsApi#updateAuthNMapping");
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""""
Edit 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_relationship_to_role import AuthNMappingRelationshipToRole
from datadog_api_client.v2.model.authn_mapping_update_attributes import AuthNMappingUpdateAttributes
from datadog_api_client.v2.model.authn_mapping_update_data import AuthNMappingUpdateData
from datadog_api_client.v2.model.authn_mapping_update_request import AuthNMappingUpdateRequest
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 "authn_mapping" in the system
AUTHN_MAPPING_DATA_ID = environ["AUTHN_MAPPING_DATA_ID"]
# there is a valid "role" in the system
ROLE_DATA_ID = environ["ROLE_DATA_ID"]
body = AuthNMappingUpdateRequest(
data=AuthNMappingUpdateData(
attributes=AuthNMappingUpdateAttributes(
attribute_key="member-of",
attribute_value="Development",
),
id=AUTHN_MAPPING_DATA_ID,
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.update_authn_mapping(authn_mapping_id=AUTHN_MAPPING_DATA_ID, 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"# Edit 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 "authn_mapping" in the system
AUTHN_MAPPING_DATA_ID = ENV["AUTHN_MAPPING_DATA_ID"]
# there is a valid "role" in the system
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]
body = DatadogAPIClient::V2::AuthNMappingUpdateRequest.new({
data: DatadogAPIClient::V2::AuthNMappingUpdateData.new({
attributes: DatadogAPIClient::V2::AuthNMappingUpdateAttributes.new({
attribute_key: "member-of",
attribute_value: "Development",
}),
id: AUTHN_MAPPING_DATA_ID,
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.update_authn_mapping(AUTHN_MAPPING_DATA_ID, 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"// Edit 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::AuthNMappingRelationshipToRole;
use datadog_api_client::datadogV2::model::AuthNMappingUpdateAttributes;
use datadog_api_client::datadogV2::model::AuthNMappingUpdateData;
use datadog_api_client::datadogV2::model::AuthNMappingUpdateRelationships;
use datadog_api_client::datadogV2::model::AuthNMappingUpdateRequest;
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 "authn_mapping" in the system
let authn_mapping_data_id = std::env::var("AUTHN_MAPPING_DATA_ID").unwrap();
// there is a valid "role" in the system
let role_data_id = std::env::var("ROLE_DATA_ID").unwrap();
let body = AuthNMappingUpdateRequest::new(
AuthNMappingUpdateData::new(
authn_mapping_data_id.clone(),
AuthNMappingsType::AUTHN_MAPPINGS,
)
.attributes(
AuthNMappingUpdateAttributes::new()
.attribute_key("member-of".to_string())
.attribute_value("Development".to_string()),
)
.relationships(
AuthNMappingUpdateRelationships::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
.update_authn_mapping(authn_mapping_data_id.clone(), 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/**
* Edit 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 "authn_mapping" in the system
const AUTHN_MAPPING_DATA_ID = process.env.AUTHN_MAPPING_DATA_ID as string;
// there is a valid "role" in the system
const ROLE_DATA_ID = process.env.ROLE_DATA_ID as string;
const params: v2.AuthNMappingsApiUpdateAuthNMappingRequest = {
body: {
data: {
attributes: {
attributeKey: "member-of",
attributeValue: "Development",
},
id: AUTHN_MAPPING_DATA_ID,
relationships: {
role: {
data: {
id: ROLE_DATA_ID,
type: "roles",
},
},
},
type: "authn_mappings",
},
},
authnMappingId: AUTHN_MAPPING_DATA_ID,
};
apiInstance
.updateAuthNMapping(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"