class Diplomat::Acl
Methods for interacting with the Consul ACL API endpoint
Attributes
Public Instance Methods
Create an Acl
definition @param value [Hash] Acl
definition, ID field is mandatory @param options [Hash] options parameter hash @return [Hash] The result Acl
# File lib/diplomat/acl.rb, line 67 def create(value, options = {}) custom_params = use_cas(@options) @raw = send_put_request(@conn, ['/v1/acl/create'], options, value, custom_params) parse_body end
Destroy an ACl token by its id @param ID [String] the Acl
ID @param options [Hash] options parameter hash @return [Bool] true if operation succeeded
# File lib/diplomat/acl.rb, line 77 def destroy(id, options = {}) @id = id @raw = send_put_request(@conn, ["/v1/acl/destroy/#{@id}"], options, nil) @raw.body.chomp == 'true' end
Get Acl
info by ID @param id [String] ID of the Acl
to get @param options [Hash] options parameter hash @return [Hash] rubocop:disable Metrics/PerceivedComplexity
# File lib/diplomat/acl.rb, line 14 def info(id, options = {}, not_found = :reject, found = :return) @id = id @options = options custom_params = [] custom_params << use_consistency(options) raw = send_get_request(@conn_no_err, ["/v1/acl/info/#{id}"], options, 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 all Acls @param options [Hash] options parameter hash @return [List] list of [Hash] of Acls
# File lib/diplomat/acl.rb, line 46 def list(options = {}) @raw = send_get_request(@conn_no_err, ['/v1/acl/list'], options) parse_body end
Update an Acl
definition, create if not present @param value [Hash] Acl
definition, ID field is mandatory @param options [Hash] options parameter hash @return [Hash] The result Acl
# File lib/diplomat/acl.rb, line 55 def update(value, options = {}) raise Diplomat::IdParameterRequired unless value['ID'] || value[:ID] custom_params = use_cas(@options) @raw = send_put_request(@conn, ['/v1/acl/update'], options, value, custom_params) parse_body end