carbon_ruby_sdk 0.1.23 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +135 -9
  4. data/lib/carbon_ruby_sdk/api/embeddings_api.rb +2 -2
  5. data/lib/carbon_ruby_sdk/api/integrations_api.rb +252 -18
  6. data/lib/carbon_ruby_sdk/api/organizations_api.rb +92 -0
  7. data/lib/carbon_ruby_sdk/api/users_api.rb +2 -2
  8. data/lib/carbon_ruby_sdk/models/chunks_and_embeddings_upload_input.rb +4 -2
  9. data/lib/carbon_ruby_sdk/models/custom_credentials_type.rb +39 -0
  10. data/lib/carbon_ruby_sdk/models/embedding_generators.rb +2 -1
  11. data/lib/carbon_ruby_sdk/models/embedding_generators_nullable.rb +2 -1
  12. data/lib/carbon_ruby_sdk/models/external_source_items_order_by.rb +37 -0
  13. data/lib/carbon_ruby_sdk/models/file_statistics.rb +15 -5
  14. data/lib/carbon_ruby_sdk/models/file_statistics_nullable.rb +15 -5
  15. data/lib/carbon_ruby_sdk/models/fresh_desk_connect_request.rb +17 -5
  16. data/lib/carbon_ruby_sdk/models/gitbook_connect_request.rb +17 -5
  17. data/lib/carbon_ruby_sdk/models/github_connect_request.rb +16 -4
  18. data/lib/carbon_ruby_sdk/models/github_fetch_repos_request.rb +260 -0
  19. data/lib/carbon_ruby_sdk/models/list_data_source_items_request.rb +26 -4
  20. data/lib/carbon_ruby_sdk/models/o_auth_url_request.rb +18 -6
  21. data/lib/carbon_ruby_sdk/models/order_dir_v2.rb +36 -0
  22. data/lib/carbon_ruby_sdk/models/organization_response.rb +15 -1
  23. data/lib/carbon_ruby_sdk/models/organization_user_data_source_api.rb +19 -5
  24. data/lib/carbon_ruby_sdk/models/s3_auth_request.rb +16 -4
  25. data/lib/carbon_ruby_sdk/models/sync_files_request.rb +1 -1
  26. data/lib/carbon_ruby_sdk/models/sync_options.rb +17 -5
  27. data/lib/carbon_ruby_sdk/models/text_embedding_generators.rb +7 -1
  28. data/lib/carbon_ruby_sdk/models/update_organization_input.rb +216 -0
  29. data/lib/carbon_ruby_sdk/models/update_users_input.rb +41 -41
  30. data/lib/carbon_ruby_sdk/models/user_configuration.rb +268 -0
  31. data/lib/carbon_ruby_sdk/models/user_configuration_nullable.rb +269 -0
  32. data/lib/carbon_ruby_sdk/version.rb +1 -1
  33. data/lib/carbon_ruby_sdk.rb +7 -0
  34. data/spec/api/integrations_api_spec.rb +26 -0
  35. data/spec/api/organizations_api_spec.rb +11 -0
  36. data/spec/models/custom_credentials_type_spec.rb +22 -0
  37. data/spec/models/external_source_items_order_by_spec.rb +22 -0
  38. data/spec/models/file_statistics_nullable_spec.rb +6 -0
  39. data/spec/models/file_statistics_spec.rb +6 -0
  40. data/spec/models/fresh_desk_connect_request_spec.rb +6 -0
  41. data/spec/models/gitbook_connect_request_spec.rb +6 -0
  42. data/spec/models/github_connect_request_spec.rb +6 -0
  43. data/spec/models/github_fetch_repos_request_spec.rb +34 -0
  44. data/spec/models/list_data_source_items_request_spec.rb +12 -0
  45. data/spec/models/o_auth_url_request_spec.rb +6 -0
  46. data/spec/models/order_dir_v2_spec.rb +22 -0
  47. data/spec/models/organization_response_spec.rb +6 -0
  48. data/spec/models/organization_user_data_source_api_spec.rb +6 -0
  49. data/spec/models/s3_auth_request_spec.rb +6 -0
  50. data/spec/models/sync_options_spec.rb +6 -0
  51. data/spec/models/update_organization_input_spec.rb +28 -0
  52. data/spec/models/update_users_input_spec.rb +4 -4
  53. data/spec/models/user_configuration_nullable_spec.rb +40 -0
  54. data/spec/models/user_configuration_spec.rb +40 -0
  55. metadata +23 -2
