carbon_ruby_sdk 0.2.37 → 0.2.39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +342 -2
  4. data/lib/carbon_ruby_sdk/api/files_api.rb +21 -6
  5. data/lib/carbon_ruby_sdk/api/github_api.rb +825 -0
  6. data/lib/carbon_ruby_sdk/api/utilities_api.rb +6 -2
  7. data/lib/carbon_ruby_sdk/models/comments_input.rb +330 -0
  8. data/lib/carbon_ruby_sdk/models/comments_order_by.rb +36 -0
  9. data/lib/carbon_ruby_sdk/models/comments_response.rb +232 -0
  10. data/lib/carbon_ruby_sdk/models/commit.rb +282 -0
  11. data/lib/carbon_ruby_sdk/models/commit_user.rb +234 -0
  12. data/lib/carbon_ruby_sdk/models/commit_user_nullable.rb +234 -0
  13. data/lib/carbon_ruby_sdk/models/commits_input.rb +307 -0
  14. data/lib/carbon_ruby_sdk/models/commits_response.rb +232 -0
  15. data/lib/carbon_ruby_sdk/models/file_status.rb +41 -0
  16. data/lib/carbon_ruby_sdk/models/file_sync_config.rb +13 -1
  17. data/lib/carbon_ruby_sdk/models/file_sync_config_nullable.rb +13 -1
  18. data/lib/carbon_ruby_sdk/models/files_input.rb +307 -0
  19. data/lib/carbon_ruby_sdk/models/files_response.rb +232 -0
  20. data/lib/carbon_ruby_sdk/models/head_or_base.rb +248 -0
  21. data/lib/carbon_ruby_sdk/models/issue.rb +434 -0
  22. data/lib/carbon_ruby_sdk/models/issue_pr.rb +230 -0
  23. data/lib/carbon_ruby_sdk/models/issue_pr_nullable.rb +230 -0
  24. data/lib/carbon_ruby_sdk/models/issues_filter.rb +217 -0
  25. data/lib/carbon_ruby_sdk/models/issues_input.rb +325 -0
  26. data/lib/carbon_ruby_sdk/models/issues_order_by.rb +37 -0
  27. data/lib/carbon_ruby_sdk/models/issues_response.rb +232 -0
  28. data/lib/carbon_ruby_sdk/models/label.rb +234 -0
  29. data/lib/carbon_ruby_sdk/models/pr_comment.rb +358 -0
  30. data/lib/carbon_ruby_sdk/models/pr_commit.rb +264 -0
  31. data/lib/carbon_ruby_sdk/models/pr_file.rb +342 -0
  32. data/lib/carbon_ruby_sdk/models/pr_order_by.rb +37 -0
  33. data/lib/carbon_ruby_sdk/models/pr_state.rb +36 -0
  34. data/lib/carbon_ruby_sdk/models/pr_state_input.rb +37 -0
  35. data/lib/carbon_ruby_sdk/models/pull_request.rb +438 -0
  36. data/lib/carbon_ruby_sdk/models/pull_request_extended.rb +536 -0
  37. data/lib/carbon_ruby_sdk/models/pull_request_filters.rb +239 -0
  38. data/lib/carbon_ruby_sdk/models/pull_request_response.rb +232 -0
  39. data/lib/carbon_ruby_sdk/models/pull_requests_input.rb +325 -0
  40. data/lib/carbon_ruby_sdk/models/raw_text_input.rb +16 -4
  41. data/lib/carbon_ruby_sdk/models/sitemap_scrape_request.rb +16 -4
  42. data/lib/carbon_ruby_sdk/models/team.rb +234 -0
  43. data/lib/carbon_ruby_sdk/models/tree.rb +234 -0
  44. data/lib/carbon_ruby_sdk/models/upload_file_from_url_input.rb +16 -4
  45. data/lib/carbon_ruby_sdk/models/user.rb +234 -0
  46. data/lib/carbon_ruby_sdk/models/user_nullable.rb +234 -0
  47. data/lib/carbon_ruby_sdk/models/webscrape_request.rb +16 -4
  48. data/lib/carbon_ruby_sdk/version.rb +1 -1
  49. data/lib/carbon_ruby_sdk.rb +38 -0
  50. data/spec/api/files_api_spec.rb +1 -0
  51. data/spec/api/github_api_spec.rb +112 -0
  52. data/spec/models/comments_input_spec.rb +76 -0
  53. data/spec/models/comments_order_by_spec.rb +22 -0
  54. data/spec/models/comments_response_spec.rb +34 -0
  55. data/spec/models/commit_spec.rb +58 -0
  56. data/spec/models/commit_user_nullable_spec.rb +34 -0
  57. data/spec/models/commit_user_spec.rb +34 -0
  58. data/spec/models/commits_input_spec.rb +64 -0
  59. data/spec/models/commits_response_spec.rb +34 -0
  60. data/spec/models/file_status_spec.rb +22 -0
  61. data/spec/models/file_sync_config_nullable_spec.rb +6 -0
  62. data/spec/models/file_sync_config_spec.rb +6 -0
  63. data/spec/models/files_input_spec.rb +64 -0
  64. data/spec/models/files_response_spec.rb +34 -0
  65. data/spec/models/head_or_base_spec.rb +40 -0
  66. data/spec/models/issue_pr_nullable_spec.rb +34 -0
  67. data/spec/models/issue_pr_spec.rb +34 -0
  68. data/spec/models/issue_spec.rb +124 -0
  69. data/spec/models/issues_filter_spec.rb +28 -0
  70. data/spec/models/issues_input_spec.rb +76 -0
  71. data/spec/models/issues_order_by_spec.rb +22 -0
  72. data/spec/models/issues_response_spec.rb +34 -0
  73. data/spec/models/label_spec.rb +34 -0
  74. data/spec/models/pr_comment_spec.rb +94 -0
  75. data/spec/models/pr_commit_spec.rb +52 -0
  76. data/spec/models/pr_file_spec.rb +82 -0
  77. data/spec/models/pr_order_by_spec.rb +22 -0
  78. data/spec/models/pr_state_input_spec.rb +22 -0
  79. data/spec/models/pr_state_spec.rb +22 -0
  80. data/spec/models/pull_request_extended_spec.rb +166 -0
  81. data/spec/models/pull_request_filters_spec.rb +40 -0
  82. data/spec/models/pull_request_response_spec.rb +34 -0
  83. data/spec/models/pull_request_spec.rb +124 -0
  84. data/spec/models/pull_requests_input_spec.rb +76 -0
  85. data/spec/models/raw_text_input_spec.rb +6 -0
  86. data/spec/models/sitemap_scrape_request_spec.rb +6 -0
  87. data/spec/models/team_spec.rb +34 -0
  88. data/spec/models/tree_spec.rb +34 -0
  89. data/spec/models/upload_file_from_url_input_spec.rb +6 -0
  90. data/spec/models/user_nullable_spec.rb +34 -0
  91. data/spec/models/user_spec.rb +34 -0
  92. data/spec/models/webscrape_request_spec.rb +6 -0
  93. metadata +301 -193
