Skip to content

Commit dde5aff

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Allow to send batches of events in pipelines API (#2639)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 7ac03ab commit dde5aff

9 files changed

+177
-12
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5994,7 +5994,7 @@ components:
59945994
description: Request object.
59955995
properties:
59965996
data:
5997-
$ref: '#/components/schemas/CIAppCreatePipelineEventRequestData'
5997+
$ref: '#/components/schemas/CIAppCreatePipelineEventRequestDataSingleOrArray'
59985998
type: object
59995999
CIAppCreatePipelineEventRequestAttributes:
60006000
description: Attributes of the pipeline event to create.
@@ -6030,6 +6030,16 @@ components:
60306030
type:
60316031
$ref: '#/components/schemas/CIAppCreatePipelineEventRequestDataType'
60326032
type: object
6033+
CIAppCreatePipelineEventRequestDataArray:
6034+
description: Array of pipeline events to create in batch.
6035+
items:
6036+
$ref: '#/components/schemas/CIAppCreatePipelineEventRequestData'
6037+
type: array
6038+
CIAppCreatePipelineEventRequestDataSingleOrArray:
6039+
description: Data of the pipeline events to create.
6040+
oneOf:
6041+
- $ref: '#/components/schemas/CIAppCreatePipelineEventRequestData'
6042+
- $ref: '#/components/schemas/CIAppCreatePipelineEventRequestDataArray'
60336043
CIAppCreatePipelineEventRequestDataType:
60346044
default: cipipeline_resource_request
60356045
description: Type of the event.
@@ -51718,6 +51728,9 @@ paths:
5171851728
we support, see [Pipeline Data Model And Execution Types](https://docs.datadoghq.com/continuous_integration/guides/pipeline_data_model/).
5171951729

5172051730

51731+
Multiple events can be sent in an array (up to 1000).
51732+
51733+
5172151734
Pipeline events can be submitted with a timestamp that is up to 18 hours in
5172251735
the past.'
5172351736
operationId: CreateCIAppPipelineEvent
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-09-02T15:10:26.479Z

cassettes/features/v2/ci_visibility_pipelines/Send-several-pipeline-events-returns-Request-accepted-for-processing-response.yml

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Send several pipeline events returns "Request accepted for processing" response
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V2::CIVisibilityPipelinesAPI.new
5+
6+
body = DatadogAPIClient::V2::CIAppCreatePipelineEventRequest.new({
7+
data: [
8+
DatadogAPIClient::V2::CIAppCreatePipelineEventRequestData.new({
9+
attributes: DatadogAPIClient::V2::CIAppCreatePipelineEventRequestAttributes.new({
10+
provider_name: "example-provider",
11+
resource: DatadogAPIClient::V2::CIAppPipelineEventFinishedPipeline.new({
12+
level: DatadogAPIClient::V2::CIAppPipelineEventPipelineLevel::PIPELINE,
13+
unique_id: "3eacb6f3-ff04-4e10-8a9c-46e6d054024a",
14+
name: "Deploy to AWS",
15+
url: "https://my-ci-provider.example/pipelines/my-pipeline/run/1",
16+
start: (Time.now + -120),
17+
_end: (Time.now + -30),
18+
status: DatadogAPIClient::V2::CIAppPipelineEventPipelineStatus::SUCCESS,
19+
partial_retry: false,
20+
git: DatadogAPIClient::V2::CIAppGitInfo.new({
21+
repository_url: "https://github.com/DataDog/datadog-agent",
22+
sha: "7f263865994b76066c4612fd1965215e7dcb4cd2",
23+
author_email: "[email protected]",
24+
}),
25+
}),
26+
}),
27+
type: DatadogAPIClient::V2::CIAppCreatePipelineEventRequestDataType::CIPIPELINE_RESOURCE_REQUEST,
28+
}),
29+
DatadogAPIClient::V2::CIAppCreatePipelineEventRequestData.new({
30+
attributes: DatadogAPIClient::V2::CIAppCreatePipelineEventRequestAttributes.new({
31+
provider_name: "example-provider",
32+
resource: DatadogAPIClient::V2::CIAppPipelineEventFinishedPipeline.new({
33+
level: DatadogAPIClient::V2::CIAppPipelineEventPipelineLevel::PIPELINE,
34+
unique_id: "7b2c8f9e-aa15-4d22-9c7d-83f4e065138b",
35+
name: "Deploy to Production",
36+
url: "https://my-ci-provider.example/pipelines/prod-pipeline/run/2",
37+
start: (Time.now + -180),
38+
_end: (Time.now + -45),
39+
status: DatadogAPIClient::V2::CIAppPipelineEventPipelineStatus::SUCCESS,
40+
partial_retry: false,
41+
git: DatadogAPIClient::V2::CIAppGitInfo.new({
42+
repository_url: "https://github.com/DataDog/datadog-agent",
43+
sha: "9a4f7c28b3e5d12f8e6c9b2a5d8f3e1c7b4a6d9e",
44+
author_email: "[email protected]",
45+
}),
46+
}),
47+
}),
48+
type: DatadogAPIClient::V2::CIAppCreatePipelineEventRequestDataType::CIPIPELINE_RESOURCE_REQUEST,
49+
}),
50+
],
51+
})
52+
p api_instance.create_ci_app_pipeline_event(body)

features/v2/ci_visibility_pipelines.feature

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Feature: CI Visibility Pipelines
1717
When the request is sent
1818
Then the response status is 400 Bad Request
1919

20-
@team:DataDog/ci-app-backend
20+
@skip-java @skip-python @skip-typescript @team:DataDog/ci-app-backend
2121
Scenario: Aggregate pipelines events returns "OK" response
2222
Given a valid "appKeyAuth" key in the system
2323
And new "AggregateCIAppPipelineEvents" request
@@ -33,7 +33,7 @@ Feature: CI Visibility Pipelines
3333
When the request is sent
3434
Then the response status is 400 Bad Request
3535

36-
@team:DataDog/ci-app-backend
36+
@skip-java @skip-python @skip-typescript @team:DataDog/ci-app-backend
3737
Scenario: Get a list of pipelines events returns "OK" response
3838
Given a valid "appKeyAuth" key in the system
3939
And new "ListCIAppPipelineEvents" request
@@ -44,7 +44,7 @@ Feature: CI Visibility Pipelines
4444
When the request is sent
4545
Then the response status is 200 OK
4646

47-
@replay-only @skip-validation @team:DataDog/ci-app-backend @with-pagination
47+
@replay-only @skip-java @skip-python @skip-typescript @skip-validation @team:DataDog/ci-app-backend @with-pagination
4848
Scenario: Get a list of pipelines events returns "OK" response with pagination
4949
Given a valid "appKeyAuth" key in the system
5050
And new "ListCIAppPipelineEvents" request
@@ -63,15 +63,15 @@ Feature: CI Visibility Pipelines
6363
When the request is sent
6464
Then the response status is 400 Bad Request
6565

66-
@team:DataDog/ci-app-backend
66+
@skip-java @skip-python @skip-typescript @team:DataDog/ci-app-backend
6767
Scenario: Search pipelines events returns "OK" response
6868
Given a valid "appKeyAuth" key in the system
6969
And new "SearchCIAppPipelineEvents" request
7070
And body with value {"filter": {"from": "now-15m", "query": "@ci.provider.name:github AND @ci.status:error", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"limit": 5}, "sort": "timestamp"}
7171
When the request is sent
7272
Then the response status is 200 OK
7373

74-
@replay-only @skip-validation @team:DataDog/ci-app-backend @with-pagination
74+
@replay-only @skip-java @skip-python @skip-typescript @skip-validation @team:DataDog/ci-app-backend @with-pagination
7575
Scenario: Search pipelines events returns "OK" response with pagination
7676
Given a valid "appKeyAuth" key in the system
7777
And new "SearchCIAppPipelineEvents" request
@@ -101,30 +101,37 @@ Feature: CI Visibility Pipelines
101101
When the request is sent
102102
Then the response status is 408 Request Timeout
103103

104-
@team:DataDog/ci-app-backend
104+
@skip-java @skip-python @skip-typescript @team:DataDog/ci-app-backend
105105
Scenario: Send pipeline event returns "Request accepted for processing" response
106106
Given new "CreateCIAppPipelineEvent" request
107107
And body with value {"data": {"attributes": {"resource": {"level": "pipeline","unique_id": "3eacb6f3-ff04-4e10-8a9c-46e6d054024a","name": "Deploy to AWS","url": "https://my-ci-provider.example/pipelines/my-pipeline/run/1","start": "{{ timeISO('now - 120s') }}","end": "{{ timeISO('now - 30s') }}","status": "success","partial_retry": false,"git": {"repository_url": "https://github.com/DataDog/datadog-agent","sha": "7f263865994b76066c4612fd1965215e7dcb4cd2","author_email": "[email protected]"}}},"type": "cipipeline_resource_request"}}
108108
When the request is sent
109109
Then the response status is 202 Request accepted for processing
110110

111-
@team:DataDog/ci-app-backend
111+
@skip-java @skip-python @skip-typescript @team:DataDog/ci-app-backend
112112
Scenario: Send pipeline event with custom provider returns "Request accepted for processing" response
113113
Given new "CreateCIAppPipelineEvent" request
114114
And body with value {"data": {"attributes": {"provider_name": "example-provider", "resource": {"level": "pipeline","unique_id": "3eacb6f3-ff04-4e10-8a9c-46e6d054024a","name": "Deploy to AWS","url": "https://my-ci-provider.example/pipelines/my-pipeline/run/1","start": "{{ timeISO('now - 120s') }}","end": "{{ timeISO('now - 30s') }}","status": "success","partial_retry": false,"git": {"repository_url": "https://github.com/DataDog/datadog-agent","sha": "7f263865994b76066c4612fd1965215e7dcb4cd2","author_email": "[email protected]"}}},"type": "cipipeline_resource_request"}}
115115
When the request is sent
116116
Then the response status is 202 Request accepted for processing
117117

118-
@skip @team:DataDog/ci-app-backend
118+
@skip @skip-java @skip-python @skip-typescript @team:DataDog/ci-app-backend
119119
Scenario: Send pipeline job event returns "Request accepted for processing" response
120120
Given new "CreateCIAppPipelineEvent" request
121121
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') }}", "end": "{{ timeISO('now - 30s') }}", "status": "error", "url": "https://my-ci-provider.example/jobs/my-jobs/run/1"}}, "type": "cipipeline_resource_request"}}
122122
When the request is sent
123123
Then the response status is 202 Request accepted for processing
124124

125-
@team:DataDog/ci-app-backend
125+
@skip-java @skip-python @skip-typescript @team:DataDog/ci-app-backend
126126
Scenario: Send running pipeline event returns "Request accepted for processing" response
127127
Given new "CreateCIAppPipelineEvent" request
128128
And body with value {"data": {"attributes": {"resource": {"level": "pipeline","unique_id": "3eacb6f3-ff04-4e10-8a9c-46e6d054024a","name": "Deploy to AWS","url": "https://my-ci-provider.example/pipelines/my-pipeline/run/1","start": "{{ timeISO('now - 120s') }}","status": "running","partial_retry": false,"git": {"repository_url": "https://github.com/DataDog/datadog-agent","sha": "7f263865994b76066c4612fd1965215e7dcb4cd2","author_email": "[email protected]"}}},"type": "cipipeline_resource_request"}}
129129
When the request is sent
130130
Then the response status is 202 Request accepted for processing
131+
132+
@skip-java @skip-python @skip-typescript @team:DataDog/ci-app-backend
133+
Scenario: Send several pipeline events returns "Request accepted for processing" response
134+
Given new "CreateCIAppPipelineEvent" request
135+
And body with value {"data": [{"attributes": {"provider_name": "example-provider", "resource": {"level": "pipeline","unique_id": "3eacb6f3-ff04-4e10-8a9c-46e6d054024a","name": "Deploy to AWS","url": "https://my-ci-provider.example/pipelines/my-pipeline/run/1","start": "{{ timeISO('now - 120s') }}","end": "{{ timeISO('now - 30s') }}","status": "success","partial_retry": false,"git": {"repository_url": "https://github.com/DataDog/datadog-agent","sha": "7f263865994b76066c4612fd1965215e7dcb4cd2","author_email": "[email protected]"}}},"type": "cipipeline_resource_request"},{"attributes": {"provider_name": "example-provider", "resource": {"level": "pipeline","unique_id": "7b2c8f9e-aa15-4d22-9c7d-83f4e065138b","name": "Deploy to Production","url": "https://my-ci-provider.example/pipelines/prod-pipeline/run/2","start": "{{ timeISO('now - 180s') }}","end": "{{ timeISO('now - 45s') }}","status": "success","partial_retry": false,"git": {"repository_url": "https://github.com/DataDog/datadog-agent","sha": "9a4f7c28b3e5d12f8e6c9b2a5d8f3e1c7b4a6d9e","author_email": "[email protected]"}}},"type": "cipipeline_resource_request"}]}
136+
When the request is sent
137+
Then the response status is 202 Request accepted for processing

lib/datadog_api_client/inflector.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ def overrides
13241324
"v2.ci_app_create_pipeline_event_request_attributes" => "CIAppCreatePipelineEventRequestAttributes",
13251325
"v2.ci_app_create_pipeline_event_request_attributes_resource" => "CIAppCreatePipelineEventRequestAttributesResource",
13261326
"v2.ci_app_create_pipeline_event_request_data" => "CIAppCreatePipelineEventRequestData",
1327+
"v2.ci_app_create_pipeline_event_request_data_single_or_array" => "CIAppCreatePipelineEventRequestDataSingleOrArray",
13271328
"v2.ci_app_create_pipeline_event_request_data_type" => "CIAppCreatePipelineEventRequestDataType",
13281329
"v2.ci_app_event_attributes" => "CIAppEventAttributes",
13291330
"v2.ci_app_git_info" => "CIAppGitInfo",

lib/datadog_api_client/v2/api/ci_visibility_pipelines_api.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ def create_ci_app_pipeline_event(body, opts = {})
102102
#
103103
# Send your pipeline event to your Datadog platform over HTTP. For details about how pipeline executions are modeled and what execution types we support, see [Pipeline Data Model And Execution Types](https://docs.datadoghq.com/continuous_integration/guides/pipeline_data_model/).
104104
#
105+
# Multiple events can be sent in an array (up to 1000).
106+
#
105107
# Pipeline events can be submitted with a timestamp that is up to 18 hours in the past.
106108
#
107109
# @param body [CIAppCreatePipelineEventRequest]

lib/datadog_api_client/v2/models/ci_app_create_pipeline_event_request.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module DatadogAPIClient::V2
2121
class CIAppCreatePipelineEventRequest
2222
include BaseGenericModel
2323

24-
# Data of the pipeline event to create.
24+
# Data of the pipeline events to create.
2525
attr_accessor :data
2626

2727
attr_accessor :additional_properties
@@ -38,7 +38,7 @@ def self.attribute_map
3838
# @!visibility private
3939
def self.openapi_types
4040
{
41-
:'data' => :'CIAppCreatePipelineEventRequestData'
41+
:'data' => :'CIAppCreatePipelineEventRequestDataSingleOrArray'
4242
}
4343
end
4444

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
=begin
2+
#Datadog API V2 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V2
20+
# Data of the pipeline events to create.
21+
module CIAppCreatePipelineEventRequestDataSingleOrArray
22+
class << self
23+
include BaseOneOfModel
24+
include BaseOneOfModelNoDiscriminator
25+
26+
# List of class defined in oneOf (OpenAPI v3)
27+
def openapi_one_of
28+
[
29+
:'CIAppCreatePipelineEventRequestData',
30+
:'Array<CIAppCreatePipelineEventRequestData>'
31+
]
32+
end
33+
# Builds the object
34+
# @param data [Mixed] Data to be matched against the list of oneOf items
35+
# @return [Object] Returns the model or the data itself
36+
def build(data)
37+
# Go through the list of oneOf items and attempt to identify the appropriate one.
38+
# Note:
39+
# - We do not attempt to check whether exactly one item matches.
40+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
41+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
42+
# - TODO: scalar values are de facto behaving as if they were nullable.
43+
# - TODO: logging when debugging is set.
44+
openapi_one_of.each do |klass|
45+
begin
46+
next if klass == :AnyType # "nullable: true"
47+
typed_data = find_and_cast_into_type(klass, data)
48+
next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed
49+
return typed_data if typed_data
50+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
51+
end
52+
end
53+
54+
if openapi_one_of.include?(:AnyType)
55+
data
56+
else
57+
self._unparsed = true
58+
DatadogAPIClient::UnparsedObject.new(data)
59+
end
60+
end
61+
end
62+
end
63+
end

0 commit comments

Comments
 (0)