Class: UnimatrixCLI::Keymaker::Policy::DestroyCommand
- Defined in:
- lib/unimatrix_cli/keymaker/policy/destroy_command.rb
Instance Method Summary collapse
Methods inherited from Command
available_commands, descendants, #initialize, #read_file, #validate, #validate_collection, #write
Methods included from UnimatrixParser
Constructor Details
This class inherits a constructor from UnimatrixCLI::Command
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/unimatrix_cli/keymaker/policy/destroy_command.rb', line 17 def execute resource_and_server = @options[ :policy ].split( ':' ) if resource_and_server.length == 2 endpoint = "#{ Configuration.default_config[ 'keymaker_url' ] }/policies?" + "access_token=#{ Configuration.access_token }" body = { policy: { resource: resource_string( resource_and_server ) }, resource_owner_uuid: @options[ :resource_owner_uuid ] } delete_response = make_request( endpoint, 'Delete', body ) if delete_response.empty? write( message: "Successfully removed policy:\n" + "Realm UUID: #{ @options[ :realm ] }\n" + "Resource Server: #{ resource_and_server[ 0 ] }\n" + "Resource: #{ resource_and_server[ 1 ] }\n\n" + "Check policies here: #{ Configuration.default_config[ 'keymaker_url' ] }" + "/policies?access_token=#{ Configuration.access_token }&" + "resource_owner_uuid=#{ @options[ :resource_owner_uuid ] }" ) else write( message: "\n**Error removing policy**\n" + "Realm UUID: #{ @options[ :realm ] }\n" + "Resource Server: #{ resource_and_server[ 0 ] }\n" + "Resource: #{ resource_and_server[ 1 ] }\n" + "Error: #{ delete_response.inspect }\n\n", error: true ) end else write( message: "Error: policy option incorrectly formatted: #{ @options[ :policy ] }", error: true ) end end |