Class: Saro::Dat::DatCmsManagerBuilder
- Inherits:
-
Object
- Object
- Saro::Dat::DatCmsManagerBuilder
- Defined in:
- lib/saro/dat/dat_cms_manager.rb
Instance Method Summary collapse
- #build ⇒ Object
- #connect_timeout_seconds(seconds) ⇒ Object
-
#initialize ⇒ DatCmsManagerBuilder
constructor
A new instance of DatCmsManagerBuilder.
- #interval_off ⇒ Object
- #interval_seconds(interval_seconds) ⇒ Object
- #sync_timeout_seconds(seconds) ⇒ Object
- #token(token) ⇒ Object
- #uri(uri) ⇒ Object
- #verify_only(verify_only) ⇒ Object
Constructor Details
#initialize ⇒ DatCmsManagerBuilder
Returns a new instance of DatCmsManagerBuilder.
203 204 205 206 207 208 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 203 def initialize @uri = "http://localhost:8088" @token = "" @verify_only = false @interval_seconds = 60 end |
Instance Method Details
#build ⇒ Object
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 245 def build parsed = begin URI.parse(@uri) rescue URI::InvalidURIError => e raise Saro::Dat::Error.new(Saro::Dat::ErrorCode::CONFIG_URI_INVALID, "cannot be parsed as a uri", cause: e) end unless %w[http https].include?(parsed.scheme) raise Saro::Dat::Error.new(Saro::Dat::ErrorCode::CONFIG_URI_INVALID, "scheme must be http or https") end if parsed.path && parsed.path != '' && parsed.path != '/' raise Saro::Dat::Error.new(Saro::Dat::ErrorCode::CONFIG_URI_INVALID, "must be path-less: #{@uri}") end if parsed.query raise Saro::Dat::Error.new(Saro::Dat::ErrorCode::CONFIG_URI_INVALID, "must be query-less: #{@uri}") end path = @verify_only ? "/v1/certs/verify-only" : "/v1/certs" final_uri = "#{parsed.scheme}://#{parsed.host}:#{parsed.port}#{path}" DatCmsManager.new( uri: final_uri, token: @token, interval_seconds: @interval_seconds, verify_only: @verify_only, connect_timeout_seconds: @connect_timeout_seconds, sync_timeout_seconds: @sync_timeout_seconds ) end |
#connect_timeout_seconds(seconds) ⇒ Object
235 236 237 238 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 235 def connect_timeout_seconds(seconds) @connect_timeout_seconds = seconds self end |
#interval_off ⇒ Object
230 231 232 233 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 230 def interval_off @interval_seconds = 0 self end |
#interval_seconds(interval_seconds) ⇒ Object
225 226 227 228 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 225 def interval_seconds(interval_seconds) @interval_seconds = interval_seconds self end |
#sync_timeout_seconds(seconds) ⇒ Object
240 241 242 243 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 240 def sync_timeout_seconds(seconds) @sync_timeout_seconds = seconds self end |
#token(token) ⇒ Object
215 216 217 218 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 215 def token(token) @token = token self end |
#uri(uri) ⇒ Object
210 211 212 213 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 210 def uri(uri) @uri = uri.delete_suffix('/') self end |
#verify_only(verify_only) ⇒ Object
220 221 222 223 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 220 def verify_only(verify_only) @verify_only = verify_only self end |