From 78d62f3b52bfa17b459fc19050857c55c7a3d0f2 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 23 Jun 2026 12:32:02 +0000 Subject: [PATCH] Regenerate client from commit af12d35 of spec repo --- .generator/schemas/v2/openapi.yaml | 210 +++++++++++++----- docs/datadog_api_client.v2.model.rst | 21 ++ .../CreateCIAppPipelineEvent_129899466.py | 4 +- .../CreateCIAppPipelineEvent_4007074677.py | 46 ++++ ...eline_event_request_attributes_resource.py | 16 +- .../ci_app_pipeline_event_finished_job.py | 202 +++++++++++++++++ .../ci_app_pipeline_event_in_progress_job.py | 199 +++++++++++++++++ .../v2/model/ci_app_pipeline_event_job.py | 157 +++---------- ...p_pipeline_event_job_in_progress_status.py | 35 +++ src/datadog_api_client/v2/models/__init__.py | 8 + ...st_accepted_for_processing_response.frozen | 1 + ...uest_accepted_for_processing_response.yaml | 21 ++ .../features/ci_visibility_pipelines.feature | 7 + 13 files changed, 727 insertions(+), 200 deletions(-) create mode 100644 examples/v2/ci-visibility-pipelines/CreateCIAppPipelineEvent_4007074677.py create mode 100644 src/datadog_api_client/v2/model/ci_app_pipeline_event_finished_job.py create mode 100644 src/datadog_api_client/v2/model/ci_app_pipeline_event_in_progress_job.py create mode 100644 src/datadog_api_client/v2/model/ci_app_pipeline_event_job_in_progress_status.py create mode 100644 tests/v2/cassettes/test_scenarios/test_send_running_job_event_returns_request_accepted_for_processing_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_send_running_job_event_returns_request_accepted_for_processing_response.yaml diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 99b25f0ac8..1779c0ae09 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -13851,11 +13851,19 @@ components: tags: $ref: "#/components/schemas/TagsEventAttribute" type: object - CIAppPipelineEventFinishedPipeline: - description: Details of a finished pipeline. + CIAppPipelineEventFinishedJob: + description: Details of a finished CI job. properties: + dependencies: + description: A list of job IDs that this job depends on. + example: ["f7e6a006-a029-46c3-b0cc-742c9d7d363b", "c8a69849-3c3b-4721-8b33-3e8ec2df1ebe"] + items: + description: A list of job IDs. + type: string + nullable: true + type: array end: - description: Time when the pipeline run finished. It cannot be older than 18 hours in the past from the current time. The time format must be RFC3339. + description: Time when the job run finished. The time format must be RFC3339. example: "2023-05-31T15:30:00Z" format: date-time type: string @@ -13863,44 +13871,30 @@ components: $ref: "#/components/schemas/CIAppCIError" git: $ref: "#/components/schemas/CIAppGitInfo" - is_manual: - description: Whether or not the pipeline was triggered manually by the user. - example: false - nullable: true - type: boolean - is_resumed: - description: Whether or not the pipeline was resumed after being blocked. - example: false - nullable: true - type: boolean + id: + description: The UUID for the job. It has to be unique within each pipeline execution. + example: c865bad4-de82-44b8-ade7-2c987528eb54 + type: string level: - $ref: "#/components/schemas/CIAppPipelineEventPipelineLevel" + $ref: "#/components/schemas/CIAppPipelineEventJobLevel" metrics: $ref: "#/components/schemas/CIAppPipelineEventMetrics" name: - description: Name of the pipeline. All pipeline runs for the builds should have the same name. - example: Deploy to AWS + description: The name for the job. + example: test type: string node: $ref: "#/components/schemas/CIAppHostInfo" parameters: $ref: "#/components/schemas/CIAppPipelineEventParameters" - parent_pipeline: - $ref: "#/components/schemas/CIAppPipelineEventParentPipeline" - partial_retry: - description: |- - Whether or not the pipeline was a partial retry of a previous attempt. A partial retry is one - which only runs a subset of the original jobs. - example: false - type: boolean - pipeline_id: - description: |- - Any ID used in the provider to identify the pipeline run even if it is not unique across retries. - If the `pipeline_id` is unique, then both `unique_id` and `pipeline_id` can be set to the same value. - example: "#023" + pipeline_name: + description: The parent pipeline name. + example: Build + type: string + pipeline_unique_id: + description: The parent pipeline UUID. + example: "76b572af-a078-42b2-a08a-cc28f98b944f" type: string - previous_attempt: - $ref: "#/components/schemas/CIAppPipelineEventPreviousPipeline" queue_time: description: The queue time in milliseconds, if applicable. example: 1004 @@ -13908,38 +13902,48 @@ components: minimum: 0 nullable: true type: integer + stage_id: + description: The parent stage UUID (if applicable). + nullable: true + type: string + stage_name: + description: The parent stage name (if applicable). + nullable: true + type: string start: - description: Time when the pipeline run started (it should not include any queue time). The time format must be RFC3339. + description: |- + Time when the job run instance started (it should not include any queue time). + The time format must be RFC3339. example: "2023-05-31T15:30:00Z" format: date-time type: string status: - $ref: "#/components/schemas/CIAppPipelineEventPipelineStatus" + $ref: "#/components/schemas/CIAppPipelineEventJobStatus" tags: $ref: "#/components/schemas/CIAppPipelineEventTags" - unique_id: - description: |- - UUID of the pipeline run. The ID has to be unique across retries and pipelines, - including partial retries. - example: "3eacb6f3-ff04-4e10-8a9c-46e6d054024a" - type: string url: - description: The URL to look at the pipeline in the CI provider UI. - example: https://my-ci-provider.example/pipelines/my-pipeline/run/1 + description: The URL to look at the job in the CI provider UI. + example: https://ci-platform.com/job/your-job-name/build/123 type: string required: - level - - unique_id + - id - name - - url + - pipeline_unique_id + - pipeline_name - start - end - status - - partial_retry + - url type: object - CIAppPipelineEventInProgressPipeline: - description: Details of a running pipeline. + CIAppPipelineEventFinishedPipeline: + description: Details of a finished pipeline. properties: + end: + description: Time when the pipeline run finished. It cannot be older than 18 hours in the past from the current time. The time format must be RFC3339. + example: "2023-05-31T15:30:00Z" + format: date-time + type: string error: $ref: "#/components/schemas/CIAppCIError" git: @@ -13995,12 +13999,13 @@ components: format: date-time type: string status: - $ref: "#/components/schemas/CIAppPipelineEventPipelineInProgressStatus" + $ref: "#/components/schemas/CIAppPipelineEventPipelineStatus" tags: $ref: "#/components/schemas/CIAppPipelineEventTags" unique_id: description: |- - UUID of the pipeline run. The ID has to be the same as the finished pipeline. + UUID of the pipeline run. The ID has to be unique across retries and pipelines, + including partial retries. example: "3eacb6f3-ff04-4e10-8a9c-46e6d054024a" type: string url: @@ -14013,11 +14018,12 @@ components: - name - url - start + - end - status - partial_retry type: object - CIAppPipelineEventJob: - description: Details of a CI job. + CIAppPipelineEventInProgressJob: + description: Details of a running CI job. properties: dependencies: description: A list of job IDs that this job depends on. @@ -14027,17 +14033,12 @@ components: type: string nullable: true type: array - end: - description: Time when the job run finished. The time format must be RFC3339. - example: "2023-05-31T15:30:00Z" - format: date-time - type: string error: $ref: "#/components/schemas/CIAppCIError" git: $ref: "#/components/schemas/CIAppGitInfo" id: - description: The UUID for the job. It has to be unique within each pipeline execution. + description: The UUID for the job. It must match the ID of the corresponding finished job. example: c865bad4-de82-44b8-ade7-2c987528eb54 type: string level: @@ -14076,12 +14077,14 @@ components: nullable: true type: string start: - description: Time when the job run instance started (it should not include any queue time). The time format must be RFC3339. + description: |- + Time when the job run instance started (it should not include any queue time). + The time format must be RFC3339. example: "2023-05-31T15:30:00Z" format: date-time type: string status: - $ref: "#/components/schemas/CIAppPipelineEventJobStatus" + $ref: "#/components/schemas/CIAppPipelineEventJobInProgressStatus" tags: $ref: "#/components/schemas/CIAppPipelineEventTags" url: @@ -14095,10 +14098,99 @@ components: - pipeline_unique_id - pipeline_name - start - - end - status - url type: object + CIAppPipelineEventInProgressPipeline: + description: Details of a running pipeline. + properties: + error: + $ref: "#/components/schemas/CIAppCIError" + git: + $ref: "#/components/schemas/CIAppGitInfo" + is_manual: + description: Whether or not the pipeline was triggered manually by the user. + example: false + nullable: true + type: boolean + is_resumed: + description: Whether or not the pipeline was resumed after being blocked. + example: false + nullable: true + type: boolean + level: + $ref: "#/components/schemas/CIAppPipelineEventPipelineLevel" + metrics: + $ref: "#/components/schemas/CIAppPipelineEventMetrics" + name: + description: Name of the pipeline. All pipeline runs for the builds should have the same name. + example: Deploy to AWS + type: string + node: + $ref: "#/components/schemas/CIAppHostInfo" + parameters: + $ref: "#/components/schemas/CIAppPipelineEventParameters" + parent_pipeline: + $ref: "#/components/schemas/CIAppPipelineEventParentPipeline" + partial_retry: + description: |- + Whether or not the pipeline was a partial retry of a previous attempt. A partial retry is one + which only runs a subset of the original jobs. + example: false + type: boolean + pipeline_id: + description: |- + Any ID used in the provider to identify the pipeline run even if it is not unique across retries. + If the `pipeline_id` is unique, then both `unique_id` and `pipeline_id` can be set to the same value. + example: "#023" + type: string + previous_attempt: + $ref: "#/components/schemas/CIAppPipelineEventPreviousPipeline" + queue_time: + description: The queue time in milliseconds, if applicable. + example: 1004 + format: int64 + minimum: 0 + nullable: true + type: integer + start: + description: Time when the pipeline run started (it should not include any queue time). The time format must be RFC3339. + example: "2023-05-31T15:30:00Z" + format: date-time + type: string + status: + $ref: "#/components/schemas/CIAppPipelineEventPipelineInProgressStatus" + tags: + $ref: "#/components/schemas/CIAppPipelineEventTags" + unique_id: + description: |- + UUID of the pipeline run. The ID has to be the same as the finished pipeline. + example: "3eacb6f3-ff04-4e10-8a9c-46e6d054024a" + type: string + url: + description: The URL to look at the pipeline in the CI provider UI. + example: https://my-ci-provider.example/pipelines/my-pipeline/run/1 + type: string + required: + - level + - unique_id + - name + - url + - start + - status + - partial_retry + type: object + CIAppPipelineEventJob: + description: Details of a CI job. + oneOf: + - $ref: "#/components/schemas/CIAppPipelineEventFinishedJob" + - $ref: "#/components/schemas/CIAppPipelineEventInProgressJob" + CIAppPipelineEventJobInProgressStatus: + description: The in-progress status of the job. + enum: ["running"] + example: running + type: string + x-enum-varnames: ["RUNNING"] CIAppPipelineEventJobLevel: default: job description: Used to distinguish between pipelines, stages, jobs, and steps. diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 14023429c7..757d5cae13 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -6150,6 +6150,13 @@ datadog\_api\_client.v2.model.ci\_app\_pipeline\_event\_attributes module :members: :show-inheritance: +datadog\_api\_client.v2.model.ci\_app\_pipeline\_event\_finished\_job module +---------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_pipeline_event_finished_job + :members: + :show-inheritance: + datadog\_api\_client.v2.model.ci\_app\_pipeline\_event\_finished\_pipeline module --------------------------------------------------------------------------------- @@ -6157,6 +6164,13 @@ datadog\_api\_client.v2.model.ci\_app\_pipeline\_event\_finished\_pipeline modul :members: :show-inheritance: +datadog\_api\_client.v2.model.ci\_app\_pipeline\_event\_in\_progress\_job module +-------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_pipeline_event_in_progress_job + :members: + :show-inheritance: + datadog\_api\_client.v2.model.ci\_app\_pipeline\_event\_in\_progress\_pipeline module ------------------------------------------------------------------------------------- @@ -6171,6 +6185,13 @@ datadog\_api\_client.v2.model.ci\_app\_pipeline\_event\_job module :members: :show-inheritance: +datadog\_api\_client.v2.model.ci\_app\_pipeline\_event\_job\_in\_progress\_status module +---------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_pipeline_event_job_in_progress_status + :members: + :show-inheritance: + datadog\_api\_client.v2.model.ci\_app\_pipeline\_event\_job\_level module ------------------------------------------------------------------------- diff --git a/examples/v2/ci-visibility-pipelines/CreateCIAppPipelineEvent_129899466.py b/examples/v2/ci-visibility-pipelines/CreateCIAppPipelineEvent_129899466.py index 2112bb9846..af70a7fa1a 100644 --- a/examples/v2/ci-visibility-pipelines/CreateCIAppPipelineEvent_129899466.py +++ b/examples/v2/ci-visibility-pipelines/CreateCIAppPipelineEvent_129899466.py @@ -14,14 +14,14 @@ from datadog_api_client.v2.model.ci_app_create_pipeline_event_request_data_type import ( CIAppCreatePipelineEventRequestDataType, ) -from datadog_api_client.v2.model.ci_app_pipeline_event_job import CIAppPipelineEventJob +from datadog_api_client.v2.model.ci_app_pipeline_event_finished_job import CIAppPipelineEventFinishedJob from datadog_api_client.v2.model.ci_app_pipeline_event_job_level import CIAppPipelineEventJobLevel from datadog_api_client.v2.model.ci_app_pipeline_event_job_status import CIAppPipelineEventJobStatus body = CIAppCreatePipelineEventRequest( data=CIAppCreatePipelineEventRequestData( attributes=CIAppCreatePipelineEventRequestAttributes( - resource=CIAppPipelineEventJob( + resource=CIAppPipelineEventFinishedJob( level=CIAppPipelineEventJobLevel.JOB, id="cf9456de-8b9e-4c27-aa79-27b1e78c1a33", name="Build image", diff --git a/examples/v2/ci-visibility-pipelines/CreateCIAppPipelineEvent_4007074677.py b/examples/v2/ci-visibility-pipelines/CreateCIAppPipelineEvent_4007074677.py new file mode 100644 index 0000000000..401cc7d503 --- /dev/null +++ b/examples/v2/ci-visibility-pipelines/CreateCIAppPipelineEvent_4007074677.py @@ -0,0 +1,46 @@ +""" +Send running job event returns "Request accepted for processing" response +""" + +from datetime import datetime +from dateutil.relativedelta import relativedelta +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.ci_visibility_pipelines_api import CIVisibilityPipelinesApi +from datadog_api_client.v2.model.ci_app_create_pipeline_event_request import CIAppCreatePipelineEventRequest +from datadog_api_client.v2.model.ci_app_create_pipeline_event_request_attributes import ( + CIAppCreatePipelineEventRequestAttributes, +) +from datadog_api_client.v2.model.ci_app_create_pipeline_event_request_data import CIAppCreatePipelineEventRequestData +from datadog_api_client.v2.model.ci_app_create_pipeline_event_request_data_type import ( + CIAppCreatePipelineEventRequestDataType, +) +from datadog_api_client.v2.model.ci_app_pipeline_event_in_progress_job import CIAppPipelineEventInProgressJob +from datadog_api_client.v2.model.ci_app_pipeline_event_job_in_progress_status import ( + CIAppPipelineEventJobInProgressStatus, +) +from datadog_api_client.v2.model.ci_app_pipeline_event_job_level import CIAppPipelineEventJobLevel + +body = CIAppCreatePipelineEventRequest( + data=CIAppCreatePipelineEventRequestData( + attributes=CIAppCreatePipelineEventRequestAttributes( + resource=CIAppPipelineEventInProgressJob( + level=CIAppPipelineEventJobLevel.JOB, + id="cf9456de-8b9e-4c27-aa79-27b1e78c1a33", + name="Build image", + pipeline_unique_id="3eacb6f3-ff04-4e10-8a9c-46e6d054024a", + pipeline_name="Deploy to AWS", + start=(datetime.now() + relativedelta(seconds=-120)), + status=CIAppPipelineEventJobInProgressStatus.RUNNING, + url="https://my-ci-provider.example/jobs/my-jobs/run/1", + ), + ), + type=CIAppCreatePipelineEventRequestDataType.CIPIPELINE_RESOURCE_REQUEST, + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = CIVisibilityPipelinesApi(api_client) + response = api_instance.create_ci_app_pipeline_event(body=body) + + print(response) diff --git a/src/datadog_api_client/v2/model/ci_app_create_pipeline_event_request_attributes_resource.py b/src/datadog_api_client/v2/model/ci_app_create_pipeline_event_request_attributes_resource.py index 41dfe5d2aa..ae34f2e714 100644 --- a/src/datadog_api_client/v2/model/ci_app_create_pipeline_event_request_attributes_resource.py +++ b/src/datadog_api_client/v2/model/ci_app_create_pipeline_event_request_attributes_resource.py @@ -64,20 +64,20 @@ def __init__(self, **kwargs): :param tags: A list of user-defined tags. The tags must follow the `key:value` pattern. :type tags: [str], none_type, optional + :param job_id: The parent job UUID (if applicable). + :type job_id: str, none_type, optional + + :param job_name: The parent job name (if applicable). + :type job_name: str, none_type, optional + :param stage_id: The parent stage UUID (if applicable). :type stage_id: str, none_type, optional :param stage_name: The parent stage name (if applicable). :type stage_name: str, none_type, optional - :param url: The URL to look at the job in the CI provider UI. - :type url: str - - :param job_id: The parent job UUID (if applicable). - :type job_id: str, none_type, optional - - :param job_name: The parent job name (if applicable). - :type job_name: str, none_type, optional + :param url: The URL to look at the step in the CI provider UI. + :type url: str, none_type, optional """ super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/ci_app_pipeline_event_finished_job.py b/src/datadog_api_client/v2/model/ci_app_pipeline_event_finished_job.py new file mode 100644 index 0000000000..7ea86569f7 --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_pipeline_event_finished_job.py @@ -0,0 +1,202 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + datetime, + none_type, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.ci_app_ci_error import CIAppCIError + from datadog_api_client.v2.model.ci_app_git_info import CIAppGitInfo + from datadog_api_client.v2.model.ci_app_pipeline_event_job_level import CIAppPipelineEventJobLevel + from datadog_api_client.v2.model.ci_app_host_info import CIAppHostInfo + from datadog_api_client.v2.model.ci_app_pipeline_event_parameters import CIAppPipelineEventParameters + from datadog_api_client.v2.model.ci_app_pipeline_event_job_status import CIAppPipelineEventJobStatus + + +class CIAppPipelineEventFinishedJob(ModelNormal): + validations = { + "queue_time": { + "inclusive_minimum": 0, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ci_app_ci_error import CIAppCIError + from datadog_api_client.v2.model.ci_app_git_info import CIAppGitInfo + from datadog_api_client.v2.model.ci_app_pipeline_event_job_level import CIAppPipelineEventJobLevel + from datadog_api_client.v2.model.ci_app_host_info import CIAppHostInfo + from datadog_api_client.v2.model.ci_app_pipeline_event_parameters import CIAppPipelineEventParameters + from datadog_api_client.v2.model.ci_app_pipeline_event_job_status import CIAppPipelineEventJobStatus + + return { + "dependencies": ([str], none_type), + "end": (datetime,), + "error": (CIAppCIError,), + "git": (CIAppGitInfo,), + "id": (str,), + "level": (CIAppPipelineEventJobLevel,), + "metrics": ([str],), + "name": (str,), + "node": (CIAppHostInfo,), + "parameters": (CIAppPipelineEventParameters,), + "pipeline_name": (str,), + "pipeline_unique_id": (str,), + "queue_time": (int, none_type), + "stage_id": (str, none_type), + "stage_name": (str, none_type), + "start": (datetime,), + "status": (CIAppPipelineEventJobStatus,), + "tags": ([str],), + "url": (str,), + } + + attribute_map = { + "dependencies": "dependencies", + "end": "end", + "error": "error", + "git": "git", + "id": "id", + "level": "level", + "metrics": "metrics", + "name": "name", + "node": "node", + "parameters": "parameters", + "pipeline_name": "pipeline_name", + "pipeline_unique_id": "pipeline_unique_id", + "queue_time": "queue_time", + "stage_id": "stage_id", + "stage_name": "stage_name", + "start": "start", + "status": "status", + "tags": "tags", + "url": "url", + } + + def __init__( + self_, + end: datetime, + id: str, + level: CIAppPipelineEventJobLevel, + name: str, + pipeline_name: str, + pipeline_unique_id: str, + start: datetime, + status: CIAppPipelineEventJobStatus, + url: str, + dependencies: Union[List[str], none_type, UnsetType] = unset, + error: Union[CIAppCIError, none_type, UnsetType] = unset, + git: Union[CIAppGitInfo, none_type, UnsetType] = unset, + metrics: Union[List[str], none_type, UnsetType] = unset, + node: Union[CIAppHostInfo, none_type, UnsetType] = unset, + parameters: Union[CIAppPipelineEventParameters, none_type, UnsetType] = unset, + queue_time: Union[int, none_type, UnsetType] = unset, + stage_id: Union[str, none_type, UnsetType] = unset, + stage_name: Union[str, none_type, UnsetType] = unset, + tags: Union[List[str], none_type, UnsetType] = unset, + **kwargs, + ): + """ + Details of a finished CI job. + + :param dependencies: A list of job IDs that this job depends on. + :type dependencies: [str], none_type, optional + + :param end: Time when the job run finished. The time format must be RFC3339. + :type end: datetime + + :param error: Contains information of the CI error. + :type error: CIAppCIError, none_type, optional + + :param git: If pipelines are triggered due to actions to a Git repository, then all payloads must contain this. + Note that either ``tag`` or ``branch`` has to be provided, but not both. + :type git: CIAppGitInfo, none_type, optional + + :param id: The UUID for the job. It has to be unique within each pipeline execution. + :type id: str + + :param level: Used to distinguish between pipelines, stages, jobs, and steps. + :type level: CIAppPipelineEventJobLevel + + :param metrics: A list of user-defined metrics. The metrics must follow the ``key:value`` pattern and the value must be numeric. + :type metrics: [str], none_type, optional + + :param name: The name for the job. + :type name: str + + :param node: Contains information of the host running the pipeline, stage, job, or step. + :type node: CIAppHostInfo, none_type, optional + + :param parameters: A map of key-value parameters or environment variables that were defined for the pipeline. + :type parameters: CIAppPipelineEventParameters, none_type, optional + + :param pipeline_name: The parent pipeline name. + :type pipeline_name: str + + :param pipeline_unique_id: The parent pipeline UUID. + :type pipeline_unique_id: str + + :param queue_time: The queue time in milliseconds, if applicable. + :type queue_time: int, none_type, optional + + :param stage_id: The parent stage UUID (if applicable). + :type stage_id: str, none_type, optional + + :param stage_name: The parent stage name (if applicable). + :type stage_name: str, none_type, optional + + :param start: Time when the job run instance started (it should not include any queue time). + The time format must be RFC3339. + :type start: datetime + + :param status: The final status of the job. + :type status: CIAppPipelineEventJobStatus + + :param tags: A list of user-defined tags. The tags must follow the ``key:value`` pattern. + :type tags: [str], none_type, optional + + :param url: The URL to look at the job in the CI provider UI. + :type url: str + """ + if dependencies is not unset: + kwargs["dependencies"] = dependencies + if error is not unset: + kwargs["error"] = error + if git is not unset: + kwargs["git"] = git + if metrics is not unset: + kwargs["metrics"] = metrics + if node is not unset: + kwargs["node"] = node + if parameters is not unset: + kwargs["parameters"] = parameters + if queue_time is not unset: + kwargs["queue_time"] = queue_time + if stage_id is not unset: + kwargs["stage_id"] = stage_id + if stage_name is not unset: + kwargs["stage_name"] = stage_name + if tags is not unset: + kwargs["tags"] = tags + super().__init__(kwargs) + + self_.end = end + self_.id = id + self_.level = level + self_.name = name + self_.pipeline_name = pipeline_name + self_.pipeline_unique_id = pipeline_unique_id + self_.start = start + self_.status = status + self_.url = url diff --git a/src/datadog_api_client/v2/model/ci_app_pipeline_event_in_progress_job.py b/src/datadog_api_client/v2/model/ci_app_pipeline_event_in_progress_job.py new file mode 100644 index 0000000000..14e466d4bc --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_pipeline_event_in_progress_job.py @@ -0,0 +1,199 @@ +# 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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + datetime, + none_type, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.ci_app_ci_error import CIAppCIError + from datadog_api_client.v2.model.ci_app_git_info import CIAppGitInfo + from datadog_api_client.v2.model.ci_app_pipeline_event_job_level import CIAppPipelineEventJobLevel + from datadog_api_client.v2.model.ci_app_host_info import CIAppHostInfo + from datadog_api_client.v2.model.ci_app_pipeline_event_parameters import CIAppPipelineEventParameters + from datadog_api_client.v2.model.ci_app_pipeline_event_job_in_progress_status import ( + CIAppPipelineEventJobInProgressStatus, + ) + + +class CIAppPipelineEventInProgressJob(ModelNormal): + validations = { + "queue_time": { + "inclusive_minimum": 0, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ci_app_ci_error import CIAppCIError + from datadog_api_client.v2.model.ci_app_git_info import CIAppGitInfo + from datadog_api_client.v2.model.ci_app_pipeline_event_job_level import CIAppPipelineEventJobLevel + from datadog_api_client.v2.model.ci_app_host_info import CIAppHostInfo + from datadog_api_client.v2.model.ci_app_pipeline_event_parameters import CIAppPipelineEventParameters + from datadog_api_client.v2.model.ci_app_pipeline_event_job_in_progress_status import ( + CIAppPipelineEventJobInProgressStatus, + ) + + return { + "dependencies": ([str], none_type), + "error": (CIAppCIError,), + "git": (CIAppGitInfo,), + "id": (str,), + "level": (CIAppPipelineEventJobLevel,), + "metrics": ([str],), + "name": (str,), + "node": (CIAppHostInfo,), + "parameters": (CIAppPipelineEventParameters,), + "pipeline_name": (str,), + "pipeline_unique_id": (str,), + "queue_time": (int, none_type), + "stage_id": (str, none_type), + "stage_name": (str, none_type), + "start": (datetime,), + "status": (CIAppPipelineEventJobInProgressStatus,), + "tags": ([str],), + "url": (str,), + } + + attribute_map = { + "dependencies": "dependencies", + "error": "error", + "git": "git", + "id": "id", + "level": "level", + "metrics": "metrics", + "name": "name", + "node": "node", + "parameters": "parameters", + "pipeline_name": "pipeline_name", + "pipeline_unique_id": "pipeline_unique_id", + "queue_time": "queue_time", + "stage_id": "stage_id", + "stage_name": "stage_name", + "start": "start", + "status": "status", + "tags": "tags", + "url": "url", + } + + def __init__( + self_, + id: str, + level: CIAppPipelineEventJobLevel, + name: str, + pipeline_name: str, + pipeline_unique_id: str, + start: datetime, + status: CIAppPipelineEventJobInProgressStatus, + url: str, + dependencies: Union[List[str], none_type, UnsetType] = unset, + error: Union[CIAppCIError, none_type, UnsetType] = unset, + git: Union[CIAppGitInfo, none_type, UnsetType] = unset, + metrics: Union[List[str], none_type, UnsetType] = unset, + node: Union[CIAppHostInfo, none_type, UnsetType] = unset, + parameters: Union[CIAppPipelineEventParameters, none_type, UnsetType] = unset, + queue_time: Union[int, none_type, UnsetType] = unset, + stage_id: Union[str, none_type, UnsetType] = unset, + stage_name: Union[str, none_type, UnsetType] = unset, + tags: Union[List[str], none_type, UnsetType] = unset, + **kwargs, + ): + """ + Details of a running CI job. + + :param dependencies: A list of job IDs that this job depends on. + :type dependencies: [str], none_type, optional + + :param error: Contains information of the CI error. + :type error: CIAppCIError, none_type, optional + + :param git: If pipelines are triggered due to actions to a Git repository, then all payloads must contain this. + Note that either ``tag`` or ``branch`` has to be provided, but not both. + :type git: CIAppGitInfo, none_type, optional + + :param id: The UUID for the job. It must match the ID of the corresponding finished job. + :type id: str + + :param level: Used to distinguish between pipelines, stages, jobs, and steps. + :type level: CIAppPipelineEventJobLevel + + :param metrics: A list of user-defined metrics. The metrics must follow the ``key:value`` pattern and the value must be numeric. + :type metrics: [str], none_type, optional + + :param name: The name for the job. + :type name: str + + :param node: Contains information of the host running the pipeline, stage, job, or step. + :type node: CIAppHostInfo, none_type, optional + + :param parameters: A map of key-value parameters or environment variables that were defined for the pipeline. + :type parameters: CIAppPipelineEventParameters, none_type, optional + + :param pipeline_name: The parent pipeline name. + :type pipeline_name: str + + :param pipeline_unique_id: The parent pipeline UUID. + :type pipeline_unique_id: str + + :param queue_time: The queue time in milliseconds, if applicable. + :type queue_time: int, none_type, optional + + :param stage_id: The parent stage UUID (if applicable). + :type stage_id: str, none_type, optional + + :param stage_name: The parent stage name (if applicable). + :type stage_name: str, none_type, optional + + :param start: Time when the job run instance started (it should not include any queue time). + The time format must be RFC3339. + :type start: datetime + + :param status: The in-progress status of the job. + :type status: CIAppPipelineEventJobInProgressStatus + + :param tags: A list of user-defined tags. The tags must follow the ``key:value`` pattern. + :type tags: [str], none_type, optional + + :param url: The URL to look at the job in the CI provider UI. + :type url: str + """ + if dependencies is not unset: + kwargs["dependencies"] = dependencies + if error is not unset: + kwargs["error"] = error + if git is not unset: + kwargs["git"] = git + if metrics is not unset: + kwargs["metrics"] = metrics + if node is not unset: + kwargs["node"] = node + if parameters is not unset: + kwargs["parameters"] = parameters + if queue_time is not unset: + kwargs["queue_time"] = queue_time + if stage_id is not unset: + kwargs["stage_id"] = stage_id + if stage_name is not unset: + kwargs["stage_name"] = stage_name + if tags is not unset: + kwargs["tags"] = tags + super().__init__(kwargs) + + self_.id = id + self_.level = level + self_.name = name + self_.pipeline_name = pipeline_name + self_.pipeline_unique_id = pipeline_unique_id + self_.start = start + self_.status = status + self_.url = url diff --git a/src/datadog_api_client/v2/model/ci_app_pipeline_event_job.py b/src/datadog_api_client/v2/model/ci_app_pipeline_event_job.py index 0543c4afde..130312231e 100644 --- a/src/datadog_api_client/v2/model/ci_app_pipeline_event_job.py +++ b/src/datadog_api_client/v2/model/ci_app_pipeline_event_job.py @@ -3,110 +3,15 @@ # Copyright 2019-Present Datadog, Inc. from __future__ import annotations -from typing import List, Union, TYPE_CHECKING from datadog_api_client.model_utils import ( - ModelNormal, + ModelComposed, cached_property, - datetime, - none_type, - unset, - UnsetType, ) -if TYPE_CHECKING: - from datadog_api_client.v2.model.ci_app_ci_error import CIAppCIError - from datadog_api_client.v2.model.ci_app_git_info import CIAppGitInfo - from datadog_api_client.v2.model.ci_app_pipeline_event_job_level import CIAppPipelineEventJobLevel - from datadog_api_client.v2.model.ci_app_host_info import CIAppHostInfo - from datadog_api_client.v2.model.ci_app_pipeline_event_parameters import CIAppPipelineEventParameters - from datadog_api_client.v2.model.ci_app_pipeline_event_job_status import CIAppPipelineEventJobStatus - - -class CIAppPipelineEventJob(ModelNormal): - validations = { - "queue_time": { - "inclusive_minimum": 0, - }, - } - - @cached_property - def openapi_types(_): - from datadog_api_client.v2.model.ci_app_ci_error import CIAppCIError - from datadog_api_client.v2.model.ci_app_git_info import CIAppGitInfo - from datadog_api_client.v2.model.ci_app_pipeline_event_job_level import CIAppPipelineEventJobLevel - from datadog_api_client.v2.model.ci_app_host_info import CIAppHostInfo - from datadog_api_client.v2.model.ci_app_pipeline_event_parameters import CIAppPipelineEventParameters - from datadog_api_client.v2.model.ci_app_pipeline_event_job_status import CIAppPipelineEventJobStatus - - return { - "dependencies": ([str], none_type), - "end": (datetime,), - "error": (CIAppCIError,), - "git": (CIAppGitInfo,), - "id": (str,), - "level": (CIAppPipelineEventJobLevel,), - "metrics": ([str],), - "name": (str,), - "node": (CIAppHostInfo,), - "parameters": (CIAppPipelineEventParameters,), - "pipeline_name": (str,), - "pipeline_unique_id": (str,), - "queue_time": (int, none_type), - "stage_id": (str, none_type), - "stage_name": (str, none_type), - "start": (datetime,), - "status": (CIAppPipelineEventJobStatus,), - "tags": ([str],), - "url": (str,), - } - - attribute_map = { - "dependencies": "dependencies", - "end": "end", - "error": "error", - "git": "git", - "id": "id", - "level": "level", - "metrics": "metrics", - "name": "name", - "node": "node", - "parameters": "parameters", - "pipeline_name": "pipeline_name", - "pipeline_unique_id": "pipeline_unique_id", - "queue_time": "queue_time", - "stage_id": "stage_id", - "stage_name": "stage_name", - "start": "start", - "status": "status", - "tags": "tags", - "url": "url", - } - - def __init__( - self_, - end: datetime, - id: str, - level: CIAppPipelineEventJobLevel, - name: str, - pipeline_name: str, - pipeline_unique_id: str, - start: datetime, - status: CIAppPipelineEventJobStatus, - url: str, - dependencies: Union[List[str], none_type, UnsetType] = unset, - error: Union[CIAppCIError, none_type, UnsetType] = unset, - git: Union[CIAppGitInfo, none_type, UnsetType] = unset, - metrics: Union[List[str], none_type, UnsetType] = unset, - node: Union[CIAppHostInfo, none_type, UnsetType] = unset, - parameters: Union[CIAppPipelineEventParameters, none_type, UnsetType] = unset, - queue_time: Union[int, none_type, UnsetType] = unset, - stage_id: Union[str, none_type, UnsetType] = unset, - stage_name: Union[str, none_type, UnsetType] = unset, - tags: Union[List[str], none_type, UnsetType] = unset, - **kwargs, - ): +class CIAppPipelineEventJob(ModelComposed): + def __init__(self, **kwargs): """ Details of a CI job. @@ -120,7 +25,7 @@ def __init__( :type error: CIAppCIError, none_type, optional :param git: If pipelines are triggered due to actions to a Git repository, then all payloads must contain this. - Note that either ``tag`` or ``branch`` has to be provided, but not both. + Note that either `tag` or `branch` has to be provided, but not both. :type git: CIAppGitInfo, none_type, optional :param id: The UUID for the job. It has to be unique within each pipeline execution. @@ -129,7 +34,7 @@ def __init__( :param level: Used to distinguish between pipelines, stages, jobs, and steps. :type level: CIAppPipelineEventJobLevel - :param metrics: A list of user-defined metrics. The metrics must follow the ``key:value`` pattern and the value must be numeric. + :param metrics: A list of user-defined metrics. The metrics must follow the `key:value` pattern and the value must be numeric. :type metrics: [str], none_type, optional :param name: The name for the job. @@ -156,46 +61,36 @@ def __init__( :param stage_name: The parent stage name (if applicable). :type stage_name: str, none_type, optional - :param start: Time when the job run instance started (it should not include any queue time). The time format must be RFC3339. + :param start: Time when the job run instance started (it should not include any queue time). + The time format must be RFC3339. :type start: datetime :param status: The final status of the job. :type status: CIAppPipelineEventJobStatus - :param tags: A list of user-defined tags. The tags must follow the ``key:value`` pattern. + :param tags: A list of user-defined tags. The tags must follow the `key:value` pattern. :type tags: [str], none_type, optional :param url: The URL to look at the job in the CI provider UI. :type url: str """ - if dependencies is not unset: - kwargs["dependencies"] = dependencies - if error is not unset: - kwargs["error"] = error - if git is not unset: - kwargs["git"] = git - if metrics is not unset: - kwargs["metrics"] = metrics - if node is not unset: - kwargs["node"] = node - if parameters is not unset: - kwargs["parameters"] = parameters - if queue_time is not unset: - kwargs["queue_time"] = queue_time - if stage_id is not unset: - kwargs["stage_id"] = stage_id - if stage_name is not unset: - kwargs["stage_name"] = stage_name - if tags is not unset: - kwargs["tags"] = tags super().__init__(kwargs) - self_.end = end - self_.id = id - self_.level = level - self_.name = name - self_.pipeline_name = pipeline_name - self_.pipeline_unique_id = pipeline_unique_id - self_.start = start - self_.status = status - self_.url = url + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v2.model.ci_app_pipeline_event_finished_job import CIAppPipelineEventFinishedJob + from datadog_api_client.v2.model.ci_app_pipeline_event_in_progress_job import CIAppPipelineEventInProgressJob + + return { + "oneOf": [ + CIAppPipelineEventFinishedJob, + CIAppPipelineEventInProgressJob, + ], + } diff --git a/src/datadog_api_client/v2/model/ci_app_pipeline_event_job_in_progress_status.py b/src/datadog_api_client/v2/model/ci_app_pipeline_event_job_in_progress_status.py new file mode 100644 index 0000000000..8ea96c3e5f --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_pipeline_event_job_in_progress_status.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 CIAppPipelineEventJobInProgressStatus(ModelSimple): + """ + The in-progress status of the job. + + :param value: If omitted defaults to "running". Must be one of ["running"]. + :type value: str + """ + + allowed_values = { + "running", + } + RUNNING: ClassVar["CIAppPipelineEventJobInProgressStatus"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +CIAppPipelineEventJobInProgressStatus.RUNNING = CIAppPipelineEventJobInProgressStatus("running") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 9413425cce..4ebe2e4924 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -888,9 +888,14 @@ from datadog_api_client.v2.model.ci_app_host_info import CIAppHostInfo from datadog_api_client.v2.model.ci_app_pipeline_event import CIAppPipelineEvent from datadog_api_client.v2.model.ci_app_pipeline_event_attributes import CIAppPipelineEventAttributes +from datadog_api_client.v2.model.ci_app_pipeline_event_finished_job import CIAppPipelineEventFinishedJob from datadog_api_client.v2.model.ci_app_pipeline_event_finished_pipeline import CIAppPipelineEventFinishedPipeline +from datadog_api_client.v2.model.ci_app_pipeline_event_in_progress_job import CIAppPipelineEventInProgressJob from datadog_api_client.v2.model.ci_app_pipeline_event_in_progress_pipeline import CIAppPipelineEventInProgressPipeline from datadog_api_client.v2.model.ci_app_pipeline_event_job import CIAppPipelineEventJob +from datadog_api_client.v2.model.ci_app_pipeline_event_job_in_progress_status import ( + CIAppPipelineEventJobInProgressStatus, +) from datadog_api_client.v2.model.ci_app_pipeline_event_job_level import CIAppPipelineEventJobLevel from datadog_api_client.v2.model.ci_app_pipeline_event_job_status import CIAppPipelineEventJobStatus from datadog_api_client.v2.model.ci_app_pipeline_event_parameters import CIAppPipelineEventParameters @@ -10072,9 +10077,12 @@ "CIAppHostInfo", "CIAppPipelineEvent", "CIAppPipelineEventAttributes", + "CIAppPipelineEventFinishedJob", "CIAppPipelineEventFinishedPipeline", + "CIAppPipelineEventInProgressJob", "CIAppPipelineEventInProgressPipeline", "CIAppPipelineEventJob", + "CIAppPipelineEventJobInProgressStatus", "CIAppPipelineEventJobLevel", "CIAppPipelineEventJobStatus", "CIAppPipelineEventParameters", diff --git a/tests/v2/cassettes/test_scenarios/test_send_running_job_event_returns_request_accepted_for_processing_response.frozen b/tests/v2/cassettes/test_scenarios/test_send_running_job_event_returns_request_accepted_for_processing_response.frozen new file mode 100644 index 0000000000..450ad249ce --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_send_running_job_event_returns_request_accepted_for_processing_response.frozen @@ -0,0 +1 @@ +2026-06-23T12:16:50.217Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_send_running_job_event_returns_request_accepted_for_processing_response.yaml b/tests/v2/cassettes/test_scenarios/test_send_running_job_event_returns_request_accepted_for_processing_response.yaml new file mode 100644 index 0000000000..3053019526 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_send_running_job_event_returns_request_accepted_for_processing_response.yaml @@ -0,0 +1,21 @@ +interactions: +- request: + body: '{"data":{"attributes":{"resource":{"id":"cf9456de-8b9e-4c27-aa79-27b1e78c1a33","level":"job","name":"Build + image","pipeline_name":"Deploy to AWS","pipeline_unique_id":"3eacb6f3-ff04-4e10-8a9c-46e6d054024a","start":"2026-06-23T12:14:50.217Z","status":"running","url":"https://my-ci-provider.example/jobs/my-jobs/run/1"}},"type":"cipipeline_resource_request"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/ci/pipeline + response: + body: + string: '{"data":null}' + headers: + content-type: + - application/vnd.api+json + status: + code: 202 + message: Accepted +version: 1 diff --git a/tests/v2/features/ci_visibility_pipelines.feature b/tests/v2/features/ci_visibility_pipelines.feature index 3c52a30f4b..c81cb9ec82 100644 --- a/tests/v2/features/ci_visibility_pipelines.feature +++ b/tests/v2/features/ci_visibility_pipelines.feature @@ -122,6 +122,13 @@ Feature: CI Visibility Pipelines When the request is sent Then the response status is 202 Request accepted for processing + @skip-java @skip-python @skip-typescript @team:DataDog/ci-app-backend + Scenario: Send running job event returns "Request accepted for processing" response + Given new "CreateCIAppPipelineEvent" request + And body with value {"data": {"attributes": {"resource": {"level": "job", "id": "cf9456de-8b9e-4c27-aa79-27b1e78c1a33", "name": "Build image", "pipeline_unique_id": "3eacb6f3-ff04-4e10-8a9c-46e6d054024a", "pipeline_name": "Deploy to AWS", "start": "{{ timeISO('now - 120s') }}", "status": "running", "url": "https://my-ci-provider.example/jobs/my-jobs/run/1"}}, "type": "cipipeline_resource_request"}} + When the request is sent + Then the response status is 202 Request accepted for processing + @skip-java @skip-python @skip-typescript @team:DataDog/ci-app-backend Scenario: Send running pipeline event returns "Request accepted for processing" response Given new "CreateCIAppPipelineEvent" request