Get code coverage summary for a branch
https://api.datadoghq.com/api/v2/code-coverage/branch/summaryhttps://api.us3.datadoghq.com/api/v2/code-coverage/branch/summaryhttps://api.us5.datadoghq.com/api/v2/code-coverage/branch/summaryhttps://api.datadoghq.eu/api/v2/code-coverage/branch/summaryhttps://api.ap1.datadoghq.com/api/v2/code-coverage/branch/summaryhttps://api.ap2.datadoghq.com/api/v2/code-coverage/branch/summaryhttps://api.uk1.datadoghq.com/api/v2/code-coverage/branch/summaryhttps://api.ddog-gov.com/api/v2/code-coverage/branch/summaryhttps://api.us2.ddog-gov.com/api/v2/code-coverage/branch/summaryOverview
Retrieve aggregated code coverage statistics for a specific branch in a repository. This endpoint provides overall coverage metrics as well as breakdowns by service, code owner, and flag.
OAuth apps require the code_coverage_read authorization scope to access this endpoint.
Request
Body Data (required)
data [required]Data object for branch summary request.
attributes [required]Attributes for requesting code coverage summary for a branch.
branch [required]The branch name.
repository_id [deprecated]DEPRECATED
Deprecated: use repository_url instead. The repository URL.
repository_urlThe repository URL. Accepts a full URL with or without a scheme (for example, https://github.com/org/repo or github.com/org/repo).
type [required]JSON:API type for branch coverage summary request. The value must always be ci_app_coverage_branch_summary_request.
ci_app_coverage_branch_summary_request{
"data": {
"attributes": {
"branch": "prod",
"repository_id": "github.com/datadog/shopist",
"repository_url": "https://github.com/datadog/shopist"
},
"type": "ci_app_coverage_branch_summary_request"
}
}Response
OK
Response object containing code coverage summary.
dataData object for coverage summary response.
attributesAttributes object for code coverage summary response.
codeownersCoverage statistics broken down by code owner.
<any-key>Coverage statistics for a specific code owner.
evaluated_flags_countNumber of coverage flags evaluated for the code owner.
evaluated_reports_countNumber of coverage reports evaluated for the code owner.
patch_coveragePatch coverage percentage for the code owner.
total_coverageTotal coverage percentage for the code owner.
evaluated_flags_countTotal number of coverage flags evaluated.
evaluated_reports_countTotal number of coverage reports evaluated.
flagsCoverage statistics broken down by flag. Each entry contains only coverage percentages. Branch summaries include the flags of the latest covered commit, including coverage carried forward to that commit. Pull request summaries include flags across all commits of the pull request.
<any-key>Coverage statistics for a specific flag.
patch_coveragePatch coverage percentage for the flag.
total_coverageTotal coverage percentage for the flag.
patch_coverageOverall patch coverage percentage.
servicesCoverage statistics broken down by service.
<any-key>Coverage statistics for a specific service.
evaluated_flags_countNumber of coverage flags evaluated for the service.
evaluated_reports_countNumber of coverage reports evaluated for the service.
patch_coveragePatch coverage percentage for the service.
total_coverageTotal coverage percentage for the service.
total_coverageOverall total coverage percentage.
idUnique identifier for the coverage summary (base64-hashed).
typeJSON:API type for coverage summary response. The value must always be ci_app_coverage_summary.
ci_app_coverage_summary{
"data": {
"attributes": {
"codeowners": {
"<any-key>": {
"evaluated_flags_count": 2,
"evaluated_reports_count": 4,
"patch_coverage": 75.2,
"total_coverage": 88.7
}
},
"evaluated_flags_count": 8,
"evaluated_reports_count": 12,
"flags": {
"<any-key>": {
"patch_coverage": 70,
"total_coverage": 75
}
},
"patch_coverage": 70.1,
"services": {
"<any-key>": {
"evaluated_flags_count": 3,
"evaluated_reports_count": 5,
"patch_coverage": 72.3,
"total_coverage": 85.5
}
},
"total_coverage": 82.4
},
"id": "ZGQxMjM0NV9tYWluXzE3MDk1NjQwMDA=",
"type": "ci_app_coverage_summary"
}
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Not Authorized
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"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Internal server error
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Code Example
# 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/code-coverage/branch/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"branch": "prod",
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_branch_summary_request"
}
}
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/code-coverage/branch/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"branch": "prod",
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_branch_summary_request"
}
}
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/code-coverage/branch/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"branch": "prod",
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_branch_summary_request"
}
}
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/code-coverage/branch/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"branch": "prod",
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_branch_summary_request"
}
}
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/code-coverage/branch/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"branch": "prod",
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_branch_summary_request"
}
}
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/code-coverage/branch/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"branch": "prod",
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_branch_summary_request"
}
}
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/code-coverage/branch/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"branch": "prod",
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_branch_summary_request"
}
}
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/code-coverage/branch/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"branch": "prod",
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_branch_summary_request"
}
}
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/code-coverage/branch/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"branch": "prod",
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_branch_summary_request"
}
}
EOF// Get code coverage summary for a branch 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.BranchCoverageSummaryRequest{
Data: datadogV2.BranchCoverageSummaryRequestData{
Attributes: datadogV2.BranchCoverageSummaryRequestAttributes{
Branch: "prod",
RepositoryId: datadog.PtrString("github.com/datadog/shopist"),
RepositoryUrl: datadog.PtrString("https://github.com/datadog/shopist"),
},
Type: datadogV2.BRANCHCOVERAGESUMMARYREQUESTTYPE_CI_APP_COVERAGE_BRANCH_SUMMARY_REQUEST,
},
}
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.NewCodeCoverageApi(apiClient)
resp, r, err := api.GetCodeCoverageBranchSummary(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CodeCoverageApi.GetCodeCoverageBranchSummary`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `CodeCoverageApi.GetCodeCoverageBranchSummary`:\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"// Get code coverage summary for a branch returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.CodeCoverageApi;
import com.datadog.api.client.v2.model.BranchCoverageSummaryRequest;
import com.datadog.api.client.v2.model.BranchCoverageSummaryRequestAttributes;
import com.datadog.api.client.v2.model.BranchCoverageSummaryRequestData;
import com.datadog.api.client.v2.model.BranchCoverageSummaryRequestType;
import com.datadog.api.client.v2.model.CoverageSummaryResponse;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
CodeCoverageApi apiInstance = new CodeCoverageApi(defaultClient);
BranchCoverageSummaryRequest body =
new BranchCoverageSummaryRequest()
.data(
new BranchCoverageSummaryRequestData()
.attributes(
new BranchCoverageSummaryRequestAttributes()
.branch("prod")
.repositoryId("github.com/datadog/shopist")
.repositoryUrl("https://github.com/datadog/shopist"))
.type(BranchCoverageSummaryRequestType.CI_APP_COVERAGE_BRANCH_SUMMARY_REQUEST));
try {
CoverageSummaryResponse result = apiInstance.getCodeCoverageBranchSummary(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling CodeCoverageApi#getCodeCoverageBranchSummary");
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""""
Get code coverage summary for a branch returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.code_coverage_api import CodeCoverageApi
from datadog_api_client.v2.model.branch_coverage_summary_request import BranchCoverageSummaryRequest
from datadog_api_client.v2.model.branch_coverage_summary_request_attributes import (
BranchCoverageSummaryRequestAttributes,
)
from datadog_api_client.v2.model.branch_coverage_summary_request_data import BranchCoverageSummaryRequestData
from datadog_api_client.v2.model.branch_coverage_summary_request_type import BranchCoverageSummaryRequestType
body = BranchCoverageSummaryRequest(
data=BranchCoverageSummaryRequestData(
attributes=BranchCoverageSummaryRequestAttributes(
branch="prod",
repository_id="github.com/datadog/shopist",
repository_url="https://github.com/datadog/shopist",
),
type=BranchCoverageSummaryRequestType.CI_APP_COVERAGE_BRANCH_SUMMARY_REQUEST,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = CodeCoverageApi(api_client)
response = api_instance.get_code_coverage_branch_summary(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"# Get code coverage summary for a branch returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::CodeCoverageAPI.new
body = DatadogAPIClient::V2::BranchCoverageSummaryRequest.new({
data: DatadogAPIClient::V2::BranchCoverageSummaryRequestData.new({
attributes: DatadogAPIClient::V2::BranchCoverageSummaryRequestAttributes.new({
branch: "prod",
repository_id: "github.com/datadog/shopist",
repository_url: "https://github.com/datadog/shopist",
}),
type: DatadogAPIClient::V2::BranchCoverageSummaryRequestType::CI_APP_COVERAGE_BRANCH_SUMMARY_REQUEST,
}),
})
p api_instance.get_code_coverage_branch_summary(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>" ruby "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" ruby "example.rb"// Get code coverage summary for a branch returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_code_coverage::CodeCoverageAPI;
use datadog_api_client::datadogV2::model::BranchCoverageSummaryRequest;
use datadog_api_client::datadogV2::model::BranchCoverageSummaryRequestAttributes;
use datadog_api_client::datadogV2::model::BranchCoverageSummaryRequestData;
use datadog_api_client::datadogV2::model::BranchCoverageSummaryRequestType;
#[tokio::main]
async fn main() {
let body = BranchCoverageSummaryRequest::new(BranchCoverageSummaryRequestData::new(
BranchCoverageSummaryRequestAttributes::new("prod".to_string())
.repository_id("github.com/datadog/shopist".to_string())
.repository_url("https://github.com/datadog/shopist".to_string()),
BranchCoverageSummaryRequestType::CI_APP_COVERAGE_BRANCH_SUMMARY_REQUEST,
));
let configuration = datadog::Configuration::new();
let api = CodeCoverageAPI::with_config(configuration);
let resp = api.get_code_coverage_branch_summary(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/**
* Get code coverage summary for a branch 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.CodeCoverageApi(configuration);
const params: v2.CodeCoverageApiGetCodeCoverageBranchSummaryRequest = {
body: {
data: {
attributes: {
branch: "prod",
repositoryId: "github.com/datadog/shopist",
repositoryUrl: "https://github.com/datadog/shopist",
},
type: "ci_app_coverage_branch_summary_request",
},
},
};
apiInstance
.getCodeCoverageBranchSummary(params)
.then((data: v2.CoverageSummaryResponse) => {
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>" npx tsx "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" npx tsx "example.ts"