Module: WavefrontCli::Mixin::Acl
Overview
Standard ACL commands. Mix this module in to get ACL support.
Instance Method Summary collapse
- #_acl_action(action) ⇒ Wavefront::Response
- #do_acl_clear ⇒ Object
- #do_acl_grant ⇒ Object
- #do_acl_revoke ⇒ Object
- #do_acls ⇒ Object
-
#everyone_id ⇒ String
UUID of ‘Everyone’ group.
- #grant_modify ⇒ Object
- #grant_view ⇒ Object
- #print_status(status) ⇒ Object
- #revoke_modify ⇒ Object
- #revoke_view ⇒ Object
Instance Method Details
#_acl_action(action) ⇒ Wavefront::Response
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 69 def _acl_action(action) entity_type, entities = acl_entities resp = send(format('%<action>s_%<type>s', action: action, type: entity_type), [:'<id>'], entities) print_status(resp.status) do_acls end |
#do_acl_clear ⇒ Object
13 14 15 16 17 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 13 def do_acl_clear cannot_noop! wf.acl_set([:'<id>'], [], [everyone_id]) do_acls end |
#do_acl_grant ⇒ Object
19 20 21 22 23 24 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 19 def do_acl_grant return grant_view if [:view] return grant_modify if [:modify] raise WavefrontCli::Exception::InsufficientData end |
#do_acl_revoke ⇒ Object
26 27 28 29 30 31 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 26 def do_acl_revoke return revoke_view if [:view] return revoke_modify if [:modify] raise WavefrontCli::Exception::InsufficientData end |
#do_acls ⇒ Object
9 10 11 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 9 def do_acls wf.acls([[:'<id>']]) end |
#everyone_id ⇒ String
Returns UUID of ‘Everyone’ group.
37 38 39 40 41 42 43 44 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 37 def everyone_id require 'wavefront-sdk/search' wfs = Wavefront::Search.new(mk_creds, mk_opts) query = conds_to_query(['name=Everyone']) wfs.search(:usergroup, query).response.items.first.id rescue RuntimeError raise WavefrontCli::Exception::UserGroupNotFound, 'Everyone' end |
#grant_modify ⇒ Object
46 47 48 49 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 46 def grant_modify wf.acl_add([:'<id>'], [], [:'<name>']) do_acls end |
#grant_view ⇒ Object
51 52 53 54 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 51 def grant_view wf.acl_add([:'<id>'], [:'<name>'], []) do_acls end |
#print_status(status) ⇒ Object
82 83 84 85 86 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 82 def print_status(status) puts status. unless status..empty? rescue NoMethodError nil end |
#revoke_modify ⇒ Object
61 62 63 64 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 61 def revoke_modify wf.acl_delete([:'<id>'], [], [:'<name>']) do_acls end |
#revoke_view ⇒ Object
56 57 58 59 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 56 def revoke_view wf.acl_delete([:'<id>'], [:'<name>'], []) do_acls end |