@@ -0,0 +1,39 @@
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 CustomCredentialsType
14
+ OPENAI = "OPENAI".freeze
15
+ COHERE = "COHERE".freeze
16
+ AZURE_OPENAI = "AZURE_OPENAI".freeze
17
+ AZURE_OPENAI_V3 = "AZURE_OPENAI_V3".freeze
18
+ UPSTAGE = "UPSTAGE".freeze
19
+
20
+ def self.all_vars
21
+ @all_vars ||= [OPENAI, COHERE, AZURE_OPENAI, AZURE_OPENAI_V3, UPSTAGE].freeze
22
+ end
23
+
24
+ # Builds the enum from string
25
+ # @param [String] The enum value in the form of the string
26
+ # @return [String] The enum value
27
+ def self.build_from_hash(value)
28
+ new.build_from_hash(value)
29
+ end
30
+
31
+ # Builds the enum from string
32
+ # @param [String] The enum value in the form of the string
33
+ # @return [String] The enum value
34
+ def build_from_hash(value)
35
+ return value if CustomCredentialsType.all_vars.include?(value)
36
+ raise "Invalid ENUM value #{value} for class #CustomCredentialsType"
37
+ end
38
+ end
39
+ end
@@ -25,9 +25,10 @@ module Carbon
25
25
  OPENAI_ADA_LARGE_3072 = "OPENAI_ADA_LARGE_3072".freeze
26
26
  OPENAI_ADA_SMALL_512 = "OPENAI_ADA_SMALL_512".freeze
27
27
  OPENAI_ADA_SMALL_1536 = "OPENAI_ADA_SMALL_1536".freeze
28
+ SOLAR_1_MINI = "SOLAR_1_MINI".freeze
28
29
 
29
30
  def self.all_vars
30
- @all_vars ||= [OPENAI, AZURE_OPENAI, AZURE_ADA_LARGE_256, AZURE_ADA_LARGE_1024, AZURE_ADA_LARGE_3072, AZURE_ADA_SMALL_512, AZURE_ADA_SMALL_1536, COHERE_MULTILINGUAL_V3, VERTEX_MULTIMODAL, OPENAI_ADA_LARGE_256, OPENAI_ADA_LARGE_1024, OPENAI_ADA_LARGE_3072, OPENAI_ADA_SMALL_512, OPENAI_ADA_SMALL_1536].freeze
31
+ @all_vars ||= [OPENAI, AZURE_OPENAI, AZURE_ADA_LARGE_256, AZURE_ADA_LARGE_1024, AZURE_ADA_LARGE_3072, AZURE_ADA_SMALL_512, AZURE_ADA_SMALL_1536, COHERE_MULTILINGUAL_V3, VERTEX_MULTIMODAL, OPENAI_ADA_LARGE_256, OPENAI_ADA_LARGE_1024, OPENAI_ADA_LARGE_3072, OPENAI_ADA_SMALL_512, OPENAI_ADA_SMALL_1536, SOLAR_1_MINI].freeze
31
32
  end
32
33
 
33
34
  # Builds the enum from string
@@ -25,9 +25,10 @@ module Carbon
25
25
  OPENAI_ADA_LARGE_3072 = "OPENAI_ADA_LARGE_3072".freeze
26
26
  OPENAI_ADA_SMALL_512 = "OPENAI_ADA_SMALL_512".freeze
27
27
  OPENAI_ADA_SMALL_1536 = "OPENAI_ADA_SMALL_1536".freeze
28
+ SOLAR_1_MINI = "SOLAR_1_MINI".freeze
28
29
 
29
30
  def self.all_vars
30
- @all_vars ||= [OPENAI, AZURE_OPENAI, AZURE_ADA_LARGE_256, AZURE_ADA_LARGE_1024, AZURE_ADA_LARGE_3072, AZURE_ADA_SMALL_512, AZURE_ADA_SMALL_1536, COHERE_MULTILINGUAL_V3, VERTEX_MULTIMODAL, OPENAI_ADA_LARGE_256, OPENAI_ADA_LARGE_1024, OPENAI_ADA_LARGE_3072, OPENAI_ADA_SMALL_512, OPENAI_ADA_SMALL_1536].freeze
31
+ @all_vars ||= [OPENAI, AZURE_OPENAI, AZURE_ADA_LARGE_256, AZURE_ADA_LARGE_1024, AZURE_ADA_LARGE_3072, AZURE_ADA_SMALL_512, AZURE_ADA_SMALL_1536, COHERE_MULTILINGUAL_V3, VERTEX_MULTIMODAL, OPENAI_ADA_LARGE_256, OPENAI_ADA_LARGE_1024, OPENAI_ADA_LARGE_3072, OPENAI_ADA_SMALL_512, OPENAI_ADA_SMALL_1536, SOLAR_1_MINI].freeze
31
32
  end
