Scorecard 결과 업데이트
https://api.datadoghq.com/api/v2/scorecard/outcomeshttps://api.us3.datadoghq.com/api/v2/scorecard/outcomeshttps://api.us5.datadoghq.com/api/v2/scorecard/outcomeshttps://api.datadoghq.eu/api/v2/scorecard/outcomeshttps://api.ap1.datadoghq.com/api/v2/scorecard/outcomeshttps://api.ap2.datadoghq.com/api/v2/scorecard/outcomeshttps://api.uk1.datadoghq.com/api/v2/scorecard/outcomeshttps://api.ddog-gov.com/api/v2/scorecard/outcomeshttps://api.us2.ddog-gov.com/api/v2/scorecard/outcomes개요
단일 일괄 요청으로 여러 Scorecard 규칙 결과를 업데이트합니다.
OAuth apps require the apm_service_catalog_write authorization scope to access this endpoint.
요청
Body Data (required)
Scorecard 결과 집합입니다.
dataScorecard 결과 일괄 요청입니다.
attributesThe JSON:API attributes for a batched set of scorecard outcomes.
resultsSet of scorecard outcomes to update asynchronously.
entity_reference [required]The unique reference for an IDP entity.
remarksAny remarks regarding the scorecard rule's evaluation. Supports HTML hyperlinks.
rule_id [required]The unique ID for a scorecard rule.
state [required]The state of the rule evaluation.
pass, fail, skiptypeThe JSON:API type for scorecard outcomes.
batched-outcomebatched-outcome{
"data": {
"attributes": {
"results": [
{
"rule_id": "q8MQxk8TCqrHnWkx",
"entity_reference": "service:my-service",
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"state": "pass"
}
]
},
"type": "batched-outcome"
}
}응답
Accepted
Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Forbidden
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"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}코드 예시
# 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/scorecard/outcomes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"rule_id": "q8MQxk8TCqrHnWkx",
"entity_reference": "service:my-service",
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"state": "pass"
}
]
},
"type": "batched-outcome"
}
}
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/scorecard/outcomes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"rule_id": "q8MQxk8TCqrHnWkx",
"entity_reference": "service:my-service",
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"state": "pass"
}
]
},
"type": "batched-outcome"
}
}
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/scorecard/outcomes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"rule_id": "q8MQxk8TCqrHnWkx",
"entity_reference": "service:my-service",
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"state": "pass"
}
]
},
"type": "batched-outcome"
}
}
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/scorecard/outcomes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"rule_id": "q8MQxk8TCqrHnWkx",
"entity_reference": "service:my-service",
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"state": "pass"
}
]
},
"type": "batched-outcome"
}
}
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/scorecard/outcomes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"rule_id": "q8MQxk8TCqrHnWkx",
"entity_reference": "service:my-service",
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"state": "pass"
}
]
},
"type": "batched-outcome"
}
}
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/scorecard/outcomes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"rule_id": "q8MQxk8TCqrHnWkx",
"entity_reference": "service:my-service",
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"state": "pass"
}
]
},
"type": "batched-outcome"
}
}
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/scorecard/outcomes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"rule_id": "q8MQxk8TCqrHnWkx",
"entity_reference": "service:my-service",
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"state": "pass"
}
]
},
"type": "batched-outcome"
}
}
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/scorecard/outcomes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"rule_id": "q8MQxk8TCqrHnWkx",
"entity_reference": "service:my-service",
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"state": "pass"
}
]
},
"type": "batched-outcome"
}
}
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/scorecard/outcomes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"rule_id": "q8MQxk8TCqrHnWkx",
"entity_reference": "service:my-service",
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"state": "pass"
}
]
},
"type": "batched-outcome"
}
}
EOF// Update Scorecard outcomes asynchronously returns "Accepted" 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 "create_scorecard_rule" in the system
CreateScorecardRuleDataID := os.Getenv("CREATE_SCORECARD_RULE_DATA_ID")
body := datadogV2.UpdateOutcomesAsyncRequest{
Data: &datadogV2.UpdateOutcomesAsyncRequestData{
Attributes: &datadogV2.UpdateOutcomesAsyncAttributes{
Results: []datadogV2.UpdateOutcomesAsyncRequestItem{
{
RuleId: CreateScorecardRuleDataID,
EntityReference: "service:my-service",
Remarks: datadog.PtrString(`See: <a href="https://app.datadoghq.com/services">Services</a>`),
State: datadogV2.STATE_PASS,
},
},
},
Type: datadogV2.UPDATEOUTCOMESASYNCTYPE_BATCHED_OUTCOME.Ptr(),
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewScorecardsApi(apiClient)
r, err := api.UpdateScorecardOutcomes(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ScorecardsApi.UpdateScorecardOutcomes`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
}
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"// Update Scorecard outcomes asynchronously returns "Accepted" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ScorecardsApi;
import com.datadog.api.client.v2.model.State;
import com.datadog.api.client.v2.model.UpdateOutcomesAsyncAttributes;
import com.datadog.api.client.v2.model.UpdateOutcomesAsyncRequest;
import com.datadog.api.client.v2.model.UpdateOutcomesAsyncRequestData;
import com.datadog.api.client.v2.model.UpdateOutcomesAsyncRequestItem;
import com.datadog.api.client.v2.model.UpdateOutcomesAsyncType;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
ScorecardsApi apiInstance = new ScorecardsApi(defaultClient);
// there is a valid "create_scorecard_rule" in the system
String CREATE_SCORECARD_RULE_DATA_ID = System.getenv("CREATE_SCORECARD_RULE_DATA_ID");
UpdateOutcomesAsyncRequest body =
new UpdateOutcomesAsyncRequest()
.data(
new UpdateOutcomesAsyncRequestData()
.attributes(
new UpdateOutcomesAsyncAttributes()
.results(
Collections.singletonList(
new UpdateOutcomesAsyncRequestItem()
.ruleId(CREATE_SCORECARD_RULE_DATA_ID)
.entityReference("service:my-service")
.remarks(
"""
See: <a href="https://app.datadoghq.com/services">Services</a>
""")
.state(State.PASS))))
.type(UpdateOutcomesAsyncType.BATCHED_OUTCOME));
try {
apiInstance.updateScorecardOutcomes(body);
} catch (ApiException e) {
System.err.println("Exception when calling ScorecardsApi#updateScorecardOutcomes");
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""""
Update Scorecard outcomes asynchronously returns "Accepted" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.scorecards_api import ScorecardsApi
from datadog_api_client.v2.model.state import State
from datadog_api_client.v2.model.update_outcomes_async_attributes import UpdateOutcomesAsyncAttributes
from datadog_api_client.v2.model.update_outcomes_async_request import UpdateOutcomesAsyncRequest
from datadog_api_client.v2.model.update_outcomes_async_request_data import UpdateOutcomesAsyncRequestData
from datadog_api_client.v2.model.update_outcomes_async_request_item import UpdateOutcomesAsyncRequestItem
from datadog_api_client.v2.model.update_outcomes_async_type import UpdateOutcomesAsyncType
# there is a valid "create_scorecard_rule" in the system
CREATE_SCORECARD_RULE_DATA_ID = environ["CREATE_SCORECARD_RULE_DATA_ID"]
body = UpdateOutcomesAsyncRequest(
data=UpdateOutcomesAsyncRequestData(
attributes=UpdateOutcomesAsyncAttributes(
results=[
UpdateOutcomesAsyncRequestItem(
rule_id=CREATE_SCORECARD_RULE_DATA_ID,
entity_reference="service:my-service",
remarks='See: <a href="https://app.datadoghq.com/services">Services</a>',
state=State.PASS,
),
],
),
type=UpdateOutcomesAsyncType.BATCHED_OUTCOME,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = ScorecardsApi(api_client)
api_instance.update_scorecard_outcomes(body=body)
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"# Update Scorecard outcomes asynchronously returns "Accepted" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::ScorecardsAPI.new
# there is a valid "create_scorecard_rule" in the system
CREATE_SCORECARD_RULE_DATA_ID = ENV["CREATE_SCORECARD_RULE_DATA_ID"]
body = DatadogAPIClient::V2::UpdateOutcomesAsyncRequest.new({
data: DatadogAPIClient::V2::UpdateOutcomesAsyncRequestData.new({
attributes: DatadogAPIClient::V2::UpdateOutcomesAsyncAttributes.new({
results: [
DatadogAPIClient::V2::UpdateOutcomesAsyncRequestItem.new({
rule_id: CREATE_SCORECARD_RULE_DATA_ID,
entity_reference: "service:my-service",
remarks: 'See: <a href="https://app.datadoghq.com/services">Services</a>',
state: DatadogAPIClient::V2::State::PASS,
}),
],
}),
type: DatadogAPIClient::V2::UpdateOutcomesAsyncType::BATCHED_OUTCOME,
}),
})
p api_instance.update_scorecard_outcomes(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"// Update Scorecard outcomes asynchronously returns "Accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_scorecards::ScorecardsAPI;
use datadog_api_client::datadogV2::model::State;
use datadog_api_client::datadogV2::model::UpdateOutcomesAsyncAttributes;
use datadog_api_client::datadogV2::model::UpdateOutcomesAsyncRequest;
use datadog_api_client::datadogV2::model::UpdateOutcomesAsyncRequestData;
use datadog_api_client::datadogV2::model::UpdateOutcomesAsyncRequestItem;
use datadog_api_client::datadogV2::model::UpdateOutcomesAsyncType;
#[tokio::main]
async fn main() {
// there is a valid "create_scorecard_rule" in the system
let create_scorecard_rule_data_id = std::env::var("CREATE_SCORECARD_RULE_DATA_ID").unwrap();
let body = UpdateOutcomesAsyncRequest::new().data(
UpdateOutcomesAsyncRequestData::new()
.attributes(UpdateOutcomesAsyncAttributes::new().results(vec![
UpdateOutcomesAsyncRequestItem::new(
"service:my-service".to_string(),
create_scorecard_rule_data_id.clone(),
State::PASS,
)
.remarks(
r#"See: <a href="https://app.datadoghq.com/services">Services</a>"#
.to_string(),
),
]))
.type_(UpdateOutcomesAsyncType::BATCHED_OUTCOME),
);
let configuration = datadog::Configuration::new();
let api = ScorecardsAPI::with_config(configuration);
let resp = api.update_scorecard_outcomes(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="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Update Scorecard outcomes asynchronously returns "Accepted" 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.ScorecardsApi(configuration);
// there is a valid "create_scorecard_rule" in the system
const CREATE_SCORECARD_RULE_DATA_ID = process.env
.CREATE_SCORECARD_RULE_DATA_ID as string;
const params: v2.ScorecardsApiUpdateScorecardOutcomesRequest = {
body: {
data: {
attributes: {
results: [
{
ruleId: CREATE_SCORECARD_RULE_DATA_ID,
entityReference: "service:my-service",
remarks: `See: <a href="https://app.datadoghq.com/services">Services</a>`,
state: "pass",
},
],
},
type: "batched-outcome",
},
},
};
apiInstance
.updateScorecardOutcomes(params)
.then((data: any) => {
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"