Skip to content

Commit 0f3ca10

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Update /api/v2/cases endpoint to add custom attributes support (DataDog#3558)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 2eca59e commit 0f3ca10

47 files changed

Lines changed: 212 additions & 133 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.generator/schemas/v2/openapi.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9168,6 +9168,11 @@ components:
91689168
CaseCreateAttributes:
91699169
description: Case creation attributes
91709170
properties:
9171+
custom_attributes:
9172+
additionalProperties:
9173+
$ref: '#/components/schemas/CustomAttributeValue'
9174+
description: Case custom attributes
9175+
type: object
91719176
description:
91729177
description: Description
91739178
type: string
@@ -14712,30 +14717,32 @@ components:
1471214717
type: number
1471314718
type: array
1471414719
CustomAttributeMultiStringValue:
14715-
description: Value of multi TEXT/URL custom attribute
14720+
description: Value of multi TEXT/URL/SELECT custom attribute
1471614721
items:
14717-
description: TEXT/URL Value
14722+
description: TEXT/URL/SELECT Value
1471814723
type: string
1471914724
type: array
1472014725
CustomAttributeNumberValue:
1472114726
description: Value of NUMBER custom attribute
1472214727
format: double
1472314728
type: number
1472414729
CustomAttributeStringValue:
14725-
description: Value of TEXT/URL custom attribute
14730+
description: Value of TEXT/URL/SELECT custom attribute
1472614731
type: string
1472714732
CustomAttributeType:
1472814733
description: Custom attributes type
1472914734
enum:
1473014735
- URL
1473114736
- TEXT
1473214737
- NUMBER
14738+
- SELECT
1473314739
example: NUMBER
1473414740
type: string
1473514741
x-enum-varnames:
1473614742
- URL
1473714743
- TEXT
1473814744
- NUMBER
14745+
- SELECT
1473914746
CustomAttributeValue:
1474014747
description: Custom attribute values
1474114748
properties:

api/datadogV2/model_case_create_attributes.go

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212

1313
// CaseCreateAttributes Case creation attributes
1414
type CaseCreateAttributes struct {
15+
// Case custom attributes
16+
CustomAttributes map[string]CustomAttributeValue `json:"custom_attributes,omitempty"`
1517
// Description
1618
Description *string `json:"description,omitempty"`
1719
// Case priority
@@ -48,6 +50,34 @@ func NewCaseCreateAttributesWithDefaults() *CaseCreateAttributes {
4850
return &this
4951
}
5052

53+
// GetCustomAttributes returns the CustomAttributes field value if set, zero value otherwise.
54+
func (o *CaseCreateAttributes) GetCustomAttributes() map[string]CustomAttributeValue {
55+
if o == nil || o.CustomAttributes == nil {
56+
var ret map[string]CustomAttributeValue
57+
return ret
58+
}
59+
return o.CustomAttributes
60+
}
61+
62+
// GetCustomAttributesOk returns a tuple with the CustomAttributes field value if set, nil otherwise
63+
// and a boolean to check if the value has been set.
64+
func (o *CaseCreateAttributes) GetCustomAttributesOk() (*map[string]CustomAttributeValue, bool) {
65+
if o == nil || o.CustomAttributes == nil {
66+
return nil, false
67+
}
68+
return &o.CustomAttributes, true
69+
}
70+
71+
// HasCustomAttributes returns a boolean if a field has been set.
72+
func (o *CaseCreateAttributes) HasCustomAttributes() bool {
73+
return o != nil && o.CustomAttributes != nil
74+
}
75+
76+
// SetCustomAttributes gets a reference to the given map[string]CustomAttributeValue and assigns it to the CustomAttributes field.
77+
func (o *CaseCreateAttributes) SetCustomAttributes(v map[string]CustomAttributeValue) {
78+
o.CustomAttributes = v
79+
}
80+
5181
// GetDescription returns the Description field value if set, zero value otherwise.
5282
func (o *CaseCreateAttributes) GetDescription() string {
5383
if o == nil || o.Description == nil {
@@ -156,6 +186,9 @@ func (o CaseCreateAttributes) MarshalJSON() ([]byte, error) {
156186
if o.UnparsedObject != nil {
157187
return datadog.Marshal(o.UnparsedObject)
158188
}
189+
if o.CustomAttributes != nil {
190+
toSerialize["custom_attributes"] = o.CustomAttributes
191+
}
159192
if o.Description != nil {
160193
toSerialize["description"] = o.Description
161194
}
@@ -174,10 +207,11 @@ func (o CaseCreateAttributes) MarshalJSON() ([]byte, error) {
174207
// UnmarshalJSON deserializes the given payload.
175208
func (o *CaseCreateAttributes) UnmarshalJSON(bytes []byte) (err error) {
176209
all := struct {
177-
Description *string `json:"description,omitempty"`
178-
Priority *CasePriority `json:"priority,omitempty"`
179-
Title *string `json:"title"`
180-
TypeId *string `json:"type_id"`
210+
CustomAttributes map[string]CustomAttributeValue `json:"custom_attributes,omitempty"`
211+
Description *string `json:"description,omitempty"`
212+
Priority *CasePriority `json:"priority,omitempty"`
213+
Title *string `json:"title"`
214+
TypeId *string `json:"type_id"`
181215
}{}
182216
if err = datadog.Unmarshal(bytes, &all); err != nil {
183217
return datadog.Unmarshal(bytes, &o.UnparsedObject)
@@ -190,12 +224,13 @@ func (o *CaseCreateAttributes) UnmarshalJSON(bytes []byte) (err error) {
190224
}
191225
additionalProperties := make(map[string]interface{})
192226
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
193-
datadog.DeleteKeys(additionalProperties, &[]string{"description", "priority", "title", "type_id"})
227+
datadog.DeleteKeys(additionalProperties, &[]string{"custom_attributes", "description", "priority", "title", "type_id"})
194228
} else {
195229
return err
196230
}
197231

198232
hasInvalidField := false
233+
o.CustomAttributes = all.CustomAttributes
199234
o.Description = all.Description
200235
if all.Priority != nil && !all.Priority.IsValid() {
201236
hasInvalidField = true

api/datadogV2/model_custom_attribute_type.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ const (
1818
CUSTOMATTRIBUTETYPE_URL CustomAttributeType = "URL"
1919
CUSTOMATTRIBUTETYPE_TEXT CustomAttributeType = "TEXT"
2020
CUSTOMATTRIBUTETYPE_NUMBER CustomAttributeType = "NUMBER"
21+
CUSTOMATTRIBUTETYPE_SELECT CustomAttributeType = "SELECT"
2122
)
2223

2324
var allowedCustomAttributeTypeEnumValues = []CustomAttributeType{
2425
CUSTOMATTRIBUTETYPE_URL,
2526
CUSTOMATTRIBUTETYPE_TEXT,
2627
CUSTOMATTRIBUTETYPE_NUMBER,
28+
CUSTOMATTRIBUTETYPE_SELECT,
2729
}
2830

2931
// GetAllowedValues reeturns the list of possible values.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-10-01T12:46:29.817Z
1+
2025-12-30T13:49:44.747Z

tests/scenarios/cassettes/TestScenarios/v2/Feature_Case_Management/Scenario_Archive_case_returns_Bad_Request_response.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ interactions:
1212
method: POST
1313
url: https://api.datadoghq.com/api/v2/cases
1414
response:
15-
body: '{"data":{"id":"3601878d-b851-43b6-900f-0deb35e536d7","type":"case","attributes":{"attributes":{},"comment_count":0,"created_at":"2025-10-01T12:46:30.261735Z","creation_source":"MANUAL","custom_attributes":{},"description":"","insights":[],"internal_id":"3601878d-b851-43b6-900f-0deb35e536d7","key":"DDFC-82968","merge_status":"NOT_MERGED","priority":"P4","public_id":"83056","status":"OPEN","status_name":"Open","title":"My
16-
new case","type":"STANDARD","type_id":"00000000-0000-0000-0000-000000000001"},"relationships":{"created_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user"}},"project":{"data":{"id":"d4bbe1af-f36e-42f1-87c1-493ca35c320e","type":"project"}}}},"included":[{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user","attributes":{"active":true,"email":"frog@datadoghq.com","handle":"frog@datadoghq.com","name":"frog"}}]}'
15+
body: '{"data":{"id":"e3f011bc-8ae6-4ec2-b80d-3069e73bc6a1","type":"case","attributes":{"attributes":{},"comment_count":0,"created_at":"2025-12-30T13:49:45.033566Z","creation_source":"MANUAL","custom_attributes":{},"description":"","insights":[],"internal_id":"e3f011bc-8ae6-4ec2-b80d-3069e73bc6a1","key":"DDFC-98805","merge_status":"NOT_MERGED","priority":"P4","public_id":"99261","status":"OPEN","status_group":"SG_OPEN","status_name":"Open","title":"My
16+
new case","type":"STANDARD","type_id":"00000000-0000-0000-0000-000000000001"},"relationships":{"created_by":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"user"}},"project":{"data":{"id":"d4bbe1af-f36e-42f1-87c1-493ca35c320e","type":"project"}}}},"included":[{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"user","attributes":{"active":true,"email":"team-intg-tools-libs-spam@datadoghq.com","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI
17+
Account"}}]}'
1718
code: 201
1819
duration: 0ms
1920
headers:
@@ -31,7 +32,7 @@ interactions:
3132
- application/json
3233
id: 1
3334
method: POST
34-
url: https://api.datadoghq.com/api/v2/cases/3601878d-b851-43b6-900f-0deb35e536d7/archive
35+
url: https://api.datadoghq.com/api/v2/cases/e3f011bc-8ae6-4ec2-b80d-3069e73bc6a1/archive
3536
response:
3637
body: '{"errors":[{"status":"400","title":"Bad Request","detail":"got type \"project\"
3738
expected one of \"case\""}]}'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-10-01T12:46:31.029Z
1+
2025-12-30T13:49:45.212Z

tests/scenarios/cassettes/TestScenarios/v2/Feature_Case_Management/Scenario_Archive_case_returns_OK_response.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ interactions:
1212
method: POST
1313
url: https://api.datadoghq.com/api/v2/cases
1414
response:
15-
body: '{"data":{"id":"b5cf9b44-cb77-4487-a436-0e3ef4e88d49","type":"case","attributes":{"attributes":{},"comment_count":0,"created_at":"2025-10-01T12:46:31.456149Z","creation_source":"MANUAL","custom_attributes":{},"description":"","insights":[],"internal_id":"b5cf9b44-cb77-4487-a436-0e3ef4e88d49","key":"DDFC-82969","merge_status":"NOT_MERGED","priority":"P4","public_id":"83057","status":"OPEN","status_name":"Open","title":"My
16-
new case","type":"STANDARD","type_id":"00000000-0000-0000-0000-000000000001"},"relationships":{"created_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user"}},"project":{"data":{"id":"d4bbe1af-f36e-42f1-87c1-493ca35c320e","type":"project"}}}},"included":[{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user","attributes":{"active":true,"email":"frog@datadoghq.com","handle":"frog@datadoghq.com","name":"frog"}}]}'
15+
body: '{"data":{"id":"926e6b8a-4af6-43b2-8a29-33813af68594","type":"case","attributes":{"attributes":{},"comment_count":0,"created_at":"2025-12-30T13:49:45.269528Z","creation_source":"MANUAL","custom_attributes":{},"description":"","insights":[],"internal_id":"926e6b8a-4af6-43b2-8a29-33813af68594","key":"DDFC-98806","merge_status":"NOT_MERGED","priority":"P4","public_id":"99262","status":"OPEN","status_group":"SG_OPEN","status_name":"Open","title":"My
16+
new case","type":"STANDARD","type_id":"00000000-0000-0000-0000-000000000001"},"relationships":{"created_by":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"user"}},"project":{"data":{"id":"d4bbe1af-f36e-42f1-87c1-493ca35c320e","type":"project"}}}},"included":[{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"user","attributes":{"active":true,"email":"team-intg-tools-libs-spam@datadoghq.com","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI
17+
Account"}}]}'
1718
code: 201
1819
duration: 0ms
1920
headers:
@@ -31,10 +32,11 @@ interactions:
3132
- application/json
3233
id: 1
3334
method: POST
34-
url: https://api.datadoghq.com/api/v2/cases/b5cf9b44-cb77-4487-a436-0e3ef4e88d49/archive
35+
url: https://api.datadoghq.com/api/v2/cases/926e6b8a-4af6-43b2-8a29-33813af68594/archive
3536
response:
36-
body: '{"data":{"id":"b5cf9b44-cb77-4487-a436-0e3ef4e88d49","type":"case","attributes":{"archived_at":"2025-10-01T12:46:31.920596976Z","attributes":{},"comment_count":0,"created_at":"2025-10-01T12:46:31.456149Z","creation_source":"MANUAL","custom_attributes":{},"description":"","insights":[],"internal_id":"b5cf9b44-cb77-4487-a436-0e3ef4e88d49","key":"DDFC-82969","merge_status":"NOT_MERGED","modified_at":"2025-10-01T12:46:31.920597Z","priority":"P4","public_id":"83057","status":"OPEN","status_name":"Open","title":"My
37-
new case","type":"STANDARD","type_id":"00000000-0000-0000-0000-000000000001"},"relationships":{"created_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user"}},"modified_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user"}},"project":{"data":{"id":"d4bbe1af-f36e-42f1-87c1-493ca35c320e","type":"project"}}}},"included":[{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user","attributes":{"active":true,"email":"frog@datadoghq.com","handle":"frog@datadoghq.com","name":"frog"}}]}'
37+
body: '{"data":{"id":"926e6b8a-4af6-43b2-8a29-33813af68594","type":"case","attributes":{"archived_at":"2025-12-30T13:49:45.40368576Z","attributes":{},"comment_count":0,"created_at":"2025-12-30T13:49:45.269528Z","creation_source":"MANUAL","custom_attributes":{},"description":"","insights":[],"internal_id":"926e6b8a-4af6-43b2-8a29-33813af68594","key":"DDFC-98806","merge_status":"NOT_MERGED","modified_at":"2025-12-30T13:49:45.403686Z","priority":"P4","public_id":"99262","status":"OPEN","status_group":"SG_OPEN","status_name":"Open","title":"My
38+
new case","type":"STANDARD","type_id":"00000000-0000-0000-0000-000000000001"},"relationships":{"created_by":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"user"}},"modified_by":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"user"}},"project":{"data":{"id":"d4bbe1af-f36e-42f1-87c1-493ca35c320e","type":"project"}}}},"included":[{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"user","attributes":{"active":true,"email":"team-intg-tools-libs-spam@datadoghq.com","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI
39+
Account"}}]}'
3840
code: 200
3941
duration: 0ms
4042
headers:
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-10-01T12:46:31.968Z
1+
2025-12-30T13:49:45.450Z

