diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index b8661d93ff..07cf64fab0 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -7297,6 +7297,51 @@ components: data: $ref: '#/components/schemas/BillingDimensionsMappingBody' type: object + BranchCoverageSummaryRequest: + description: Request object for getting code coverage summary for a branch. + properties: + data: + $ref: '#/components/schemas/BranchCoverageSummaryRequestData' + required: + - data + type: object + BranchCoverageSummaryRequestAttributes: + description: Attributes for requesting code coverage summary for a branch. + properties: + branch: + description: The branch name. + example: prod + minLength: 1 + type: string + repository_id: + description: The repository identifier. + example: github.com/datadog/shopist + minLength: 1 + type: string + required: + - repository_id + - branch + type: object + BranchCoverageSummaryRequestData: + description: Data object for branch summary request. + properties: + attributes: + $ref: '#/components/schemas/BranchCoverageSummaryRequestAttributes' + type: + $ref: '#/components/schemas/BranchCoverageSummaryRequestType' + required: + - type + - attributes + type: object + BranchCoverageSummaryRequestType: + description: JSON:API type for branch coverage summary request. The value must + always be `ci_app_coverage_branch_summary_request`. + enum: + - ci_app_coverage_branch_summary_request + example: ci_app_coverage_branch_summary_request + type: string + x-enum-varnames: + - CI_APP_COVERAGE_BRANCH_SUMMARY_REQUEST Budget: description: A budget. properties: @@ -11760,6 +11805,51 @@ components: required: - location type: object + CommitCoverageSummaryRequest: + description: Request object for getting code coverage summary for a commit. + properties: + data: + $ref: '#/components/schemas/CommitCoverageSummaryRequestData' + required: + - data + type: object + CommitCoverageSummaryRequestAttributes: + description: Attributes for requesting code coverage summary for a commit. + properties: + commit_sha: + description: The commit SHA (40-character hexadecimal string). + example: 66adc9350f2cc9b250b69abddab733dd55e1a588 + pattern: ^[a-fA-F0-9]{40}$ + type: string + repository_id: + description: The repository identifier. + example: github.com/datadog/shopist + minLength: 1 + type: string + required: + - repository_id + - commit_sha + type: object + CommitCoverageSummaryRequestData: + description: Data object for commit summary request. + properties: + attributes: + $ref: '#/components/schemas/CommitCoverageSummaryRequestAttributes' + type: + $ref: '#/components/schemas/CommitCoverageSummaryRequestType' + required: + - type + - attributes + type: object + CommitCoverageSummaryRequestType: + description: JSON:API type for commit coverage summary request. The value must + always be `ci_app_coverage_commit_summary_request`. + enum: + - ci_app_coverage_commit_summary_request + example: ci_app_coverage_commit_summary_request + type: string + x-enum-varnames: + - CI_APP_COVERAGE_COMMIT_SUMMARY_REQUEST CompletionCondition: description: The definition of `CompletionCondition` object. properties: @@ -13270,6 +13360,123 @@ components: type: string x-enum-varnames: - COST_BY_ORG + CoverageSummaryAttributes: + description: Attributes object for code coverage summary response. + properties: + codeowners: + additionalProperties: + $ref: '#/components/schemas/CoverageSummaryCodeownerStats' + description: Coverage statistics broken down by code owner. + nullable: true + type: object + evaluated_flags_count: + description: Total number of coverage flags evaluated. + example: 8 + format: int64 + type: integer + evaluated_reports_count: + description: Total number of coverage reports evaluated. + example: 12 + format: int64 + type: integer + patch_coverage: + description: Overall patch coverage percentage. + example: 70.1 + format: double + nullable: true + type: number + services: + additionalProperties: + $ref: '#/components/schemas/CoverageSummaryServiceStats' + description: Coverage statistics broken down by service. + nullable: true + type: object + total_coverage: + description: Overall total coverage percentage. + example: 82.4 + format: double + nullable: true + type: number + type: object + CoverageSummaryCodeownerStats: + description: Coverage statistics for a specific code owner. + properties: + evaluated_flags_count: + description: Number of coverage flags evaluated for the code owner. + example: 2 + format: int64 + type: integer + evaluated_reports_count: + description: Number of coverage reports evaluated for the code owner. + example: 4 + format: int64 + type: integer + patch_coverage: + description: Patch coverage percentage for the code owner. + example: 75.2 + format: double + nullable: true + type: number + total_coverage: + description: Total coverage percentage for the code owner. + example: 88.7 + format: double + nullable: true + type: number + type: object + CoverageSummaryData: + description: Data object for coverage summary response. + properties: + attributes: + $ref: '#/components/schemas/CoverageSummaryAttributes' + id: + description: Unique identifier for the coverage summary (base64-hashed). + example: ZGQxMjM0NV9tYWluXzE3MDk1NjQwMDA= + type: string + type: + $ref: '#/components/schemas/CoverageSummaryType' + type: object + CoverageSummaryResponse: + description: Response object containing code coverage summary. + properties: + data: + $ref: '#/components/schemas/CoverageSummaryData' + type: object + CoverageSummaryServiceStats: + description: Coverage statistics for a specific service. + properties: + evaluated_flags_count: + description: Number of coverage flags evaluated for the service. + example: 3 + format: int64 + type: integer + evaluated_reports_count: + description: Number of coverage reports evaluated for the service. + example: 5 + format: int64 + type: integer + patch_coverage: + description: Patch coverage percentage for the service. + example: 72.3 + format: double + nullable: true + type: number + total_coverage: + description: Total coverage percentage for the service. + example: 85.5 + format: double + nullable: true + type: number + type: object + CoverageSummaryType: + description: JSON:API type for coverage summary response. The value must always + be `ci_app_coverage_summary`. + enum: + - ci_app_coverage_summary + example: ci_app_coverage_summary + type: string + x-enum-varnames: + - CI_APP_COVERAGE_SUMMARY Cpu: description: CPU usage statistics derived from historical Spark job metrics. Provides multiple estimates so users can choose between conservative and cost-saving @@ -67602,6 +67809,7 @@ components: cloud_cost_management_write: Configure cloud cost accounts and global customizations. For more details, see the Cloud Cost Management docs. code_analysis_read: View Code Analysis. + code_coverage_read: View Code Coverage. continuous_profiler_pgo_read: Read and query Continuous Profiler data for Profile-Guided Optimization (PGO). coterm_read: Read terminal recordings. @@ -74203,6 +74411,119 @@ paths: operator: OR permissions: - security_monitoring_filters_write + /api/v2/code-coverage/branch/summary: + post: + description: 'Retrieve aggregated code coverage statistics for a specific branch + in a repository. + + This endpoint provides overall coverage metrics as well as breakdowns by service + + and code owner. + + + **Note**: This endpoint requires the `code_coverage_read` permission.' + operationId: GetCodeCoverageBranchSummary + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/BranchCoverageSummaryRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CoverageSummaryResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Internal server error + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - code_coverage_read + summary: Get code coverage summary for a branch + tags: + - Code Coverage + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - code_coverage_read + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/code-coverage/commit/summary: + post: + description: 'Retrieve aggregated code coverage statistics for a specific commit + in a repository. + + This endpoint provides overall coverage metrics as well as breakdowns by service + + and code owner. + + + The commit SHA must be a 40-character hexadecimal string (SHA-1 hash). + + + **Note**: This endpoint requires the `code_coverage_read` permission.' + operationId: GetCodeCoverageCommitSummary + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CommitCoverageSummaryRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CoverageSummaryResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Internal server error + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - code_coverage_read + summary: Get code coverage summary for a commit + tags: + - Code Coverage + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - code_coverage_read + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/container_images: get: description: 'Get all Container Images for your organization. @@ -103481,6 +103802,9 @@ tags: API. See the [Cloudflare integration page](https://docs.datadoghq.com/integrations/cloudflare/) for more information. name: Cloudflare Integration +- description: Retrieve and analyze code coverage data from Code Coverage. See the + [Code Coverage page](https://docs.datadoghq.com/code_coverage/) for more information. + name: Code Coverage - description: Manage your Datadog Confluent Cloud integration accounts and account resources directly through the Datadog API. See the [Confluent Cloud page](https://docs.datadoghq.com/integrations/confluent_cloud/) for more information. diff --git a/docs/datadog_api_client.v2.api.rst b/docs/datadog_api_client.v2.api.rst index 44f19cd202..f1a56e28e8 100644 --- a/docs/datadog_api_client.v2.api.rst +++ b/docs/datadog_api_client.v2.api.rst @@ -144,6 +144,13 @@ datadog\_api\_client.v2.api.cloudflare\_integration\_api module :members: :show-inheritance: +datadog\_api\_client.v2.api.code\_coverage\_api module +------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.api.code_coverage_api + :members: + :show-inheritance: + datadog\_api\_client.v2.api.confluent\_cloud\_api module -------------------------------------------------------- diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index bca0ce24b2..6ea9cfc5d1 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -2692,6 +2692,34 @@ datadog\_api\_client.v2.model.billing\_dimensions\_mapping\_response module :members: :show-inheritance: +datadog\_api\_client.v2.model.branch\_coverage\_summary\_request module +----------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.branch_coverage_summary_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.branch\_coverage\_summary\_request\_attributes module +----------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.branch_coverage_summary_request_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.branch\_coverage\_summary\_request\_data module +----------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.branch_coverage_summary_request_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.branch\_coverage\_summary\_request\_type module +----------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.branch_coverage_summary_request_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.budget module ------------------------------------------- @@ -4603,6 +4631,34 @@ datadog\_api\_client.v2.model.code\_location module :members: :show-inheritance: +datadog\_api\_client.v2.model.commit\_coverage\_summary\_request module +----------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.commit_coverage_summary_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.commit\_coverage\_summary\_request\_attributes module +----------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.commit_coverage_summary_request_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.commit\_coverage\_summary\_request\_data module +----------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.commit_coverage_summary_request_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.commit\_coverage\_summary\_request\_type module +----------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.commit_coverage_summary_request_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.completion\_condition module ---------------------------------------------------------- @@ -5296,6 +5352,48 @@ datadog\_api\_client.v2.model.cost\_by\_org\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.coverage\_summary\_attributes module +------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.coverage_summary_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.coverage\_summary\_codeowner\_stats module +------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.coverage_summary_codeowner_stats + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.coverage\_summary\_data module +------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.coverage_summary_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.coverage\_summary\_response module +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.coverage_summary_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.coverage\_summary\_service\_stats module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.coverage_summary_service_stats + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.coverage\_summary\_type module +------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.coverage_summary_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.cpu module ---------------------------------------- diff --git a/examples/v2/code-coverage/GetCodeCoverageBranchSummary.py b/examples/v2/code-coverage/GetCodeCoverageBranchSummary.py new file mode 100644 index 0000000000..50f8d8f49b --- /dev/null +++ b/examples/v2/code-coverage/GetCodeCoverageBranchSummary.py @@ -0,0 +1,30 @@ +""" +Get code coverage summary for a branch 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.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", + ), + type=BranchCoverageSummaryRequestType.CI_APP_COVERAGE_BRANCH_SUMMARY_REQUEST, + ), +) + +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) + + print(response) diff --git a/examples/v2/code-coverage/GetCodeCoverageBranchSummary_2532383345.py b/examples/v2/code-coverage/GetCodeCoverageBranchSummary_2532383345.py new file mode 100644 index 0000000000..aa164e129e --- /dev/null +++ b/examples/v2/code-coverage/GetCodeCoverageBranchSummary_2532383345.py @@ -0,0 +1,30 @@ +""" +Get code coverage summary for an existing branch with valid repository +""" + +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( + repository_id="github.com/datadog/shopist", + branch="prod", + ), + type=BranchCoverageSummaryRequestType.CI_APP_COVERAGE_BRANCH_SUMMARY_REQUEST, + ), +) + +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) + + print(response) diff --git a/examples/v2/code-coverage/GetCodeCoverageCommitSummary.py b/examples/v2/code-coverage/GetCodeCoverageCommitSummary.py new file mode 100644 index 0000000000..9431f67adb --- /dev/null +++ b/examples/v2/code-coverage/GetCodeCoverageCommitSummary.py @@ -0,0 +1,30 @@ +""" +Get code coverage summary for a commit 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.commit_coverage_summary_request import CommitCoverageSummaryRequest +from datadog_api_client.v2.model.commit_coverage_summary_request_attributes import ( + CommitCoverageSummaryRequestAttributes, +) +from datadog_api_client.v2.model.commit_coverage_summary_request_data import CommitCoverageSummaryRequestData +from datadog_api_client.v2.model.commit_coverage_summary_request_type import CommitCoverageSummaryRequestType + +body = CommitCoverageSummaryRequest( + data=CommitCoverageSummaryRequestData( + attributes=CommitCoverageSummaryRequestAttributes( + commit_sha="66adc9350f2cc9b250b69abddab733dd55e1a588", + repository_id="github.com/datadog/shopist", + ), + type=CommitCoverageSummaryRequestType.CI_APP_COVERAGE_COMMIT_SUMMARY_REQUEST, + ), +) + +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) + + print(response) diff --git a/examples/v2/code-coverage/GetCodeCoverageCommitSummary_2575243916.py b/examples/v2/code-coverage/GetCodeCoverageCommitSummary_2575243916.py new file mode 100644 index 0000000000..1ad4e2934d --- /dev/null +++ b/examples/v2/code-coverage/GetCodeCoverageCommitSummary_2575243916.py @@ -0,0 +1,30 @@ +""" +Get code coverage summary for an existing commit with valid repository +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.code_coverage_api import CodeCoverageApi +from datadog_api_client.v2.model.commit_coverage_summary_request import CommitCoverageSummaryRequest +from datadog_api_client.v2.model.commit_coverage_summary_request_attributes import ( + CommitCoverageSummaryRequestAttributes, +) +from datadog_api_client.v2.model.commit_coverage_summary_request_data import CommitCoverageSummaryRequestData +from datadog_api_client.v2.model.commit_coverage_summary_request_type import CommitCoverageSummaryRequestType + +body = CommitCoverageSummaryRequest( + data=CommitCoverageSummaryRequestData( + attributes=CommitCoverageSummaryRequestAttributes( + repository_id="github.com/datadog/shopist", + commit_sha="c55b0ce584e139bde41a00002ab31bc7d75f791d", + ), + type=CommitCoverageSummaryRequestType.CI_APP_COVERAGE_COMMIT_SUMMARY_REQUEST, + ), +) + +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) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index f3edb31d63..efa1d3f521 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -295,6 +295,8 @@ def __init__( "v2.mute_findings": False, "v2.run_threat_hunting_job": False, "v2.search_security_monitoring_histsignals": False, + "v2.get_code_coverage_branch_summary": False, + "v2.get_code_coverage_commit_summary": False, "v2.create_dataset": False, "v2.delete_dataset": False, "v2.get_all_datasets": False, diff --git a/src/datadog_api_client/v2/api/code_coverage_api.py b/src/datadog_api_client/v2/api/code_coverage_api.py new file mode 100644 index 0000000000..968e48c47b --- /dev/null +++ b/src/datadog_api_client/v2/api/code_coverage_api.py @@ -0,0 +1,105 @@ +# 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 Any, Dict + +from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint +from datadog_api_client.configuration import Configuration +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 + + +class CodeCoverageApi: + """ + Retrieve and analyze code coverage data from Code Coverage. See the `Code Coverage page `_ for more information. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient(Configuration()) + self.api_client = api_client + + self._get_code_coverage_branch_summary_endpoint = _Endpoint( + settings={ + "response_type": (CoverageSummaryResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/code-coverage/branch/summary", + "operation_id": "get_code_coverage_branch_summary", + "http_method": "POST", + "version": "v2", + }, + params_map={ + "body": { + "required": True, + "openapi_types": (BranchCoverageSummaryRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + + self._get_code_coverage_commit_summary_endpoint = _Endpoint( + settings={ + "response_type": (CoverageSummaryResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/code-coverage/commit/summary", + "operation_id": "get_code_coverage_commit_summary", + "http_method": "POST", + "version": "v2", + }, + params_map={ + "body": { + "required": True, + "openapi_types": (CommitCoverageSummaryRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + + def get_code_coverage_branch_summary( + self, + body: BranchCoverageSummaryRequest, + ) -> CoverageSummaryResponse: + """Get code coverage summary for a branch. + + Retrieve aggregated code coverage statistics for a specific branch in a repository. + This endpoint provides overall coverage metrics as well as breakdowns by service + and code owner. + + **Note** : This endpoint requires the ``code_coverage_read`` permission. + + :type body: BranchCoverageSummaryRequest + :rtype: CoverageSummaryResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._get_code_coverage_branch_summary_endpoint.call_with_http_info(**kwargs) + + def get_code_coverage_commit_summary( + self, + body: CommitCoverageSummaryRequest, + ) -> CoverageSummaryResponse: + """Get code coverage summary for a commit. + + Retrieve aggregated code coverage statistics for a specific commit in a repository. + This endpoint provides overall coverage metrics as well as breakdowns by service + and code owner. + + The commit SHA must be a 40-character hexadecimal string (SHA-1 hash). + + **Note** : This endpoint requires the ``code_coverage_read`` permission. + + :type body: CommitCoverageSummaryRequest + :rtype: CoverageSummaryResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._get_code_coverage_commit_summary_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/apis/__init__.py b/src/datadog_api_client/v2/apis/__init__.py index 210ab0dd47..e2d3e5d6da 100644 --- a/src/datadog_api_client/v2/apis/__init__.py +++ b/src/datadog_api_client/v2/apis/__init__.py @@ -21,6 +21,7 @@ from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi from datadog_api_client.v2.api.cloud_network_monitoring_api import CloudNetworkMonitoringApi from datadog_api_client.v2.api.cloudflare_integration_api import CloudflareIntegrationApi +from datadog_api_client.v2.api.code_coverage_api import CodeCoverageApi from datadog_api_client.v2.api.confluent_cloud_api import ConfluentCloudApi from datadog_api_client.v2.api.container_images_api import ContainerImagesApi from datadog_api_client.v2.api.containers_api import ContainersApi @@ -120,6 +121,7 @@ "CloudCostManagementApi", "CloudNetworkMonitoringApi", "CloudflareIntegrationApi", + "CodeCoverageApi", "ConfluentCloudApi", "ContainerImagesApi", "ContainersApi", diff --git a/src/datadog_api_client/v2/model/branch_coverage_summary_request.py b/src/datadog_api_client/v2/model/branch_coverage_summary_request.py new file mode 100644 index 0000000000..fef9110dbc --- /dev/null +++ b/src/datadog_api_client/v2/model/branch_coverage_summary_request.py @@ -0,0 +1,40 @@ +# 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 TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.branch_coverage_summary_request_data import BranchCoverageSummaryRequestData + + +class BranchCoverageSummaryRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.branch_coverage_summary_request_data import BranchCoverageSummaryRequestData + + return { + "data": (BranchCoverageSummaryRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: BranchCoverageSummaryRequestData, **kwargs): + """ + Request object for getting code coverage summary for a branch. + + :param data: Data object for branch summary request. + :type data: BranchCoverageSummaryRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/branch_coverage_summary_request_attributes.py b/src/datadog_api_client/v2/model/branch_coverage_summary_request_attributes.py new file mode 100644 index 0000000000..f073146759 --- /dev/null +++ b/src/datadog_api_client/v2/model/branch_coverage_summary_request_attributes.py @@ -0,0 +1,48 @@ +# 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 datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class BranchCoverageSummaryRequestAttributes(ModelNormal): + validations = { + "branch": { + "min_length": 1, + }, + "repository_id": { + "min_length": 1, + }, + } + + @cached_property + def openapi_types(_): + return { + "branch": (str,), + "repository_id": (str,), + } + + attribute_map = { + "branch": "branch", + "repository_id": "repository_id", + } + + def __init__(self_, branch: str, repository_id: str, **kwargs): + """ + Attributes for requesting code coverage summary for a branch. + + :param branch: The branch name. + :type branch: str + + :param repository_id: The repository identifier. + :type repository_id: str + """ + super().__init__(kwargs) + + self_.branch = branch + self_.repository_id = repository_id diff --git a/src/datadog_api_client/v2/model/branch_coverage_summary_request_data.py b/src/datadog_api_client/v2/model/branch_coverage_summary_request_data.py new file mode 100644 index 0000000000..4f93d8914f --- /dev/null +++ b/src/datadog_api_client/v2/model/branch_coverage_summary_request_data.py @@ -0,0 +1,54 @@ +# 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 TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.branch_coverage_summary_request_attributes import ( + BranchCoverageSummaryRequestAttributes, + ) + from datadog_api_client.v2.model.branch_coverage_summary_request_type import BranchCoverageSummaryRequestType + + +class BranchCoverageSummaryRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.branch_coverage_summary_request_attributes import ( + BranchCoverageSummaryRequestAttributes, + ) + from datadog_api_client.v2.model.branch_coverage_summary_request_type import BranchCoverageSummaryRequestType + + return { + "attributes": (BranchCoverageSummaryRequestAttributes,), + "type": (BranchCoverageSummaryRequestType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__( + self_, attributes: BranchCoverageSummaryRequestAttributes, type: BranchCoverageSummaryRequestType, **kwargs + ): + """ + Data object for branch summary request. + + :param attributes: Attributes for requesting code coverage summary for a branch. + :type attributes: BranchCoverageSummaryRequestAttributes + + :param type: JSON:API type for branch coverage summary request. The value must always be ``ci_app_coverage_branch_summary_request``. + :type type: BranchCoverageSummaryRequestType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/branch_coverage_summary_request_type.py b/src/datadog_api_client/v2/model/branch_coverage_summary_request_type.py new file mode 100644 index 0000000000..59b1212ad7 --- /dev/null +++ b/src/datadog_api_client/v2/model/branch_coverage_summary_request_type.py @@ -0,0 +1,37 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class BranchCoverageSummaryRequestType(ModelSimple): + """ + JSON:API type for branch coverage summary request. The value must always be `ci_app_coverage_branch_summary_request`. + + :param value: If omitted defaults to "ci_app_coverage_branch_summary_request". Must be one of ["ci_app_coverage_branch_summary_request"]. + :type value: str + """ + + allowed_values = { + "ci_app_coverage_branch_summary_request", + } + CI_APP_COVERAGE_BRANCH_SUMMARY_REQUEST: ClassVar["BranchCoverageSummaryRequestType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +BranchCoverageSummaryRequestType.CI_APP_COVERAGE_BRANCH_SUMMARY_REQUEST = BranchCoverageSummaryRequestType( + "ci_app_coverage_branch_summary_request" +) diff --git a/src/datadog_api_client/v2/model/commit_coverage_summary_request.py b/src/datadog_api_client/v2/model/commit_coverage_summary_request.py new file mode 100644 index 0000000000..d5a1ca29d8 --- /dev/null +++ b/src/datadog_api_client/v2/model/commit_coverage_summary_request.py @@ -0,0 +1,40 @@ +# 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 TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.commit_coverage_summary_request_data import CommitCoverageSummaryRequestData + + +class CommitCoverageSummaryRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.commit_coverage_summary_request_data import CommitCoverageSummaryRequestData + + return { + "data": (CommitCoverageSummaryRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: CommitCoverageSummaryRequestData, **kwargs): + """ + Request object for getting code coverage summary for a commit. + + :param data: Data object for commit summary request. + :type data: CommitCoverageSummaryRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/commit_coverage_summary_request_attributes.py b/src/datadog_api_client/v2/model/commit_coverage_summary_request_attributes.py new file mode 100644 index 0000000000..49a92853dc --- /dev/null +++ b/src/datadog_api_client/v2/model/commit_coverage_summary_request_attributes.py @@ -0,0 +1,46 @@ +# 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 datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class CommitCoverageSummaryRequestAttributes(ModelNormal): + validations = { + "commit_sha": {}, + "repository_id": { + "min_length": 1, + }, + } + + @cached_property + def openapi_types(_): + return { + "commit_sha": (str,), + "repository_id": (str,), + } + + attribute_map = { + "commit_sha": "commit_sha", + "repository_id": "repository_id", + } + + def __init__(self_, commit_sha: str, repository_id: str, **kwargs): + """ + Attributes for requesting code coverage summary for a commit. + + :param commit_sha: The commit SHA (40-character hexadecimal string). + :type commit_sha: str + + :param repository_id: The repository identifier. + :type repository_id: str + """ + super().__init__(kwargs) + + self_.commit_sha = commit_sha + self_.repository_id = repository_id diff --git a/src/datadog_api_client/v2/model/commit_coverage_summary_request_data.py b/src/datadog_api_client/v2/model/commit_coverage_summary_request_data.py new file mode 100644 index 0000000000..c250c9201d --- /dev/null +++ b/src/datadog_api_client/v2/model/commit_coverage_summary_request_data.py @@ -0,0 +1,54 @@ +# 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 TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.commit_coverage_summary_request_attributes import ( + CommitCoverageSummaryRequestAttributes, + ) + from datadog_api_client.v2.model.commit_coverage_summary_request_type import CommitCoverageSummaryRequestType + + +class CommitCoverageSummaryRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.commit_coverage_summary_request_attributes import ( + CommitCoverageSummaryRequestAttributes, + ) + from datadog_api_client.v2.model.commit_coverage_summary_request_type import CommitCoverageSummaryRequestType + + return { + "attributes": (CommitCoverageSummaryRequestAttributes,), + "type": (CommitCoverageSummaryRequestType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__( + self_, attributes: CommitCoverageSummaryRequestAttributes, type: CommitCoverageSummaryRequestType, **kwargs + ): + """ + Data object for commit summary request. + + :param attributes: Attributes for requesting code coverage summary for a commit. + :type attributes: CommitCoverageSummaryRequestAttributes + + :param type: JSON:API type for commit coverage summary request. The value must always be ``ci_app_coverage_commit_summary_request``. + :type type: CommitCoverageSummaryRequestType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/commit_coverage_summary_request_type.py b/src/datadog_api_client/v2/model/commit_coverage_summary_request_type.py new file mode 100644 index 0000000000..7e94a592bc --- /dev/null +++ b/src/datadog_api_client/v2/model/commit_coverage_summary_request_type.py @@ -0,0 +1,37 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class CommitCoverageSummaryRequestType(ModelSimple): + """ + JSON:API type for commit coverage summary request. The value must always be `ci_app_coverage_commit_summary_request`. + + :param value: If omitted defaults to "ci_app_coverage_commit_summary_request". Must be one of ["ci_app_coverage_commit_summary_request"]. + :type value: str + """ + + allowed_values = { + "ci_app_coverage_commit_summary_request", + } + CI_APP_COVERAGE_COMMIT_SUMMARY_REQUEST: ClassVar["CommitCoverageSummaryRequestType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +CommitCoverageSummaryRequestType.CI_APP_COVERAGE_COMMIT_SUMMARY_REQUEST = CommitCoverageSummaryRequestType( + "ci_app_coverage_commit_summary_request" +) diff --git a/src/datadog_api_client/v2/model/coverage_summary_attributes.py b/src/datadog_api_client/v2/model/coverage_summary_attributes.py new file mode 100644 index 0000000000..66ea526fcd --- /dev/null +++ b/src/datadog_api_client/v2/model/coverage_summary_attributes.py @@ -0,0 +1,89 @@ +# 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, + none_type, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.coverage_summary_codeowner_stats import CoverageSummaryCodeownerStats + from datadog_api_client.v2.model.coverage_summary_service_stats import CoverageSummaryServiceStats + + +class CoverageSummaryAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.coverage_summary_codeowner_stats import CoverageSummaryCodeownerStats + from datadog_api_client.v2.model.coverage_summary_service_stats import CoverageSummaryServiceStats + + return { + "codeowners": ({str: (CoverageSummaryCodeownerStats,)}, none_type), + "evaluated_flags_count": (int,), + "evaluated_reports_count": (int,), + "patch_coverage": (float, none_type), + "services": ({str: (CoverageSummaryServiceStats,)}, none_type), + "total_coverage": (float, none_type), + } + + attribute_map = { + "codeowners": "codeowners", + "evaluated_flags_count": "evaluated_flags_count", + "evaluated_reports_count": "evaluated_reports_count", + "patch_coverage": "patch_coverage", + "services": "services", + "total_coverage": "total_coverage", + } + + def __init__( + self_, + codeowners: Union[Dict[str, CoverageSummaryCodeownerStats], none_type, UnsetType] = unset, + evaluated_flags_count: Union[int, UnsetType] = unset, + evaluated_reports_count: Union[int, UnsetType] = unset, + patch_coverage: Union[float, none_type, UnsetType] = unset, + services: Union[Dict[str, CoverageSummaryServiceStats], none_type, UnsetType] = unset, + total_coverage: Union[float, none_type, UnsetType] = unset, + **kwargs, + ): + """ + Attributes object for code coverage summary response. + + :param codeowners: Coverage statistics broken down by code owner. + :type codeowners: {str: (CoverageSummaryCodeownerStats,)}, none_type, optional + + :param evaluated_flags_count: Total number of coverage flags evaluated. + :type evaluated_flags_count: int, optional + + :param evaluated_reports_count: Total number of coverage reports evaluated. + :type evaluated_reports_count: int, optional + + :param patch_coverage: Overall patch coverage percentage. + :type patch_coverage: float, none_type, optional + + :param services: Coverage statistics broken down by service. + :type services: {str: (CoverageSummaryServiceStats,)}, none_type, optional + + :param total_coverage: Overall total coverage percentage. + :type total_coverage: float, none_type, optional + """ + if codeowners is not unset: + kwargs["codeowners"] = codeowners + if evaluated_flags_count is not unset: + kwargs["evaluated_flags_count"] = evaluated_flags_count + if evaluated_reports_count is not unset: + kwargs["evaluated_reports_count"] = evaluated_reports_count + if patch_coverage is not unset: + kwargs["patch_coverage"] = patch_coverage + if services is not unset: + kwargs["services"] = services + if total_coverage is not unset: + kwargs["total_coverage"] = total_coverage + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/coverage_summary_codeowner_stats.py b/src/datadog_api_client/v2/model/coverage_summary_codeowner_stats.py new file mode 100644 index 0000000000..5ccb9511eb --- /dev/null +++ b/src/datadog_api_client/v2/model/coverage_summary_codeowner_stats.py @@ -0,0 +1,65 @@ +# 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 + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, + unset, + UnsetType, +) + + +class CoverageSummaryCodeownerStats(ModelNormal): + @cached_property + def openapi_types(_): + return { + "evaluated_flags_count": (int,), + "evaluated_reports_count": (int,), + "patch_coverage": (float, none_type), + "total_coverage": (float, none_type), + } + + attribute_map = { + "evaluated_flags_count": "evaluated_flags_count", + "evaluated_reports_count": "evaluated_reports_count", + "patch_coverage": "patch_coverage", + "total_coverage": "total_coverage", + } + + def __init__( + self_, + evaluated_flags_count: Union[int, UnsetType] = unset, + evaluated_reports_count: Union[int, UnsetType] = unset, + patch_coverage: Union[float, none_type, UnsetType] = unset, + total_coverage: Union[float, none_type, UnsetType] = unset, + **kwargs, + ): + """ + Coverage statistics for a specific code owner. + + :param evaluated_flags_count: Number of coverage flags evaluated for the code owner. + :type evaluated_flags_count: int, optional + + :param evaluated_reports_count: Number of coverage reports evaluated for the code owner. + :type evaluated_reports_count: int, optional + + :param patch_coverage: Patch coverage percentage for the code owner. + :type patch_coverage: float, none_type, optional + + :param total_coverage: Total coverage percentage for the code owner. + :type total_coverage: float, none_type, optional + """ + if evaluated_flags_count is not unset: + kwargs["evaluated_flags_count"] = evaluated_flags_count + if evaluated_reports_count is not unset: + kwargs["evaluated_reports_count"] = evaluated_reports_count + if patch_coverage is not unset: + kwargs["patch_coverage"] = patch_coverage + if total_coverage is not unset: + kwargs["total_coverage"] = total_coverage + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/coverage_summary_data.py b/src/datadog_api_client/v2/model/coverage_summary_data.py new file mode 100644 index 0000000000..b49bddee2b --- /dev/null +++ b/src/datadog_api_client/v2/model/coverage_summary_data.py @@ -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.coverage_summary_attributes import CoverageSummaryAttributes + from datadog_api_client.v2.model.coverage_summary_type import CoverageSummaryType + + +class CoverageSummaryData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.coverage_summary_attributes import CoverageSummaryAttributes + from datadog_api_client.v2.model.coverage_summary_type import CoverageSummaryType + + return { + "attributes": (CoverageSummaryAttributes,), + "id": (str,), + "type": (CoverageSummaryType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + attributes: Union[CoverageSummaryAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + type: Union[CoverageSummaryType, UnsetType] = unset, + **kwargs, + ): + """ + Data object for coverage summary response. + + :param attributes: Attributes object for code coverage summary response. + :type attributes: CoverageSummaryAttributes, optional + + :param id: Unique identifier for the coverage summary (base64-hashed). + :type id: str, optional + + :param type: JSON:API type for coverage summary response. The value must always be ``ci_app_coverage_summary``. + :type type: CoverageSummaryType, 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) diff --git a/src/datadog_api_client/v2/model/coverage_summary_response.py b/src/datadog_api_client/v2/model/coverage_summary_response.py new file mode 100644 index 0000000000..dd4c6b5094 --- /dev/null +++ b/src/datadog_api_client/v2/model/coverage_summary_response.py @@ -0,0 +1,42 @@ +# 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.coverage_summary_data import CoverageSummaryData + + +class CoverageSummaryResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.coverage_summary_data import CoverageSummaryData + + return { + "data": (CoverageSummaryData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: Union[CoverageSummaryData, UnsetType] = unset, **kwargs): + """ + Response object containing code coverage summary. + + :param data: Data object for coverage summary response. + :type data: CoverageSummaryData, optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/coverage_summary_service_stats.py b/src/datadog_api_client/v2/model/coverage_summary_service_stats.py new file mode 100644 index 0000000000..18e373deed --- /dev/null +++ b/src/datadog_api_client/v2/model/coverage_summary_service_stats.py @@ -0,0 +1,65 @@ +# 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 + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, + unset, + UnsetType, +) + + +class CoverageSummaryServiceStats(ModelNormal): + @cached_property + def openapi_types(_): + return { + "evaluated_flags_count": (int,), + "evaluated_reports_count": (int,), + "patch_coverage": (float, none_type), + "total_coverage": (float, none_type), + } + + attribute_map = { + "evaluated_flags_count": "evaluated_flags_count", + "evaluated_reports_count": "evaluated_reports_count", + "patch_coverage": "patch_coverage", + "total_coverage": "total_coverage", + } + + def __init__( + self_, + evaluated_flags_count: Union[int, UnsetType] = unset, + evaluated_reports_count: Union[int, UnsetType] = unset, + patch_coverage: Union[float, none_type, UnsetType] = unset, + total_coverage: Union[float, none_type, UnsetType] = unset, + **kwargs, + ): + """ + Coverage statistics for a specific service. + + :param evaluated_flags_count: Number of coverage flags evaluated for the service. + :type evaluated_flags_count: int, optional + + :param evaluated_reports_count: Number of coverage reports evaluated for the service. + :type evaluated_reports_count: int, optional + + :param patch_coverage: Patch coverage percentage for the service. + :type patch_coverage: float, none_type, optional + + :param total_coverage: Total coverage percentage for the service. + :type total_coverage: float, none_type, optional + """ + if evaluated_flags_count is not unset: + kwargs["evaluated_flags_count"] = evaluated_flags_count + if evaluated_reports_count is not unset: + kwargs["evaluated_reports_count"] = evaluated_reports_count + if patch_coverage is not unset: + kwargs["patch_coverage"] = patch_coverage + if total_coverage is not unset: + kwargs["total_coverage"] = total_coverage + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/coverage_summary_type.py b/src/datadog_api_client/v2/model/coverage_summary_type.py new file mode 100644 index 0000000000..7e3e69de23 --- /dev/null +++ b/src/datadog_api_client/v2/model/coverage_summary_type.py @@ -0,0 +1,35 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class CoverageSummaryType(ModelSimple): + """ + JSON:API type for coverage summary response. The value must always be `ci_app_coverage_summary`. + + :param value: If omitted defaults to "ci_app_coverage_summary". Must be one of ["ci_app_coverage_summary"]. + :type value: str + """ + + allowed_values = { + "ci_app_coverage_summary", + } + CI_APP_COVERAGE_SUMMARY: ClassVar["CoverageSummaryType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +CoverageSummaryType.CI_APP_COVERAGE_SUMMARY = CoverageSummaryType("ci_app_coverage_summary") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 3fa7932ad3..2eece21eff 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -515,6 +515,12 @@ BillingDimensionsMappingBodyItemAttributesEndpointsItemsStatus, ) from datadog_api_client.v2.model.billing_dimensions_mapping_response import BillingDimensionsMappingResponse +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 from datadog_api_client.v2.model.budget import Budget from datadog_api_client.v2.model.budget_array import BudgetArray from datadog_api_client.v2.model.budget_attributes import BudgetAttributes @@ -896,6 +902,12 @@ from datadog_api_client.v2.model.cloudflare_integration_type import CloudflareIntegrationType from datadog_api_client.v2.model.cloudflare_integration_update import CloudflareIntegrationUpdate from datadog_api_client.v2.model.code_location import CodeLocation +from datadog_api_client.v2.model.commit_coverage_summary_request import CommitCoverageSummaryRequest +from datadog_api_client.v2.model.commit_coverage_summary_request_attributes import ( + CommitCoverageSummaryRequestAttributes, +) +from datadog_api_client.v2.model.commit_coverage_summary_request_data import CommitCoverageSummaryRequestData +from datadog_api_client.v2.model.commit_coverage_summary_request_type import CommitCoverageSummaryRequestType from datadog_api_client.v2.model.completion_condition import CompletionCondition from datadog_api_client.v2.model.completion_condition_operator import CompletionConditionOperator from datadog_api_client.v2.model.completion_gate import CompletionGate @@ -1003,6 +1015,12 @@ from datadog_api_client.v2.model.cost_by_org_attributes import CostByOrgAttributes from datadog_api_client.v2.model.cost_by_org_response import CostByOrgResponse from datadog_api_client.v2.model.cost_by_org_type import CostByOrgType +from datadog_api_client.v2.model.coverage_summary_attributes import CoverageSummaryAttributes +from datadog_api_client.v2.model.coverage_summary_codeowner_stats import CoverageSummaryCodeownerStats +from datadog_api_client.v2.model.coverage_summary_data import CoverageSummaryData +from datadog_api_client.v2.model.coverage_summary_response import CoverageSummaryResponse +from datadog_api_client.v2.model.coverage_summary_service_stats import CoverageSummaryServiceStats +from datadog_api_client.v2.model.coverage_summary_type import CoverageSummaryType from datadog_api_client.v2.model.cpu import Cpu from datadog_api_client.v2.model.create_action_connection_request import CreateActionConnectionRequest from datadog_api_client.v2.model.create_action_connection_response import CreateActionConnectionResponse @@ -6391,6 +6409,10 @@ "BillingDimensionsMappingBodyItemAttributesEndpointsItems", "BillingDimensionsMappingBodyItemAttributesEndpointsItemsStatus", "BillingDimensionsMappingResponse", + "BranchCoverageSummaryRequest", + "BranchCoverageSummaryRequestAttributes", + "BranchCoverageSummaryRequestData", + "BranchCoverageSummaryRequestType", "Budget", "BudgetArray", "BudgetAttributes", @@ -6668,6 +6690,10 @@ "CloudflareIntegrationType", "CloudflareIntegrationUpdate", "CodeLocation", + "CommitCoverageSummaryRequest", + "CommitCoverageSummaryRequestAttributes", + "CommitCoverageSummaryRequestData", + "CommitCoverageSummaryRequestType", "CompletionCondition", "CompletionConditionOperator", "CompletionGate", @@ -6767,6 +6793,12 @@ "CostByOrgAttributes", "CostByOrgResponse", "CostByOrgType", + "CoverageSummaryAttributes", + "CoverageSummaryCodeownerStats", + "CoverageSummaryData", + "CoverageSummaryResponse", + "CoverageSummaryServiceStats", + "CoverageSummaryType", "Cpu", "CreateActionConnectionRequest", "CreateActionConnectionResponse", diff --git a/tests/v2/features/code_coverage.feature b/tests/v2/features/code_coverage.feature new file mode 100644 index 0000000000..657ee0375c --- /dev/null +++ b/tests/v2/features/code_coverage.feature @@ -0,0 +1,156 @@ +@endpoint(code-coverage) @endpoint(code-coverage-v2) +Feature: Code Coverage + Retrieve and analyze code coverage data from Code Coverage. See the [Code + Coverage page](https://docs.datadoghq.com/code_coverage/) for more + information. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "CodeCoverage" API + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a branch returns "Bad Request" response + Given operation "GetCodeCoverageBranchSummary" enabled + And new "GetCodeCoverageBranchSummary" request + And body with value {"data": {"attributes": {"branch": "prod", "repository_id": "github.com/datadog/shopist"}, "type": "ci_app_coverage_branch_summary_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a branch returns "Not Found" response + Given operation "GetCodeCoverageBranchSummary" enabled + And new "GetCodeCoverageBranchSummary" request + And body with value {"data": {"attributes": {"branch": "prod", "repository_id": "github.com/datadog/shopist"}, "type": "ci_app_coverage_branch_summary_request"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a branch returns "OK" response + Given operation "GetCodeCoverageBranchSummary" enabled + And new "GetCodeCoverageBranchSummary" request + And body with value {"data": {"attributes": {"branch": "prod", "repository_id": "github.com/datadog/shopist"}, "type": "ci_app_coverage_branch_summary_request"}} + When the request is sent + Then the response status is 200 OK + + @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a branch with empty branch name returns bad request + Given operation "GetCodeCoverageBranchSummary" enabled + And new "GetCodeCoverageBranchSummary" request + And body with value {"data": {"attributes": {"repository_id": "github.com/datadog/shopist", "branch": ""}, "type": "ci_app_coverage_branch_summary_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a branch with empty repository_id returns bad request + Given operation "GetCodeCoverageBranchSummary" enabled + And new "GetCodeCoverageBranchSummary" request + And body with value {"data": {"attributes": {"repository_id": "", "branch": "prod"}, "type": "ci_app_coverage_branch_summary_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a commit in nonexistent repository returns not found + Given operation "GetCodeCoverageCommitSummary" enabled + And new "GetCodeCoverageCommitSummary" request + And body with value {"data": {"attributes": {"repository_id": "github.com/datadog/nonexistent-repo", "commit_sha": "c55b0ce584e139bde41a00002ab31bc7d75f791d"}, "type": "ci_app_coverage_commit_summary_request"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a commit returns "Bad Request" response + Given operation "GetCodeCoverageCommitSummary" enabled + And new "GetCodeCoverageCommitSummary" request + And body with value {"data": {"attributes": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_id": "github.com/datadog/shopist"}, "type": "ci_app_coverage_commit_summary_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a commit returns "Not Found" response + Given operation "GetCodeCoverageCommitSummary" enabled + And new "GetCodeCoverageCommitSummary" request + And body with value {"data": {"attributes": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_id": "github.com/datadog/shopist"}, "type": "ci_app_coverage_commit_summary_request"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a commit returns "OK" response + Given operation "GetCodeCoverageCommitSummary" enabled + And new "GetCodeCoverageCommitSummary" request + And body with value {"data": {"attributes": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_id": "github.com/datadog/shopist"}, "type": "ci_app_coverage_commit_summary_request"}} + When the request is sent + Then the response status is 200 OK + + @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a commit with empty commit_sha returns bad request + Given operation "GetCodeCoverageCommitSummary" enabled + And new "GetCodeCoverageCommitSummary" request + And body with value {"data": {"attributes": {"repository_id": "github.com/datadog/shopist", "commit_sha": ""}, "type": "ci_app_coverage_commit_summary_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a commit with empty repository_id returns bad request + Given operation "GetCodeCoverageCommitSummary" enabled + And new "GetCodeCoverageCommitSummary" request + And body with value {"data": {"attributes": {"repository_id": "", "commit_sha": "c55b0ce584e139bde41a00002ab31bc7d75f791d"}, "type": "ci_app_coverage_commit_summary_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a commit with invalid commit SHA returns bad request + Given operation "GetCodeCoverageCommitSummary" enabled + And new "GetCodeCoverageCommitSummary" request + And body with value {"data": {"attributes": {"repository_id": "github.com/datadog/shopist", "commit_sha": "abc123"}, "type": "ci_app_coverage_commit_summary_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a nonexistent branch returns not found + Given operation "GetCodeCoverageBranchSummary" enabled + And new "GetCodeCoverageBranchSummary" request + And body with value {"data": {"attributes": {"repository_id": "github.com/datadog/shopist", "branch": "nonexistent-branch"}, "type": "ci_app_coverage_branch_summary_request"}} + When the request is sent + Then the response status is 404 Not Found + + @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a nonexistent commit returns not found + Given operation "GetCodeCoverageCommitSummary" enabled + And new "GetCodeCoverageCommitSummary" request + And body with value {"data": {"attributes": {"repository_id": "github.com/datadog/shopist", "commit_sha": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, "type": "ci_app_coverage_commit_summary_request"}} + When the request is sent + Then the response status is 404 Not Found + + @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for a nonexistent repository returns not found + Given operation "GetCodeCoverageBranchSummary" enabled + And new "GetCodeCoverageBranchSummary" request + And body with value {"data": {"attributes": {"repository_id": "github.com/datadog/nonexistent-repo", "branch": "main"}, "type": "ci_app_coverage_branch_summary_request"}} + When the request is sent + Then the response status is 404 Not Found + + @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for an existing branch with valid repository + Given operation "GetCodeCoverageBranchSummary" enabled + And new "GetCodeCoverageBranchSummary" request + And body with value {"data": {"attributes": {"repository_id": "github.com/datadog/shopist", "branch": "prod"}, "type": "ci_app_coverage_branch_summary_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "ci_app_coverage_branch_summary" + And the response "data.attributes" has field "total_coverage" + And the response "data.attributes" has field "patch_coverage" + And the response "data.attributes" has field "evaluated_reports_count" + And the response "data.attributes" has field "evaluated_flags_count" + + @skip @team:DataDog/ci-app-backend + Scenario: Get code coverage summary for an existing commit with valid repository + Given operation "GetCodeCoverageCommitSummary" enabled + And new "GetCodeCoverageCommitSummary" request + And body with value {"data": {"attributes": {"repository_id": "github.com/datadog/shopist", "commit_sha": "c55b0ce584e139bde41a00002ab31bc7d75f791d"}, "type": "ci_app_coverage_commit_summary_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "ci_app_coverage_commit_summary" + And the response "data.attributes" has field "total_coverage" + And the response "data.attributes" has field "patch_coverage" + And the response "data.attributes" has field "evaluated_reports_count" + And the response "data.attributes" has field "evaluated_flags_count" diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 5727d36b95..75d0d7f71e 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -1061,6 +1061,18 @@ "type": "idempotent" } }, + "GetCodeCoverageBranchSummary": { + "tag": "Code Coverage", + "undo": { + "type": "safe" + } + }, + "GetCodeCoverageCommitSummary": { + "tag": "Code Coverage", + "undo": { + "type": "safe" + } + }, "ListContainerImages": { "tag": "Container Images", "undo": {