Skip to content

Commit

Permalink
Update spec for DORA Metrics Incident endpoint (#2381)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Feb 14, 2024
1 parent e4db190 commit 385f52d
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 44 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": "2024-02-12 17:39:25.538669",
"spec_repo_commit": "3cda457d"
"regenerated": "2024-02-14 10:50:03.602357",
"spec_repo_commit": "9348385b"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-02-12 17:39:25.567065",
"spec_repo_commit": "3cda457d"
"regenerated": "2024-02-14 10:50:03.618501",
"spec_repo_commit": "9348385b"
}
}
}
24 changes: 17 additions & 7 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5425,16 +5425,21 @@ components:
git:
$ref: '#/components/schemas/DORAGitInfo'
id:
description: Incident ID
description: Incident ID. Required to update a previously sent incident.
type: string
name:
description: Incident name.
example: Webserver is down failing all requests
type: string
service:
description: Service name from a service available in the Service Catalog.
example: shopist
example: Webserver is down failing all requests.
type: string
services:
description: Service names impacted by the incident. If possible, use names
registered in the Service Catalog. Required when the team field is not
provided.
example:
- shopist
items:
type: string
type: array
severity:
description: Incident severity.
example: High
Expand All @@ -5444,12 +5449,17 @@ components:
example: 1693491974000000000
format: int64
type: integer
team:
description: Name of the team owning the services impacted. If possible,
use team handles registered in Datadog. Required when the services field
is not provided.
example: backend
type: string
version:
description: Version to correlate with [APM Deployment Tracking](https://docs.datadoghq.com/tracing/services/deployment_tracking/).
example: v1.12.07
type: string
required:
- service
- started_at
type: object
DORAIncidentRequestData:
Expand Down
86 changes: 62 additions & 24 deletions api/datadogV2/model_dora_incident_request_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ type DORAIncidentRequestAttributes struct {
FinishedAt *int64 `json:"finished_at,omitempty"`
// Git info for DORA Metrics events.
Git *DORAGitInfo `json:"git,omitempty"`
// Incident ID
// Incident ID. Required to update a previously sent incident.
Id *string `json:"id,omitempty"`
// Incident name.
Name *string `json:"name,omitempty"`
// Service name from a service available in the Service Catalog.
Service string `json:"service"`
// Service names impacted by the incident. If possible, use names registered in the Service Catalog. Required when the team field is not provided.
Services []string `json:"services,omitempty"`
// Incident severity.
Severity *string `json:"severity,omitempty"`
// Unix timestamp in nanoseconds when the incident started.
StartedAt int64 `json:"started_at"`
// Name of the team owning the services impacted. If possible, use team handles registered in Datadog. Required when the services field is not provided.
Team *string `json:"team,omitempty"`
// Version to correlate with [APM Deployment Tracking](https://docs.datadoghq.com/tracing/services/deployment_tracking/).
Version *string `json:"version,omitempty"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
Expand All @@ -39,9 +41,8 @@ type DORAIncidentRequestAttributes struct {
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed.
func NewDORAIncidentRequestAttributes(service string, startedAt int64) *DORAIncidentRequestAttributes {
func NewDORAIncidentRequestAttributes(startedAt int64) *DORAIncidentRequestAttributes {
this := DORAIncidentRequestAttributes{}
this.Service = service
this.StartedAt = startedAt
return &this
}
Expand Down Expand Up @@ -194,27 +195,32 @@ func (o *DORAIncidentRequestAttributes) SetName(v string) {
o.Name = &v
}

// GetService returns the Service field value.
func (o *DORAIncidentRequestAttributes) GetService() string {
if o == nil {
var ret string
// GetServices returns the Services field value if set, zero value otherwise.
func (o *DORAIncidentRequestAttributes) GetServices() []string {
if o == nil || o.Services == nil {
var ret []string
return ret
}
return o.Service
return o.Services
}

// GetServiceOk returns a tuple with the Service field value
// GetServicesOk returns a tuple with the Services field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *DORAIncidentRequestAttributes) GetServiceOk() (*string, bool) {
if o == nil {
func (o *DORAIncidentRequestAttributes) GetServicesOk() (*[]string, bool) {
if o == nil || o.Services == nil {
return nil, false
}
return &o.Service, true
return &o.Services, true
}

// SetService sets field value.
func (o *DORAIncidentRequestAttributes) SetService(v string) {
o.Service = v
// HasServices returns a boolean if a field has been set.
func (o *DORAIncidentRequestAttributes) HasServices() bool {
return o != nil && o.Services != nil
}

// SetServices gets a reference to the given []string and assigns it to the Services field.
func (o *DORAIncidentRequestAttributes) SetServices(v []string) {
o.Services = v
}

// GetSeverity returns the Severity field value if set, zero value otherwise.
Expand Down Expand Up @@ -268,6 +274,34 @@ func (o *DORAIncidentRequestAttributes) SetStartedAt(v int64) {
o.StartedAt = v
}

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

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

// HasTeam returns a boolean if a field has been set.
func (o *DORAIncidentRequestAttributes) HasTeam() bool {
return o != nil && o.Team != nil
}

// SetTeam gets a reference to the given string and assigns it to the Team field.
func (o *DORAIncidentRequestAttributes) SetTeam(v string) {
o.Team = &v
}

// GetVersion returns the Version field value if set, zero value otherwise.
func (o *DORAIncidentRequestAttributes) GetVersion() string {
if o == nil || o.Version == nil {
Expand Down Expand Up @@ -317,11 +351,16 @@ func (o DORAIncidentRequestAttributes) MarshalJSON() ([]byte, error) {
if o.Name != nil {
toSerialize["name"] = o.Name
}
toSerialize["service"] = o.Service
if o.Services != nil {
toSerialize["services"] = o.Services
}
if o.Severity != nil {
toSerialize["severity"] = o.Severity
}
toSerialize["started_at"] = o.StartedAt
if o.Team != nil {
toSerialize["team"] = o.Team
}
if o.Version != nil {
toSerialize["version"] = o.Version
}
Expand All @@ -340,23 +379,21 @@ func (o *DORAIncidentRequestAttributes) UnmarshalJSON(bytes []byte) (err error)
Git *DORAGitInfo `json:"git,omitempty"`
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Service *string `json:"service"`
Services []string `json:"services,omitempty"`
Severity *string `json:"severity,omitempty"`
StartedAt *int64 `json:"started_at"`
Team *string `json:"team,omitempty"`
Version *string `json:"version,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
if all.Service == nil {
return fmt.Errorf("required field service missing")
}
if all.StartedAt == nil {
return fmt.Errorf("required field started_at missing")
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"env", "finished_at", "git", "id", "name", "service", "severity", "started_at", "version"})
datadog.DeleteKeys(additionalProperties, &[]string{"env", "finished_at", "git", "id", "name", "services", "severity", "started_at", "team", "version"})
} else {
return err
}
Expand All @@ -370,9 +407,10 @@ func (o *DORAIncidentRequestAttributes) UnmarshalJSON(bytes []byte) (err error)
o.Git = all.Git
o.Id = all.Id
o.Name = all.Name
o.Service = *all.Service
o.Services = all.Services
o.Severity = all.Severity
o.StartedAt = *all.StartedAt
o.Team = all.Team
o.Version = all.Version

