Skip to content

Commit

Permalink
Regenerate client from commit 05535c9b of spec repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ci.datadog-api-spec committed Jan 15, 2025
1 parent 851e958 commit 7012c3d
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 8 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-15 18:03:16.492918",
"spec_repo_commit": "e54847a1"
"regenerated": "2025-01-15 20:49:24.757373",
"spec_repo_commit": "05535c9b"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-01-15 18:03:16.518844",
"spec_repo_commit": "e54847a1"
"regenerated": "2025-01-15 20:49:24.772527",
"spec_repo_commit": "05535c9b"
}
}
}
3 changes: 3 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3382,6 +3382,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
Expand Up @@ -14,6 +14,8 @@ import (
type CIAppCreatePipelineEventRequestAttributes struct {
// The Datadog environment.
Env *string `json:"env,omitempty"`
// The name of the CI provider. By default, this is "custom".
ProviderName *string `json:"provider_name,omitempty"`
// Details of the CI pipeline event.
Resource CIAppCreatePipelineEventRequestAttributesResource `json:"resource"`
// If the CI provider is SaaS, use this to differentiate between instances.
Expand Down Expand Up @@ -69,6 +71,34 @@ func (o *CIAppCreatePipelineEventRequestAttributes) SetEnv(v string) {
o.Env = &v
}

// GetProviderName returns the ProviderName field value if set, zero value otherwise.
func (o *CIAppCreatePipelineEventRequestAttributes) GetProviderName() string {
if o == nil || o.ProviderName == nil {
var ret string
return ret
}
return *o.ProviderName
}

// GetProviderNameOk returns a tuple with the ProviderName field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CIAppCreatePipelineEventRequestAttributes) GetProviderNameOk() (*string, bool) {
if o == nil || o.ProviderName == nil {
return nil, false
}
return o.ProviderName, true
}

// HasProviderName returns a boolean if a field has been set.
func (o *CIAppCreatePipelineEventRequestAttributes) HasProviderName() bool {
return o != nil && o.ProviderName != nil
}

// SetProviderName gets a reference to the given string and assigns it to the ProviderName field.
func (o *CIAppCreatePipelineEventRequestAttributes) SetProviderName(v string) {
o.ProviderName = &v
}

// GetResource returns the Resource field value.
func (o *CIAppCreatePipelineEventRequestAttributes) GetResource() CIAppCreatePipelineEventRequestAttributesResource {
if o == nil {
Expand Down Expand Up @@ -129,6 +159,9 @@ func (o CIAppCreatePipelineEventRequestAttributes) MarshalJSON() ([]byte, error)
if o.Env != nil {
toSerialize["env"] = o.Env
}
if o.ProviderName != nil {
toSerialize["provider_name"] = o.ProviderName
}
toSerialize["resource"] = o.Resource
if o.Service != nil {
toSerialize["service"] = o.Service
Expand All @@ -143,9 +176,10 @@ func (o CIAppCreatePipelineEventRequestAttributes) MarshalJSON() ([]byte, error)
// UnmarshalJSON deserializes the given payload.
func (o *CIAppCreatePipelineEventRequestAttributes) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Env *string `json:"env,omitempty"`
Resource *CIAppCreatePipelineEventRequestAttributesResource `json:"resource"`
Service *string `json:"service,omitempty"`
Env *string `json:"env,omitempty"`
ProviderName *string `json:"provider_name,omitempty"`
Resource *CIAppCreatePipelineEventRequestAttributesResource `json:"resource"`
Service *string `json:"service,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
Expand All @@ -155,11 +189,12 @@ func (o *CIAppCreatePipelineEventRequestAttributes) UnmarshalJSON(bytes []byte)
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"env", "resource", "service"})
datadog.DeleteKeys(additionalProperties, &[]string{"env", "provider_name", "resource", "service"})
} else {
return err
}
o.Env = all.Env
o.ProviderName = all.ProviderName
o.Resource = *all.Resource
o.Service = all.Service

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Send pipeline event with custom provider returns "Request accepted for processing" response

package main

import (
"context"
"encoding/json"
"fmt"
"os"
"time"

"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
body := datadogV2.CIAppCreatePipelineEventRequest{
Data: &datadogV2.CIAppCreatePipelineEventRequestData{
Attributes: &datadogV2.CIAppCreatePipelineEventRequestAttributes{
ProviderName: datadog.PtrString("example-provider"),
Resource: datadogV2.CIAppCreatePipelineEventRequestAttributesResource{
CIAppPipelineEventPipeline: &datadogV2.CIAppPipelineEventPipeline{
CIAppPipelineEventFinishedPipeline: &datadogV2.CIAppPipelineEventFinishedPipeline{
Level: datadogV2.CIAPPPIPELINEEVENTPIPELINELEVEL_PIPELINE,
UniqueId: "3eacb6f3-ff04-4e10-8a9c-46e6d054024a",
Name: "Deploy to AWS",
Url: "https://my-ci-provider.example/pipelines/my-pipeline/run/1",
Start: time.Now().Add(time.Second * -120),
End: time.Now().Add(time.Second * -30),
Status: datadogV2.CIAPPPIPELINEEVENTPIPELINESTATUS_SUCCESS,
PartialRetry: false,
Git: *datadogV2.NewNullableCIAppGitInfo(&datadogV2.CIAppGitInfo{
RepositoryUrl: "https://github.com/DataDog/datadog-agent",
Sha: "7f263865994b76066c4612fd1965215e7dcb4cd2",
AuthorEmail: "[email protected]",
}),
}}},
},
Type: datadogV2.CIAPPCREATEPIPELINEEVENTREQUESTDATATYPE_CIPIPELINE_RESOURCE_REQUEST.Ptr(),
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewCIVisibilityPipelinesApi(apiClient)
resp, r, err := api.CreateCIAppPipelineEvent(ctx, body)

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CIVisibilityPipelinesApi.CreateCIAppPipelineEvent`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}

responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `CIVisibilityPipelinesApi.CreateCIAppPipelineEvent`:\n%s\n", responseContent)
}
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,22 @@
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"}}
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
id: 0
method: POST
url: https://api.datadoghq.com/api/v2/ci/pipeline
response:
body: '{"data":null}'
code: 202
duration: 0ms
headers:
Content-Type:
- application/vnd.api+json
status: 202 Accepted
version: 2
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

0 comments on commit 7012c3d

Please sign in to comment.