@@ -439,9 +439,10 @@ module Carbon
439
439
  # @param urls_to_scrape [Array<String>] You can submit a subset of URLs from the sitemap that should be scraped. To get the list of URLs, you can check out /process_sitemap endpoint. If left empty, all URLs from the sitemap will be scraped.
440
440
  # @param download_css_and_media [Boolean] Whether the scraper should download css and media from the page (images, fonts, etc). Scrapes might take longer to finish with this flag enabled, but the success rate is improved.
441
441
  # @param generate_chunks_only [Boolean] If this flag is enabled, the file will be chunked and stored with Carbon, but no embeddings will be generated. This overrides the skip_embedding_generation flag.
442
+ # @param store_file_only [Boolean] If this flag is enabled, the file will be stored with Carbon, but no processing will be done.
442
443
  # @param body [SitemapScrapeRequest]
443
444
  # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
444
- def scrape_sitemap(url:, tags: SENTINEL, max_pages_to_scrape: SENTINEL, chunk_size: 1500, chunk_overlap: 20, skip_embedding_generation: false, enable_auto_sync: false, generate_sparse_vectors: false, prepend_filename_to_chunks: false, html_tags_to_skip: SENTINEL, css_classes_to_skip: SENTINEL, css_selectors_to_skip: SENTINEL, embedding_model: 'OPENAI', url_paths_to_include: SENTINEL, url_paths_to_exclude: SENTINEL, urls_to_scrape: SENTINEL, download_css_and_media: false, generate_chunks_only: false, extra: {})
445
+ def scrape_sitemap(url:, tags: SENTINEL, max_pages_to_scrape: SENTINEL, chunk_size: 1500, chunk_overlap: 20, skip_embedding_generation: false, enable_auto_sync: false, generate_sparse_vectors: false, prepend_filename_to_chunks: false, html_tags_to_skip: SENTINEL, css_classes_to_skip: SENTINEL, css_selectors_to_skip: SENTINEL, embedding_model: 'OPENAI', url_paths_to_include: SENTINEL, url_paths_to_exclude: SENTINEL, urls_to_scrape: SENTINEL, download_css_and_media: false, generate_chunks_only: false, store_file_only: false, extra: {})
445
446
  _body = {}
