Create outcomes batch

Note: This endpoint is in Preview. If you have any feedback, contact Datadog support.

POST https://api.ap1.datadoghq.com/api/v2/scorecard/outcomes/batchhttps://api.ap2.datadoghq.com/api/v2/scorecard/outcomes/batchhttps://api.datadoghq.eu/api/v2/scorecard/outcomes/batchhttps://api.ddog-gov.com/api/v2/scorecard/outcomes/batchhttps://api.us2.ddog-gov.com/api/v2/scorecard/outcomes/batchhttps://api.uk1.datadoghq.com/api/v2/scorecard/outcomes/batchhttps://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/batch

概要

1 つのバッチリクエストで複数のサービスルール成果を設定します。

OAuth apps require the apm_service_catalog_write authorization scope to access this endpoint.

リクエスト

Body Data (required)

スコアカード成果のセット。

Expand All

フィールド

種類

説明

data

object

Scorecard outcomes batch request data.

attributes

object

The JSON:API attributes for a batched set of scorecard outcomes.

results

[object]

Set of scorecard outcomes to update.

remarks

string

Any remarks regarding the scorecard rule's evaluation, and supports HTML hyperlinks.

rule_id [required]

string

The unique ID for a scorecard rule.

service_name [required]

string

The unique name for a service in the catalog.

state [required]

enum

The state of the rule evaluation. Allowed enum values: pass,fail,skip

type

enum

The JSON:API type for scorecard outcomes. Allowed enum values: batched-outcome

default: batched-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"
  }
}

応答

OK

Scorecard outcomes batch response.

Expand All

フィールド

種類

説明

data [required]

[object]

List of rule outcomes which were affected during the bulk operation.

attributes

object

The JSON:API attributes for an outcome.

created_at

date-time

Creation time of the rule outcome.

modified_at

date-time

Time of last rule outcome modification.

remarks

string

Any remarks regarding the scorecard rule's evaluation, and supports HTML hyperlinks.

service_name

string

The unique name for a service in the catalog.

state

enum

The state of the rule evaluation. Allowed enum values: pass,fail,skip

id

string

The unique ID for a rule outcome.

relationships

object

The JSON:API relationship to a scorecard rule.

rule

object

The JSON:API relationship to a scorecard outcome.

data

object

The JSON:API relationship to an outcome, which returns the related rule id.

id

string

The unique ID for a scorecard rule.

type

enum

The JSON:API type for scorecard rules. Allowed enum values: rule

default: rule

type

enum

The JSON:API type for an outcome. Allowed enum values: outcome

default: outcome

meta [required]

object

Metadata pertaining to the bulk operation.

total_received

int64

Total number of scorecard results received during the bulk operation.

total_updated

int64

Total 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.

Expand All

フィールド

種類

説明

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

フィールド

種類

説明

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

API error response.

Expand All

フィールド

種類

説明

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

コード例

                          ## default
# 

# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.uk1.datadoghq.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/scorecard/outcomes/batch" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "results": [ { "remarks": "See: \u003ca href=\"https://app.datadoghq.com/services\"\u003eServices\u003c/a\u003e", "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())
	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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" 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.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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" 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.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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Create outcomes batch returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" 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.CreateScorecardOutcomesBatch", 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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.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();
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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"