Class: Wavefront::Role
- Includes:
- Mixin::User
- Defined in:
- lib/wavefront-sdk/role.rb
Overview
Manage and query Wavefront roles
Instance Attribute Summary
Attributes inherited from CoreApi
Instance Method Summary collapse
-
#add_assignees(id, assignees) ⇒ Wavefront::Response
POST /api/v2/role/id/addAssignees Add multiple users and user groups to a specific role.
-
#create(body) ⇒ Wavefront::Response
POST /api/v2/role Create a specific role.
-
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/role/id Delete a specific role.
-
#describe(id) ⇒ Wavefront::Response
GET /api/v2/role/id Get a specific role.
-
#grant(permission, roles) ⇒ Wavefront::Response
POST /api/v2/role/grant/permission Grants a single permission to role(s).
-
#list(offset = 0, limit = 100) ⇒ Wavefront::Response
GET /api/v2/role Get all roles for a customer.
-
#remove_assignees(id, assignees) ⇒ Wavefront::Response
POST /api/v2/role/id/removeAssignees Remove multiple users and user groups from a specific role.
-
#revoke(permission, roles) ⇒ Wavefront::Response
POST /api/v2/role/revoke/permission Revokes a single permission from role(s).
-
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/role/id Update a specific role.
- #update_keys ⇒ Object
Methods included from Mixin::User
#validate_account_list, #validate_role_list, #validate_user_list, #validate_usergroup_list
Methods inherited from CoreApi
#api_base, #api_path, #hash_for_update, #initialize, #setup_api, #time_to_ms
Methods included from Mixins
#log, #parse_relative_time, #parse_time, #relative_time, #time_multiplier, #valid_relative_time?
Methods included from Validators
#uuid?, #wf_account_id?, #wf_alert_id?, #wf_alert_severity?, #wf_apitoken_id?, #wf_aws_external_id?, #wf_cloudintegration_id?, #wf_dashboard_id?, #wf_derivedmetric_id?, #wf_distribution?, #wf_distribution_count?, #wf_distribution_interval?, #wf_distribution_values?, #wf_epoch?, #wf_event_id?, #wf_granularity?, #wf_ingestionpolicy_id?, #wf_integration_id?, #wf_link_id?, #wf_link_template?, #wf_maintenance_window_id?, #wf_message_id?, #wf_metric_name?, #wf_metricspolicy_id?, #wf_monitoredapplication_id?, #wf_monitoredcluster_id?, #wf_ms_ts?, #wf_name?, #wf_notificant_id?, #wf_permission?, #wf_point?, #wf_point_tag?, #wf_point_tags?, #wf_proxy_id?, #wf_role_id?, #wf_sampling_value?, #wf_savedsearch_entity?, #wf_savedsearch_id?, #wf_serviceaccount_id?, #wf_source_id?, #wf_spansamplingpolicy_id?, #wf_string?, #wf_tag?, #wf_trace?, #wf_ts?, #wf_user_id?, #wf_usergroup_id?, #wf_value?, #wf_version?, #wf_webhook_id?
Constructor Details
This class inherits a constructor from Wavefront::CoreApi
Instance Method Details
#add_assignees(id, assignees) ⇒ Wavefront::Response
POST /api/v2/role/id/addAssignees Add multiple users and user groups to a specific role
84 85 86 87 88 |
# File 'lib/wavefront-sdk/role.rb', line 84 def add_assignees(id, assignees) wf_role_id?(id) validate_user_list(assignees) api.post([id, 'addAssignees'].uri_concat, assignees, 'application/json') end |
#create(body) ⇒ Wavefront::Response
POST /api/v2/role Create a specific role
33 34 35 36 37 |
# File 'lib/wavefront-sdk/role.rb', line 33 def create(body) raise ArgumentError unless body.is_a?(Hash) api.post('', body, 'application/json') end |
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/role/id Delete a specific role
44 45 46 47 |
# File 'lib/wavefront-sdk/role.rb', line 44 def delete(id) wf_role_id?(id) api.delete(id) end |
#describe(id) ⇒ Wavefront::Response
GET /api/v2/role/id Get a specific role
54 55 56 57 |
# File 'lib/wavefront-sdk/role.rb', line 54 def describe(id) wf_role_id?(id) api.get(id) end |
#grant(permission, roles) ⇒ Wavefront::Response
POST /api/v2/role/grant/permission Grants a single permission to role(s)
110 111 112 113 114 |
# File 'lib/wavefront-sdk/role.rb', line 110 def grant(, roles) () validate_role_list(roles) api.post(['grant', ].uri_concat, roles, 'application/json') end |
#list(offset = 0, limit = 100) ⇒ Wavefront::Response
GET /api/v2/role Get all roles for a customer
23 24 25 |
# File 'lib/wavefront-sdk/role.rb', line 23 def list(offset = 0, limit = 100) api.get('', offset: offset, limit: limit) end |
#remove_assignees(id, assignees) ⇒ Wavefront::Response
POST /api/v2/role/id/removeAssignees Remove multiple users and user groups from a specific role
96 97 98 99 100 101 102 |
# File 'lib/wavefront-sdk/role.rb', line 96 def remove_assignees(id, assignees) wf_role_id?(id) validate_user_list(assignees) api.post([id, 'removeAssignees'].uri_concat, assignees, 'application/json') end |
#revoke(permission, roles) ⇒ Wavefront::Response
POST /api/v2/role/revoke/permission Revokes a single permission from role(s)
122 123 124 125 126 |
# File 'lib/wavefront-sdk/role.rb', line 122 def revoke(, roles) () validate_role_list(roles) api.post(['revoke', ].uri_concat, roles, 'application/json') end |
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/role/id Update a specific role
68 69 70 71 72 73 74 75 76 |
# File 'lib/wavefront-sdk/role.rb', line 68 def update(id, body, modify = true) wf_role_id?(id) raise ArgumentError unless body.is_a?(Hash) return api.put(id, body, 'application/json') unless modify api.put(id, hash_for_update(describe(id).response, body), 'application/json') end |
#update_keys ⇒ Object
13 14 15 |
# File 'lib/wavefront-sdk/role.rb', line 13 def update_keys %i[id name description] end |