Get code coverage summary for a pull request
https://api.datadoghq.com/api/v2/code-coverage/pr/summaryhttps://api.us3.datadoghq.com/api/v2/code-coverage/pr/summaryhttps://api.us5.datadoghq.com/api/v2/code-coverage/pr/summaryhttps://api.datadoghq.eu/api/v2/code-coverage/pr/summaryhttps://api.ap1.datadoghq.com/api/v2/code-coverage/pr/summaryhttps://api.ap2.datadoghq.com/api/v2/code-coverage/pr/summaryhttps://api.uk1.datadoghq.com/api/v2/code-coverage/pr/summaryhttps://api.ddog-gov.com/api/v2/code-coverage/pr/summaryhttps://api.us2.ddog-gov.com/api/v2/code-coverage/pr/summaryOverview
Retrieve aggregated code coverage statistics for a specific pull request in a repository. This endpoint provides overall coverage metrics as well as breakdowns by service and code owner.
OAuth apps require the code_coverage_read authorization scope to access this endpoint.
Request
Body Data (required)
data [required]Data object for PR summary request.
attributes [required]Attributes for requesting code coverage summary for a pull request.
pr_number [required]The pull request number. Must be a positive integer.
repository_url [required]The 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 PR coverage summary request. The value must always be ci_app_coverage_pr_summary_request.
ci_app_coverage_pr_summary_request{
"data": {
"attributes": {
"pr_number": 42,
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_pr_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.
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,
"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/pr/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"pr_number": 42,
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_pr_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/pr/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"pr_number": 42,
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_pr_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/pr/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"pr_number": 42,
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_pr_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/pr/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"pr_number": 42,
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_pr_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/pr/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"pr_number": 42,
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_pr_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/pr/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"pr_number": 42,
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_pr_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/pr/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"pr_number": 42,
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_pr_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/pr/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"pr_number": 42,
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_pr_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/pr/summary" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"pr_number": 42,
"repository_url": "https://github.com/datadog/test-service"
},
"type": "ci_app_coverage_pr_summary_request"
}
}
EOF// Get code coverage summary for a pull request 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.PRCoverageSummaryRequest{
Data: datadogV2.PRCoverageSummaryRequestData{
Attributes: datadogV2.PRCoverageSummaryRequestAttributes{
PrNumber: 42,
RepositoryUrl: "https://github.com/datadog/shopist",
},
Type: datadogV2.PRCOVERAGESUMMARYREQUESTTYPE_CI_APP_COVERAGE_PR_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.GetCodeCoveragePRSummary(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CodeCoverageApi.GetCodeCoveragePRSummary`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `CodeCoverageApi.GetCodeCoveragePRSummary`:\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 pull request 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.CoverageSummaryResponse;
import com.datadog.api.client.v2.model.PRCoverageSummaryRequest;
import com.datadog.api.client.v2.model.PRCoverageSummaryRequestAttributes;
import com.datadog.api.client.v2.model.PRCoverageSummaryRequestData;
import com.datadog.api.client.v2.model.PRCoverageSummaryRequestType;
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);
PRCoverageSummaryRequest body =
new PRCoverageSummaryRequest()
.data(
new PRCoverageSummaryRequestData()
.attributes(
new PRCoverageSummaryRequestAttributes()
.prNumber(42L)
.repositoryUrl("https://github.com/datadog/shopist"))
.type(PRCoverageSummaryRequestType.CI_APP_COVERAGE_PR_SUMMARY_REQUEST));
try {
CoverageSummaryResponse result = apiInstance.getCodeCoveragePRSummary(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling CodeCoverageApi#getCodeCoveragePRSummary");
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 pull request 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.pr_coverage_summary_request import PRCoverageSummaryRequest
from datadog_api_client.v2.model.pr_coverage_summary_request_attributes import PRCoverageSummaryRequestAttributes
from datadog_api_client.v2.model.pr_coverage_summary_request_data import PRCoverageSummaryRequestData
from datadog_api_client.v2.model.pr_coverage_summary_request_type import PRCoverageSummaryRequestType
body = PRCoverageSummaryRequest(
data=PRCoverageSummaryRequestData(
attributes=PRCoverageSummaryRequestAttributes(
pr_number=42,
repository_url="https://github.com/datadog/shopist",
),
type=PRCoverageSummaryRequestType.CI_APP_COVERAGE_PR_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_pr_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 pull request 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::PRCoverageSummaryRequest.new({
data: DatadogAPIClient::V2::PRCoverageSummaryRequestData.new({
attributes: DatadogAPIClient::V2::PRCoverageSummaryRequestAttributes.new({
pr_number: 42,
repository_url: "https://github.com/datadog/shopist",
}),
type: DatadogAPIClient::V2::PRCoverageSummaryRequestType::CI_APP_COVERAGE_PR_SUMMARY_REQUEST,
}),
})
p api_instance.get_code_coverage_pr_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>" 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"// Get code coverage summary for a pull request returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_code_coverage::CodeCoverageAPI;
use datadog_api_client::datadogV2::model::PRCoverageSummaryRequest;
use datadog_api_client::datadogV2::model::PRCoverageSummaryRequestAttributes;
use datadog_api_client::datadogV2::model::PRCoverageSummaryRequestData;
use datadog_api_client::datadogV2::model::PRCoverageSummaryRequestType;
#[tokio::main]
async fn main() {
let body = PRCoverageSummaryRequest::new(PRCoverageSummaryRequestData::new(
PRCoverageSummaryRequestAttributes::new(
42,
"https://github.com/datadog/shopist".to_string(),
),
PRCoverageSummaryRequestType::CI_APP_COVERAGE_PR_SUMMARY_REQUEST,
));
let configuration = datadog::Configuration::new();
let api = CodeCoverageAPI::with_config(configuration);
let resp = api.get_code_coverage_pr_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 pull request 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.CodeCoverageApiGetCodeCoveragePRSummaryRequest = {
body: {
data: {
attributes: {
prNumber: 42,
repositoryUrl: "https://github.com/datadog/shopist",
},
type: "ci_app_coverage_pr_summary_request",
},
},
};
apiInstance
.getCodeCoveragePRSummary(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>" 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"