Class: Matterhorn::Endpoint::Acl
- Inherits:
-
Matterhorn::Endpoint
- Object
- Matterhorn::Endpoint
- Matterhorn::Endpoint::Acl
- Defined in:
- lib/matterhorn/endpoint/acl.rb
Overview
Matterhorn::Endpoint::Acl ===
Instance Attribute Summary
Attributes inherited from Matterhorn::Endpoint
#response_body, #response_code
Instance Method Summary collapse
-
#create(name, acl) ⇒ Object
Create a new acl with name and acl list.
-
#delete(acl_id) ⇒ Object
————————————————————————————- delete —.
- #get(acl_id) ⇒ Object
-
#index ⇒ Object
————————————————————————————— read —.
-
#update(acl_id, name, acl) ⇒ Object
————————————————————————————- update —.
Methods inherited from Matterhorn::Endpoint
#close, create, #error_code, #error_msg, #error_occurred?, #initialize, open
Constructor Details
This class inherits a constructor from Matterhorn::Endpoint
Instance Method Details
#create(name, acl) ⇒ Object
Create a new acl with name and acl list.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/matterhorn/endpoint/acl.rb', line 14 def create(name, acl) ret_acl = false begin split_response http_endpoint_client.post( "acl-manager/acl", { 'name' => name.to_s, 'acl' => acl.to_json } ) ret_acl = JSON.parse(response_body) rescue => ex exception_handler('create', ex, { 400 => "Unable to parse the ACL!", 409 => "An ACL with the same name[#{name}] already exists!" } ) end ret_acl end |
#delete(acl_id) ⇒ Object
————————————————————————————- delete —
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/matterhorn/endpoint/acl.rb', line 89 def delete(acl_id) done = false begin split_response http_endpoint_client.delete( "acl-manager/acl/#{acl_id}" ) done = true rescue => ex exception_handler('create', ex, { 404 => "The Acl[#{acl_id}] has not been found!", 409 => "The Acl[#{acl_id}] could not be deleted, there are still references on it!" } ) end done end |
#get(acl_id) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/matterhorn/endpoint/acl.rb', line 49 def get(acl_id) acl = {} begin split_response http_endpoint_client.get( "acl-manager/acl/#{acl_id}" ) acl = JSON.parse(response_body) rescue => ex exception_handler('index', ex, { 404 => "The Acl[#{acl_id}] has not been found!" } ) end acl end |
#index ⇒ Object
————————————————————————————— read —
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/matterhorn/endpoint/acl.rb', line 35 def index acls = {} begin split_response http_endpoint_client.get( "acl-manager/acl/acls.json" ) acls = JSON.parse(response_body) rescue => ex exception_handler('index', ex, {}) end acls end |
#update(acl_id, name, acl) ⇒ Object
————————————————————————————- update —
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/matterhorn/endpoint/acl.rb', line 68 def update(acl_id, name, acl) ret_acl = false begin split_response http_endpoint_client.put( "acl-manager/acl/#{acl_id}", { 'name' => name.to_s, 'acl' => acl.to_json } ) ret_acl = JSON.parse(response_body) rescue => ex exception_handler('create', ex, { 400 => "Unable to parse the ACL!", 404 => "The Acl[#{acl_id}] has not been found!" } ) end ret_acl end |