32
33
 
33
34
  # Builds the enum from string
@@ -0,0 +1,37 @@
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 ExternalSourceItemsOrderBy
14
+ NAME = "name".freeze
15
+ ID = "id".freeze
16
+ DIRECTORIES_FIRST = "directories_first".freeze
17
+
18
+ def self.all_vars
19
+ @all_vars ||= [NAME, ID, DIRECTORIES_FIRST].freeze
20
+ end
21
+
22
+ # Builds the enum from string
23
+ # @param [String] The enum value in the form of the string
24
+ # @return [String] The enum value
25
+ def self.build_from_hash(value)
26
+ new.build_from_hash(value)
27
+ end
28
+
29
+ # Builds the enum from string
30
+ # @param [String] The enum value in the form of the string
31
+ # @return [String] The enum value
32
+ def build_from_hash(value)
33
+ return value if ExternalSourceItemsOrderBy.all_vars.include?(value)
34
+ raise "Invalid ENUM value #{value} for class #ExternalSourceItemsOrderBy"
35
+ end
36
+ end
37
+ end
@@ -21,6 +21,8 @@ module Carbon
21
21
 
22
22
  attr_accessor :num_embeddings
23
23
 
24
+ attr_accessor :mime_type
25
+
24
26
  # Attribute mapping from ruby-style variable name to JSON key.
25
27
  def self.attribute_map
26
28
  {
@@ -28,7 +30,8 @@ module Carbon
28
30
  :'file_size' => :'file_size',
29
31
  :'num_characters' => :'num_characters',
30
32
  :'num_tokens' => :'num_tokens',
31
- :'num_embeddings' => :'num_embeddings'
33
+ :'num_embeddings' => :'num_embeddings',
34
+ :'mime_type' => :'mime_type'
32
35
  }
33
36
  end
34
37
 
@@ -44,7 +47,8 @@ module Carbon
44
47
  :'file_size' => :'Integer',
45
48
  :'num_characters' => :'Integer',
46
49
  :'num_tokens' => :'Integer',
47
- :'num_embeddings' => :'Integer'
50
+ :'num_embeddings' => :'Integer',
51
+ :'mime_type' => :'String'
48
52
  }
49
53
  end
50
54
 
@@ -55,7 +59,8 @@ module Carbon
55
59
  :'file_size',
56
60
  :'num_characters',
57
61
  :'num_tokens',
58
- :'num_embeddings'
62
+ :'num_embeddings',
63
+ :'mime_type'
59
64
  ])
60
65
  end
61
66
 
@@ -93,6 +98,10 @@ module Carbon
93
98
  if attributes.key?(:'num_embeddings')
94
99
  self.num_embeddings = attributes[:'num_embeddings']
95
100
  end
101
+
102
+ if attributes.key?(:'mime_type')
103
+ self.mime_type = attributes[:'mime_type']
104
+ end
96
105
  end
97
106
 
98
107
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -117,7 +126,8 @@ module Carbon
117
126
  file_size == o.file_size &&
118
127
  num_characters == o.num_characters &&
119
128
  num_tokens == o.num_tokens &&
120
- num_embeddings == o.num_embeddings
129
+ num_embeddings == o.num_embeddings &&
130
+ mime_type == o.mime_type
121
131
  end
122
132
 
123
133
  # @see the `==` method
@@ -129,7 +139,7 @@ module Carbon
129
139
  # Calculates hash code according to all attributes.
130
140
  # @return [Integer] Hash code
131
141
  def hash
132
- [file_format, file_size, num_characters, num_tokens, num_embeddings].hash
142
+ [file_format, file_size, num_characters, num_tokens, num_embeddings, mime_type].hash
133
143
  end
134
144
 
135
145
  # Builds the object from hash
@@ -21,6 +21,8 @@ module Carbon
21
21
 
22
22
  attr_accessor :num_embeddings
