Module: Occi::Cli::Helpers::DeleteHelper

Defined in:
lib/occi/cli/helpers/delete_helper.rb

Instance Method Summary collapse

Instance Method Details

#helper_delete(options, output = nil) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/occi/cli/helpers/delete_helper.rb', line 3

def helper_delete(options, output = nil)
  unless resource_types.include?(options.resource) || resource_type_identifiers.include?(options.resource) || options.resource.start_with?(options.endpoint) || options.resource.start_with?('/')
    message = "Resource #{options.resource.inspect} cannot be deleted!"

    Occi::Cli::Log.error message
    raise ArgumentError, message
  end

  if delete(options.resource)
    Occi::Cli::Log.info "Resource #{options.resource.inspect} successfully removed!"
  else
    message = "Failed to remove resource #{options.resource.inspect}!"

    Occi::Cli::Log.error message
    raise message
  end

  true
end