Update Test Optimization service settings

PATCH https://api.ap1.datadoghq.com/api/v2/ci/test-optimization/settings/servicehttps://api.ap2.datadoghq.com/api/v2/ci/test-optimization/settings/servicehttps://api.datadoghq.eu/api/v2/ci/test-optimization/settings/servicehttps://api.ddog-gov.com/api/v2/ci/test-optimization/settings/servicehttps://api.us2.ddog-gov.com/api/v2/ci/test-optimization/settings/servicehttps://api.datadoghq.com/api/v2/ci/test-optimization/settings/servicehttps://api.us3.datadoghq.com/api/v2/ci/test-optimization/settings/servicehttps://api.us5.datadoghq.com/api/v2/ci/test-optimization/settings/service

Overview

Partially update Test Optimization settings for a specific service identified by repository, service name, and environment. Only provided fields are updated; null or omitted fields are left unchanged. This endpoint requires the test_optimization_settings_write permission.

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

Request

Body Data (required)

Expand All

Field

Type

Description

data [required]

object

Data object for update service settings request.

attributes [required]

object

Attributes for updating Test Optimization service settings. All non-required fields are optional; only provided fields will be updated.

auto_test_retries_enabled

boolean

Whether Auto Test Retries are enabled for this service.

code_coverage_enabled

boolean

Whether Code Coverage is enabled for this service.

early_flake_detection_enabled

boolean

Whether Early Flake Detection is enabled for this service.

env

string

The environment name. If omitted, defaults to none.

failed_test_replay_enabled

boolean

Whether Failed Test Replay is enabled for this service.

pr_comments_enabled

boolean

Whether PR Comments are enabled for this service.

repository_id [required]

string

The repository identifier.

service_name [required]

string

The service name.

test_impact_analysis_enabled

boolean

Whether Test Impact Analysis is enabled for this service.

type [required]

enum

JSON:API type for update service settings request. The value must always be test_optimization_update_service_settings_request. Allowed enum values: test_optimization_update_service_settings_request

{
  "data": {
    "attributes": {
      "auto_test_retries_enabled": false,
      "code_coverage_enabled": false,
      "early_flake_detection_enabled": false,
      "env": "prod",
      "failed_test_replay_enabled": false,
      "pr_comments_enabled": true,
      "repository_id": "github.com/datadog/shopist",
      "service_name": "shopist",
      "test_impact_analysis_enabled": false
    },
    "type": "test_optimization_update_service_settings_request"
  }
}

Response

OK

Response object containing Test Optimization service settings.

Expand All

Field

Type

Description

data

object

Data object for Test Optimization service settings response.

attributes

object

Attributes for Test Optimization service settings.

auto_test_retries_enabled

boolean

Whether Auto Test Retries are enabled for this service.

code_coverage_enabled

boolean

Whether Code Coverage is enabled for this service.

early_flake_detection_enabled

boolean

Whether Early Flake Detection is enabled for this service.

env

string

The environment name.

failed_test_replay_enabled

boolean

Whether Failed Test Replay is enabled for this service.

pr_comments_enabled

boolean

Whether PR Comments are enabled for this service.

repository_id

string

The repository identifier.

service_name

string

The service name.

test_impact_analysis_enabled

boolean

Whether Test Impact Analysis is enabled for this service.

id

string

Unique identifier for the service settings.

type

enum

JSON:API type for service settings response. The value must always be test_optimization_service_settings. Allowed enum values: test_optimization_service_settings

{
  "data": {
    "attributes": {
      "auto_test_retries_enabled": false,
      "code_coverage_enabled": false,
      "early_flake_detection_enabled": false,
      "env": "prod",
      "failed_test_replay_enabled": false,
      "pr_comments_enabled": true,
      "repository_id": "github.com/datadog/shopist",
      "service_name": "shopist",
      "test_impact_analysis_enabled": false
    },
    "id": "github.com/datadog/shopist::shopist::prod",
    "type": "test_optimization_service_settings"
  }
}

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Not Authorized

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Not Found

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example

                  ## default
# 

