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
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 66 def _acl_action(action) entity_type, entities = acl_entities resp = send(format('%s_%s', action, entity_type), [:'<id>'], entities) print_status(resp.status) do_acls end |
#do_acl_clear ⇒ Object
11 12 13 14 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 11 def do_acl_clear wf.acl_set([:'<id>'], [], [everyone_id]) do_acls end |
#do_acl_grant ⇒ Object
16 17 18 19 20 21 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 16 def do_acl_grant return grant_view if [:view] return grant_modify if [:modify] raise WavefrontCli::Exception::InsufficientData end |
#do_acl_revoke ⇒ Object
23 24 25 26 27 28 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 23 def do_acl_revoke return revoke_view if [:view] return revoke_modify if [:modify] raise WavefrontCli::Exception::InsufficientData end |
#do_acls ⇒ Object
7 8 9 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 7 def do_acls wf.acls([[:'<id>']]) end |
#everyone_id ⇒ String
Returns UUID of ‘Everyone’ group.
34 35 36 37 38 39 40 41 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 34 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
43 44 45 46 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 43 def grant_modify wf.acl_add([:'<id>'], [], [:'<name>']) do_acls end |
#grant_view ⇒ Object
48 49 50 51 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 48 def grant_view wf.acl_add([:'<id>'], [:'<name>'], []) do_acls end |
#print_status(status) ⇒ Object
77 78 79 80 81 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 77 def print_status(status) puts status. unless status..empty? rescue NoMethodError nil end |
#revoke_modify ⇒ Object
58 59 60 61 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 58 def revoke_modify wf.acl_delete([:'<id>'], [], [:'<name>']) do_acls end |
#revoke_view ⇒ Object
53 54 55 56 |
# File 'lib/wavefront-cli/command_mixins/acl.rb', line 53 def revoke_view wf.acl_delete([:'<id>'], [:'<name>'], []) do_acls end |