carbon_ruby_sdk 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +89 -0
- data/README.md +2325 -0
- data/Rakefile +10 -0
- data/carbon_ruby_sdk.gemspec +39 -0
- data/header.png +0 -0
- data/lib/carbon_ruby_sdk/api/auth_api.rb +177 -0
- data/lib/carbon_ruby_sdk/api/data_sources_api.rb +217 -0
- data/lib/carbon_ruby_sdk/api/embeddings_api.rb +565 -0
- data/lib/carbon_ruby_sdk/api/files_api.rb +1526 -0
- data/lib/carbon_ruby_sdk/api/health_api.rb +92 -0
- data/lib/carbon_ruby_sdk/api/integrations_api.rb +2201 -0
- data/lib/carbon_ruby_sdk/api/organizations_api.rb +92 -0
- data/lib/carbon_ruby_sdk/api/users_api.rb +209 -0
- data/lib/carbon_ruby_sdk/api/utilities_api.rb +710 -0
- data/lib/carbon_ruby_sdk/api/webhooks_api.rb +296 -0
- data/lib/carbon_ruby_sdk/api_client.rb +436 -0
- data/lib/carbon_ruby_sdk/api_client_custom.rb +14 -0
- data/lib/carbon_ruby_sdk/api_error.rb +53 -0
- data/lib/carbon_ruby_sdk/configuration.rb +354 -0
- data/lib/carbon_ruby_sdk/models/add_webhook_props.rb +220 -0
- data/lib/carbon_ruby_sdk/models/body_create_upload_file_uploadfile_post.rb +220 -0
- data/lib/carbon_ruby_sdk/models/chunk_properties.rb +248 -0
- data/lib/carbon_ruby_sdk/models/chunk_properties_nullable.rb +248 -0
- data/lib/carbon_ruby_sdk/models/chunks_and_embeddings.rb +246 -0
- data/lib/carbon_ruby_sdk/models/chunks_and_embeddings_upload_input.rb +247 -0
- data/lib/carbon_ruby_sdk/models/data_source_last_sync_actions.rb +38 -0
- data/lib/carbon_ruby_sdk/models/data_source_sync_statuses.rb +38 -0
- data/lib/carbon_ruby_sdk/models/data_source_type.rb +76 -0
- data/lib/carbon_ruby_sdk/models/data_source_type_nullable.rb +76 -0
- data/lib/carbon_ruby_sdk/models/delete_files_query_input.rb +252 -0
- data/lib/carbon_ruby_sdk/models/directory_item.rb +266 -0
- data/lib/carbon_ruby_sdk/models/document_response.rb +328 -0
- data/lib/carbon_ruby_sdk/models/document_response_list.rb +222 -0
- data/lib/carbon_ruby_sdk/models/embedding_and_chunk.rb +256 -0
- data/lib/carbon_ruby_sdk/models/embedding_generators.rb +43 -0
- data/lib/carbon_ruby_sdk/models/embedding_generators_nullable.rb +43 -0
- data/lib/carbon_ruby_sdk/models/embedding_properties.rb +226 -0
- data/lib/carbon_ruby_sdk/models/embeddings_and_chunks_filters.rb +232 -0
- data/lib/carbon_ruby_sdk/models/embeddings_and_chunks_order_by_columns.rb +37 -0
- data/lib/carbon_ruby_sdk/models/embeddings_and_chunks_query_input.rb +262 -0
- data/lib/carbon_ruby_sdk/models/embeddings_and_chunks_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/external_file_sync_statuses.rb +43 -0
- data/lib/carbon_ruby_sdk/models/external_source_item.rb +420 -0
- data/lib/carbon_ruby_sdk/models/fetch_urls_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/file_content_types.rb +36 -0
- data/lib/carbon_ruby_sdk/models/file_content_types_nullable.rb +36 -0
- data/lib/carbon_ruby_sdk/models/file_formats.rb +76 -0
- data/lib/carbon_ruby_sdk/models/file_formats_nullable.rb +76 -0
- data/lib/carbon_ruby_sdk/models/file_statistics.rb +256 -0
- data/lib/carbon_ruby_sdk/models/file_statistics_nullable.rb +256 -0
- data/lib/carbon_ruby_sdk/models/fresh_desk_connect_request.rb +316 -0
- data/lib/carbon_ruby_sdk/models/generic_success_response.rb +220 -0
- data/lib/carbon_ruby_sdk/models/get_embedding_documents_body.rb +416 -0
- data/lib/carbon_ruby_sdk/models/gitbook_connect_request.rb +234 -0
- data/lib/carbon_ruby_sdk/models/gitbook_sync_request.rb +336 -0
- data/lib/carbon_ruby_sdk/models/gmail_sync_input.rb +301 -0
- data/lib/carbon_ruby_sdk/models/http_validation_error.rb +217 -0
- data/lib/carbon_ruby_sdk/models/hybrid_search_tuning_params.rb +234 -0
- data/lib/carbon_ruby_sdk/models/hybrid_search_tuning_params_nullable.rb +235 -0
- data/lib/carbon_ruby_sdk/models/list_data_source_items_request.rb +239 -0
- data/lib/carbon_ruby_sdk/models/list_data_source_items_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/list_request.rb +230 -0
- data/lib/carbon_ruby_sdk/models/list_response.rb +222 -0
- data/lib/carbon_ruby_sdk/models/location_property_inner.rb +226 -0
- data/lib/carbon_ruby_sdk/models/modify_user_configuration_input.rb +234 -0
- data/lib/carbon_ruby_sdk/models/o_auth_url_request.rb +362 -0
- data/lib/carbon_ruby_sdk/models/order_dir.rb +36 -0
- data/lib/carbon_ruby_sdk/models/organization_response.rb +362 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_api.rb +380 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_filters.rb +238 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_order_by_columns.rb +36 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_query_input.rb +246 -0
- data/lib/carbon_ruby_sdk/models/organization_user_data_source_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/organization_user_file_tag_create.rb +236 -0
- data/lib/carbon_ruby_sdk/models/organization_user_file_tags_remove.rb +236 -0
- data/lib/carbon_ruby_sdk/models/organization_user_files_to_sync_filters.rb +330 -0
- data/lib/carbon_ruby_sdk/models/organization_user_files_to_sync_order_by_types.rb +39 -0
- data/lib/carbon_ruby_sdk/models/organization_user_files_to_sync_query_input.rb +276 -0
- data/lib/carbon_ruby_sdk/models/outlook_sync_input.rb +313 -0
- data/lib/carbon_ruby_sdk/models/pagination.rb +228 -0
- data/lib/carbon_ruby_sdk/models/presigned_url_response.rb +220 -0
- data/lib/carbon_ruby_sdk/models/rank_property.rb +226 -0
- data/lib/carbon_ruby_sdk/models/raw_text_input.rb +295 -0
- data/lib/carbon_ruby_sdk/models/raw_transcript_property_inner_value.rb +226 -0
- data/lib/carbon_ruby_sdk/models/resync_file_query_input.rb +240 -0
- data/lib/carbon_ruby_sdk/models/revoke_access_token_input.rb +220 -0
- data/lib/carbon_ruby_sdk/models/rss_feed_input.rb +301 -0
- data/lib/carbon_ruby_sdk/models/s3_auth_request.rb +234 -0
- data/lib/carbon_ruby_sdk/models/s3_file_sync_input.rb +313 -0
- data/lib/carbon_ruby_sdk/models/s3_get_file_input.rb +226 -0
- data/lib/carbon_ruby_sdk/models/single_chunks_and_embeddings_upload_input.rb +256 -0
- data/lib/carbon_ruby_sdk/models/sitemap_scrape_request.rb +361 -0
- data/lib/carbon_ruby_sdk/models/source_property.rb +226 -0
- data/lib/carbon_ruby_sdk/models/sync_directory_request.rb +220 -0
- data/lib/carbon_ruby_sdk/models/sync_files_request.rb +328 -0
- data/lib/carbon_ruby_sdk/models/tags.rb +232 -0
- data/lib/carbon_ruby_sdk/models/tags1.rb +230 -0
- data/lib/carbon_ruby_sdk/models/text_embedding_generators.rb +42 -0
- data/lib/carbon_ruby_sdk/models/token_response.rb +234 -0
- data/lib/carbon_ruby_sdk/models/upload_file_from_url_input.rb +326 -0
- data/lib/carbon_ruby_sdk/models/user_file.rb +524 -0
- data/lib/carbon_ruby_sdk/models/user_files_v2.rb +236 -0
- data/lib/carbon_ruby_sdk/models/user_request_content.rb +220 -0
- data/lib/carbon_ruby_sdk/models/user_response.rb +354 -0
- data/lib/carbon_ruby_sdk/models/validation_error.rb +250 -0
- data/lib/carbon_ruby_sdk/models/webhook.rb +290 -0
- data/lib/carbon_ruby_sdk/models/webhook_filters.rb +218 -0
- data/lib/carbon_ruby_sdk/models/webhook_no_key.rb +276 -0
- data/lib/carbon_ruby_sdk/models/webhook_order_by_columns.rb +36 -0
- data/lib/carbon_ruby_sdk/models/webhook_query_input.rb +246 -0
- data/lib/carbon_ruby_sdk/models/webhook_query_response.rb +236 -0
- data/lib/carbon_ruby_sdk/models/webscrape_request.rb +375 -0
- data/lib/carbon_ruby_sdk/models/white_labeling_response.rb +234 -0
- data/lib/carbon_ruby_sdk/models/youtube_transcript_response.rb +252 -0
- data/lib/carbon_ruby_sdk/version.rb +11 -0
- data/lib/carbon_ruby_sdk.rb +207 -0
- data/spec/api/auth_api_spec.rb +50 -0
- data/spec/api/data_sources_api_spec.rb +51 -0
- data/spec/api/embeddings_api_spec.rb +63 -0
- data/spec/api/files_api_spec.rb +178 -0
- data/spec/api/health_api_spec.rb +39 -0
- data/spec/api/integrations_api_spec.rb +226 -0
- data/spec/api/organizations_api_spec.rb +39 -0
- data/spec/api/users_api_spec.rb +51 -0
- data/spec/api/utilities_api_spec.rb +102 -0
- data/spec/api/webhooks_api_spec.rb +62 -0
- data/spec/api_client_spec.rb +191 -0
- data/spec/configuration_spec.rb +38 -0
- data/spec/getting_started_spec.rb +196 -0
- data/spec/models/add_webhook_props_spec.rb +28 -0
- data/spec/models/body_create_upload_file_uploadfile_post_spec.rb +28 -0
- data/spec/models/chunk_properties_nullable_spec.rb +40 -0
- data/spec/models/chunk_properties_spec.rb +40 -0
- data/spec/models/chunks_and_embeddings_spec.rb +40 -0
- data/spec/models/chunks_and_embeddings_upload_input_spec.rb +40 -0
- data/spec/models/data_source_last_sync_actions_spec.rb +22 -0
- data/spec/models/data_source_sync_statuses_spec.rb +22 -0
- data/spec/models/data_source_type_nullable_spec.rb +22 -0
- data/spec/models/data_source_type_spec.rb +22 -0
- data/spec/models/delete_files_query_input_spec.rb +46 -0
- data/spec/models/directory_item_spec.rb +46 -0
- data/spec/models/document_response_list_spec.rb +28 -0
- data/spec/models/document_response_spec.rb +88 -0
- data/spec/models/embedding_and_chunk_spec.rb +46 -0
- data/spec/models/embedding_generators_nullable_spec.rb +22 -0
- data/spec/models/embedding_generators_spec.rb +22 -0
- data/spec/models/embedding_properties_spec.rb +34 -0
- data/spec/models/embeddings_and_chunks_filters_spec.rb +34 -0
- data/spec/models/embeddings_and_chunks_order_by_columns_spec.rb +22 -0
- data/spec/models/embeddings_and_chunks_query_input_spec.rb +52 -0
- data/spec/models/embeddings_and_chunks_response_spec.rb +34 -0
- data/spec/models/external_file_sync_statuses_spec.rb +22 -0
- data/spec/models/external_source_item_spec.rb +124 -0
- data/spec/models/fetch_urls_response_spec.rb +34 -0
- data/spec/models/file_content_types_nullable_spec.rb +22 -0
- data/spec/models/file_content_types_spec.rb +22 -0
- data/spec/models/file_formats_nullable_spec.rb +22 -0
- data/spec/models/file_formats_spec.rb +22 -0
- data/spec/models/file_statistics_nullable_spec.rb +52 -0
- data/spec/models/file_statistics_spec.rb +52 -0
- data/spec/models/fresh_desk_connect_request_spec.rb +76 -0
- data/spec/models/generic_success_response_spec.rb +28 -0
- data/spec/models/get_embedding_documents_body_spec.rb +106 -0
- data/spec/models/gitbook_connect_request_spec.rb +34 -0
- data/spec/models/gitbook_sync_request_spec.rb +76 -0
- data/spec/models/gmail_sync_input_spec.rb +70 -0
- data/spec/models/http_validation_error_spec.rb +28 -0
- data/spec/models/hybrid_search_tuning_params_nullable_spec.rb +34 -0
- data/spec/models/hybrid_search_tuning_params_spec.rb +34 -0
- data/spec/models/list_data_source_items_request_spec.rb +40 -0
- data/spec/models/list_data_source_items_response_spec.rb +34 -0
- data/spec/models/list_request_spec.rb +34 -0
- data/spec/models/list_response_spec.rb +28 -0
- data/spec/models/location_property_inner_spec.rb +22 -0
- data/spec/models/modify_user_configuration_input_spec.rb +34 -0
- data/spec/models/o_auth_url_request_spec.rb +106 -0
- data/spec/models/order_dir_spec.rb +22 -0
- data/spec/models/organization_response_spec.rb +94 -0
- data/spec/models/organization_user_data_source_api_spec.rb +100 -0
- data/spec/models/organization_user_data_source_filters_spec.rb +40 -0
- data/spec/models/organization_user_data_source_order_by_columns_spec.rb +22 -0
- data/spec/models/organization_user_data_source_query_input_spec.rb +46 -0
- data/spec/models/organization_user_data_source_response_spec.rb +34 -0
- data/spec/models/organization_user_file_tag_create_spec.rb +34 -0
- data/spec/models/organization_user_file_tags_remove_spec.rb +34 -0
- data/spec/models/organization_user_files_to_sync_filters_spec.rb +88 -0
- data/spec/models/organization_user_files_to_sync_order_by_types_spec.rb +22 -0
- data/spec/models/organization_user_files_to_sync_query_input_spec.rb +64 -0
- data/spec/models/outlook_sync_input_spec.rb +76 -0
- data/spec/models/pagination_spec.rb +34 -0
- data/spec/models/presigned_url_response_spec.rb +28 -0
- data/spec/models/rank_property_spec.rb +22 -0
- data/spec/models/raw_text_input_spec.rb +70 -0
- data/spec/models/raw_transcript_property_inner_value_spec.rb +22 -0
- data/spec/models/resync_file_query_input_spec.rb +40 -0
- data/spec/models/revoke_access_token_input_spec.rb +28 -0
- data/spec/models/rss_feed_input_spec.rb +70 -0
- data/spec/models/s3_auth_request_spec.rb +34 -0
- data/spec/models/s3_file_sync_input_spec.rb +76 -0
- data/spec/models/s3_get_file_input_spec.rb +34 -0
- data/spec/models/single_chunks_and_embeddings_upload_input_spec.rb +46 -0
- data/spec/models/sitemap_scrape_request_spec.rb +100 -0
- data/spec/models/source_property_spec.rb +22 -0
- data/spec/models/sync_directory_request_spec.rb +28 -0
- data/spec/models/sync_files_request_spec.rb +82 -0
- data/spec/models/tags1_spec.rb +22 -0
- data/spec/models/tags_spec.rb +22 -0
- data/spec/models/text_embedding_generators_spec.rb +22 -0
- data/spec/models/token_response_spec.rb +34 -0
- data/spec/models/upload_file_from_url_input_spec.rb +88 -0
- data/spec/models/user_file_spec.rb +190 -0
- data/spec/models/user_files_v2_spec.rb +34 -0
- data/spec/models/user_request_content_spec.rb +28 -0
- data/spec/models/user_response_spec.rb +88 -0
- data/spec/models/validation_error_spec.rb +40 -0
- data/spec/models/webhook_filters_spec.rb +28 -0
- data/spec/models/webhook_no_key_spec.rb +52 -0
- data/spec/models/webhook_order_by_columns_spec.rb +22 -0
- data/spec/models/webhook_query_input_spec.rb +46 -0
- data/spec/models/webhook_query_response_spec.rb +34 -0
- data/spec/models/webhook_spec.rb +58 -0
- data/spec/models/webscrape_request_spec.rb +106 -0
- data/spec/models/white_labeling_response_spec.rb +34 -0
- data/spec/models/youtube_transcript_response_spec.rb +46 -0
- data/spec/spec_helper.rb +107 -0
- metadata +440 -0
@@ -0,0 +1,354 @@
|
|
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
|
+
module Carbon
|
10
|
+
class Configuration
|
11
|
+
# Defines url scheme
|
12
|
+
attr_accessor :scheme
|
13
|
+
|
14
|
+
# Defines url host
|
15
|
+
attr_accessor :host
|
16
|
+
|
17
|
+
# Defines url base path
|
18
|
+
attr_accessor :base_path
|
19
|
+
|
20
|
+
# Define server configuration index
|
21
|
+
attr_accessor :server_index
|
22
|
+
|
23
|
+
# Define server operation configuration index
|
24
|
+
attr_accessor :server_operation_index
|
25
|
+
|
26
|
+
# Default server variables
|
27
|
+
attr_accessor :server_variables
|
28
|
+
|
29
|
+
# Default server operation variables
|
30
|
+
attr_accessor :server_operation_variables
|
31
|
+
|
32
|
+
def access_token=(value)
|
33
|
+
@api_key_store['accessToken'] = value
|
34
|
+
end
|
35
|
+
|
36
|
+
def api_key=(value)
|
37
|
+
@api_key_store['apiKey'] = value
|
38
|
+
end
|
39
|
+
|
40
|
+
def customer_id=(value)
|
41
|
+
@api_key_store['customerId'] = value
|
42
|
+
end
|
43
|
+
|
44
|
+
# Defines API keys used with API Key authentications.
|
45
|
+
#
|
46
|
+
# @return [Hash] key: parameter name, value: parameter value (API key)
|
47
|
+
#
|
48
|
+
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
49
|
+
# config.api_key_store['api_key'] = 'xxx'
|
50
|
+
attr_accessor :api_key_store
|
51
|
+
|
52
|
+
# Defines API key prefixes used with API Key authentications.
|
53
|
+
#
|
54
|
+
# @return [Hash] key: parameter name, value: API key prefix
|
55
|
+
#
|
56
|
+
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
57
|
+
# config.api_key_prefix['api_key'] = 'Token'
|
58
|
+
attr_accessor :api_key_prefix
|
59
|
+
|
60
|
+
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
61
|
+
# details will be logged with `logger.debug` (see the `logger` attribute).
|
62
|
+
# Default to false.
|
63
|
+
#
|
64
|
+
# @return [true, false]
|
65
|
+
attr_accessor :debugging
|
66
|
+
|
67
|
+
# Defines the logger used for debugging.
|
68
|
+
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
69
|
+
#
|
70
|
+
# @return [#debug]
|
71
|
+
attr_accessor :logger
|
72
|
+
|
73
|
+
# Defines the temporary folder to store downloaded files
|
74
|
+
# (for API endpoints that have file response).
|
75
|
+
# Default to use `Tempfile`.
|
76
|
+
#
|
77
|
+
# @return [String]
|
78
|
+
attr_accessor :temp_folder_path
|
79
|
+
|
80
|
+
# The time limit for HTTP request in seconds.
|
81
|
+
# Default to 0 (never times out).
|
82
|
+
attr_accessor :timeout
|
83
|
+
|
84
|
+
# Set this to false to skip client side validation in the operation.
|
85
|
+
# Default to true.
|
86
|
+
# @return [true, false]
|
87
|
+
attr_accessor :client_side_validation
|
88
|
+
|
89
|
+
### TLS/SSL setting
|
90
|
+
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
91
|
+
# Default to true.
|
92
|
+
#
|
93
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
94
|
+
#
|
95
|
+
# @return [true, false]
|
96
|
+
attr_accessor :ssl_verify
|
97
|
+
|
98
|
+
### TLS/SSL setting
|
99
|
+
# Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
|
100
|
+
#
|
101
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
102
|
+
#
|
103
|
+
attr_accessor :ssl_verify_mode
|
104
|
+
|
105
|
+
### TLS/SSL setting
|
106
|
+
# Set this to customize the certificate file to verify the peer.
|
107
|
+
#
|
108
|
+
# @return [String] the path to the certificate file
|
109
|
+
attr_accessor :ssl_ca_file
|
110
|
+
|
111
|
+
### TLS/SSL setting
|
112
|
+
# Client certificate file (for client certificate)
|
113
|
+
attr_accessor :ssl_client_cert
|
114
|
+
|
115
|
+
### TLS/SSL setting
|
116
|
+
# Client private key file (for client certificate)
|
117
|
+
attr_accessor :ssl_client_key
|
118
|
+
|
119
|
+
### Proxy setting
|
120
|
+
# HTTP Proxy settings
|
121
|
+
attr_accessor :proxy
|
122
|
+
|
123
|
+
# Set this to customize parameters encoder of array parameter.
|
124
|
+
# Default to nil. Faraday uses NestedParamsEncoder when nil.
|
125
|
+
#
|
126
|
+
# @see The params_encoder option of Faraday. Related source code:
|
127
|
+
# https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders
|
128
|
+
attr_accessor :params_encoder
|
129
|
+
|
130
|
+
|
131
|
+
attr_accessor :inject_format
|
132
|
+
|
133
|
+
attr_accessor :force_ending_format
|
134
|
+
|
135
|
+
def initialize
|
136
|
+
@scheme = 'https'
|
137
|
+
@host = 'api.carbon.ai'
|
138
|
+
@base_path = ''
|
139
|
+
@server_index = 0
|
140
|
+
@server_operation_index = {}
|
141
|
+
@server_variables = {}
|
142
|
+
@server_operation_variables = {}
|
143
|
+
@api_key_store = {}
|
144
|
+
@api_key_prefix = {}
|
145
|
+
@api_key_prefix['accessToken'] = 'Token '
|
146
|
+
@api_key_prefix['apiKey'] = 'Bearer '
|
147
|
+
@client_side_validation = true
|
148
|
+
@ssl_verify = true
|
149
|
+
@ssl_verify_mode = nil
|
150
|
+
@ssl_ca_file = nil
|
151
|
+
@ssl_client_cert = nil
|
152
|
+
@ssl_client_key = nil
|
153
|
+
@middlewares = Hash.new { |h, k| h[k] = [] }
|
154
|
+
@timeout = 60
|
155
|
+
# return data as binary instead of file
|
156
|
+
@return_binary_data = false
|
157
|
+
@params_encoder = nil
|
158
|
+
@debugging = false
|
159
|
+
@inject_format = false
|
160
|
+
@force_ending_format = false
|
161
|
+
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
162
|
+
|
163
|
+
yield(self) if block_given?
|
164
|
+
end
|
165
|
+
|
166
|
+
# The default Configuration object.
|
167
|
+
def self.default
|
168
|
+
@@default ||= Configuration.new
|
169
|
+
end
|
170
|
+
|
171
|
+
def configure
|
172
|
+
yield(self) if block_given?
|
173
|
+
end
|
174
|
+
|
175
|
+
def scheme=(scheme)
|
176
|
+
# remove :// from scheme
|
177
|
+
@scheme = scheme.sub(/:\/\//, '')
|
178
|
+
end
|
179
|
+
|
180
|
+
def host=(host)
|
181
|
+
# remove http(s):// and anything after a slash
|
182
|
+
@host = host.sub(/https?:\/\//, '').split('/').first
|
183
|
+
|
184
|
+
# try to set @scheme and @base_path if possible
|
185
|
+
begin
|
186
|
+
uri = URI.parse(host)
|
187
|
+
@scheme = uri.scheme
|
188
|
+
@base_path = uri.path
|
189
|
+
rescue InvalidURIError
|
190
|
+
end
|
191
|
+
|
192
|
+
# unset server_index so host is used when getting request url (see ApiClient#build_request_url)
|
193
|
+
@server_index = nil
|
194
|
+
end
|
195
|
+
|
196
|
+
def base_path=(base_path)
|
197
|
+
# Add leading and trailing slashes to base_path
|
198
|
+
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
199
|
+
@base_path = '' if @base_path == '/'
|
200
|
+
end
|
201
|
+
|
202
|
+
# Returns base URL for specified operation based on server settings
|
203
|
+
def base_url(operation = nil)
|
204
|
+
index = server_operation_index.fetch(operation, server_index)
|
205
|
+
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
|
206
|
+
|
207
|
+
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
208
|
+
end
|
209
|
+
|
210
|
+
# Gets API key (with prefix if set).
|
211
|
+
# @param [String] param_name the parameter name of API key auth
|
212
|
+
def api_key_with_prefix(param_name, param_alias = nil)
|
213
|
+
value = @api_key_store[param_name]
|
214
|
+
value = @api_key_store.fetch(param_alias, value) unless param_alias.nil?
|
215
|
+
return nil if value.nil?
|
216
|
+
if @api_key_prefix[param_name]
|
217
|
+
"#{@api_key_prefix[param_name]}#{value}"
|
218
|
+
else
|
219
|
+
value
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns Auth Settings hash for api client.
|
224
|
+
def auth_settings
|
225
|
+
{
|
226
|
+
'accessToken' =>
|
227
|
+
{
|
228
|
+
type: 'api_key',
|
229
|
+
in: 'header',
|
230
|
+
key: 'authorization',
|
231
|
+
value: api_key_with_prefix('accessToken')
|
232
|
+
},
|
233
|
+
'apiKey' =>
|
234
|
+
{
|
235
|
+
type: 'api_key',
|
236
|
+
in: 'header',
|
237
|
+
key: 'authorization',
|
238
|
+
value: api_key_with_prefix('apiKey')
|
239
|
+
},
|
240
|
+
'customerId' =>
|
241
|
+
{
|
242
|
+
type: 'api_key',
|
243
|
+
in: 'header',
|
244
|
+
key: 'customer-id',
|
245
|
+
value: api_key_with_prefix('customerId')
|
246
|
+
},
|
247
|
+
}
|
248
|
+
end
|
249
|
+
|
250
|
+
# Returns an array of Server setting
|
251
|
+
def server_settings
|
252
|
+
[
|
253
|
+
{
|
254
|
+
url: "https://api.carbon.ai",
|
255
|
+
description: "No description provided",
|
256
|
+
}
|
257
|
+
]
|
258
|
+
end
|
259
|
+
|
260
|
+
def operation_server_settings
|
261
|
+
{
|
262
|
+
}
|
263
|
+
end
|
264
|
+
|
265
|
+
# Returns URL based on server settings
|
266
|
+
#
|
267
|
+
# @param index array index of the server settings
|
268
|
+
# @param variables hash of variable and the corresponding value
|
269
|
+
def server_url(index, variables = {}, servers = nil)
|
270
|
+
servers = server_settings if servers == nil
|
271
|
+
|
272
|
+
# check array index out of bound
|
273
|
+
if (index < 0 || index >= servers.size)
|
274
|
+
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
275
|
+
end
|
276
|
+
|
277
|
+
server = servers[index]
|
278
|
+
url = server[:url]
|
279
|
+
|
280
|
+
return url unless server.key? :variables
|
281
|
+
|
282
|
+
# go through variable and assign a value
|
283
|
+
server[:variables].each do |name, variable|
|
284
|
+
if variables.key?(name)
|
285
|
+
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
|
286
|
+
url.gsub! "{" + name.to_s + "}", variables[name]
|
287
|
+
else
|
288
|
+
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
|
289
|
+
end
|
290
|
+
else
|
291
|
+
# use default value
|
292
|
+
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
url
|
297
|
+
end
|
298
|
+
|
299
|
+
# Adds middleware to the stack
|
300
|
+
def use(*middleware)
|
301
|
+
set_faraday_middleware(:use, *middleware)
|
302
|
+
end
|
303
|
+
|
304
|
+
# Adds request middleware to the stack
|
305
|
+
def request(*middleware)
|
306
|
+
set_faraday_middleware(:request, *middleware)
|
307
|
+
end
|
308
|
+
|
309
|
+
# Adds response middleware to the stack
|
310
|
+
def response(*middleware)
|
311
|
+
set_faraday_middleware(:response, *middleware)
|
312
|
+
end
|
313
|
+
|
314
|
+
# Adds Faraday middleware setting information to the stack
|
315
|
+
#
|
316
|
+
# @example Use the `set_faraday_middleware` method to set middleware information
|
317
|
+
# config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
|
318
|
+
# config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
|
319
|
+
# config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
|
320
|
+
# config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
|
321
|
+
# config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger)
|
322
|
+
# config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
|
323
|
+
#
|
324
|
+
# @see https://github.com/lostisland/faraday/blob/v2.3.0/lib/faraday/rack_builder.rb#L92-L143
|
325
|
+
def set_faraday_middleware(operation, key, *args, &block)
|
326
|
+
unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation)
|
327
|
+
fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \
|
328
|
+
" :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete."
|
329
|
+
end
|
330
|
+
|
331
|
+
@middlewares[operation] << [key, args, block]
|
332
|
+
end
|
333
|
+
ruby2_keywords(:set_faraday_middleware) if respond_to?(:ruby2_keywords, true)
|
334
|
+
|
335
|
+
# Set up middleware on the connection
|
336
|
+
def configure_middleware(connection)
|
337
|
+
return if @middlewares.empty?
|
338
|
+
|
339
|
+
[:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation|
|
340
|
+
next unless @middlewares.key?(operation)
|
341
|
+
|
342
|
+
@middlewares[operation].each do |key, args, block|
|
343
|
+
connection.builder.send(operation, key, *args, &block)
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
if @middlewares.key?(:delete)
|
348
|
+
@middlewares[:delete].each do |key, _args, _block|
|
349
|
+
connection.builder.delete(key)
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
@@ -0,0 +1,220 @@
|
|
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 AddWebhookProps
|
14
|
+
attr_accessor :url
|
15
|
+
|
16
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
:'url' => :'url'
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns all the JSON keys this model knows about
|
24
|
+
def self.acceptable_attributes
|
25
|
+
attribute_map.values
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.openapi_types
|
30
|
+
{
|
31
|
+
:'url' => :'String'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# List of attributes with nullable: true
|
36
|
+
def self.openapi_nullable
|
37
|
+
Set.new([
|
38
|
+
])
|
39
|
+
end
|
40
|
+
|
41
|
+
# Initializes the object
|
42
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
43
|
+
def initialize(attributes = {})
|
44
|
+
if (!attributes.is_a?(Hash))
|
45
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::AddWebhookProps` initialize method"
|
46
|
+
end
|
47
|
+
|
48
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
49
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
50
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
51
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::AddWebhookProps`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
52
|
+
end
|
53
|
+
h[k.to_sym] = v
|
54
|
+
}
|
55
|
+
|
56
|
+
if attributes.key?(:'url')
|
57
|
+
self.url = attributes[:'url']
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
62
|
+
# @return Array for valid properties with the reasons
|
63
|
+
def list_invalid_properties
|
64
|
+
invalid_properties = Array.new
|
65
|
+
if @url.nil?
|
66
|
+
invalid_properties.push('invalid value for "url", url cannot be nil.')
|
67
|
+
end
|
68
|
+
|
69
|
+
invalid_properties
|
70
|
+
end
|
71
|
+
|
72
|
+
# Check to see if the all the properties in the model are valid
|
73
|
+
# @return true if the model is valid
|
74
|
+
def valid?
|
75
|
+
return false if @url.nil?
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
79
|
+
# Checks equality by comparing each attribute.
|
80
|
+
# @param [Object] Object to be compared
|
81
|
+
def ==(o)
|
82
|
+
return true if self.equal?(o)
|
83
|
+
self.class == o.class &&
|
84
|
+
url == o.url
|
85
|
+
end
|
86
|
+
|
87
|
+
# @see the `==` method
|
88
|
+
# @param [Object] Object to be compared
|
89
|
+
def eql?(o)
|
90
|
+
self == o
|
91
|
+
end
|
92
|
+
|
93
|
+
# Calculates hash code according to all attributes.
|
94
|
+
# @return [Integer] Hash code
|
95
|
+
def hash
|
96
|
+
[url].hash
|
97
|
+
end
|
98
|
+
|
99
|
+
# Builds the object from hash
|
100
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
101
|
+
# @return [Object] Returns the model itself
|
102
|
+
def self.build_from_hash(attributes)
|
103
|
+
new.build_from_hash(attributes)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Builds the object from hash
|
107
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
108
|
+
# @return [Object] Returns the model itself
|
109
|
+
def build_from_hash(attributes)
|
110
|
+
return nil unless attributes.is_a?(Hash)
|
111
|
+
attributes = attributes.transform_keys(&:to_sym)
|
112
|
+
self.class.openapi_types.each_pair do |key, type|
|
113
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
114
|
+
self.send("#{key}=", nil)
|
115
|
+
elsif type =~ /\AArray<(.*)>/i
|
116
|
+
# check to ensure the input is an array given that the attribute
|
117
|
+
# is documented as an array but the input is not
|
118
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
119
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
120
|
+
end
|
121
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
122
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
self
|
127
|
+
end
|
128
|
+
|
129
|
+
# Deserializes the data based on type
|
130
|
+
# @param string type Data type
|
131
|
+
# @param string value Value to be deserialized
|
132
|
+
# @return [Object] Deserialized data
|
133
|
+
def _deserialize(type, value)
|
134
|
+
case type.to_sym
|
135
|
+
when :Time
|
136
|
+
Time.parse(value)
|
137
|
+
when :Date
|
138
|
+
Date.parse(value)
|
139
|
+
when :String
|
140
|
+
value.to_s
|
141
|
+
when :Integer
|
142
|
+
value.to_i
|
143
|
+
when :Float
|
144
|
+
value.to_f
|
145
|
+
when :Boolean
|
146
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
147
|
+
true
|
148
|
+
else
|
149
|
+
false
|
150
|
+
end
|
151
|
+
when :Object
|
152
|
+
# generic object (usually a Hash), return directly
|
153
|
+
value
|
154
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
155
|
+
inner_type = Regexp.last_match[:inner_type]
|
156
|
+
value.map { |v| _deserialize(inner_type, v) }
|
157
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
158
|
+
k_type = Regexp.last_match[:k_type]
|
159
|
+
v_type = Regexp.last_match[:v_type]
|
160
|
+
{}.tap do |hash|
|
161
|
+
value.each do |k, v|
|
162
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
else # model
|
166
|
+
# models (e.g. Pet) or oneOf
|
167
|
+
klass = Carbon.const_get(type)
|
168
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
# Returns the string representation of the object
|
173
|
+
# @return [String] String presentation of the object
|
174
|
+
def to_s
|
175
|
+
to_hash.to_s
|
176
|
+
end
|
177
|
+
|
178
|
+
# to_body is an alias to to_hash (backward compatibility)
|
179
|
+
# @return [Hash] Returns the object in the form of hash
|
180
|
+
def to_body
|
181
|
+
to_hash
|
182
|
+
end
|
183
|
+
|
184
|
+
# Returns the object in the form of hash
|
185
|
+
# @return [Hash] Returns the object in the form of hash
|
186
|
+
def to_hash
|
187
|
+
hash = {}
|
188
|
+
self.class.attribute_map.each_pair do |attr, param|
|
189
|
+
value = self.send(attr)
|
190
|
+
if value.nil?
|
191
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
192
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
193
|
+
end
|
194
|
+
|
195
|
+
hash[param] = _to_hash(value)
|
196
|
+
end
|
197
|
+
hash
|
198
|
+
end
|
199
|
+
|
200
|
+
# Outputs non-array value in the form of hash
|
201
|
+
# For object, use to_hash. Otherwise, just return the value
|
202
|
+
# @param [Object] value Any valid value
|
203
|
+
# @return [Hash] Returns the value in the form of hash
|
204
|
+
def _to_hash(value)
|
205
|
+
if value.is_a?(Array)
|
206
|
+
value.compact.map { |v| _to_hash(v) }
|
207
|
+
elsif value.is_a?(Hash)
|
208
|
+
{}.tap do |hash|
|
209
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
210
|
+
end
|
211
|
+
elsif value.respond_to? :to_hash
|
212
|
+
value.to_hash
|
213
|
+
else
|
214
|
+
value
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|