# Curl command
curl -X PATCH "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.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/ci/test-optimization/settings/service" \ -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": { "auto_test_retries_enabled": false, "code_coverage_enabled": false, "early_flake_detection_enabled": false, "env": "prod", "failed_test_replay_enabled": false, "pr_comments_enabled": true, "repository_id": "github.com/datadog/test-service", "service_name": "test-service", "test_impact_analysis_enabled": false }, "type": "test_optimization_update_service_settings_request" } } EOF
"""
Update Test Optimization service settings returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.test_optimization_api import TestOptimizationApi
from datadog_api_client.v2.model.test_optimization_update_service_settings_request import (
    TestOptimizationUpdateServiceSettingsRequest,
)
from datadog_api_client.v2.model.test_optimization_update_service_settings_request_attributes import (
    TestOptimizationUpdateServiceSettingsRequestAttributes,
)
from datadog_api_client.v2.model.test_optimization_update_service_settings_request_data import (
    TestOptimizationUpdateServiceSettingsRequestData,
)
from datadog_api_client.v2.model.test_optimization_update_service_settings_request_data_type import (
    TestOptimizationUpdateServiceSettingsRequestDataType,
)

body = TestOptimizationUpdateServiceSettingsRequest(
    data=TestOptimizationUpdateServiceSettingsRequestData(
        attributes=TestOptimizationUpdateServiceSettingsRequestAttributes(
            auto_test_retries_enabled=False,
            code_coverage_enabled=False,
            early_flake_detection_enabled=False,
            env="prod",
            failed_test_replay_enabled=False,
            pr_comments_enabled=True,
            repository_id="github.com/datadog/shopist",
            service_name="shopist",
            test_impact_analysis_enabled=False,
        ),
        type=TestOptimizationUpdateServiceSettingsRequestDataType.TEST_OPTIMIZATION_UPDATE_SERVICE_SETTINGS_REQUEST,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = TestOptimizationApi(api_client)
    response = api_instance.update_test_optimization_service_settings(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.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Update Test Optimization service settings returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::TestOptimizationAPI.new

body = DatadogAPIClient::V2::TestOptimizationUpdateServiceSettingsRequest.new({
  data: DatadogAPIClient::V2::TestOptimizationUpdateServiceSettingsRequestData.new({
    attributes: DatadogAPIClient::V2::TestOptimizationUpdateServiceSettingsRequestAttributes.new({
      auto_test_retries_enabled: false,
      code_coverage_enabled: false,
      early_flake_detection_enabled: false,
      env: "prod",
      failed_test_replay_enabled: false,
      pr_comments_enabled: true,
      repository_id: "github.com/datadog/shopist",
      service_name: "shopist",
      test_impact_analysis_enabled: false,
    }),
    type: DatadogAPIClient::V2::TestOptimizationUpdateServiceSettingsRequestDataType::TEST_OPTIMIZATION_UPDATE_SERVICE_SETTINGS_REQUEST,
  }),
})
p api_instance.update_test_optimization_service_settings(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.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Update Test Optimization service settings 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() {
	body := datadogV2.TestOptimizationUpdateServiceSettingsRequest{
		Data: datadogV2.TestOptimizationUpdateServiceSettingsRequestData{
			Attributes: datadogV2.TestOptimizationUpdateServiceSettingsRequestAttributes{
				AutoTestRetriesEnabled:     datadog.PtrBool(false),
				CodeCoverageEnabled:        datadog.PtrBool(false),
				EarlyFlakeDetectionEnabled: datadog.PtrBool(false),
				Env:                        datadog.PtrString("prod"),
				FailedTestReplayEnabled:    datadog.PtrBool(false),
				PrCommentsEnabled:          datadog.PtrBool(true),
				RepositoryId:               "github.com/datadog/shopist",
				ServiceName:                "shopist",
				TestImpactAnalysisEnabled:  datadog.PtrBool(false),
			},
			Type: datadogV2.TESTOPTIMIZATIONUPDATESERVICESETTINGSREQUESTDATATYPE_TEST_OPTIMIZATION_UPDATE_SERVICE_SETTINGS_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewTestOptimizationApi(apiClient)
	resp, r, err := api.UpdateTestOptimizationServiceSettings(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `TestOptimizationApi.UpdateTestOptimizationServiceSettings`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `TestOptimizationApi.UpdateTestOptimizationServiceSettings`:\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.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Update Test Optimization service settings returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.TestOptimizationApi;
import com.datadog.api.client.v2.model.TestOptimizationServiceSettingsResponse;
import com.datadog.api.client.v2.model.TestOptimizationUpdateServiceSettingsRequest;
import com.datadog.api.client.v2.model.TestOptimizationUpdateServiceSettingsRequestAttributes;
import com.datadog.api.client.v2.model.TestOptimizationUpdateServiceSettingsRequestData;
import com.datadog.api.client.v2.model.TestOptimizationUpdateServiceSettingsRequestDataType;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    TestOptimizationApi apiInstance = new TestOptimizationApi(defaultClient);

    TestOptimizationUpdateServiceSettingsRequest body =
        new TestOptimizationUpdateServiceSettingsRequest()
            .data(
                new TestOptimizationUpdateServiceSettingsRequestData()
                    .attributes(
                        new TestOptimizationUpdateServiceSettingsRequestAttributes()
                            .autoTestRetriesEnabled(false)
                            .codeCoverageEnabled(false)
                            .earlyFlakeDetectionEnabled(false)
                            .env("prod")
                            .failedTestReplayEnabled(false)
                            .prCommentsEnabled(true)
                            .repositoryId("github.com/datadog/shopist")
                            .serviceName("shopist")
                            .testImpactAnalysisEnabled(false))
                    .type(
                        TestOptimizationUpdateServiceSettingsRequestDataType
                            .TEST_OPTIMIZATION_UPDATE_SERVICE_SETTINGS_REQUEST));

    try {
      TestOptimizationServiceSettingsResponse result =
          apiInstance.updateTestOptimizationServiceSettings(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println(
          "Exception when calling TestOptimizationApi#updateTestOptimizationServiceSettings");
      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.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// Update Test Optimization service settings returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_test_optimization::TestOptimizationAPI;
use datadog_api_client::datadogV2::model::TestOptimizationUpdateServiceSettingsRequest;
use datadog_api_client::datadogV2::model::TestOptimizationUpdateServiceSettingsRequestAttributes;
use datadog_api_client::datadogV2::model::TestOptimizationUpdateServiceSettingsRequestData;
use datadog_api_client::datadogV2::model::TestOptimizationUpdateServiceSettingsRequestDataType;

#[tokio::main]
async fn main() {
    let body =
        TestOptimizationUpdateServiceSettingsRequest::new(
            TestOptimizationUpdateServiceSettingsRequestData::new(
                TestOptimizationUpdateServiceSettingsRequestAttributes::new(
                    "github.com/datadog/shopist".to_string(),
                    "shopist".to_string(),
                )
                    .auto_test_retries_enabled(false)
                    .code_coverage_enabled(false)
                    .early_flake_detection_enabled(false)
                    .env("prod".to_string())
                    .failed_test_replay_enabled(false)
                    .pr_comments_enabled(true)
                    .test_impact_analysis_enabled(false),
                TestOptimizationUpdateServiceSettingsRequestDataType
                ::TEST_OPTIMIZATION_UPDATE_SERVICE_SETTINGS_REQUEST,
            ),
        );
    let configuration = datadog::Configuration::new();
    let api = TestOptimizationAPI::with_config(configuration);
    let resp = api.update_test_optimization_service_settings(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.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * Update Test Optimization service settings returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.TestOptimizationApi(configuration);

const params: v2.TestOptimizationApiUpdateTestOptimizationServiceSettingsRequest =
  {
    body: {
      data: {
        attributes: {
          autoTestRetriesEnabled: false,
          codeCoverageEnabled: false,
          earlyFlakeDetectionEnabled: false,
          env: "prod",
          failedTestReplayEnabled: false,
          prCommentsEnabled: true,
          repositoryId: "github.com/datadog/shopist",
          serviceName: "shopist",
          testImpactAnalysisEnabled: false,
        },
        type: "test_optimization_update_service_settings_request",
      },
    },
  };

apiInstance
  .updateTestOptimizationServiceSettings(params)
  .then((data: v2.TestOptimizationServiceSettingsResponse) => {
    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.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"