|
5 | 5 | package datadogV2 |
6 | 6 |
|
7 | 7 | import ( |
8 | | - "fmt" |
9 | | - |
10 | 8 | "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
11 | 9 | ) |
12 | 10 |
|
13 | | -// LLMObsAnnotatedInteractionItem An interaction with its associated annotations. |
| 11 | +// LLMObsAnnotatedInteractionItem - An interaction with its associated annotations. |
14 | 12 | type LLMObsAnnotatedInteractionItem struct { |
15 | | - // List of annotations for this interaction. |
16 | | - Annotations []LLMObsAnnotationItem `json:"annotations"` |
17 | | - // Identifier of the content (trace ID or session ID) for this interaction. |
18 | | - ContentId string `json:"content_id"` |
19 | | - // Unique identifier of the interaction. |
20 | | - Id string `json:"id"` |
21 | | - // Type of interaction in an annotation queue. |
22 | | - Type LLMObsInteractionType `json:"type"` |
23 | | - // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
24 | | - UnparsedObject map[string]interface{} `json:"-"` |
25 | | - AdditionalProperties map[string]interface{} `json:"-"` |
26 | | -} |
27 | | - |
28 | | -// NewLLMObsAnnotatedInteractionItem instantiates a new LLMObsAnnotatedInteractionItem object. |
29 | | -// This constructor will assign default values to properties that have it defined, |
30 | | -// and makes sure properties required by API are set, but the set of arguments |
31 | | -// will change when the set of required properties is changed. |
32 | | -func NewLLMObsAnnotatedInteractionItem(annotations []LLMObsAnnotationItem, contentId string, id string, typeVar LLMObsInteractionType) *LLMObsAnnotatedInteractionItem { |
33 | | - this := LLMObsAnnotatedInteractionItem{} |
34 | | - this.Annotations = annotations |
35 | | - this.ContentId = contentId |
36 | | - this.Id = id |
37 | | - this.Type = typeVar |
38 | | - return &this |
39 | | -} |
40 | | - |
41 | | -// NewLLMObsAnnotatedInteractionItemWithDefaults instantiates a new LLMObsAnnotatedInteractionItem object. |
42 | | -// This constructor will only assign default values to properties that have it defined, |
43 | | -// but it doesn't guarantee that properties required by API are set. |
44 | | -func NewLLMObsAnnotatedInteractionItemWithDefaults() *LLMObsAnnotatedInteractionItem { |
45 | | - this := LLMObsAnnotatedInteractionItem{} |
46 | | - return &this |
47 | | -} |
48 | | - |
49 | | -// GetAnnotations returns the Annotations field value. |
50 | | -func (o *LLMObsAnnotatedInteractionItem) GetAnnotations() []LLMObsAnnotationItem { |
51 | | - if o == nil { |
52 | | - var ret []LLMObsAnnotationItem |
53 | | - return ret |
54 | | - } |
55 | | - return o.Annotations |
56 | | -} |
57 | | - |
58 | | -// GetAnnotationsOk returns a tuple with the Annotations field value |
59 | | -// and a boolean to check if the value has been set. |
60 | | -func (o *LLMObsAnnotatedInteractionItem) GetAnnotationsOk() (*[]LLMObsAnnotationItem, bool) { |
61 | | - if o == nil { |
62 | | - return nil, false |
63 | | - } |
64 | | - return &o.Annotations, true |
65 | | -} |
66 | | - |
67 | | -// SetAnnotations sets field value. |
68 | | -func (o *LLMObsAnnotatedInteractionItem) SetAnnotations(v []LLMObsAnnotationItem) { |
69 | | - o.Annotations = v |
70 | | -} |
71 | | - |
72 | | -// GetContentId returns the ContentId field value. |
73 | | -func (o *LLMObsAnnotatedInteractionItem) GetContentId() string { |
74 | | - if o == nil { |
75 | | - var ret string |
76 | | - return ret |
77 | | - } |
78 | | - return o.ContentId |
79 | | -} |
80 | | - |
81 | | -// GetContentIdOk returns a tuple with the ContentId field value |
82 | | -// and a boolean to check if the value has been set. |
83 | | -func (o *LLMObsAnnotatedInteractionItem) GetContentIdOk() (*string, bool) { |
84 | | - if o == nil { |
85 | | - return nil, false |
86 | | - } |
87 | | - return &o.ContentId, true |
88 | | -} |
89 | | - |
90 | | -// SetContentId sets field value. |
91 | | -func (o *LLMObsAnnotatedInteractionItem) SetContentId(v string) { |
92 | | - o.ContentId = v |
93 | | -} |
| 13 | + LLMObsTraceAnnotatedInteractionItem *LLMObsTraceAnnotatedInteractionItem |
| 14 | + LLMObsDisplayBlockAnnotatedInteractionItem *LLMObsDisplayBlockAnnotatedInteractionItem |
94 | 15 |
|
95 | | -// GetId returns the Id field value. |
96 | | -func (o *LLMObsAnnotatedInteractionItem) GetId() string { |
97 | | - if o == nil { |
98 | | - var ret string |
99 | | - return ret |
100 | | - } |
101 | | - return o.Id |
102 | | -} |
103 | | - |
104 | | -// GetIdOk returns a tuple with the Id field value |
105 | | -// and a boolean to check if the value has been set. |
106 | | -func (o *LLMObsAnnotatedInteractionItem) GetIdOk() (*string, bool) { |
107 | | - if o == nil { |
108 | | - return nil, false |
| 16 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 17 | + UnparsedObject interface{} |
| 18 | +} |
| 19 | + |
| 20 | +// LLMObsTraceAnnotatedInteractionItemAsLLMObsAnnotatedInteractionItem is a convenience function that returns LLMObsTraceAnnotatedInteractionItem wrapped in LLMObsAnnotatedInteractionItem. |
| 21 | +func LLMObsTraceAnnotatedInteractionItemAsLLMObsAnnotatedInteractionItem(v *LLMObsTraceAnnotatedInteractionItem) LLMObsAnnotatedInteractionItem { |
| 22 | + return LLMObsAnnotatedInteractionItem{LLMObsTraceAnnotatedInteractionItem: v} |
| 23 | +} |
| 24 | + |
| 25 | +// LLMObsDisplayBlockAnnotatedInteractionItemAsLLMObsAnnotatedInteractionItem is a convenience function that returns LLMObsDisplayBlockAnnotatedInteractionItem wrapped in LLMObsAnnotatedInteractionItem. |
| 26 | +func LLMObsDisplayBlockAnnotatedInteractionItemAsLLMObsAnnotatedInteractionItem(v *LLMObsDisplayBlockAnnotatedInteractionItem) LLMObsAnnotatedInteractionItem { |
| 27 | + return LLMObsAnnotatedInteractionItem{LLMObsDisplayBlockAnnotatedInteractionItem: v} |
| 28 | +} |
| 29 | + |
| 30 | +// UnmarshalJSON turns data into one of the pointers in the struct. |
| 31 | +func (obj *LLMObsAnnotatedInteractionItem) UnmarshalJSON(data []byte) error { |
| 32 | + var err error |
| 33 | + match := 0 |
| 34 | + // try to unmarshal data into LLMObsTraceAnnotatedInteractionItem |
| 35 | + err = datadog.Unmarshal(data, &obj.LLMObsTraceAnnotatedInteractionItem) |
| 36 | + if err == nil { |
| 37 | + if obj.LLMObsTraceAnnotatedInteractionItem != nil && obj.LLMObsTraceAnnotatedInteractionItem.UnparsedObject == nil { |
| 38 | + jsonLLMObsTraceAnnotatedInteractionItem, _ := datadog.Marshal(obj.LLMObsTraceAnnotatedInteractionItem) |
| 39 | + if string(jsonLLMObsTraceAnnotatedInteractionItem) == "{}" { // empty struct |
| 40 | + obj.LLMObsTraceAnnotatedInteractionItem = nil |
| 41 | + } else { |
| 42 | + match++ |
| 43 | + } |
| 44 | + } else { |
| 45 | + obj.LLMObsTraceAnnotatedInteractionItem = nil |
| 46 | + } |
| 47 | + } else { |
| 48 | + obj.LLMObsTraceAnnotatedInteractionItem = nil |
| 49 | + } |
| 50 | + |
| 51 | + // try to unmarshal data into LLMObsDisplayBlockAnnotatedInteractionItem |
| 52 | + err = datadog.Unmarshal(data, &obj.LLMObsDisplayBlockAnnotatedInteractionItem) |
| 53 | + if err == nil { |
| 54 | + if obj.LLMObsDisplayBlockAnnotatedInteractionItem != nil && obj.LLMObsDisplayBlockAnnotatedInteractionItem.UnparsedObject == nil { |
| 55 | + jsonLLMObsDisplayBlockAnnotatedInteractionItem, _ := datadog.Marshal(obj.LLMObsDisplayBlockAnnotatedInteractionItem) |
| 56 | + if string(jsonLLMObsDisplayBlockAnnotatedInteractionItem) == "{}" { // empty struct |
| 57 | + obj.LLMObsDisplayBlockAnnotatedInteractionItem = nil |
| 58 | + } else { |
| 59 | + match++ |
| 60 | + } |
| 61 | + } else { |
| 62 | + obj.LLMObsDisplayBlockAnnotatedInteractionItem = nil |
| 63 | + } |
| 64 | + } else { |
| 65 | + obj.LLMObsDisplayBlockAnnotatedInteractionItem = nil |
109 | 66 | } |
110 | | - return &o.Id, true |
111 | | -} |
112 | | - |
113 | | -// SetId sets field value. |
114 | | -func (o *LLMObsAnnotatedInteractionItem) SetId(v string) { |
115 | | - o.Id = v |
116 | | -} |
117 | 67 |
|
118 | | -// GetType returns the Type field value. |
119 | | -func (o *LLMObsAnnotatedInteractionItem) GetType() LLMObsInteractionType { |
120 | | - if o == nil { |
121 | | - var ret LLMObsInteractionType |
122 | | - return ret |
| 68 | + if match != 1 { // more than 1 match |
| 69 | + // reset to nil |
| 70 | + obj.LLMObsTraceAnnotatedInteractionItem = nil |
| 71 | + obj.LLMObsDisplayBlockAnnotatedInteractionItem = nil |
| 72 | + return datadog.Unmarshal(data, &obj.UnparsedObject) |
123 | 73 | } |
124 | | - return o.Type |
| 74 | + return nil // exactly one match |
125 | 75 | } |
126 | 76 |
|
127 | | -// GetTypeOk returns a tuple with the Type field value |
128 | | -// and a boolean to check if the value has been set. |
129 | | -func (o *LLMObsAnnotatedInteractionItem) GetTypeOk() (*LLMObsInteractionType, bool) { |
130 | | - if o == nil { |
131 | | - return nil, false |
| 77 | +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. |
| 78 | +func (obj LLMObsAnnotatedInteractionItem) MarshalJSON() ([]byte, error) { |
| 79 | + if obj.LLMObsTraceAnnotatedInteractionItem != nil { |
| 80 | + return datadog.Marshal(&obj.LLMObsTraceAnnotatedInteractionItem) |
132 | 81 | } |
133 | | - return &o.Type, true |
134 | | -} |
135 | | - |
136 | | -// SetType sets field value. |
137 | | -func (o *LLMObsAnnotatedInteractionItem) SetType(v LLMObsInteractionType) { |
138 | | - o.Type = v |
139 | | -} |
140 | 82 |
|
141 | | -// MarshalJSON serializes the struct using spec logic. |
142 | | -func (o LLMObsAnnotatedInteractionItem) MarshalJSON() ([]byte, error) { |
143 | | - toSerialize := map[string]interface{}{} |
144 | | - if o.UnparsedObject != nil { |
145 | | - return datadog.Marshal(o.UnparsedObject) |
| 83 | + if obj.LLMObsDisplayBlockAnnotatedInteractionItem != nil { |
| 84 | + return datadog.Marshal(&obj.LLMObsDisplayBlockAnnotatedInteractionItem) |
146 | 85 | } |
147 | | - toSerialize["annotations"] = o.Annotations |
148 | | - toSerialize["content_id"] = o.ContentId |
149 | | - toSerialize["id"] = o.Id |
150 | | - toSerialize["type"] = o.Type |
151 | 86 |
|
152 | | - for key, value := range o.AdditionalProperties { |
153 | | - toSerialize[key] = value |
| 87 | + if obj.UnparsedObject != nil { |
| 88 | + return datadog.Marshal(obj.UnparsedObject) |
154 | 89 | } |
155 | | - return datadog.Marshal(toSerialize) |
| 90 | + return nil, nil // no data in oneOf schemas |
156 | 91 | } |
157 | 92 |
|
158 | | -// UnmarshalJSON deserializes the given payload. |
159 | | -func (o *LLMObsAnnotatedInteractionItem) UnmarshalJSON(bytes []byte) (err error) { |
160 | | - all := struct { |
161 | | - Annotations *[]LLMObsAnnotationItem `json:"annotations"` |
162 | | - ContentId *string `json:"content_id"` |
163 | | - Id *string `json:"id"` |
164 | | - Type *LLMObsInteractionType `json:"type"` |
165 | | - }{} |
166 | | - if err = datadog.Unmarshal(bytes, &all); err != nil { |
167 | | - return datadog.Unmarshal(bytes, &o.UnparsedObject) |
168 | | - } |
169 | | - if all.Annotations == nil { |
170 | | - return fmt.Errorf("required field annotations missing") |
171 | | - } |
172 | | - if all.ContentId == nil { |
173 | | - return fmt.Errorf("required field content_id missing") |
174 | | - } |
175 | | - if all.Id == nil { |
176 | | - return fmt.Errorf("required field id missing") |
177 | | - } |
178 | | - if all.Type == nil { |
179 | | - return fmt.Errorf("required field type missing") |
180 | | - } |
181 | | - additionalProperties := make(map[string]interface{}) |
182 | | - if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
183 | | - datadog.DeleteKeys(additionalProperties, &[]string{"annotations", "content_id", "id", "type"}) |
184 | | - } else { |
185 | | - return err |
186 | | - } |
187 | | - |
188 | | - hasInvalidField := false |
189 | | - o.Annotations = *all.Annotations |
190 | | - o.ContentId = *all.ContentId |
191 | | - o.Id = *all.Id |
192 | | - if !all.Type.IsValid() { |
193 | | - hasInvalidField = true |
194 | | - } else { |
195 | | - o.Type = *all.Type |
196 | | - } |
197 | | - |
198 | | - if len(additionalProperties) > 0 { |
199 | | - o.AdditionalProperties = additionalProperties |
| 93 | +// GetActualInstance returns the actual instance. |
| 94 | +func (obj *LLMObsAnnotatedInteractionItem) GetActualInstance() interface{} { |
| 95 | + if obj.LLMObsTraceAnnotatedInteractionItem != nil { |
| 96 | + return obj.LLMObsTraceAnnotatedInteractionItem |
200 | 97 | } |
201 | 98 |
|
202 | | - if hasInvalidField { |
203 | | - return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 99 | + if obj.LLMObsDisplayBlockAnnotatedInteractionItem != nil { |
| 100 | + return obj.LLMObsDisplayBlockAnnotatedInteractionItem |
204 | 101 | } |
205 | 102 |
|
| 103 | + // all schemas are nil |
206 | 104 | return nil |
207 | 105 | } |
0 commit comments