sz-apimatic-sdk 0.0.1
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.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +153 -0
- data/bin/console +15 -0
- data/lib/seltz_api/api_helper.rb +10 -0
- data/lib/seltz_api/apis/agent_api.rb +140 -0
- data/lib/seltz_api/apis/answer_api.rb +61 -0
- data/lib/seltz_api/apis/base_api.rb +67 -0
- data/lib/seltz_api/apis/fetch_api.rb +48 -0
- data/lib/seltz_api/apis/monitors_api.rb +161 -0
- data/lib/seltz_api/apis/records_api.rb +97 -0
- data/lib/seltz_api/apis/runs_api.rb +109 -0
- data/lib/seltz_api/apis/search_api.rb +55 -0
- data/lib/seltz_api/client.rb +111 -0
- data/lib/seltz_api/configuration.rb +165 -0
- data/lib/seltz_api/exceptions/api_exception.rb +21 -0
- data/lib/seltz_api/exceptions/error_envelope_exception.rb +46 -0
- data/lib/seltz_api/http/api_response.rb +19 -0
- data/lib/seltz_api/http/auth/custom_header_authentication.rb +52 -0
- data/lib/seltz_api/http/http_call_back.rb +10 -0
- data/lib/seltz_api/http/http_method_enum.rb +10 -0
- data/lib/seltz_api/http/http_request.rb +10 -0
- data/lib/seltz_api/http/http_response.rb +10 -0
- data/lib/seltz_api/http/proxy_settings.rb +22 -0
- data/lib/seltz_api/logging/configuration/api_logging_configuration.rb +186 -0
- data/lib/seltz_api/logging/sdk_logger.rb +17 -0
- data/lib/seltz_api/models/agent_run.rb +161 -0
- data/lib/seltz_api/models/agent_run_citation.rb +85 -0
- data/lib/seltz_api/models/agent_run_grounding.rb +94 -0
- data/lib/seltz_api/models/agent_run_output.rb +131 -0
- data/lib/seltz_api/models/agent_run_output2.rb +131 -0
- data/lib/seltz_api/models/agent_run_request.rb +100 -0
- data/lib/seltz_api/models/agent_run_request2.rb +100 -0
- data/lib/seltz_api/models/agent_run_source.rb +86 -0
- data/lib/seltz_api/models/agent_run_status.rb +49 -0
- data/lib/seltz_api/models/agent_run_status2.rb +48 -0
- data/lib/seltz_api/models/agent_run_stop_reason.rb +53 -0
- data/lib/seltz_api/models/agent_run_stop_reason2.rb +52 -0
- data/lib/seltz_api/models/answer_http_request.rb +172 -0
- data/lib/seltz_api/models/answer_http_response.rb +93 -0
- data/lib/seltz_api/models/base_model.rb +110 -0
- data/lib/seltz_api/models/content_options.rb +99 -0
- data/lib/seltz_api/models/create_agent_run_request.rb +104 -0
- data/lib/seltz_api/models/create_monitor_request.rb +143 -0
- data/lib/seltz_api/models/create_monitor_response.rb +90 -0
- data/lib/seltz_api/models/document.rb +128 -0
- data/lib/seltz_api/models/envelope_error.rb +83 -0
- data/lib/seltz_api/models/envelope_error1.rb +82 -0
- data/lib/seltz_api/models/fetch_error.rb +107 -0
- data/lib/seltz_api/models/fetch_error1.rb +108 -0
- data/lib/seltz_api/models/fetch_request.rb +144 -0
- data/lib/seltz_api/models/fetch_response.rb +87 -0
- data/lib/seltz_api/models/fetch_result.rb +176 -0
- data/lib/seltz_api/models/fetch_status.rb +36 -0
- data/lib/seltz_api/models/fetch_status2.rb +40 -0
- data/lib/seltz_api/models/fields.rb +108 -0
- data/lib/seltz_api/models/fields2.rb +101 -0
- data/lib/seltz_api/models/get_monitor_response.rb +87 -0
- data/lib/seltz_api/models/get_run_response.rb +76 -0
- data/lib/seltz_api/models/http_citation.rb +86 -0
- data/lib/seltz_api/models/list_agent_runs_response.rb +96 -0
- data/lib/seltz_api/models/list_monitors_response.rb +97 -0
- data/lib/seltz_api/models/list_records_response.rb +96 -0
- data/lib/seltz_api/models/list_run_records_response.rb +96 -0
- data/lib/seltz_api/models/list_run_requests_response.rb +84 -0
- data/lib/seltz_api/models/list_runs_response.rb +96 -0
- data/lib/seltz_api/models/monitor.rb +157 -0
- data/lib/seltz_api/models/monitor_search_request.rb +110 -0
- data/lib/seltz_api/models/monitor_status.rb +47 -0
- data/lib/seltz_api/models/monitor_status2.rb +45 -0
- data/lib/seltz_api/models/payload.rb +74 -0
- data/lib/seltz_api/models/record.rb +116 -0
- data/lib/seltz_api/models/record_type.rb +26 -0
- data/lib/seltz_api/models/request_status.rb +36 -0
- data/lib/seltz_api/models/run.rb +200 -0
- data/lib/seltz_api/models/run_request.rb +127 -0
- data/lib/seltz_api/models/run_state.rb +40 -0
- data/lib/seltz_api/models/run_state2.rb +41 -0
- data/lib/seltz_api/models/run_status.rb +47 -0
- data/lib/seltz_api/models/schedule.rb +73 -0
- data/lib/seltz_api/models/search_record.rb +101 -0
- data/lib/seltz_api/models/search_request.rb +208 -0
- data/lib/seltz_api/models/search_request_ref.rb +87 -0
- data/lib/seltz_api/models/search_response.rb +85 -0
- data/lib/seltz_api/models/snippet.rb +76 -0
- data/lib/seltz_api/models/snippet_options.rb +151 -0
- data/lib/seltz_api/models/update_monitor_request.rb +153 -0
- data/lib/seltz_api/models/update_monitor_response.rb +77 -0
- data/lib/seltz_api/models/webhook.rb +113 -0
- data/lib/seltz_api/models/webhook1.rb +114 -0
- data/lib/seltz_api/utilities/date_time_helper.rb +11 -0
- data/lib/seltz_api/utilities/file_wrapper.rb +28 -0
- data/lib/seltz_api/utilities/union_type_lookup.rb +62 -0
- data/lib/seltz_api.rb +115 -0
- metadata +178 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# seltz_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SeltzApi
|
|
7
|
+
# An enum for SDK environments.
|
|
8
|
+
class Environment
|
|
9
|
+
# PRODUCTION: Seltz API
|
|
10
|
+
ENVIRONMENT = [
|
|
11
|
+
PRODUCTION = 'production'.freeze
|
|
12
|
+
].freeze
|
|
13
|
+
|
|
14
|
+
# Converts a string or symbol into a valid Environment constant.
|
|
15
|
+
def self.from_value(value, default_value = PRODUCTION)
|
|
16
|
+
return default_value if value.nil?
|
|
17
|
+
|
|
18
|
+
default_value
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# An enum for API servers.
|
|
23
|
+
class Server
|
|
24
|
+
SERVER = [
|
|
25
|
+
DEFAULT = 'default'.freeze
|
|
26
|
+
].freeze
|
|
27
|
+
|
|
28
|
+
# Converts a string or symbol into a valid Server constant.
|
|
29
|
+
def self.from_value(value, default_value = DEFAULT)
|
|
30
|
+
return default_value if value.nil?
|
|
31
|
+
|
|
32
|
+
default_value
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# All configuration including auth info and base URI for the API access
|
|
37
|
+
# are configured in this class.
|
|
38
|
+
class Configuration < CoreLibrary::HttpClientConfiguration
|
|
39
|
+
# The attribute readers for properties.
|
|
40
|
+
attr_reader :environment, :custom_header_authentication_credentials
|
|
41
|
+
|
|
42
|
+
class << self
|
|
43
|
+
attr_reader :environments
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def initialize(
|
|
47
|
+
connection: nil, adapter: :net_http_persistent, timeout: 30,
|
|
48
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
|
49
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
|
50
|
+
retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
|
|
51
|
+
logging_configuration: nil, environment: Environment::PRODUCTION,
|
|
52
|
+
custom_header_authentication_credentials: nil
|
|
53
|
+
)
|
|
54
|
+
super connection: connection, adapter: adapter, timeout: timeout,
|
|
55
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
|
56
|
+
backoff_factor: backoff_factor, retry_statuses: retry_statuses,
|
|
57
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
|
58
|
+
proxy_settings: proxy_settings,
|
|
59
|
+
logging_configuration: logging_configuration
|
|
60
|
+
|
|
61
|
+
# Current API environment
|
|
62
|
+
@environment = String(environment)
|
|
63
|
+
|
|
64
|
+
# The object holding Custom Header Signature credentials
|
|
65
|
+
@custom_header_authentication_credentials = custom_header_authentication_credentials
|
|
66
|
+
|
|
67
|
+
# Initializing Custom Header Signature credentials with the provided auth parameters
|
|
68
|
+
@custom_header_authentication_credentials = custom_header_authentication_credentials
|
|
69
|
+
|
|
70
|
+
# The Http Client to use for making requests.
|
|
71
|
+
set_http_client CoreLibrary::FaradayClient.new(self)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def clone_with(connection: nil, adapter: nil, timeout: nil,
|
|
75
|
+
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
|
76
|
+
retry_statuses: nil, retry_methods: nil, http_callback: nil,
|
|
77
|
+
proxy_settings: nil, logging_configuration: nil,
|
|
78
|
+
environment: nil,
|
|
79
|
+
custom_header_authentication_credentials: nil)
|
|
80
|
+
connection ||= self.connection
|
|
81
|
+
adapter ||= self.adapter
|
|
82
|
+
timeout ||= self.timeout
|
|
83
|
+
max_retries ||= self.max_retries
|
|
84
|
+
retry_interval ||= self.retry_interval
|
|
85
|
+
backoff_factor ||= self.backoff_factor
|
|
86
|
+
retry_statuses ||= self.retry_statuses
|
|
87
|
+
retry_methods ||= self.retry_methods
|
|
88
|
+
http_callback ||= self.http_callback
|
|
89
|
+
proxy_settings ||= self.proxy_settings
|
|
90
|
+
logging_configuration ||= self.logging_configuration
|
|
91
|
+
environment ||= self.environment
|
|
92
|
+
custom_header_authentication_credentials ||= self.custom_header_authentication_credentials
|
|
93
|
+
|
|
94
|
+
Configuration.new(
|
|
95
|
+
connection: connection, adapter: adapter, timeout: timeout,
|
|
96
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
|
97
|
+
backoff_factor: backoff_factor, retry_statuses: retry_statuses,
|
|
98
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
|
99
|
+
proxy_settings: proxy_settings,
|
|
100
|
+
logging_configuration: logging_configuration, environment: environment,
|
|
101
|
+
custom_header_authentication_credentials: custom_header_authentication_credentials
|
|
102
|
+
)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# All the environments the SDK can run in.
|
|
107
|
+
ENVIRONMENTS = {
|
|
108
|
+
Environment::PRODUCTION => {
|
|
109
|
+
Server::DEFAULT => 'https://api.seltz.ai'
|
|
110
|
+
}
|
|
111
|
+
}.freeze
|
|
112
|
+
|
|
113
|
+
# Generates the appropriate base URI for the environment and the server.
|
|
114
|
+
# @param [Configuration::Server] server The server enum for which the base URI is
|
|
115
|
+
# required.
|
|
116
|
+
# @return [String] The base URI.
|
|
117
|
+
def get_base_uri(server = Server::DEFAULT)
|
|
118
|
+
ENVIRONMENTS[environment][server].clone
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Builds a Configuration instance using environment variables.
|
|
122
|
+
def self.build_default_config_from_env
|
|
123
|
+
# === Core environment ===
|
|
124
|
+
environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
|
|
125
|
+
timeout = (ENV['TIMEOUT'] || 30).to_f
|
|
126
|
+
max_retries = (ENV['MAX_RETRIES'] || 0).to_i
|
|
127
|
+
retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
|
|
128
|
+
backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
|
|
129
|
+
retry_statuses = ENV.fetch('RETRY_STATUSES',
|
|
130
|
+
'[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
|
|
131
|
+
.split(',')
|
|
132
|
+
.map(&:strip)
|
|
133
|
+
.map do |item|
|
|
134
|
+
item.match?(/\A\d+\z/) ? item.to_i : item.downcase
|
|
135
|
+
end
|
|
136
|
+
retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
|
|
137
|
+
.split(',')
|
|
138
|
+
.map(&:strip)
|
|
139
|
+
.map do |item|
|
|
140
|
+
item.match?(/\A\d+\z/) ? item.to_i : item.downcase
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# === Authentication credentials ===
|
|
144
|
+
custom_header_authentication_credentials = CustomHeaderAuthenticationCredentials.from_env
|
|
145
|
+
|
|
146
|
+
# === Proxy settings ===
|
|
147
|
+
proxy_settings = ProxySettings.from_env
|
|
148
|
+
# === Logging Configuration ===
|
|
149
|
+
logging_configuration = LoggingConfiguration.from_env if LoggingConfiguration.any_logging_configured?
|
|
150
|
+
|
|
151
|
+
Configuration.new(
|
|
152
|
+
environment: environment,
|
|
153
|
+
timeout: timeout,
|
|
154
|
+
max_retries: max_retries,
|
|
155
|
+
retry_interval: retry_interval,
|
|
156
|
+
backoff_factor: backoff_factor,
|
|
157
|
+
retry_statuses: retry_statuses,
|
|
158
|
+
retry_methods: retry_methods,
|
|
159
|
+
custom_header_authentication_credentials: custom_header_authentication_credentials,
|
|
160
|
+
proxy_settings: proxy_settings,
|
|
161
|
+
logging_configuration: logging_configuration
|
|
162
|
+
)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# seltz_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SeltzApi
|
|
7
|
+
# Class for exceptions when there is a network error, status code error, etc.
|
|
8
|
+
class APIException < CoreLibrary::ApiException
|
|
9
|
+
# Provides a human-readable string representation of the object.
|
|
10
|
+
def to_s
|
|
11
|
+
class_name = self.class.name.split('::').last
|
|
12
|
+
"<#{class_name} status_code: #{@response_code}, reason: #{@reason}>"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
16
|
+
def inspect
|
|
17
|
+
class_name = self.class.name.split('::').last
|
|
18
|
+
"<#{class_name} status_code: #{@response_code.inspect}, reason: #{@reason.inspect}>"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# seltz_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SeltzApi
|
|
7
|
+
# The response body returned for any error.
|
|
8
|
+
class ErrorEnvelopeException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# The error context.
|
|
13
|
+
# @return [EnvelopeError1]
|
|
14
|
+
attr_accessor :error
|
|
15
|
+
|
|
16
|
+
# The constructor.
|
|
17
|
+
# @param [String] reason The reason for raising an exception.
|
|
18
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
19
|
+
def initialize(reason, response)
|
|
20
|
+
super(reason, response)
|
|
21
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
22
|
+
unbox(hash)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Populates this object by extracting properties from a hash.
|
|
26
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
27
|
+
# response body.
|
|
28
|
+
def unbox(hash)
|
|
29
|
+
return nil unless hash
|
|
30
|
+
|
|
31
|
+
@error = EnvelopeError1.from_hash(hash['error']) if hash['error']
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Provides a human-readable string representation of the object.
|
|
35
|
+
def to_s
|
|
36
|
+
class_name = self.class.name.split('::').last
|
|
37
|
+
"<#{class_name} error: #{@error}>"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
41
|
+
def inspect
|
|
42
|
+
class_name = self.class.name.split('::').last
|
|
43
|
+
"<#{class_name} error: #{@error.inspect}>"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# seltz_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SeltzApi
|
|
7
|
+
# Http response received.
|
|
8
|
+
class ApiResponse < CoreLibrary::ApiResponse
|
|
9
|
+
# The constructor
|
|
10
|
+
# @param [HttpResponse] http_response The original, raw response from the api.
|
|
11
|
+
# @param [Object] data The data field specified for the response.
|
|
12
|
+
# @param [Array<String>] errors Any errors returned by the server.
|
|
13
|
+
def initialize(http_response,
|
|
14
|
+
data: nil,
|
|
15
|
+
errors: nil)
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# seltz_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SeltzApi
|
|
7
|
+
# Utility class for custom header authorization.
|
|
8
|
+
class CustomHeaderAuthentication < CoreLibrary::HeaderAuth
|
|
9
|
+
# Display error message on occurrence of authentication failure.
|
|
10
|
+
# @returns [String] The oAuth error message.
|
|
11
|
+
def error_message
|
|
12
|
+
'CustomHeaderAuthentication: x_api_key is undefined.'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Initialization constructor.
|
|
16
|
+
def initialize(custom_header_authentication_credentials)
|
|
17
|
+
auth_params = {}
|
|
18
|
+
auth_params['x-api-key'] = custom_header_authentication_credentials.x_api_key unless
|
|
19
|
+
custom_header_authentication_credentials.nil? || custom_header_authentication_credentials.x_api_key.nil?
|
|
20
|
+
|
|
21
|
+
super auth_params
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Data class for CustomHeaderAuthenticationCredentials.
|
|
26
|
+
# Data class for CustomHeaderAuthenticationCredentials.
|
|
27
|
+
class CustomHeaderAuthenticationCredentials
|
|
28
|
+
attr_reader :x_api_key
|
|
29
|
+
|
|
30
|
+
def initialize(x_api_key:)
|
|
31
|
+
raise ArgumentError, 'x_api_key cannot be nil' if x_api_key.nil?
|
|
32
|
+
|
|
33
|
+
@x_api_key = x_api_key
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.from_env
|
|
37
|
+
x_api_key = ENV['X_API_KEY']
|
|
38
|
+
all_nil = [
|
|
39
|
+
x_api_key
|
|
40
|
+
].all?(&:nil?)
|
|
41
|
+
return nil if all_nil
|
|
42
|
+
|
|
43
|
+
new(x_api_key: x_api_key)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def clone_with(x_api_key: nil)
|
|
47
|
+
x_api_key ||= self.x_api_key
|
|
48
|
+
|
|
49
|
+
CustomHeaderAuthenticationCredentials.new(x_api_key: x_api_key)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# seltz_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SeltzApi
|
|
7
|
+
##
|
|
8
|
+
# ProxySettings encapsulates HTTP proxy configuration for Faraday,
|
|
9
|
+
# including optional basic authentication.
|
|
10
|
+
#
|
|
11
|
+
class ProxySettings < CoreLibrary::ProxySettings
|
|
12
|
+
def self.from_env
|
|
13
|
+
address = ENV['PROXY_ADDRESS']
|
|
14
|
+
port = ENV['PROXY_PORT']
|
|
15
|
+
username = ENV['PROXY_USERNAME']
|
|
16
|
+
password = ENV['PROXY_PASSWORD']
|
|
17
|
+
return nil if address.nil? || address.strip.empty?
|
|
18
|
+
|
|
19
|
+
new(address: address, port: port, username: username, password: password)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# seltz_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SeltzApi
|
|
7
|
+
# Initializes a new instance of RequestLoggingConfiguration.
|
|
8
|
+
class RequestLoggingConfiguration < CoreLibrary::ApiRequestLoggingConfiguration
|
|
9
|
+
# @param log_body [Boolean] Indicates whether the message body should be logged. Default is false.
|
|
10
|
+
# @param log_headers [Boolean] Indicates whether the message headers should be logged. Default is false.
|
|
11
|
+
# @param headers_to_exclude [Array<String>] Array of headers not displayed in logging. Default is an empty array.
|
|
12
|
+
# @param headers_to_include [Array<String>] Array of headers to be displayed in logging. Default is an empty array.
|
|
13
|
+
# @param headers_to_unmask [Array<String>] Array of headers which values are non-sensitive to display in logging.
|
|
14
|
+
# Default is an empty array.
|
|
15
|
+
def initialize(log_body: false, log_headers: false, headers_to_include: nil,
|
|
16
|
+
headers_to_exclude: nil, headers_to_unmask: nil,
|
|
17
|
+
include_query_in_path: false)
|
|
18
|
+
super(
|
|
19
|
+
log_body,
|
|
20
|
+
log_headers,
|
|
21
|
+
headers_to_exclude,
|
|
22
|
+
headers_to_include,
|
|
23
|
+
headers_to_unmask,
|
|
24
|
+
include_query_in_path
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def clone_with(log_body: nil, log_headers: nil, headers_to_include: nil,
|
|
29
|
+
headers_to_exclude: nil, headers_to_unmask: nil, include_query_in_path: nil)
|
|
30
|
+
log_body ||= self.log_body
|
|
31
|
+
log_headers ||= self.log_headers
|
|
32
|
+
headers_to_include ||= self.headers_to_include
|
|
33
|
+
headers_to_exclude ||= self.headers_to_exclude
|
|
34
|
+
headers_to_unmask ||= self.headers_to_unmask
|
|
35
|
+
include_query_in_path ||= self.include_query_in_path
|
|
36
|
+
|
|
37
|
+
RequestLoggingConfiguration.new(
|
|
38
|
+
log_body: log_body,
|
|
39
|
+
log_headers: log_headers,
|
|
40
|
+
headers_to_include: headers_to_include,
|
|
41
|
+
headers_to_exclude: headers_to_exclude,
|
|
42
|
+
headers_to_unmask: headers_to_unmask,
|
|
43
|
+
include_query_in_path: include_query_in_path
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.from_env
|
|
48
|
+
log_body = ENV['REQUEST_LOG_BODY']
|
|
49
|
+
log_headers = ENV['REQUEST_LOG_HEADERS']
|
|
50
|
+
headers_to_include = ENV['REQUEST_HEADERS_TO_INCLUDE']
|
|
51
|
+
headers_to_exclude = ENV['REQUEST_HEADERS_TO_EXCLUDE']
|
|
52
|
+
headers_to_unmask = ENV['REQUEST_HEADERS_TO_UNMASK']
|
|
53
|
+
include_query_in_path = ENV['REQUEST_INCLUDE_QUERY_IN_PATH']
|
|
54
|
+
|
|
55
|
+
new(
|
|
56
|
+
log_body: log_body,
|
|
57
|
+
log_headers: log_headers,
|
|
58
|
+
headers_to_include: headers_to_include,
|
|
59
|
+
headers_to_exclude: headers_to_exclude,
|
|
60
|
+
headers_to_unmask: headers_to_unmask,
|
|
61
|
+
include_query_in_path: include_query_in_path
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def self.any_logging_configured?
|
|
66
|
+
%w[
|
|
67
|
+
REQUEST_LOG_BODY
|
|
68
|
+
REQUEST_LOG_HEADERS
|
|
69
|
+
REQUEST_HEADERS_TO_INCLUDE
|
|
70
|
+
REQUEST_HEADERS_TO_EXCLUDE
|
|
71
|
+
REQUEST_HEADERS_TO_UNMASK
|
|
72
|
+
REQUEST_INCLUDE_QUERY_IN_PATH
|
|
73
|
+
].any? { |key| ENV.key?(key) && !ENV[key].nil? && !ENV[key].empty? }
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Initializes a new instance of ResponseLoggingConfiguration.
|
|
78
|
+
class ResponseLoggingConfiguration < CoreLibrary::ApiResponseLoggingConfiguration
|
|
79
|
+
def initialize(log_body: false, log_headers: false, headers_to_include: nil,
|
|
80
|
+
headers_to_exclude: nil, headers_to_unmask: nil)
|
|
81
|
+
super(
|
|
82
|
+
log_body,
|
|
83
|
+
log_headers,
|
|
84
|
+
headers_to_exclude,
|
|
85
|
+
headers_to_include,
|
|
86
|
+
headers_to_unmask
|
|
87
|
+
)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def clone_with(log_body: nil, log_headers: nil, headers_to_include: nil,
|
|
91
|
+
headers_to_exclude: nil, headers_to_unmask: nil)
|
|
92
|
+
log_body ||= self.log_body
|
|
93
|
+
log_headers ||= self.log_headers
|
|
94
|
+
headers_to_include ||= self.headers_to_include
|
|
95
|
+
headers_to_exclude ||= self.headers_to_exclude
|
|
96
|
+
headers_to_unmask ||= self.headers_to_unmask
|
|
97
|
+
|
|
98
|
+
ResponseLoggingConfiguration.new(
|
|
99
|
+
log_body: log_body,
|
|
100
|
+
log_headers: log_headers,
|
|
101
|
+
headers_to_include: headers_to_include,
|
|
102
|
+
headers_to_exclude: headers_to_exclude,
|
|
103
|
+
headers_to_unmask: headers_to_unmask
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def self.from_env
|
|
108
|
+
log_body = ENV['RESPONSE_LOG_BODY']
|
|
109
|
+
log_headers = ENV['RESPONSE_LOG_HEADERS']
|
|
110
|
+
headers_to_include = ENV['RESPONSE_HEADERS_TO_INCLUDE']
|
|
111
|
+
headers_to_exclude = ENV['RESPONSE_HEADERS_TO_EXCLUDE']
|
|
112
|
+
headers_to_unmask = ENV['RESPONSE_HEADERS_TO_UNMASK']
|
|
113
|
+
|
|
114
|
+
new(
|
|
115
|
+
log_body: log_body,
|
|
116
|
+
log_headers: log_headers,
|
|
117
|
+
headers_to_include: headers_to_include,
|
|
118
|
+
headers_to_exclude: headers_to_exclude,
|
|
119
|
+
headers_to_unmask: headers_to_unmask
|
|
120
|
+
)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def self.any_logging_configured?
|
|
124
|
+
%w[
|
|
125
|
+
RESPONSE_LOG_BODY
|
|
126
|
+
RESPONSE_LOG_HEADERS
|
|
127
|
+
RESPONSE_HEADERS_TO_INCLUDE
|
|
128
|
+
RESPONSE_HEADERS_TO_EXCLUDE
|
|
129
|
+
RESPONSE_HEADERS_TO_UNMASK
|
|
130
|
+
].any? { |key| ENV.key?(key) && !ENV[key].nil? && !ENV[key].empty? }
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Initializes a new instance of LoggingConfiguration.
|
|
135
|
+
class LoggingConfiguration < CoreLibrary::ApiLoggingConfiguration
|
|
136
|
+
def initialize(logger: nil, log_level: nil, mask_sensitive_headers: true,
|
|
137
|
+
request_logging_config: nil,
|
|
138
|
+
response_logging_config: nil)
|
|
139
|
+
request_logging_config ||= RequestLoggingConfiguration.new
|
|
140
|
+
response_logging_config ||= ResponseLoggingConfiguration.new
|
|
141
|
+
super(
|
|
142
|
+
logger,
|
|
143
|
+
log_level,
|
|
144
|
+
request_logging_config,
|
|
145
|
+
response_logging_config,
|
|
146
|
+
mask_sensitive_headers
|
|
147
|
+
)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def clone_with(logger: nil, log_level: nil, mask_sensitive_headers: nil,
|
|
151
|
+
request_logging_config: nil, response_logging_config: nil)
|
|
152
|
+
logger ||= self.logger
|
|
153
|
+
log_level ||= self.log_level
|
|
154
|
+
mask_sensitive_headers ||= self.mask_sensitive_headers
|
|
155
|
+
request_logging_config ||= self.request_logging_config.clone
|
|
156
|
+
response_logging_config ||= self.response_logging_config.clone
|
|
157
|
+
|
|
158
|
+
LoggingConfiguration.new(
|
|
159
|
+
logger: logger,
|
|
160
|
+
log_level: log_level,
|
|
161
|
+
mask_sensitive_headers: mask_sensitive_headers,
|
|
162
|
+
request_logging_config: request_logging_config,
|
|
163
|
+
response_logging_config: response_logging_config
|
|
164
|
+
)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def self.from_env
|
|
168
|
+
log_level = ENV['LOG_LEVEL']
|
|
169
|
+
mask_sensitive_headers = ENV['MASK_SENSITIVE_HEADERS']
|
|
170
|
+
|
|
171
|
+
new(
|
|
172
|
+
log_level: log_level,
|
|
173
|
+
mask_sensitive_headers: mask_sensitive_headers,
|
|
174
|
+
request_logging_config: RequestLoggingConfiguration.from_env,
|
|
175
|
+
response_logging_config: ResponseLoggingConfiguration.from_env
|
|
176
|
+
)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def self.any_logging_configured?
|
|
180
|
+
RequestLoggingConfiguration.any_logging_configured? ||
|
|
181
|
+
ResponseLoggingConfiguration.any_logging_configured? ||
|
|
182
|
+
ENV.key?('LOG_LEVEL') ||
|
|
183
|
+
ENV.key?('MASK_SENSITIVE_HEADERS')
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# seltz_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SeltzApi
|
|
7
|
+
# Represents the generic logger facade
|
|
8
|
+
class AbstractLogger < Logger
|
|
9
|
+
# Logs a message with a specified log level and additional parameters.
|
|
10
|
+
# @param level [Symbol] The log level of the message.
|
|
11
|
+
# @param message [String] The message to log.
|
|
12
|
+
# @param params [Hash] Additional parameters to include in the log message.
|
|
13
|
+
def log(level, message, params)
|
|
14
|
+
raise NotImplementedError, 'This method needs to be implemented in a child class.'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|