Skip to content

Commit

Permalink
Add provider_name attribute to pipelines API (#2345)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <[email protected]>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Jan 21, 2025
1 parent 44a302a commit e668aae
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-01-17 21:41:13.492369",
"spec_repo_commit": "27e609f7"
"regenerated": "2025-01-21 14:16:28.882998",
"spec_repo_commit": "0bbc13ae"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-01-17 21:41:13.506549",
"spec_repo_commit": "27e609f7"
"regenerated": "2025-01-21 14:16:28.896986",
"spec_repo_commit": "0bbc13ae"
}
}
}
3 changes: 3 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3552,6 +3552,9 @@ components:
env:
description: The Datadog environment.
type: string
provider_name:
description: The name of the CI provider. By default, this is "custom".
type: string
resource:
$ref: '#/components/schemas/CIAppCreatePipelineEventRequestAttributesResource'
service:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""
Send pipeline event with custom provider 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_git_info import CIAppGitInfo
from datadog_api_client.v2.model.ci_app_pipeline_event_finished_pipeline import CIAppPipelineEventFinishedPipeline
from datadog_api_client.v2.model.ci_app_pipeline_event_pipeline_level import CIAppPipelineEventPipelineLevel
from datadog_api_client.v2.model.ci_app_pipeline_event_pipeline_status import CIAppPipelineEventPipelineStatus

body = CIAppCreatePipelineEventRequest(
data=CIAppCreatePipelineEventRequestData(
attributes=CIAppCreatePipelineEventRequestAttributes(
provider_name="example-provider",
resource=CIAppPipelineEventFinishedPipeline(
level=CIAppPipelineEventPipelineLevel.PIPELINE,
unique_id="3eacb6f3-ff04-4e10-8a9c-46e6d054024a",
name="Deploy to AWS",
url="https://my-ci-provider.example/pipelines/my-pipeline/run/1",
start=(datetime.now() + relativedelta(seconds=-120)),
end=(datetime.now() + relativedelta(seconds=-30)),
status=CIAppPipelineEventPipelineStatus.SUCCESS,
partial_retry=False,
git=CIAppGitInfo(
repository_url="https://github.com/DataDog/datadog-agent",
sha="7f263865994b76066c4612fd1965215e7dcb4cd2",
author_email="[email protected]",
),
),
),
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)
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ def openapi_types(_):

return {
"env": (str,),
"provider_name": (str,),
"resource": (CIAppCreatePipelineEventRequestAttributesResource,),
"service": (str,),
}

attribute_map = {
"env": "env",
"provider_name": "provider_name",
"resource": "resource",
"service": "service",
}
Expand All @@ -52,6 +54,7 @@ def __init__(
CIAppPipelineEventStep,
],
env: Union[str, UnsetType] = unset,
provider_name: Union[str, UnsetType] = unset,
service: Union[str, UnsetType] = unset,
**kwargs,
):
Expand All @@ -61,6 +64,9 @@ def __init__(
:param env: The Datadog environment.
:type env: str, optional
:param provider_name: The name of the CI provider. By default, this is "custom".
:type provider_name: str, optional
:param resource: Details of the CI pipeline event.
:type resource: CIAppCreatePipelineEventRequestAttributesResource
Expand All @@ -69,6 +75,8 @@ def __init__(
"""
if env is not unset:
kwargs["env"] = env
if provider_name is not unset:
kwargs["provider_name"] = provider_name
if service is not unset:
kwargs["service"] = service
super().__init__(kwargs)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2025-01-08T08:57:29.599Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
interactions:
- request:
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
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"}}'
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
7 changes: 7 additions & 0 deletions tests/v2/features/ci_visibility_pipelines.feature
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ Feature: CI Visibility Pipelines
When the request is sent
Then the response status is 202 Request accepted for processing

@team:Datadog/ci-app-backend
Scenario: Send pipeline event with custom provider returns "Request accepted for processing" response
Given new "CreateCIAppPipelineEvent" request
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"}}
When the request is sent
Then the response status is 202 Request accepted for processing

@skip @team:Datadog/ci-app-backend
Scenario: Send pipeline job event returns "Request accepted for processing" response
Given new "CreateCIAppPipelineEvent" request
Expand Down

0 comments on commit e668aae

Please sign in to comment.