Skip to content

Commit e668aae

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
and
ci.datadog-api-spec
authored
Add provider_name attribute to pipelines API (#2345)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 44a302a commit e668aae

7 files changed

+95
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-01-17 21:41:13.492369",
8-
"spec_repo_commit": "27e609f7"
7+
"regenerated": "2025-01-21 14:16:28.882998",
8+
"spec_repo_commit": "0bbc13ae"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-01-17 21:41:13.506549",
13-
"spec_repo_commit": "27e609f7"
12+
"regenerated": "2025-01-21 14:16:28.896986",
13+
"spec_repo_commit": "0bbc13ae"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3552,6 +3552,9 @@ components:
35523552
env:
35533553
description: The Datadog environment.
35543554
type: string
3555+
provider_name:
3556+
description: The name of the CI provider. By default, this is "custom".
3557+
type: string
35553558
resource:
35563559
$ref: '#/components/schemas/CIAppCreatePipelineEventRequestAttributesResource'
35573560
service:
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""
2+
Send pipeline event with custom provider returns "Request accepted for processing" response
3+
"""
4+
5+
from datetime import datetime
6+
from dateutil.relativedelta import relativedelta
7+
from datadog_api_client import ApiClient, Configuration
8+
from datadog_api_client.v2.api.ci_visibility_pipelines_api import CIVisibilityPipelinesApi
9+
from datadog_api_client.v2.model.ci_app_create_pipeline_event_request import CIAppCreatePipelineEventRequest
10+
from datadog_api_client.v2.model.ci_app_create_pipeline_event_request_attributes import (
11+
CIAppCreatePipelineEventRequestAttributes,
12+
)
13+
from datadog_api_client.v2.model.ci_app_create_pipeline_event_request_data import CIAppCreatePipelineEventRequestData
14+
from datadog_api_client.v2.model.ci_app_create_pipeline_event_request_data_type import (
15+
CIAppCreatePipelineEventRequestDataType,
16+
)
17+
from datadog_api_client.v2.model.ci_app_git_info import CIAppGitInfo
18+
from datadog_api_client.v2.model.ci_app_pipeline_event_finished_pipeline import CIAppPipelineEventFinishedPipeline
19+
from datadog_api_client.v2.model.ci_app_pipeline_event_pipeline_level import CIAppPipelineEventPipelineLevel
20+
from datadog_api_client.v2.model.ci_app_pipeline_event_pipeline_status import CIAppPipelineEventPipelineStatus
21+
22+
body = CIAppCreatePipelineEventRequest(
23+
data=CIAppCreatePipelineEventRequestData(
24+
attributes=CIAppCreatePipelineEventRequestAttributes(
25+
provider_name="example-provider",
26+
resource=CIAppPipelineEventFinishedPipeline(
27+
level=CIAppPipelineEventPipelineLevel.PIPELINE,
28+
unique_id="3eacb6f3-ff04-4e10-8a9c-46e6d054024a",
29+
name="Deploy to AWS",
30+
url="https://my-ci-provider.example/pipelines/my-pipeline/run/1",
31+
start=(datetime.now() + relativedelta(seconds=-120)),
32+
end=(datetime.now() + relativedelta(seconds=-30)),
33+
status=CIAppPipelineEventPipelineStatus.SUCCESS,
34+
partial_retry=False,
35+
git=CIAppGitInfo(
36+
repository_url="https://github.com/DataDog/datadog-agent",
37+
sha="7f263865994b76066c4612fd1965215e7dcb4cd2",
38+
author_email="[email protected]",
39+
),
40+
),
41+
),
42+
type=CIAppCreatePipelineEventRequestDataType.CIPIPELINE_RESOURCE_REQUEST,
43+
),
44+
)
45+
46+
configuration = Configuration()
47+
with ApiClient(configuration) as api_client:
48+
api_instance = CIVisibilityPipelinesApi(api_client)
49+
response = api_instance.create_ci_app_pipeline_event(body=body)
50+
51+
print(response)

src/datadog_api_client/v2/model/ci_app_create_pipeline_event_request_attributes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ def openapi_types(_):
3232

3333
return {
3434
"env": (str,),
35+
"provider_name": (str,),
3536
"resource": (CIAppCreatePipelineEventRequestAttributesResource,),
3637
"service": (str,),
3738
}
3839

3940
attribute_map = {
4041
"env": "env",
42+
"provider_name": "provider_name",
4143
"resource": "resource",
4244
"service": "service",
4345
}
@@ -52,6 +54,7 @@ def __init__(
5254
CIAppPipelineEventStep,
5355
],
5456
env: Union[str, UnsetType] = unset,
57+
provider_name: Union[str, UnsetType] = unset,
5558
service: Union[str, UnsetType] = unset,
5659
**kwargs,
5760
):
@@ -61,6 +64,9 @@ def __init__(
6164
:param env: The Datadog environment.
6265
:type env: str, optional
6366
67+
:param provider_name: The name of the CI provider. By default, this is "custom".
68+
:type provider_name: str, optional
69+
6470
:param resource: Details of the CI pipeline event.
6571
:type resource: CIAppCreatePipelineEventRequestAttributesResource
6672
@@ -69,6 +75,8 @@ def __init__(
6975
"""
7076
if env is not unset:
7177
kwargs["env"] = env
78+
if provider_name is not unset:
79+
kwargs["provider_name"] = provider_name
7280
if service is not unset:
7381
kwargs["service"] = service
7482
super().__init__(kwargs)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-01-08T08:57:29.599Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
interactions:
2+
- request:
3+
body: '{"data":{"attributes":{"provider_name":"example-provider","resource":{"end":"2025-01-08T08:56:59.599Z","git":{"author_email":"[email protected]","repository_url":"https://github.com/DataDog/datadog-agent","sha":"7f263865994b76066c4612fd1965215e7dcb4cd2"},"level":"pipeline","name":"Deploy
4+
to AWS","partial_retry":false,"start":"2025-01-08T08:55:29.599Z","status":"success","unique_id":"3eacb6f3-ff04-4e10-8a9c-46e6d054024a","url":"https://my-ci-provider.example/pipelines/my-pipeline/run/1"}},"type":"cipipeline_resource_request"}}'
5+
headers:
6+
accept:
7+
- application/json
8+
content-type:
9+
- application/json
10+
method: POST
11+
uri: https://api.datadoghq.com/api/v2/ci/pipeline
12+
response:
13+
body:
14+
string: '{"data":null}'
15+
headers:
16+
content-type:
17+
- application/vnd.api+json
18+
status:
19+
code: 202
20+
message: Accepted
21+
version: 1

tests/v2/features/ci_visibility_pipelines.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ Feature: CI Visibility Pipelines
108108
When the request is sent
109109
Then the response status is 202 Request accepted for processing
110110

111+
@team:Datadog/ci-app-backend
112+
Scenario: Send pipeline event with custom provider returns "Request accepted for processing" response
113+
Given new "CreateCIAppPipelineEvent" request
114+
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"}}
115+
When the request is sent
116+
Then the response status is 202 Request accepted for processing
117+
111118
@skip @team:Datadog/ci-app-backend
112119
Scenario: Send pipeline job event returns "Request accepted for processing" response
113120
Given new "CreateCIAppPipelineEvent" request

0 commit comments

Comments
 (0)