class Diplomat::Acl
Methods for interacting with the Consul ACL API endpoint
Attributes
acl[R]
id[R]
type[R]
Public Instance Methods
create(value)
click to toggle source
Create an Acl
definition @param value [Hash] Acl
definition, ID field is mandatory @return [Hash] The result Acl
# File lib/diplomat/acl.rb, line 70 def create(value) @raw = @conn.put do |req| url = ['/v1/acl/create'] url += check_acl_token url += use_cas(@options) req.url concat_url url req.body = value.to_json end parse_body end
destroy(id)
click to toggle source
Destroy an ACl token by its id @param ID [String] the Acl
ID @return [Bool]
# File lib/diplomat/acl.rb, line 84 def destroy(id) @id = id url = ["/v1/acl/destroy/#{@id}"] url << check_acl_token @raw = @conn.put concat_url url @raw.body.chomp == 'true' end
info(id, options = nil, not_found = :reject, found = :return)
click to toggle source
Get Acl
info by ID @param id [String] ID of the Acl
to get @return [Hash] rubocop:disable PerceivedComplexity, MethodLength, CyclomaticComplexity, AbcSize
# File lib/diplomat/acl.rb, line 13 def info(id, options = nil, not_found = :reject, found = :return) @id = id @options = options url = ["/v1/acl/info/#{id}"] url << check_acl_token url << use_consistency(options) raw = @conn_no_err.get concat_url url 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()
click to toggle source
List all Acls @return [List] list of [Hash] of Acls
# File lib/diplomat/acl.rb, line 44 def list url = ['/v1/acl/list'] url += check_acl_token @raw = @conn_no_err.get concat_url url parse_body end
update(value)
click to toggle source
Update an Acl
definition, create if not present @param value [Hash] Acl
definition, ID field is mandatory @return [Hash] The result Acl
# File lib/diplomat/acl.rb, line 54 def update(value) raise Diplomat::IdParameterRequired unless value['ID'] @raw = @conn.put do |req| url = ['/v1/acl/update'] url += check_acl_token url += use_cas(@options) req.url concat_url url req.body = value.to_json end parse_body end