23
23
 
24
+ attr_accessor :mime_type
25
+
24
26
  # Attribute mapping from ruby-style variable name to JSON key.
25
27
  def self.attribute_map
26
28
  {
@@ -28,7 +30,8 @@ module Carbon
28
30
  :'file_size' => :'file_size',
29
31
  :'num_characters' => :'num_characters',
30
32
  :'num_tokens' => :'num_tokens',
31
- :'num_embeddings' => :'num_embeddings'
33
+ :'num_embeddings' => :'num_embeddings',
34
+ :'mime_type' => :'mime_type'
32
35
  }
33
36
  end
34
37
 
@@ -44,7 +47,8 @@ module Carbon
44
47
  :'file_size' => :'Integer',
45
48
  :'num_characters' => :'Integer',
46
49
  :'num_tokens' => :'Integer',
47
- :'num_embeddings' => :'Integer'
50
+ :'num_embeddings' => :'Integer',
51
+ :'mime_type' => :'String'
48
52
  }
49
53
  end
50
54
 
@@ -55,7 +59,8 @@ module Carbon
55
59
  :'file_size',
56
60
  :'num_characters',
57
61
  :'num_tokens',
58
- :'num_embeddings'
62
+ :'num_embeddings',
63
+ :'mime_type'
59
64
  ])
60
65
  end
61
66
 
@@ -93,6 +98,10 @@ module Carbon
93
98
  if attributes.key?(:'num_embeddings')
94
99
  self.num_embeddings = attributes[:'num_embeddings']
95
100
  end
101
+
102
+ if attributes.key?(:'mime_type')
103
+ self.mime_type = attributes[:'mime_type']
104
+ end
96
105
  end
97
106
 
98
107
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -117,7 +126,8 @@ module Carbon
117
126
  file_size == o.file_size &&
118
127
  num_characters == o.num_characters &&
119
128
  num_tokens == o.num_tokens &&
120
- num_embeddings == o.num_embeddings
129
+ num_embeddings == o.num_embeddings &&
130
+ mime_type == o.mime_type
121
131
  end
122
132
 
123
133
  # @see the `==` method
@@ -129,7 +139,7 @@ module Carbon
129
139
  # Calculates hash code according to all attributes.
130
140
  # @return [Integer] Hash code
131
141
  def hash
132
- [file_format, file_size, num_characters, num_tokens, num_embeddings].hash
142
+ [file_format, file_size, num_characters, num_tokens, num_embeddings, mime_type].hash
133
143
  end
134
144
 
135
145
  # Builds the object from hash
@@ -33,6 +33,9 @@ module Carbon
33
33
 
34
34
  attr_accessor :request_id
35
35
 
36
+ # Enabling this flag will fetch all available content from the source to be listed via list items endpoint
37
+ attr_accessor :sync_source_items
38
+
36
39
  # Attribute mapping from ruby-style variable name to JSON key.
37
40
  def self.attribute_map
38
41
  {
@@ -46,7 +49,8 @@ module Carbon
46
49
  :'generate_sparse_vectors' => :'generate_sparse_vectors',
47
50
  :'prepend_filename_to_chunks' => :'prepend_filename_to_chunks',
48
51
  :'sync_files_on_connection' => :'sync_files_on_connection',
49
- :'request_id' => :'request_id'
52
+ :'request_id' => :'request_id',
53
+ :'sync_source_items' => :'sync_source_items'
50
54
  }
51
55
  end
52
56
 
@@ -68,7 +72,8 @@ module Carbon
68
72
  :'generate_sparse_vectors' => :'Boolean',
69
73
  :'prepend_filename_to_chunks' => :'Boolean',
70
74
  :'sync_files_on_connection' => :'Boolean',
71
- :'request_id' => :'String'
75
+ :'request_id' => :'String',
76
+ :'sync_source_items' => :'Boolean'
72
77
  }
73
78
  end
74
79
 
@@ -83,7 +88,7 @@ module Carbon
83
88
  :'generate_sparse_vectors',
84
89
  :'prepend_filename_to_chunks',
85
90
  :'sync_files_on_connection',
86
- :'request_id'
91
+ :'request_id',
87
92
  ])
88
93
  end
89
94
 
@@ -159,6 +164,12 @@ module Carbon
159
164
  if attributes.key?(:'request_id')
160
165
  self.request_id = attributes[:'request_id']
161
166
  end