tests/scenarios/cassettes/TestScenarios/v2/Feature_Case_Management/Scenario_Assign_case_returns_Bad_Request_response.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ interactions:
1212
method: POST
1313
url: https://api.datadoghq.com/api/v2/cases
1414
response:
15-
body: '{"data":{"id":"1beeecc8-5c4f-4194-a785-e5c60234e263","type":"case","attributes":{"attributes":{},"comment_count":0,"created_at":"2025-10-01T12:46:32.453117Z","creation_source":"MANUAL","custom_attributes":{},"description":"","insights":[],"internal_id":"1beeecc8-5c4f-4194-a785-e5c60234e263","key":"DDFC-82970","merge_status":"NOT_MERGED","priority":"P4","public_id":"83058","status":"OPEN","status_name":"Open","title":"My
16-
new case","type":"STANDARD","type_id":"00000000-0000-0000-0000-000000000001"},"relationships":{"created_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user"}},"project":{"data":{"id":"d4bbe1af-f36e-42f1-87c1-493ca35c320e","type":"project"}}}},"included":[{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user","attributes":{"active":true,"email":"frog@datadoghq.com","handle":"frog@datadoghq.com","name":"frog"}}]}'
15+
body: '{"data":{"id":"b3cef7a0-9637-43fb-88cf-d9ac56310a7b","type":"case","attributes":{"attributes":{},"comment_count":0,"created_at":"2025-12-30T13:49:45.508531Z","creation_source":"MANUAL","custom_attributes":{},"description":"","insights":[],"internal_id":"b3cef7a0-9637-43fb-88cf-d9ac56310a7b","key":"DDFC-98807","merge_status":"NOT_MERGED","priority":"P4","public_id":"99263","status":"OPEN","status_group":"SG_OPEN","status_name":"Open","title":"My
16+
new case","type":"STANDARD","type_id":"00000000-0000-0000-0000-000000000001"},"relationships":{"created_by":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"user"}},"project":{"data":{"id":"d4bbe1af-f36e-42f1-87c1-493ca35c320e","type":"project"}}}},"included":[{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"user","attributes":{"active":true,"email":"team-intg-tools-libs-spam@datadoghq.com","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI
17+
Account"}}]}'
1718
code: 201
1819
duration: 0ms
1920
headers:
@@ -31,7 +32,7 @@ interactions:
3132
- application/json
3233
id: 1
3334
method: POST
34-
url: https://api.datadoghq.com/api/v2/cases/1beeecc8-5c4f-4194-a785-e5c60234e263/assign
35+
url: https://api.datadoghq.com/api/v2/cases/b3cef7a0-9637-43fb-88cf-d9ac56310a7b/assign
3536
response:
3637
body: '{"errors":[{"status":"400","title":"Bad Request"}]}'
3738
code: 400
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-10-01T12:46:34.590Z
1+
2025-12-30T13:49:45.709Z

0 commit comments

Comments
 (0)