Skip to content

Commit

Permalink
Add a command for deleting containers
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamMcCumstie committed Sep 8, 2020
1 parent 52f3655 commit cec3c4f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/flight_asset/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ def self.create_command(name, args_str = '')
c.slop.integer '--y-capacity', 'Define the hieght', meta: 'HEIGHT'
end

create_command 'delete-container', 'CONTAINER' do |c|
c.summary = 'Permanently destroy an empty container'
end

create_command 'move-container', 'CONTAINER PARENT X_START X_END Y_START Y_END' do |c|
c.summary = 'Reposition a container within another container'
end
Expand Down
44 changes: 44 additions & 0 deletions lib/flight_asset/commands/delete_container.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#==============================================================================
# Copyright (C) 2020-present Alces Flight Ltd.
#
# This file is part of Flight Asset.
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which is available at
# <https://www.eclipse.org/legal/epl-2.0>, or alternative license
# terms made available by Alces Flight Ltd - please direct inquiries
# about licensing to [email protected].
#
# Flight Asset is distributed in the hope that it will be useful, but
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
# IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS
# OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A
# PARTICULAR PURPOSE. See the Eclipse Public License 2.0 for more
# details.
#
# You should have received a copy of the Eclipse Public License 2.0
# along with Flight Asset. If not, see:
#
# https://opensource.org/licenses/EPL-2.0
#
# For more information on Flight Asset, please visit:
# https://github.com/alces-flight/alces-flight/flight-asset-cli
#==============================================================================

module FlightAsset
module Commands
class DeleteContainer < FlightAsset::Command
include Concerns::BeforeConfiguredCheck

define_args :name

def run
request_asset_containers_record_by_name(name).delete
rescue SimpleJSONAPIClient::Errors::APIError
raise ClientError, <<~ERROR.chomp
Failed to delete the container! Please ensure it is empty and try again.
ERROR
end
end
end
end

0 comments on commit cec3c4f

Please sign in to comment.