167
+
168
+ if attributes.key?(:'sync_source_items')
169
+ self.sync_source_items = attributes[:'sync_source_items']
170
+ else
171
+ self.sync_source_items = true
172
+ end
162
173
  end
163
174
 
164
175
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -199,7 +210,8 @@ module Carbon
199
210
  generate_sparse_vectors == o.generate_sparse_vectors &&
200
211
  prepend_filename_to_chunks == o.prepend_filename_to_chunks &&
201
212
  sync_files_on_connection == o.sync_files_on_connection &&
202
- request_id == o.request_id
213
+ request_id == o.request_id &&
214
+ sync_source_items == o.sync_source_items
203
215
  end
204
216
 
205
217
  # @see the `==` method
@@ -211,7 +223,7 @@ module Carbon
211
223
  # Calculates hash code according to all attributes.
212
224
  # @return [Integer] Hash code
213
225
  def hash
214
- [tags, domain, api_key, chunk_size, chunk_overlap, skip_embedding_generation, embedding_model, generate_sparse_vectors, prepend_filename_to_chunks, sync_files_on_connection, request_id].hash
226
+ [tags, domain, api_key, chunk_size, chunk_overlap, skip_embedding_generation, embedding_model, generate_sparse_vectors, prepend_filename_to_chunks, sync_files_on_connection, request_id, sync_source_items].hash
215
227
  end
216
228
 
217
229
  # Builds the object from hash
@@ -33,6 +33,9 @@ module Carbon
33
33
 
34
34
  attr_accessor :request_id
35
35
 
36
+ # Enabling this flag will fetch all available content from the source to be listed via list items endpoint
37
+ attr_accessor :sync_source_items
38
+
36
39
  # Attribute mapping from ruby-style variable name to JSON key.
37
40
  def self.attribute_map
38
41
  {
@@ -46,7 +49,8 @@ module Carbon
46
49
  :'generate_sparse_vectors' => :'generate_sparse_vectors',
47
50
  :'prepend_filename_to_chunks' => :'prepend_filename_to_chunks',
48
51
  :'sync_files_on_connection' => :'sync_files_on_connection',
49
- :'request_id' => :'request_id'
52
+ :'request_id' => :'request_id',
53
+ :'sync_source_items' => :'sync_source_items'
50
54
  }
51
55
  end
52
56
 
@@ -68,7 +72,8 @@ module Carbon
68
72
  :'generate_sparse_vectors' => :'Boolean',
69
73
  :'prepend_filename_to_chunks' => :'Boolean',
70
74
  :'sync_files_on_connection' => :'Boolean',
71
- :'request_id' => :'String'
75
+ :'request_id' => :'String',
76
+ :'sync_source_items' => :'Boolean'
72
77
  }
73
78
  end
74
79
 
@@ -82,7 +87,7 @@ module Carbon
82
87
  :'generate_sparse_vectors',
83
88
  :'prepend_filename_to_chunks',
84
89
  :'sync_files_on_connection',
85
- :'request_id'
90
+ :'request_id',
86
91
  ])
87
92
  end
88
93
 
@@ -158,6 +163,12 @@ module Carbon
158
163
  if attributes.key?(:'request_id')
159
164
  self.request_id = attributes[:'request_id']
160
165
  end
166
+
167
+ if attributes.key?(:'sync_source_items')
168
+ self.sync_source_items = attributes[:'sync_source_items']
169
+ else
170
+ self.sync_source_items = true
171
+ end
161
172
  end
162
173
 
163
174
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -198,7 +209,8 @@ module Carbon
198
209
  generate_sparse_vectors == o.generate_sparse_vectors &&
199
210
  prepend_filename_to_chunks == o.prepend_filename_to_chunks &&
200
211
  sync_files_on_connection == o.sync_files_on_connection &&
201
- request_id == o.request_id
212
+ request_id == o.request_id &&
213
+ sync_source_items == o.sync_source_items
202
214
  end
203
215
 
204
216
  # @see the `==` method
@@ -210,7 +222,7 @@ module Carbon
210
222
  # Calculates hash code according to all attributes.
211
223
  # @return [Integer] Hash code
212
224
  def hash
