Module: Diplomat::ApiOptions
Overview
Helper methods for interacting with the Consul RESTful API
Instance Method Summary collapse
- #check_acl_token ⇒ Object
- #use_cas(options) ⇒ Object
- #use_consistency(options) ⇒ Object
-
#valid_transaction_verbs ⇒ Hash
Mapping for valid key/value store transaction verbs and required parameters.
-
#valid_value_transactions ⇒ Array<String>
Key/value store transactions that require that a value be set.
Instance Method Details
#check_acl_token ⇒ Object
4 5 6 |
# File 'lib/diplomat/api_options.rb', line 4 def check_acl_token use_named_parameter('token', Diplomat.configuration.acl_token) end |
#use_cas(options) ⇒ Object
8 9 10 |
# File 'lib/diplomat/api_options.rb', line 8 def use_cas() ? use_named_parameter('cas', [:cas]) : [] end |
#use_consistency(options) ⇒ Object
12 13 14 |
# File 'lib/diplomat/api_options.rb', line 12 def use_consistency() && [:consistency] ? [[:consistency].to_s] : [] end |
#valid_transaction_verbs ⇒ Hash
Mapping for valid key/value store transaction verbs and required parameters
rubocop:disable MethodLength
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/diplomat/api_options.rb', line 20 def valid_transaction_verbs { 'set' => %w[Key Value], 'cas' => %w[Key Value Index], 'lock' => %w[Key Value Session], 'unlock' => %w[Key Value Session], 'get' => %w[Key], 'get-tree' => %w[Key], 'check-index' => %w[Key Index], 'check-session' => %w[Key Session], 'delete' => %w[Key], 'delete-tree' => %w[Key], 'delete-cas' => %w[Key Index] } end |
#valid_value_transactions ⇒ Array<String>
Key/value store transactions that require that a value be set
40 41 42 43 44 |
# File 'lib/diplomat/api_options.rb', line 40 def valid_value_transactions @valid_value_transactions ||= valid_transaction_verbs.select do |verb, requires| verb if requires.include? 'Value' end end |