446
447
  _body[:tags] = tags if tags != SENTINEL
447
448
  _body[:url] = url if url != SENTINEL
@@ -461,6 +462,7 @@ module Carbon
461
462
  _body[:urls_to_scrape] = urls_to_scrape if urls_to_scrape != SENTINEL
462
463
  _body[:download_css_and_media] = download_css_and_media if download_css_and_media != SENTINEL
463
464
  _body[:generate_chunks_only] = generate_chunks_only if generate_chunks_only != SENTINEL
465
+ _body[:store_file_only] = store_file_only if store_file_only != SENTINEL
464
466
  sitemap_scrape_request = _body
465
467
  api_response = scrape_sitemap_with_http_info_impl(sitemap_scrape_request, extra)
466
468
  api_response.data
@@ -494,9 +496,10 @@ module Carbon
494
496
  # @param urls_to_scrape [Array<String>] You can submit a subset of URLs from the sitemap that should be scraped. To get the list of URLs, you can check out /process_sitemap endpoint. If left empty, all URLs from the sitemap will be scraped.
495
497
  # @param download_css_and_media [Boolean] Whether the scraper should download css and media from the page (images, fonts, etc). Scrapes might take longer to finish with this flag enabled, but the success rate is improved.
496
498
  # @param generate_chunks_only [Boolean] If this flag is enabled, the file will be chunked and stored with Carbon, but no embeddings will be generated. This overrides the skip_embedding_generation flag.
499
+ # @param store_file_only [Boolean] If this flag is enabled, the file will be stored with Carbon, but no processing will be done.
497
500
  # @param body [SitemapScrapeRequest]
498
501
  # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
499
- def scrape_sitemap_with_http_info(url:, tags: SENTINEL, max_pages_to_scrape: SENTINEL, chunk_size: 1500, chunk_overlap: 20, skip_embedding_generation: false, enable_auto_sync: false, generate_sparse_vectors: false, prepend_filename_to_chunks: false, html_tags_to_skip: SENTINEL, css_classes_to_skip: SENTINEL, css_selectors_to_skip: SENTINEL, embedding_model: 'OPENAI', url_paths_to_include: SENTINEL, url_paths_to_exclude: SENTINEL, urls_to_scrape: SENTINEL, download_css_and_media: false, generate_chunks_only: false, extra: {})
502
+ def scrape_sitemap_with_http_info(url:, tags: SENTINEL, max_pages_to_scrape: SENTINEL, chunk_size: 1500, chunk_overlap: 20, skip_embedding_generation: false, enable_auto_sync: false, generate_sparse_vectors: false, prepend_filename_to_chunks: false, html_tags_to_skip: SENTINEL, css_classes_to_skip: SENTINEL, css_selectors_to_skip: SENTINEL, embedding_model: 'OPENAI', url_paths_to_include: SENTINEL, url_paths_to_exclude: SENTINEL, urls_to_scrape: SENTINEL, download_css_and_media: false, generate_chunks_only: false, store_file_only: false, extra: {})
500
503
  _body = {}