213
- [tags, organization, access_token, chunk_size, chunk_overlap, skip_embedding_generation, embedding_model, generate_sparse_vectors, prepend_filename_to_chunks, sync_files_on_connection, request_id].hash
225
+ [tags, organization, access_token, chunk_size, chunk_overlap, skip_embedding_generation, embedding_model, generate_sparse_vectors, prepend_filename_to_chunks, sync_files_on_connection, request_id, sync_source_items].hash
214
226
  end
215
227
 
216
228
  # Builds the object from hash
@@ -15,11 +15,15 @@ module Carbon
15
15
 
16
16
  attr_accessor :access_token
17
17
 
18
+ # Enabling this flag will fetch all available content from the source to be listed via list items endpoint
19
+ attr_accessor :sync_source_items
20
+
18
21
  # Attribute mapping from ruby-style variable name to JSON key.
19
22
  def self.attribute_map
20
23
  {
21
24
  :'username' => :'username',
22
- :'access_token' => :'access_token'
25
+ :'access_token' => :'access_token',
26
+ :'sync_source_items' => :'sync_source_items'
23
27
  }
24
28
  end
25
29
 
@@ -32,7 +36,8 @@ module Carbon
32
36
  def self.openapi_types
33
37
  {
34
38
  :'username' => :'String',
35
- :'access_token' => :'String'
39
+ :'access_token' => :'String',
40
+ :'sync_source_items' => :'Boolean'
36
41
  }
37
42
  end
38
43
 
@@ -64,6 +69,12 @@ module Carbon
64
69
  if attributes.key?(:'access_token')
65
70
  self.access_token = attributes[:'access_token']
66
71
  end
72
+
73
+ if attributes.key?(:'sync_source_items')
74
+ self.sync_source_items = attributes[:'sync_source_items']
75
+ else
76
+ self.sync_source_items = false
77
+ end
67
78
  end
68
79
 
69
80
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -95,7 +106,8 @@ module Carbon
95
106
  return true if self.equal?(o)
96
107
  self.class == o.class &&
97
108
  username == o.username &&
98
- access_token == o.access_token
109
+ access_token == o.access_token &&
110
+ sync_source_items == o.sync_source_items
99
111
  end
100
112
 
101
113
  # @see the `==` method
@@ -107,7 +119,7 @@ module Carbon
107
119
  # Calculates hash code according to all attributes.
108
120
  # @return [Integer] Hash code
109
121
  def hash
110
- [username, access_token].hash
122
+ [username, access_token, sync_source_items].hash
111
123
  end
112
124
 
113
125
  # Builds the object from hash
