|
18 | 18 |
|
19 | 19 | module DatadogAPIClient::V2 |
20 | 20 | # An interaction with its associated annotations. |
21 | | - class LLMObsAnnotatedInteractionItem |
22 | | - include BaseGenericModel |
23 | | - |
24 | | - # List of annotations for this interaction. |
25 | | - attr_reader :annotations |
26 | | - |
27 | | - # Identifier of the content (trace ID or session ID) for this interaction. |
28 | | - attr_reader :content_id |
29 | | - |
30 | | - # Unique identifier of the interaction. |
31 | | - attr_reader :id |
32 | | - |
33 | | - # Type of interaction in an annotation queue. |
34 | | - attr_reader :type |
35 | | - |
36 | | - attr_accessor :additional_properties |
37 | | - |
38 | | - # Attribute mapping from ruby-style variable name to JSON key. |
39 | | - # @!visibility private |
40 | | - def self.attribute_map |
41 | | - { |
42 | | - :'annotations' => :'annotations', |
43 | | - :'content_id' => :'content_id', |
44 | | - :'id' => :'id', |
45 | | - :'type' => :'type' |
46 | | - } |
47 | | - end |
48 | | - |
49 | | - # Attribute type mapping. |
50 | | - # @!visibility private |
51 | | - def self.openapi_types |
52 | | - { |
53 | | - :'annotations' => :'Array<LLMObsAnnotationItem>', |
54 | | - :'content_id' => :'String', |
55 | | - :'id' => :'String', |
56 | | - :'type' => :'LLMObsInteractionType' |
57 | | - } |
58 | | - end |
59 | | - |
60 | | - # Initializes the object |
61 | | - # @param attributes [Hash] Model attributes in the form of hash |
62 | | - # @!visibility private |
63 | | - def initialize(attributes = {}) |
64 | | - if (!attributes.is_a?(Hash)) |
65 | | - fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::LLMObsAnnotatedInteractionItem` initialize method" |
66 | | - end |
67 | | - |
68 | | - self.additional_properties = {} |
69 | | - # check to see if the attribute exists and convert string to symbol for hash key |
70 | | - attributes = attributes.each_with_object({}) { |(k, v), h| |
71 | | - if (!self.class.attribute_map.key?(k.to_sym)) |
72 | | - self.additional_properties[k.to_sym] = v |
73 | | - else |
74 | | - h[k.to_sym] = v |
75 | | - end |
76 | | - } |
77 | | - |
78 | | - if attributes.key?(:'annotations') |
79 | | - if (value = attributes[:'annotations']).is_a?(Array) |
80 | | - self.annotations = value |
| 21 | + module LLMObsAnnotatedInteractionItem |
| 22 | + class << self |
| 23 | + include BaseOneOfModel |
| 24 | + include BaseOneOfModelNoDiscriminator |
| 25 | + |
| 26 | + # List of class defined in oneOf (OpenAPI v3) |
| 27 | + def openapi_one_of |
| 28 | + [ |
| 29 | + :'LLMObsTraceAnnotatedInteractionItem', |
| 30 | + :'LLMObsDisplayBlockAnnotatedInteractionItem' |
| 31 | + ] |
| 32 | + end |
| 33 | + # Builds the object |
| 34 | + # @param data [Mixed] Data to be matched against the list of oneOf items |
| 35 | + # @return [Object] Returns the model or the data itself |
| 36 | + def build(data) |
| 37 | + # Go through the list of oneOf items and attempt to identify the appropriate one. |
| 38 | + # Note: |
| 39 | + # - We do not attempt to check whether exactly one item matches. |
| 40 | + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) |
| 41 | + # due to the way the deserialization is made in the base_object template (it just casts without verifying). |
| 42 | + # - TODO: scalar values are de facto behaving as if they were nullable. |
| 43 | + # - TODO: logging when debugging is set. |
| 44 | + openapi_one_of.each do |klass| |
| 45 | + begin |
| 46 | + next if klass == :AnyType # "nullable: true" |
| 47 | + typed_data = find_and_cast_into_type(klass, data) |
| 48 | + next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed |
| 49 | + return typed_data if typed_data |
| 50 | + rescue # rescue all errors so we keep iterating even if the current item lookup raises |
| 51 | + end |
81 | 52 | end |
82 | | - end |
83 | | - |
84 | | - if attributes.key?(:'content_id') |
85 | | - self.content_id = attributes[:'content_id'] |
86 | | - end |
87 | | - |
88 | | - if attributes.key?(:'id') |
89 | | - self.id = attributes[:'id'] |
90 | | - end |
91 | | - |
92 | | - if attributes.key?(:'type') |
93 | | - self.type = attributes[:'type'] |
94 | | - end |
95 | | - end |
96 | | - |
97 | | - # Check to see if the all the properties in the model are valid |
98 | | - # @return true if the model is valid |
99 | | - # @!visibility private |
100 | | - def valid? |
101 | | - return false if @annotations.nil? |
102 | | - return false if @content_id.nil? |
103 | | - return false if @id.nil? |
104 | | - return false if @type.nil? |
105 | | - true |
106 | | - end |
107 | | - |
108 | | - # Custom attribute writer method with validation |
109 | | - # @param annotations [Object] Object to be assigned |
110 | | - # @!visibility private |
111 | | - def annotations=(annotations) |
112 | | - if annotations.nil? |
113 | | - fail ArgumentError, 'invalid value for "annotations", annotations cannot be nil.' |
114 | | - end |
115 | | - @annotations = annotations |
116 | | - end |
117 | | - |
118 | | - # Custom attribute writer method with validation |
119 | | - # @param content_id [Object] Object to be assigned |
120 | | - # @!visibility private |
121 | | - def content_id=(content_id) |
122 | | - if content_id.nil? |
123 | | - fail ArgumentError, 'invalid value for "content_id", content_id cannot be nil.' |
124 | | - end |
125 | | - @content_id = content_id |
126 | | - end |
127 | | - |
128 | | - # Custom attribute writer method with validation |
129 | | - # @param id [Object] Object to be assigned |
130 | | - # @!visibility private |
131 | | - def id=(id) |
132 | | - if id.nil? |
133 | | - fail ArgumentError, 'invalid value for "id", id cannot be nil.' |
134 | | - end |
135 | | - @id = id |
136 | | - end |
137 | | - |
138 | | - # Custom attribute writer method with validation |
139 | | - # @param type [Object] Object to be assigned |
140 | | - # @!visibility private |
141 | | - def type=(type) |
142 | | - if type.nil? |
143 | | - fail ArgumentError, 'invalid value for "type", type cannot be nil.' |
144 | | - end |
145 | | - @type = type |
146 | | - end |
147 | 53 |
|
148 | | - # Returns the object in the form of hash, with additionalProperties support. |
149 | | - # @return [Hash] Returns the object in the form of hash |
150 | | - # @!visibility private |
151 | | - def to_hash |
152 | | - hash = {} |
153 | | - self.class.attribute_map.each_pair do |attr, param| |
154 | | - value = self.send(attr) |
155 | | - if value.nil? |
156 | | - is_nullable = self.class.openapi_nullable.include?(attr) |
157 | | - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) |
| 54 | + if openapi_one_of.include?(:AnyType) |
| 55 | + data |
| 56 | + else |
| 57 | + self._unparsed = true |
| 58 | + DatadogAPIClient::UnparsedObject.new(data) |
158 | 59 | end |
159 | | - |
160 | | - hash[param] = _to_hash(value) |
161 | 60 | end |
162 | | - self.additional_properties.each_pair do |attr, value| |
163 | | - hash[attr] = value |
164 | | - end |
165 | | - hash |
166 | | - end |
167 | | - |
168 | | - # Checks equality by comparing each attribute. |
169 | | - # @param o [Object] Object to be compared |
170 | | - # @!visibility private |
171 | | - def ==(o) |
172 | | - return true if self.equal?(o) |
173 | | - self.class == o.class && |
174 | | - annotations == o.annotations && |
175 | | - content_id == o.content_id && |
176 | | - id == o.id && |
177 | | - type == o.type && |
178 | | - additional_properties == o.additional_properties |
179 | | - end |
180 | | - |
181 | | - # Calculates hash code according to all attributes. |
182 | | - # @return [Integer] Hash code |
183 | | - # @!visibility private |
184 | | - def hash |
185 | | - [annotations, content_id, id, type, additional_properties].hash |
186 | 61 | end |
187 | 62 | end |
188 | 63 | end |
0 commit comments