Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,892 changes: 2,446 additions & 2,446 deletions .generator/schemas/v1/openapi.yaml

Large diffs are not rendered by default.

26,980 changes: 13,653 additions & 13,327 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
)

configuration = Configuration()
configuration.unstable_operations["get_code_coverage_branch_summary"] = True
with ApiClient(configuration) as api_client:
api_instance = CodeCoverageApi(api_client)
response = api_instance.get_code_coverage_branch_summary(body=body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
)

configuration = Configuration()
configuration.unstable_operations["get_code_coverage_commit_summary"] = True
with ApiClient(configuration) as api_client:
api_instance = CodeCoverageApi(api_client)
response = api_instance.get_code_coverage_commit_summary(body=body)
Expand Down
28 changes: 28 additions & 0 deletions examples/v2/code-coverage/GetCodeCoverageFiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Get per-file code coverage data returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.code_coverage_api import CodeCoverageApi
from datadog_api_client.v2.model.files_coverage_request import FilesCoverageRequest
from datadog_api_client.v2.model.files_coverage_request_attributes import FilesCoverageRequestAttributes
from datadog_api_client.v2.model.files_coverage_request_data import FilesCoverageRequestData
from datadog_api_client.v2.model.files_coverage_request_type import FilesCoverageRequestType

body = FilesCoverageRequest(
data=FilesCoverageRequestData(
attributes=FilesCoverageRequestAttributes(
changed_only=True,
commit_sha="66adc9350f2cc9b250b69abddab733dd55e1a588",
repository_url="https://github.com/datadog/shopist",
),
type=FilesCoverageRequestType.CI_APP_COVERAGE_FILES_REQUEST,
),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = CodeCoverageApi(api_client)
response = api_instance.get_code_coverage_files(body=body)

print(response)
27 changes: 27 additions & 0 deletions examples/v2/code-coverage/GetCodeCoveragePRSummary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
Get code coverage summary for a pull request returns "OK" response
"""

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()
with ApiClient(configuration) as api_client:
api_instance = CodeCoverageApi(api_client)
response = api_instance.get_code_coverage_pr_summary(body=body)

print(response)
2 changes: 0 additions & 2 deletions src/datadog_api_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,6 @@ def __init__(
"v2.update_security_monitoring_integration_config": False,
"v2.validate_security_monitoring_integration_config": False,
"v2.validate_security_monitoring_integration_credentials": False,
"v2.get_code_coverage_branch_summary": False,
"v2.get_code_coverage_commit_summary": False,
"v2.get_rule_based_view": False,
"v2.create_unit_cost": False,
"v2.delete_unit_cost": False,
Expand Down
79 changes: 79 additions & 0 deletions src/datadog_api_client/v2/api/code_coverage_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from datadog_api_client.v2.model.coverage_summary_response import CoverageSummaryResponse
from datadog_api_client.v2.model.branch_coverage_summary_request import BranchCoverageSummaryRequest
from datadog_api_client.v2.model.commit_coverage_summary_request import CommitCoverageSummaryRequest
from datadog_api_client.v2.model.files_coverage_response import FilesCoverageResponse
from datadog_api_client.v2.model.files_coverage_request import FilesCoverageRequest
from datadog_api_client.v2.model.pr_coverage_summary_request import PRCoverageSummaryRequest


class CodeCoverageApi:
Expand Down Expand Up @@ -62,6 +65,46 @@ def __init__(self, api_client=None):
api_client=api_client,
)

self._get_code_coverage_files_endpoint = _Endpoint(
settings={
"response_type": (FilesCoverageResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/code-coverage/files",
"operation_id": "get_code_coverage_files",
"http_method": "POST",
"version": "v2",
},
params_map={
"body": {
"required": True,
"openapi_types": (FilesCoverageRequest,),
"location": "body",
},
},
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
api_client=api_client,
)

self._get_code_coverage_pr_summary_endpoint = _Endpoint(
settings={
"response_type": (CoverageSummaryResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/code-coverage/pr/summary",
"operation_id": "get_code_coverage_pr_summary",
"http_method": "POST",
"version": "v2",
},
params_map={
"body": {
"required": True,
"openapi_types": (PRCoverageSummaryRequest,),
"location": "body",
},
},
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
api_client=api_client,
)

def get_code_coverage_branch_summary(
self,
body: BranchCoverageSummaryRequest,
Expand Down Expand Up @@ -99,3 +142,39 @@ def get_code_coverage_commit_summary(
kwargs["body"] = body

return self._get_code_coverage_commit_summary_endpoint.call_with_http_info(**kwargs)

def get_code_coverage_files(
self,
body: FilesCoverageRequest,
) -> FilesCoverageResponse:
"""Get per-file code coverage data.

Retrieve per-file code coverage data for a specific commit, branch, or pull request.
Exactly one of ``commit_sha`` , ``branch`` , or ``pr_number`` must be provided.
Optionally filter by ``service`` , ``codeowner`` , or ``flag`` (at most one).

:type body: FilesCoverageRequest
:rtype: FilesCoverageResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["body"] = body

return self._get_code_coverage_files_endpoint.call_with_http_info(**kwargs)

def get_code_coverage_pr_summary(
self,
body: PRCoverageSummaryRequest,
) -> CoverageSummaryResponse:
"""Get code coverage summary for a pull request.

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.

:type body: PRCoverageSummaryRequest
:rtype: CoverageSummaryResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["body"] = body

return self._get_code_coverage_pr_summary_endpoint.call_with_http_info(**kwargs)
56 changes: 56 additions & 0 deletions src/datadog_api_client/v2/model/file_coverage_lines.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import List, Union

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


class FileCoverageLines(ModelNormal):
@cached_property
def openapi_types(_):
return {
"added_lines": ([int],),
"covered_lines": ([int],),
"executable_lines": ([int],),
}

attribute_map = {
"added_lines": "added_lines",
"covered_lines": "covered_lines",
"executable_lines": "executable_lines",
}

def __init__(
self_,
added_lines: Union[List[int], UnsetType] = unset,
covered_lines: Union[List[int], UnsetType] = unset,
executable_lines: Union[List[int], UnsetType] = unset,
**kwargs,
):
"""
Per-file line coverage data including executable, covered, and added lines.

:param added_lines: Line numbers that were added in the specified scope (for example, in a PR diff).
:type added_lines: [int], optional

:param covered_lines: Line numbers that were covered by tests.
:type covered_lines: [int], optional

:param executable_lines: Line numbers that are executable (can be covered).
:type executable_lines: [int], optional
"""
if added_lines is not unset:
kwargs["added_lines"] = added_lines
if covered_lines is not unset:
kwargs["covered_lines"] = covered_lines
if executable_lines is not unset:
kwargs["executable_lines"] = executable_lines
super().__init__(kwargs)
78 changes: 78 additions & 0 deletions src/datadog_api_client/v2/model/files_coverage_attributes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Dict, Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.file_coverage_lines import FileCoverageLines


class FilesCoverageAttributes(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.file_coverage_lines import FileCoverageLines

return {
"base_commit_sha": (str,),
"event_timestamp": (int,),
"files": ({str: (FileCoverageLines,)},),
"head_commit_sha": (str,),
"report_count": (int,),
}

attribute_map = {
"base_commit_sha": "base_commit_sha",
"event_timestamp": "event_timestamp",
"files": "files",
"head_commit_sha": "head_commit_sha",
"report_count": "report_count",
}

def __init__(
self_,
base_commit_sha: Union[str, UnsetType] = unset,
event_timestamp: Union[int, UnsetType] = unset,
files: Union[Dict[str, FileCoverageLines], UnsetType] = unset,
head_commit_sha: Union[str, UnsetType] = unset,
report_count: Union[int, UnsetType] = unset,
**kwargs,
):
"""
Attributes of the per-file code coverage response.

:param base_commit_sha: The SHA of the base commit used for comparison (for example, the merge base for a PR).
:type base_commit_sha: str, optional

:param event_timestamp: Unix timestamp (milliseconds) of the coverage event.
:type event_timestamp: int, optional

:param files: Map of file paths to per-file coverage line data.
:type files: {str: (FileCoverageLines,)}, optional

:param head_commit_sha: The SHA of the head commit for which coverage was evaluated.
:type head_commit_sha: str, optional

:param report_count: Number of coverage reports evaluated.
:type report_count: int, optional
"""
if base_commit_sha is not unset:
kwargs["base_commit_sha"] = base_commit_sha
if event_timestamp is not unset:
kwargs["event_timestamp"] = event_timestamp
if files is not unset:
kwargs["files"] = files
if head_commit_sha is not unset:
kwargs["head_commit_sha"] = head_commit_sha
if report_count is not unset:
kwargs["report_count"] = report_count
super().__init__(kwargs)
64 changes: 64 additions & 0 deletions src/datadog_api_client/v2/model/files_coverage_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.files_coverage_attributes import FilesCoverageAttributes
from datadog_api_client.v2.model.files_coverage_response_type import FilesCoverageResponseType


class FilesCoverageData(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.files_coverage_attributes import FilesCoverageAttributes
from datadog_api_client.v2.model.files_coverage_response_type import FilesCoverageResponseType

return {
"attributes": (FilesCoverageAttributes,),
"id": (str,),
"type": (FilesCoverageResponseType,),
}

attribute_map = {
"attributes": "attributes",
"id": "id",
"type": "type",
}

def __init__(
self_,
attributes: Union[FilesCoverageAttributes, UnsetType] = unset,
id: Union[str, UnsetType] = unset,
type: Union[FilesCoverageResponseType, UnsetType] = unset,
**kwargs,
):
"""
Data object for files coverage response.

:param attributes: Attributes of the per-file code coverage response.
:type attributes: FilesCoverageAttributes, optional

:param id: Unique identifier for the files coverage response.
:type id: str, optional

:param type: JSON:API type for files coverage response. The value must always be ``ci_app_coverage_files``.
:type type: FilesCoverageResponseType, optional
"""
if attributes is not unset:
kwargs["attributes"] = attributes
if id is not unset:
kwargs["id"] = id
if type is not unset:
kwargs["type"] = type
super().__init__(kwargs)
Loading
Loading