501
504
  _body[:tags] = tags if tags != SENTINEL
502
505
  _body[:url] = url if url != SENTINEL
@@ -516,6 +519,7 @@ module Carbon
516
519
  _body[:urls_to_scrape] = urls_to_scrape if urls_to_scrape != SENTINEL
517
520
  _body[:download_css_and_media] = download_css_and_media if download_css_and_media != SENTINEL
518
521
  _body[:generate_chunks_only] = generate_chunks_only if generate_chunks_only != SENTINEL
522
+ _body[:store_file_only] = store_file_only if store_file_only != SENTINEL
519
523
  sitemap_scrape_request = _body
520
524
  scrape_sitemap_with_http_info_impl(sitemap_scrape_request, extra)
521
525
  end
@@ -0,0 +1,330 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class CommentsInput
14
+ attr_accessor :data_source_id
15
+
16
+ attr_accessor :include_remote_data
17
+
18
+ # Full name of the repository, denoted as {owner}/{repo}
19
+ attr_accessor :repository
20
+
21
+ attr_accessor :page
22
+
23
+ attr_accessor :page_size
24
+
25
+ attr_accessor :next_cursor
26
+
27
+ attr_accessor :pull_number
28
+
29
+ attr_accessor :order_by
30
+
31
+ attr_accessor :order_dir
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'data_source_id' => :'data_source_id',
37
+ :'include_remote_data' => :'include_remote_data',
38
+ :'repository' => :'repository',
39
+ :'page' => :'page',
40
+ :'page_size' => :'page_size',
41
+ :'next_cursor' => :'next_cursor',
42
+ :'pull_number' => :'pull_number',
43
+ :'order_by' => :'order_by',
44
+ :'order_dir' => :'order_dir'
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'data_source_id' => :'Integer',
57
+ :'include_remote_data' => :'Boolean',
58
+ :'repository' => :'String',
59
+ :'page' => :'Integer',
60
+ :'page_size' => :'Integer',
61
+ :'next_cursor' => :'String',
62
+ :'pull_number' => :'Integer',
63
+ :'order_by' => :'CommentsOrderBy',
64
+ :'order_dir' => :'OrderDirV2Nullable'
65
+ }
66
+ end
67
+
68
+ # List of attributes with nullable: true
69
+ def self.openapi_nullable
70
+ Set.new([
71
+ :'next_cursor',
72
+ :'order_dir'
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::CommentsInput` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ attributes = attributes.each_with_object({}) { |(k, v), h|
85
+ if (!self.class.attribute_map.key?(k.to_sym))
86
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::CommentsInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
+ end
88
+ h[k.to_sym] = v
89
+ }
90
+
91
+ if attributes.key?(:'data_source_id')
92
+ self.data_source_id = attributes[:'data_source_id']
93
+ end
94
+
95
+ if attributes.key?(:'include_remote_data')
96
+ self.include_remote_data = attributes[:'include_remote_data']
97
+ else
98
+ self.include_remote_data = false
99
+ end
100
+
101
+ if attributes.key?(:'repository')
102
+ self.repository = attributes[:'repository']
103
+ end
104
+
105
+ if attributes.key?(:'page')
106
+ self.page = attributes[:'page']
107
+ else
108
+ self.page = 1
109
+ end
110
+
111
+ if attributes.key?(:'page_size')
112
+ self.page_size = attributes[:'page_size']
113
+ else
114
+ self.page_size = 30
115
+ end
116
+
117
+ if attributes.key?(:'next_cursor')
118
+ self.next_cursor = attributes[:'next_cursor']
119
+ end
120
+
121
+ if attributes.key?(:'pull_number')
122
+ self.pull_number = attributes[:'pull_number']
123
+ end
124
+
125
+ if attributes.key?(:'order_by')
126
+ self.order_by = attributes[:'order_by']
127
+ else
128
+ self.order_by = 'created'
129
+ end
130
+
131
+ if attributes.key?(:'order_dir')
132
+ self.order_dir = attributes[:'order_dir']
133
+ else
134
+ self.order_dir = 'asc'
135
+ end
136
+ end
137
+
138
+ # Show invalid properties with the reasons. Usually used together with valid?
139
+ # @return Array for valid properties with the reasons
140
+ def list_invalid_properties
141
+ invalid_properties = Array.new
142
+ if @data_source_id.nil?
143
+ invalid_properties.push('invalid value for "data_source_id", data_source_id cannot be nil.')
144
+ end
145
+
146
+ if @repository.nil?
147
+ invalid_properties.push('invalid value for "repository", repository cannot be nil.')
148
+ end
149
+
150
+ if !@page_size.nil? && @page_size > 100
151
+ invalid_properties.push('invalid value for "page_size", must be smaller than or equal to 100.')
152
+ end
153
+
154
+ if @pull_number.nil?
155
+ invalid_properties.push('invalid value for "pull_number", pull_number cannot be nil.')
156
+ end
157
+
158
+ invalid_properties
159
+ end
160
+
161
+ # Check to see if the all the properties in the model are valid
162
+ # @return true if the model is valid
163
+ def valid?
164
+ return false if @data_source_id.nil?
165
+ return false if @repository.nil?
166
+ return false if !@page_size.nil? && @page_size > 100
167
+ return false if @pull_number.nil?
168
+ true
169
+ end
170
+
171
+ # Custom attribute writer method with validation
172
+ # @param [Object] page_size Value to be assigned
173
+ def page_size=(page_size)
174
+ if !page_size.nil? && page_size > 100
175
+ fail ArgumentError, 'invalid value for "page_size", must be smaller than or equal to 100.'
176
+ end
177
+
178
+ @page_size = page_size
179
+ end
180
+
181
+ # Checks equality by comparing each attribute.
182
+ # @param [Object] Object to be compared
183
+ def ==(o)
184
+ return true if self.equal?(o)
185
+ self.class == o.class &&
186
+ data_source_id == o.data_source_id &&
187
+ include_remote_data == o.include_remote_data &&
188
+ repository == o.repository &&
189
+ page == o.page &&
190
+ page_size == o.page_size &&
191
+ next_cursor == o.next_cursor &&
192
+ pull_number == o.pull_number &&
193
+ order_by == o.order_by &&
194
+ order_dir == o.order_dir
195
+ end
196
+
197
+ # @see the `==` method
198
+ # @param [Object] Object to be compared
199
+ def eql?(o)
200
+ self == o
201
+ end
202
+
203
+ # Calculates hash code according to all attributes.
204
+ # @return [Integer] Hash code
205
+ def hash
206
+ [data_source_id, include_remote_data, repository, page, page_size, next_cursor, pull_number, order_by, order_dir].hash
207
+ end
208
+
209
+ # Builds the object from hash
210
+ # @param [Hash] attributes Model attributes in the form of hash
211
+ # @return [Object] Returns the model itself
212
+ def self.build_from_hash(attributes)
213
+ new.build_from_hash(attributes)
214
+ end
215
+
216
+ # Builds the object from hash
217
+ # @param [Hash] attributes Model attributes in the form of hash
218
+ # @return [Object] Returns the model itself
219
+ def build_from_hash(attributes)
220
+ return nil unless attributes.is_a?(Hash)
221
+ attributes = attributes.transform_keys(&:to_sym)
222
+ self.class.openapi_types.each_pair do |key, type|
223
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
224
+ self.send("#{key}=", nil)
225
+ elsif type =~ /\AArray<(.*)>/i
226
+ # check to ensure the input is an array given that the attribute
227
+ # is documented as an array but the input is not
228
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
229
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
230
+ end
231
+ elsif !attributes[self.class.attribute_map[key]].nil?
232
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
233
+ end
234
+ end
235
+
236
+ self
237
+ end
238
+
239
+ # Deserializes the data based on type
240
+ # @param string type Data type
241
+ # @param string value Value to be deserialized
242
+ # @return [Object] Deserialized data
243
+ def _deserialize(type, value)
244
+ case type.to_sym
245
+ when :Time
246
+ Time.parse(value)
247
+ when :Date
248
+ Date.parse(value)
249
+ when :String
250
+ value.to_s
251
+ when :Integer
252
+ value.to_i
253
+ when :Float
254
+ value.to_f
255
+ when :Boolean
256
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
257
+ true
258
+ else
259
+ false
260
+ end
261
+ when :Object
262
+ # generic object (usually a Hash), return directly
263
+ value
264
+ when /\AArray<(?<inner_type>.+)>\z/
265
+ inner_type = Regexp.last_match[:inner_type]
266
+ value.map { |v| _deserialize(inner_type, v) }
267
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
268
+ k_type = Regexp.last_match[:k_type]
269
+ v_type = Regexp.last_match[:v_type]
270
+ {}.tap do |hash|
271
+ value.each do |k, v|
272
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
273
+ end
274
+ end
275
+ else # model
276
+ # models (e.g. Pet) or oneOf
277
+ klass = Carbon.const_get(type)
278
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
279
+ end
280
+ end
281
+
282
+ # Returns the string representation of the object
283
+ # @return [String] String presentation of the object
284
+ def to_s
285
+ to_hash.to_s
286
+ end
287
+
288
+ # to_body is an alias to to_hash (backward compatibility)
289
+ # @return [Hash] Returns the object in the form of hash
290
+ def to_body
291
+ to_hash
292
+ end
293
+
294
+ # Returns the object in the form of hash
295
+ # @return [Hash] Returns the object in the form of hash
296
+ def to_hash
297
+ hash = {}
298
+ self.class.attribute_map.each_pair do |attr, param|
299
+ value = self.send(attr)
300
+ if value.nil?
301
+ is_nullable = self.class.openapi_nullable.include?(attr)
302
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
303
+ end
304
+
305
+ hash[param] = _to_hash(value)
306
+ end
307
+ hash
308
+ end
309
+
310
+ # Outputs non-array value in the form of hash
311
+ # For object, use to_hash. Otherwise, just return the value
312
+ # @param [Object] value Any valid value
313
+ # @return [Hash] Returns the value in the form of hash
314
+ def _to_hash(value)
315
+ if value.is_a?(Array)
316
+ value.compact.map { |v| _to_hash(v) }
317
+ elsif value.is_a?(Hash)
318
+ {}.tap do |hash|
319
+ value.each { |k, v| hash[k] = _to_hash(v) }
320
+ end
321
+ elsif value.respond_to? :to_hash
322
+ value.to_hash
323
+ else
324
+ value
325
+ end
326
+ end
327
+
328
+ end
329
+
330
+ end
@@ -0,0 +1,36 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class CommentsOrderBy
14
+ CREATED = "created".freeze
15
+ UPDATED = "updated".freeze
16
+
17
+ def self.all_vars
18
+ @all_vars ||= [CREATED, UPDATED].freeze
19
+ end
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ return value if CommentsOrderBy.all_vars.include?(value)
33
+ raise "Invalid ENUM value #{value} for class #CommentsOrderBy"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,232 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class CommentsResponse
14
+ attr_accessor :data
15
+
16
+ attr_accessor :next_cursor
17
+
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ :'data' => :'data',
22
+ :'next_cursor' => :'next_cursor'
23
+ }
24
+ end
25
+
26
+ # Returns all the JSON keys this model knows about
27
+ def self.acceptable_attributes
28
+ attribute_map.values
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.openapi_types
33
+ {
34
+ :'data' => :'Array<PRComment>',
35
+ :'next_cursor' => :'String'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ :'next_cursor'
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::CommentsResponse` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::CommentsResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'data')
62
+ if (value = attributes[:'data']).is_a?(Array)
63
+ self.data = value
64
+ end
65
+ end
66
+
67
+ if attributes.key?(:'next_cursor')
68
+ self.next_cursor = attributes[:'next_cursor']
69
+ end
70
+ end
71
+
72
+ # Show invalid properties with the reasons. Usually used together with valid?
73
+ # @return Array for valid properties with the reasons
74
+ def list_invalid_properties
75
+ invalid_properties = Array.new
76
+ if @data.nil?
77
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
78
+ end
79
+
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ return false if @data.nil?
87
+ true
88
+ end
89
+
90
+ # Checks equality by comparing each attribute.
91
+ # @param [Object] Object to be compared
92
+ def ==(o)
93
+ return true if self.equal?(o)
94
+ self.class == o.class &&
95
+ data == o.data &&
96
+ next_cursor == o.next_cursor
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Integer] Hash code
107
+ def hash
108
+ [data, next_cursor].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def self.build_from_hash(attributes)
115
+ new.build_from_hash(attributes)
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ attributes = attributes.transform_keys(&:to_sym)
124
+ self.class.openapi_types.each_pair do |key, type|
125
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
126
+ self.send("#{key}=", nil)
127
+ elsif type =~ /\AArray<(.*)>/i
128
+ # check to ensure the input is an array given that the attribute
129
+ # is documented as an array but the input is not
130
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
131
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
132
+ end
133
+ elsif !attributes[self.class.attribute_map[key]].nil?
134
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
135
+ end
136
+ end
137
+
138
+ self
139
+ end
140
+
141
+ # Deserializes the data based on type
142
+ # @param string type Data type
143
+ # @param string value Value to be deserialized
144
+ # @return [Object] Deserialized data
145
+ def _deserialize(type, value)
146
+ case type.to_sym
147
+ when :Time
148
+ Time.parse(value)
149
+ when :Date
150
+ Date.parse(value)
151
+ when :String
152
+ value.to_s
153
+ when :Integer
154
+ value.to_i
155
+ when :Float
156
+ value.to_f
157
+ when :Boolean
158
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
159
+ true
160
+ else
161
+ false
162
+ end
163
+ when :Object
164
+ # generic object (usually a Hash), return directly
165
+ value
166
+ when /\AArray<(?<inner_type>.+)>\z/
167
+ inner_type = Regexp.last_match[:inner_type]
168
+ value.map { |v| _deserialize(inner_type, v) }
169
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
170
+ k_type = Regexp.last_match[:k_type]
171
+ v_type = Regexp.last_match[:v_type]
172
+ {}.tap do |hash|
173
+ value.each do |k, v|
174
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
175
+ end
176
+ end
177
+ else # model
178
+ # models (e.g. Pet) or oneOf
179
+ klass = Carbon.const_get(type)
180
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
181
+ end
182
+ end
183
+
184
+ # Returns the string representation of the object
185
+ # @return [String] String presentation of the object
186
+ def to_s
187
+ to_hash.to_s
188
+ end
189
+
190
+ # to_body is an alias to to_hash (backward compatibility)
191
+ # @return [Hash] Returns the object in the form of hash
192
+ def to_body
193
+ to_hash
194
+ end
195
+
196
+ # Returns the object in the form of hash
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_hash
199
+ hash = {}
200
+ self.class.attribute_map.each_pair do |attr, param|
201
+ value = self.send(attr)
202
+ if value.nil?
203
+ is_nullable = self.class.openapi_nullable.include?(attr)
204
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
205
+ end
206
+
207
+ hash[param] = _to_hash(value)
208
+ end
209
+ hash
210
+ end
211
+
212
+ # Outputs non-array value in the form of hash
213
+ # For object, use to_hash. Otherwise, just return the value
214
+ # @param [Object] value Any valid value
215
+ # @return [Hash] Returns the value in the form of hash
216
+ def _to_hash(value)
217
+ if value.is_a?(Array)
218
+ value.compact.map { |v| _to_hash(v) }
219
+ elsif value.is_a?(Hash)
220
+ {}.tap do |hash|
221
+ value.each { |k, v| hash[k] = _to_hash(v) }
222
+ end
223
+ elsif value.respond_to? :to_hash
224
+ value.to_hash
225
+ else
226
+ value
227
+ end
228
+ end
229
+
230
+ end
231
+
232
+ end