Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:10.807788",
"spec_repo_commit": "27e609f7"
"regenerated": "2025-01-21 14:16:33.643377",
"spec_repo_commit": "0bbc13ae"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-01-17 21:41:10.823634",
"spec_repo_commit": "27e609f7"
"regenerated": "2025-01-21 14:16:33.659202",
"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,67 @@
// Send pipeline event with custom provider returns "Request accepted for
// processing" response
use chrono::{DateTime, Utc};
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_ci_visibility_pipelines::CIVisibilityPipelinesAPI;
use datadog_api_client::datadogV2::model::CIAppCreatePipelineEventRequest;
use datadog_api_client::datadogV2::model::CIAppCreatePipelineEventRequestAttributes;
use datadog_api_client::datadogV2::model::CIAppCreatePipelineEventRequestAttributesResource;
use datadog_api_client::datadogV2::model::CIAppCreatePipelineEventRequestData;
use datadog_api_client::datadogV2::model::CIAppCreatePipelineEventRequestDataType;
use datadog_api_client::datadogV2::model::CIAppGitInfo;
use datadog_api_client::datadogV2::model::CIAppPipelineEventFinishedPipeline;
use datadog_api_client::datadogV2::model::CIAppPipelineEventPipeline;
use datadog_api_client::datadogV2::model::CIAppPipelineEventPipelineLevel;
use datadog_api_client::datadogV2::model::CIAppPipelineEventPipelineStatus;

#[tokio::main]
async fn main() {
let body =
CIAppCreatePipelineEventRequest
::new().data(
CIAppCreatePipelineEventRequestData::new()
.attributes(
CIAppCreatePipelineEventRequestAttributes::new(
CIAppCreatePipelineEventRequestAttributesResource::CIAppPipelineEventPipeline(
Box::new(
CIAppPipelineEventPipeline::CIAppPipelineEventFinishedPipeline(
Box::new(
CIAppPipelineEventFinishedPipeline::new(
DateTime::parse_from_rfc3339("2021-11-11T11:10:41+00:00")
.expect("Failed to parse datetime")
.with_timezone(&Utc),
CIAppPipelineEventPipelineLevel::PIPELINE,
"Deploy to AWS".to_string(),
false,
DateTime::parse_from_rfc3339("2021-11-11T11:09:11+00:00")
.expect("Failed to parse datetime")
.with_timezone(&Utc),
CIAppPipelineEventPipelineStatus::SUCCESS,
"3eacb6f3-ff04-4e10-8a9c-46e6d054024a".to_string(),
"https://my-ci-provider.example/pipelines/my-pipeline/run/1".to_string(),
).git(
Some(
CIAppGitInfo::new(
"[email protected]".to_string(),
"https://github.com/DataDog/datadog-agent".to_string(),
"7f263865994b76066c4612fd1965215e7dcb4cd2".to_string(),
),
),
),
),
),
),
),
).provider_name("example-provider".to_string()),
)
.type_(CIAppCreatePipelineEventRequestDataType::CIPIPELINE_RESOURCE_REQUEST),
);
let configuration = datadog::Configuration::new();
let api = CIVisibilityPipelinesAPI::with_config(configuration);
let resp = api.create_ci_app_pipeline_event(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ pub struct CIAppCreatePipelineEventRequestAttributes {
/// The Datadog environment.
#[serde(rename = "env")]
pub env: Option<String>,
/// The name of the CI provider. By default, this is "custom".
#[serde(rename = "provider_name")]
pub provider_name: Option<String>,
/// Details of the CI pipeline event.
#[serde(rename = "resource")]
pub resource: crate::datadogV2::model::CIAppCreatePipelineEventRequestAttributesResource,
Expand All @@ -33,6 +36,7 @@ impl CIAppCreatePipelineEventRequestAttributes {
) -> CIAppCreatePipelineEventRequestAttributes {
CIAppCreatePipelineEventRequestAttributes {
env: None,
provider_name: None,
resource,
service: None,
additional_properties: std::collections::BTreeMap::new(),
Expand All @@ -45,6 +49,11 @@ impl CIAppCreatePipelineEventRequestAttributes {
self
}

pub fn provider_name(mut self, value: String) -> Self {
self.provider_name = Some(value);
self
}

pub fn service(mut self, value: String) -> Self {
self.service = Some(value);
self
Expand Down Expand Up @@ -77,6 +86,7 @@ impl<'de> Deserialize<'de> for CIAppCreatePipelineEventRequestAttributes {
M: MapAccess<'a>,
{
let mut env: Option<String> = None;
let mut provider_name: Option<String> = None;
let mut resource: Option<
crate::datadogV2::model::CIAppCreatePipelineEventRequestAttributesResource,
> = None;
Expand All @@ -95,6 +105,13 @@ impl<'de> Deserialize<'de> for CIAppCreatePipelineEventRequestAttributes {
}
env = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"provider_name" => {
if v.is_null() {
continue;
}
provider_name =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"resource" => {
resource = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _resource) = resource {
Expand Down Expand Up @@ -123,6 +140,7 @@ impl<'de> Deserialize<'de> for CIAppCreatePipelineEventRequestAttributes {

let content = CIAppCreatePipelineEventRequestAttributes {
env,
provider_name,
resource,
service,
additional_properties,
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,39 @@
{
"http_interactions": [
{
"request": {
"body": {
"string": "{\"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\"}}",
"encoding": null
},
"headers": {
"Accept": [
"application/json"
],
"Content-Type": [
"application/json"
]
},
"method": "post",
"uri": "https://api.datadoghq.com/api/v2/ci/pipeline"
},
"response": {
"body": {
"string": "{\"data\":null}",
"encoding": null
},
"headers": {
"Content-Type": [
"application/vnd.api+json"
]
},
"status": {
"code": 202,
"message": "Accepted"
}
},
"recorded_at": "Wed, 08 Jan 2025 08:57:29 GMT"
}
],
"recorded_with": "VCR 6.0.0"
}
7 changes: 7 additions & 0 deletions tests/scenarios/features/v2/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
Loading