Skip to content

Commit

Permalink
Add customer_impact_scope to fields (#1974)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored May 1, 2023
1 parent 44c41ac commit 45e4a38
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 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.4",
"regenerated": "2023-05-01 17:21:09.100467",
"spec_repo_commit": "4d58341b"
"regenerated": "2023-05-01 17:53:03.795424",
"spec_repo_commit": "6b2e8b39"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2023-05-01 17:21:09.113264",
"spec_repo_commit": "4d58341b"
"regenerated": "2023-05-01 17:53:03.813726",
"spec_repo_commit": "6b2e8b39"
}
}
}
5 changes: 5 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4498,6 +4498,11 @@ components:
IncidentCreateAttributes:
description: The incident's attributes for a create request.
properties:
customer_impact_scope:
description: Required if `customer_impacted:"true"`. A summary of the impact
customers experienced during the incident.
example: Example customer impact scope
type: string
customer_impacted:
description: A flag indicating whether the incident caused customer impact.
example: false
Expand Down
37 changes: 36 additions & 1 deletion api/datadogV2/model_incident_create_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (

// IncidentCreateAttributes The incident's attributes for a create request.
type IncidentCreateAttributes struct {
// Required if `customer_impacted:"true"`. A summary of the impact customers experienced during the incident.
CustomerImpactScope *string `json:"customer_impact_scope,omitempty"`
// A flag indicating whether the incident caused customer impact.
CustomerImpacted bool `json:"customer_impacted"`
// A condensed view of the user-defined fields for which to create initial selections.
Expand Down Expand Up @@ -47,6 +49,34 @@ func NewIncidentCreateAttributesWithDefaults() *IncidentCreateAttributes {
return &this
}

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

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

// HasCustomerImpactScope returns a boolean if a field has been set.
func (o *IncidentCreateAttributes) HasCustomerImpactScope() bool {
return o != nil && o.CustomerImpactScope != nil
}

// SetCustomerImpactScope gets a reference to the given string and assigns it to the CustomerImpactScope field.
func (o *IncidentCreateAttributes) SetCustomerImpactScope(v string) {
o.CustomerImpactScope = &v
}

// GetCustomerImpacted returns the CustomerImpacted field value.
func (o *IncidentCreateAttributes) GetCustomerImpacted() bool {
if o == nil {
Expand Down Expand Up @@ -183,6 +213,9 @@ func (o IncidentCreateAttributes) MarshalJSON() ([]byte, error) {
if o.UnparsedObject != nil {
return json.Marshal(o.UnparsedObject)
}
if o.CustomerImpactScope != nil {
toSerialize["customer_impact_scope"] = o.CustomerImpactScope
}
toSerialize["customer_impacted"] = o.CustomerImpacted
if o.Fields != nil {
toSerialize["fields"] = o.Fields
Expand All @@ -209,6 +242,7 @@ func (o *IncidentCreateAttributes) UnmarshalJSON(bytes []byte) (err error) {
Title *string `json:"title"`
}{}
all := struct {
CustomerImpactScope *string `json:"customer_impact_scope,omitempty"`
CustomerImpacted bool `json:"customer_impacted"`
Fields map[string]IncidentFieldAttributes `json:"fields,omitempty"`
InitialCells []IncidentTimelineCellCreateAttributes `json:"initial_cells,omitempty"`
Expand Down Expand Up @@ -236,10 +270,11 @@ func (o *IncidentCreateAttributes) UnmarshalJSON(bytes []byte) (err error) {
}
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"customer_impacted", "fields", "initial_cells", "notification_handles", "title"})
datadog.DeleteKeys(additionalProperties, &[]string{"customer_impact_scope", "customer_impacted", "fields", "initial_cells", "notification_handles", "title"})
} else {
return err
}
o.CustomerImpactScope = all.CustomerImpactScope
o.CustomerImpacted = all.CustomerImpacted
o.Fields = all.Fields
o.InitialCells = all.InitialCells
Expand Down
4 changes: 2 additions & 2 deletions tests/scenarios/features/v2/incidents.feature
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Feature: Incidents
Scenario: Create an incident returns "Bad Request" response
Given operation "CreateIncident" enabled
And new "CreateIncident" request
And body with value {"data": {"attributes": {"customer_impacted": false, "fields": {"severity": {"type": "dropdown", "value": "SEV-5"}}, "initial_cells": [{"cell_type": "markdown", "content": {"content": "An example timeline cell message."}, "important": false}], "notification_handles": [{"display_name": "Jane Doe", "handle": "@test.user@test.com"}], "title": "A test incident title"}, "relationships": {"commander_user": {"data": {"id": "00000000-0000-0000-0000-000000000000", "type": "users"}}}, "type": "incidents"}}
And body with value {"data": {"attributes": {"customer_impact_scope": "Example customer impact scope", "customer_impacted": false, "fields": {"severity": {"type": "dropdown", "value": "SEV-5"}}, "initial_cells": [{"cell_type": "markdown", "content": {"content": "An example timeline cell message."}, "important": false}], "notification_handles": [{"display_name": "Jane Doe", "handle": "@test.user@test.com"}], "title": "A test incident title"}, "relationships": {"commander_user": {"data": {"id": "00000000-0000-0000-0000-000000000000", "type": "users"}}}, "type": "incidents"}}
When the request is sent
Then the response status is 400 Bad Request

Expand All @@ -86,7 +86,7 @@ Feature: Incidents
Scenario: Create an incident returns "Not Found" response
Given operation "CreateIncident" enabled
And new "CreateIncident" request
And body with value {"data": {"attributes": {"customer_impacted": false, "fields": {"severity": {"type": "dropdown", "value": "SEV-5"}}, "initial_cells": [{"cell_type": "markdown", "content": {"content": "An example timeline cell message."}, "important": false}], "notification_handles": [{"display_name": "Jane Doe", "handle": "@test.user@test.com"}], "title": "A test incident title"}, "relationships": {"commander_user": {"data": {"id": "00000000-0000-0000-0000-000000000000", "type": "users"}}}, "type": "incidents"}}
And body with value {"data": {"attributes": {"customer_impact_scope": "Example customer impact scope", "customer_impacted": false, "fields": {"severity": {"type": "dropdown", "value": "SEV-5"}}, "initial_cells": [{"cell_type": "markdown", "content": {"content": "An example timeline cell message."}, "important": false}], "notification_handles": [{"display_name": "Jane Doe", "handle": "@test.user@test.com"}], "title": "A test incident title"}, "relationships": {"commander_user": {"data": {"id": "00000000-0000-0000-0000-000000000000", "type": "users"}}}, "type": "incidents"}}
When the request is sent
Then the response status is 404 Not Found

Expand Down

0 comments on commit 45e4a38

Please sign in to comment.