@@ -0,0 +1,260 @@
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 GithubFetchReposRequest
14
+ attr_accessor :repos
15
+
16
+ attr_accessor :data_source_id
17
+
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ :'repos' => :'repos',
22
+ :'data_source_id' => :'data_source_id'
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
+ :'repos' => :'Array<String>',
35
+ :'data_source_id' => :'Integer'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ :'data_source_id'
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::GithubFetchReposRequest` 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::GithubFetchReposRequest`. 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?(:'repos')
62
+ if (value = attributes[:'repos']).is_a?(Array)
63
+ self.repos = value
64
+ end
65
+ end
66
+
67
+ if attributes.key?(:'data_source_id')
68
+ self.data_source_id = attributes[:'data_source_id']
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 @repos.nil?
77
+ invalid_properties.push('invalid value for "repos", repos cannot be nil.')
78
+ end
79
+
80
+ if @repos.length > 25
81
+ invalid_properties.push('invalid value for "repos", number of items must be less than or equal to 25.')
82
+ end
83
+
84
+ if @repos.length < 1
85
+ invalid_properties.push('invalid value for "repos", number of items must be greater than or equal to 1.')
86
+ end
87
+
88
+ invalid_properties
89
+ end
90
+
91
+ # Check to see if the all the properties in the model are valid
92
+ # @return true if the model is valid
93
+ def valid?
94
+ return false if @repos.nil?
95
+ return false if @repos.length > 25
96
+ return false if @repos.length < 1
97
+ true
98
+ end
99
+
100
+ # Custom attribute writer method with validation
101
+ # @param [Object] repos Value to be assigned
102
+ def repos=(repos)
103
+ if repos.nil?
104
+ fail ArgumentError, 'repos cannot be nil'
105
+ end
106
+
107
+ if repos.length > 25
108
+ fail ArgumentError, 'invalid value for "repos", number of items must be less than or equal to 25.'
109
+ end
110
+
111
+ if repos.length < 1
112
+ fail ArgumentError, 'invalid value for "repos", number of items must be greater than or equal to 1.'
113
+ end
114
+
115
+ @repos = repos
116
+ end
117
+
118
+ # Checks equality by comparing each attribute.
119
+ # @param [Object] Object to be compared
120
+ def ==(o)
121
+ return true if self.equal?(o)
122
+ self.class == o.class &&
123
+ repos == o.repos &&
124
+ data_source_id == o.data_source_id
125
+ end
126
+
127
+ # @see the `==` method
128
+ # @param [Object] Object to be compared
129
+ def eql?(o)
130
+ self == o
131
+ end
132
+
133
+ # Calculates hash code according to all attributes.
134
+ # @return [Integer] Hash code
135
+ def hash
136
+ [repos, data_source_id].hash
137
+ end
138
+
139
+ # Builds the object from hash
140
+ # @param [Hash] attributes Model attributes in the form of hash
141
+ # @return [Object] Returns the model itself
142
+ def self.build_from_hash(attributes)
143
+ new.build_from_hash(attributes)
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+ attributes = attributes.transform_keys(&:to_sym)
152
+ self.class.openapi_types.each_pair do |key, type|
153
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
154
+ self.send("#{key}=", nil)
155
+ elsif type =~ /\AArray<(.*)>/i
156
+ # check to ensure the input is an array given that the attribute
157
+ # is documented as an array but the input is not
158
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
159
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
160
+ end
161
+ elsif !attributes[self.class.attribute_map[key]].nil?
162
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
163
+ end
164
+ end
165
+
166
+ self
167
+ end
168
+
169
+ # Deserializes the data based on type
170
+ # @param string type Data type
171
+ # @param string value Value to be deserialized
172
+ # @return [Object] Deserialized data
173
+ def _deserialize(type, value)
174
+ case type.to_sym
175
+ when :Time
176
+ Time.parse(value)
177
+ when :Date
178
+ Date.parse(value)
179
+ when :String
180
+ value.to_s
181
+ when :Integer
182
+ value.to_i
183
+ when :Float
184
+ value.to_f
185
+ when :Boolean
186
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
187
+ true
188
+ else
189
+ false
190
+ end
191
+ when :Object
192
+ # generic object (usually a Hash), return directly
193
+ value
194
+ when /\AArray<(?<inner_type>.+)>\z/
195
+ inner_type = Regexp.last_match[:inner_type]
196
+ value.map { |v| _deserialize(inner_type, v) }
197
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
198
+ k_type = Regexp.last_match[:k_type]
199
+ v_type = Regexp.last_match[:v_type]
200
+ {}.tap do |hash|
201
+ value.each do |k, v|
202
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
203
+ end
204
+ end
205
+ else # model
206
+ # models (e.g. Pet) or oneOf
207
+ klass = Carbon.const_get(type)
208
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
209
+ end
210
+ end
211
+
212
+ # Returns the string representation of the object
213
+ # @return [String] String presentation of the object
214
+ def to_s
215
+ to_hash.to_s
216
+ end
217
+
218
+ # to_body is an alias to to_hash (backward compatibility)
219
+ # @return [Hash] Returns the object in the form of hash
220
+ def to_body
221
+ to_hash
222
+ end
223
+
224
+ # Returns the object in the form of hash
225
+ # @return [Hash] Returns the object in the form of hash
226
+ def to_hash
227
+ hash = {}
228
+ self.class.attribute_map.each_pair do |attr, param|
229
+ value = self.send(attr)
230
+ if value.nil?
231
+ is_nullable = self.class.openapi_nullable.include?(attr)
232
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
233
+ end
234
+
235
+ hash[param] = _to_hash(value)
236
+ end
237
+ hash
238
+ end
239
+
240
+ # Outputs non-array value in the form of hash
241
+ # For object, use to_hash. Otherwise, just return the value
242
+ # @param [Object] value Any valid value
243
+ # @return [Hash] Returns the value in the form of hash
244
+ def _to_hash(value)
245
+ if value.is_a?(Array)
246
+ value.compact.map { |v| _to_hash(v) }
247
+ elsif value.is_a?(Hash)
248
+ {}.tap do |hash|
249
+ value.each { |k, v| hash[k] = _to_hash(v) }
250
+ end
251
+ elsif value.respond_to? :to_hash
252
+ value.to_hash
253
+ else
254
+ value
255
+ end
256
+ end
257
+
258
+ end
259
+
260
+ end