Crear lote de resultados
https://api.datadoghq.com/api/v2/scorecard/outcomes/batchhttps://api.us3.datadoghq.com/api/v2/scorecard/outcomes/batchhttps://api.us5.datadoghq.com/api/v2/scorecard/outcomes/batchhttps://api.datadoghq.eu/api/v2/scorecard/outcomes/batchhttps://api.ap1.datadoghq.com/api/v2/scorecard/outcomes/batchhttps://api.ap2.datadoghq.com/api/v2/scorecard/outcomes/batchhttps://api.uk1.datadoghq.com/api/v2/scorecard/outcomes/batchhttps://api.ddog-gov.com/api/v2/scorecard/outcomes/batchhttps://api.us2.ddog-gov.com/api/v2/scorecard/outcomes/batchDescripción general
Establece varios resultados de la regla de servicio en una única solicitud por lotes.
OAuth apps require the apm_service_catalog_write authorization scope to access this endpoint.
Solicitud
Body Data (required)
Conjunto de resultados del cuadro de mando.
dataSolicitud por lotes de los resultados de los cuadros de mando.
attributesThe JSON:API attributes for a batched set of scorecard outcomes.
resultsSet of scorecard outcomes to update.
remarksAny remarks regarding the scorecard rule's evaluation, and supports HTML hyperlinks.
rule_id [required]The unique ID for a scorecard rule.
service_name [required]The unique name for a service in the catalog.
state [required]The state of the rule evaluation.
pass, fail, skiptypeThe JSON:API type for scorecard outcomes.
batched-outcomebatched-outcome{
"data": {
"attributes": {
"results": [
{
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"rule_id": "q8MQxk8TCqrHnWkx",
"service_name": "my-service",
"state": "pass"
}
]
},
"type": "batched-outcome"
}
}Respuesta
OK
Scorecard outcomes batch response.
data [required]List of rule outcomes which were affected during the bulk operation.
attributesThe JSON:API attributes for an outcome.
created_atCreation time of the rule outcome.
modified_atTime of last rule outcome modification.
remarksAny remarks regarding the scorecard rule's evaluation, and supports HTML hyperlinks.
service_nameThe unique name for a service in the catalog.
stateThe state of the rule evaluation.
pass, fail, skipidThe unique ID for a rule outcome.
relationshipsThe JSON:API relationship to a scorecard rule.
ruleThe JSON:API relationship to a scorecard outcome.
dataThe JSON:API relationship to an outcome, which returns the related rule id.
idThe unique ID for a scorecard rule.
typeThe JSON:API type for scorecard rules.
ruleruletypeThe JSON:API type for an outcome.
outcomeoutcomemeta [required]Metadata pertaining to the bulk operation.
total_receivedTotal number of scorecard results received during the bulk operation.
total_updatedTotal number of scorecard results modified during the bulk operation.
{
"data": [
{
"attributes": {
"created_at": "2019-09-19T10:00:00.000Z",
"modified_at": "2019-09-19T10:00:00.000Z",
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"service_name": "my-service",
"state": "pass"
},
"id": "outcome-abc123",
"relationships": {
"rule": {
"data": {
"id": "q8MQxk8TCqrHnWkx",
"type": "rule"
}
}
},
"type": "outcome"
}
],
"meta": {
"total_received": "integer",
"total_updated": "integer"
}
}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"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Ejemplo de código
# 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/batch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"rule_id": "q8MQxk8TCqrHnWkx",
"service_name": "my-service",
"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/batch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"rule_id": "q8MQxk8TCqrHnWkx",
"service_name": "my-service",
"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/batch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"rule_id": "q8MQxk8TCqrHnWkx",
"service_name": "my-service",
"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/batch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"rule_id": "q8MQxk8TCqrHnWkx",
"service_name": "my-service",
"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/batch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"rule_id": "q8MQxk8TCqrHnWkx",
"service_name": "my-service",
"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/batch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"rule_id": "q8MQxk8TCqrHnWkx",
"service_name": "my-service",
"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/batch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"rule_id": "q8MQxk8TCqrHnWkx",
"service_name": "my-service",
"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/batch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"rule_id": "q8MQxk8TCqrHnWkx",
"service_name": "my-service",
"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/batch" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"results": [
{
"remarks": "See: <a href=\"https://app.datadoghq.com/services\">Services</a>",
"rule_id": "q8MQxk8TCqrHnWkx",
"service_name": "my-service",
"state": "pass"
}
]
},
"type": "batched-outcome"
}
}
EOF// Create outcomes batch 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 "create_scorecard_rule" in the system
CreateScorecardRuleDataID := os.Getenv("CREATE_SCORECARD_RULE_DATA_ID")
body := datadogV2.OutcomesBatchRequest{
Data: &datadogV2.OutcomesBatchRequestData{
Attributes: &datadogV2.OutcomesBatchAttributes{
Results: []datadogV2.OutcomesBatchRequestItem{
{
Remarks: datadog.PtrString(`See: <a href="https://app.datadoghq.com/services">Services</a>`),
RuleId: CreateScorecardRuleDataID,
ServiceName: "my-service",
State: datadogV2.STATE_PASS,
},
},
},
Type: datadogV2.OUTCOMESBATCHTYPE_BATCHED_OUTCOME.Ptr(),
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.CreateScorecardOutcomesBatch", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewScorecardsApi(apiClient)
resp, r, err := api.CreateScorecardOutcomesBatch(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ScorecardsApi.CreateScorecardOutcomesBatch`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ScorecardsApi.CreateScorecardOutcomesBatch`:\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 outcomes batch returns "OK" 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.OutcomesBatchAttributes;
import com.datadog.api.client.v2.model.OutcomesBatchRequest;
import com.datadog.api.client.v2.model.OutcomesBatchRequestData;
import com.datadog.api.client.v2.model.OutcomesBatchRequestItem;
import com.datadog.api.client.v2.model.OutcomesBatchResponse;
import com.datadog.api.client.v2.model.OutcomesBatchType;
import com.datadog.api.client.v2.model.State;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.createScorecardOutcomesBatch", true);
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");
OutcomesBatchRequest body =
new OutcomesBatchRequest()
.data(
new OutcomesBatchRequestData()
.attributes(
new OutcomesBatchAttributes()
.results(
Collections.singletonList(
new OutcomesBatchRequestItem()
.remarks(
"""
See: <a href="https://app.datadoghq.com/services">Services</a>
""")
.ruleId(CREATE_SCORECARD_RULE_DATA_ID)
.serviceName("my-service")
.state(State.PASS))))
.type(OutcomesBatchType.BATCHED_OUTCOME));
try {
OutcomesBatchResponse result = apiInstance.createScorecardOutcomesBatch(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ScorecardsApi#createScorecardOutcomesBatch");
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 outcomes batch returns "OK" 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.outcomes_batch_attributes import OutcomesBatchAttributes
from datadog_api_client.v2.model.outcomes_batch_request import OutcomesBatchRequest
from datadog_api_client.v2.model.outcomes_batch_request_data import OutcomesBatchRequestData
from datadog_api_client.v2.model.outcomes_batch_request_item import OutcomesBatchRequestItem
from datadog_api_client.v2.model.outcomes_batch_type import OutcomesBatchType
from datadog_api_client.v2.model.state import State
# there is a valid "create_scorecard_rule" in the system
CREATE_SCORECARD_RULE_DATA_ID = environ["CREATE_SCORECARD_RULE_DATA_ID"]
body = OutcomesBatchRequest(
data=OutcomesBatchRequestData(
attributes=OutcomesBatchAttributes(
results=[
OutcomesBatchRequestItem(
remarks='See: <a href="https://app.datadoghq.com/services">Services</a>',
rule_id=CREATE_SCORECARD_RULE_DATA_ID,
service_name="my-service",
state=State.PASS,
),
],
),
type=OutcomesBatchType.BATCHED_OUTCOME,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["create_scorecard_outcomes_batch"] = True
with ApiClient(configuration) as api_client:
api_instance = ScorecardsApi(api_client)
response = api_instance.create_scorecard_outcomes_batch(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 outcomes batch returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.create_scorecard_outcomes_batch".to_sym] = true
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::OutcomesBatchRequest.new({
data: DatadogAPIClient::V2::OutcomesBatchRequestData.new({
attributes: DatadogAPIClient::V2::OutcomesBatchAttributes.new({
results: [
DatadogAPIClient::V2::OutcomesBatchRequestItem.new({
remarks: 'See: <a href="https://app.datadoghq.com/services">Services</a>',
rule_id: CREATE_SCORECARD_RULE_DATA_ID,
service_name: "my-service",
state: DatadogAPIClient::V2::State::PASS,
}),
],
}),
type: DatadogAPIClient::V2::OutcomesBatchType::BATCHED_OUTCOME,
}),
})
p api_instance.create_scorecard_outcomes_batch(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 outcomes batch returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_scorecards::ScorecardsAPI;
use datadog_api_client::datadogV2::model::OutcomesBatchAttributes;
use datadog_api_client::datadogV2::model::OutcomesBatchRequest;
use datadog_api_client::datadogV2::model::OutcomesBatchRequestData;
use datadog_api_client::datadogV2::model::OutcomesBatchRequestItem;
use datadog_api_client::datadogV2::model::OutcomesBatchType;
use datadog_api_client::datadogV2::model::State;
#[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 = OutcomesBatchRequest::new().data(
OutcomesBatchRequestData::new()
.attributes(
OutcomesBatchAttributes::new().results(vec![OutcomesBatchRequestItem::new(
create_scorecard_rule_data_id.clone(),
"my-service".to_string(),
State::PASS,
)
.remarks(
r#"See: <a href="https://app.datadoghq.com/services">Services</a>"#.to_string(),
)]),
)
.type_(OutcomesBatchType::BATCHED_OUTCOME),
);
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.create_scorecard_outcomes_batch", true);
let api = ScorecardsAPI::with_config(configuration);
let resp = api.create_scorecard_outcomes_batch(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/**
* Create outcomes batch 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,
},
},
});
configuration.unstableOperations["v2.createScorecardOutcomesBatch"] = true;
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.ScorecardsApiCreateScorecardOutcomesBatchRequest = {
body: {
data: {
attributes: {
results: [
{
remarks: `See: <a href="https://app.datadoghq.com/services">Services</a>`,
ruleId: CREATE_SCORECARD_RULE_DATA_ID,
serviceName: "my-service",
state: "pass",
},
],
},
type: "batched-outcome",
},
},
};
apiInstance
.createScorecardOutcomesBatch(params)
.then((data: v2.OutcomesBatchResponse) => {
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"