if len(additionalProperties) > 0 {
Expand Down
11 changes: 7 additions & 4 deletions examples/v2/dora-metrics/CreateDORAIncident.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ func main() {
body := datadogV2.DORAIncidentRequest{
Data: datadogV2.DORAIncidentRequestData{
Attributes: datadogV2.DORAIncidentRequestAttributes{
FinishedAt: datadog.PtrInt64(1693491984000000000),
FinishedAt: datadog.PtrInt64(1707842944600000000),
Git: &datadogV2.DORAGitInfo{
CommitSha: "66adc9350f2cc9b250b69abddab733dd55e1a588",
RepositoryUrl: "https://github.com/organization/example-repository",
},
Name: datadog.PtrString("Webserver is down failing all requests"),
Service: "shopist",
Name: datadog.PtrString("Webserver is down failing all requests"),
Services: []string{
"shopist",
},
Severity: datadog.PtrString("High"),
StartedAt: 1693491974000000000,
StartedAt: 1707842944500000000,
Team: datadog.PtrString("backend"),
Version: datadog.PtrString("v1.12.07"),
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-11-16T16:58:35.716Z
2024-02-13T16:54:07.556Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: |
{"data":{"attributes":{"finished_at":1693491984000000000,"git":{"commit_sha":"66adc9350f2cc9b250b69abddab733dd55e1a588","repository_url":"https://github.com/organization/example-repository"},"name":"Webserver is down failing all requests","service":"shopist","severity":"High","started_at":1693491974000000000,"version":"v1.12.07"}}}
{"data":{"attributes":{"finished_at":1707842944600000000,"git":{"commit_sha":"66adc9350f2cc9b250b69abddab733dd55e1a588","repository_url":"https://github.com/organization/example-repository"},"name":"Webserver is down failing all requests","services":["shopist"],"severity":"High","started_at":1707842944500000000,"team":"backend","version":"v1.12.07"}}}
form: {}
headers:
Accept:
Expand All @@ -12,7 +12,7 @@ interactions:
method: POST
url: https://api.datadoghq.com/api/v2/dora/incident
response:
body: '{"data":{"id":"2a47b5f25b160b8a","type":"dora_incident"}}'
body: '{"data":{"id":"2775a2d3-6c28-4934-ae60-0ef9ce3720ee","type":"dora_incident"}}'
code: 200
duration: 0ms
headers:
Expand Down
4 changes: 2 additions & 2 deletions tests/scenarios/features/v2/dora_metrics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ Feature: DORA Metrics
Scenario: Send an incident event for DORA Metrics returns "OK - but delayed due to incident" response
Given operation "CreateDORAIncident" enabled
And new "CreateDORAIncident" request
And body with value {"data": {"attributes": {"env": "staging", "finished_at": 1693491984000000000, "git": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_url": "https://github.com/organization/example-repository"}, "name": "Webserver is down failing all requests", "service": "shopist", "severity": "High", "started_at": 1693491974000000000, "version": "v1.12.07"}}}
And body with value {"data": {"attributes": {"env": "staging", "finished_at": 1693491984000000000, "git": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_url": "https://github.com/organization/example-repository"}, "name": "Webserver is down failing all requests.", "services": ["shopist"], "severity": "High", "started_at": 1693491974000000000, "team": "backend", "version": "v1.12.07"}}}
When the request is sent
Then the response status is 202 OK - but delayed due to incident

@replay-only @team:Datadog/ci-app-backend @team:Datadog/integrations-tools-and-libraries
Scenario: Send an incident event for DORA Metrics returns "OK" response
Given operation "CreateDORAIncident" enabled
And new "CreateDORAIncident" request
And body with value {"data": {"attributes": {"finished_at": 1693491984000000000, "git": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_url": "https://github.com/organization/example-repository"}, "name": "Webserver is down failing all requests", "service": "shopist", "severity": "High", "started_at": 1693491974000000000, "version": "v1.12.07"}}}
And body with value {"data": {"attributes": {"finished_at": 1707842944600000000, "git": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_url": "https://github.com/organization/example-repository"}, "name": "Webserver is down failing all requests", "services": ["shopist"], "severity": "High", "started_at": 1707842944500000000, "team": "backend", "version": "v1.12.07"}}}
When the request is sent
Then the response status is 200 OK

0 comments on commit 385f52d

Please sign in to comment.