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
-
#initialize ⇒ DatCmsManagerBuilder
constructor
A new instance of DatCmsManagerBuilder.
- #interval_off ⇒ Object
- #interval_seconds(interval_seconds) ⇒ Object
- #token(token) ⇒ Object
- #uri(uri) ⇒ Object
- #verify_only(verify_only) ⇒ Object
Constructor Details
#initialize ⇒ DatCmsManagerBuilder
Returns a new instance of DatCmsManagerBuilder.
196 197 198 199 200 201 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 196 def initialize @uri = "http://localhost:8088" @token = "" @verify_only = false @interval_seconds = 60 end |
Instance Method Details
#build ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 228 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 ) end |
#interval_off ⇒ Object
223 224 225 226 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 223 def interval_off @interval_seconds = 0 self end |
#interval_seconds(interval_seconds) ⇒ Object
218 219 220 221 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 218 def interval_seconds(interval_seconds) @interval_seconds = interval_seconds self end |
#token(token) ⇒ Object
208 209 210 211 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 208 def token(token) @token = token self end |
#uri(uri) ⇒ Object
203 204 205 206 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 203 def uri(uri) @uri = uri.delete_suffix('/') self end |
#verify_only(verify_only) ⇒ Object
213 214 215 216 |
# File 'lib/saro/dat/dat_cms_manager.rb', line 213 def verify_only(verify_only) @verify_only = verify_only self end |