Class: Diplomat::Acl
- Inherits:
-
RestClient
- Object
- RestClient
- Diplomat::Acl
- Defined in:
- lib/diplomat/acl.rb
Overview
Methods for interacting with the Consul ACL API endpoint
Instance Attribute Summary collapse
-
#acl ⇒ Object
readonly
Returns the value of attribute acl.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#create(value, options = {}) ⇒ Hash
Create an Acl definition.
-
#destroy(id, options = {}) ⇒ Bool
Destroy an ACl token by its id.
-
#info(id, options = {}, not_found = :reject, found = :return) ⇒ Hash
Get Acl info by ID rubocop:disable Metrics/PerceivedComplexity.
-
#list(options = {}) ⇒ List
List all Acls.
-
#update(value, options = {}) ⇒ Hash
Update an Acl definition, create if not present.
Methods inherited from RestClient
access_method?, #concat_url, #configuration, #initialize, method_missing, respond_to?, respond_to_missing?, #use_named_parameter
Constructor Details
This class inherits a constructor from Diplomat::RestClient
Instance Attribute Details
#acl ⇒ Object (readonly)
Returns the value of attribute acl.
7 8 9 |
# File 'lib/diplomat/acl.rb', line 7 def acl @acl end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/diplomat/acl.rb', line 7 def id @id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/diplomat/acl.rb', line 7 def type @type end |
Instance Method Details
#create(value, options = {}) ⇒ Hash
Create an Acl definition
67 68 69 70 71 |
# File 'lib/diplomat/acl.rb', line 67 def create(value, = {}) custom_params = use_cas() @raw = send_put_request(@conn, ['/v1/acl/create'], , value, custom_params) parse_body end |
#destroy(id, options = {}) ⇒ Bool
Destroy an ACl token by its id
77 78 79 80 81 |
# File 'lib/diplomat/acl.rb', line 77 def destroy(id, = {}) @id = id @raw = send_put_request(@conn, ["/v1/acl/destroy/#{@id}"], , nil) @raw.body.chomp == 'true' end |
#info(id, options = {}, not_found = :reject, found = :return) ⇒ Hash
Get Acl info by ID rubocop:disable Metrics/PerceivedComplexity
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/diplomat/acl.rb', line 14 def info(id, = {}, not_found = :reject, found = :return) @id = id = custom_params = [] custom_params << use_consistency() raw = send_get_request(@conn_no_err, ["/v1/acl/info/#{id}"], , custom_params) if raw.status == 200 && raw.body.chomp != 'null' case found when :reject raise Diplomat::AclAlreadyExists, id when :return @raw = raw return parse_body end elsif raw.status == 200 && raw.body.chomp == 'null' case not_found when :reject raise Diplomat::AclNotFound, id when :return return nil end else raise Diplomat::UnknownStatus, "status #{raw.status}: #{raw.body}" end end |
#list(options = {}) ⇒ List
List all Acls
46 47 48 49 |
# File 'lib/diplomat/acl.rb', line 46 def list( = {}) @raw = send_get_request(@conn_no_err, ['/v1/acl/list'], ) parse_body end |
#update(value, options = {}) ⇒ Hash
Update an Acl definition, create if not present
55 56 57 58 59 60 61 |
# File 'lib/diplomat/acl.rb', line 55 def update(value, = {}) raise Diplomat::IdParameterRequired unless value['ID'] || value[:ID] custom_params = use_cas() @raw = send_put_request(@conn, ['/v1/acl/update'], , value, custom_params) parse_body end |