diff --git a/app/controllers/api/cloud_volume_snapshots_controller.rb b/app/controllers/api/cloud_volume_snapshots_controller.rb new file mode 100644 index 0000000000..449f351a33 --- /dev/null +++ b/app/controllers/api/cloud_volume_snapshots_controller.rb @@ -0,0 +1,9 @@ +module Api + class CloudVolumeSnapshotsController < BaseController + def delete_resource_action(type, id = nil, _data = nil) + api_resource(type, id, "Deleting", :supports => :delete) do |snapshot| + {:task_id => snapshot.delete_snapshot_queue(User.current_userid)} + end + end + end +end diff --git a/config/api.yml b/config/api.yml index db7d418274..c3e84ceec2 100644 --- a/config/api.yml +++ b/config/api.yml @@ -758,10 +758,26 @@ :identifier: cloud_tenant_tag :cloud_volume_snapshots: :description: Cloud Volume Snapshots + :identifier: cloud_volume_snapshot :options: - - :subcollection + - :collection :verbs: *gpppd :klass: CloudVolumeSnapshot + :subcollections: + :collection_actions: + :get: + - :name: read + :identifier: cloud_volume_snapshot_view + :post: + - :name: delete + :identifier: cloud_volume_snapshot_delete + :resource_actions: + :get: + - :name: read + :identifier: cloud_volume_snapshot_view + :post: + - :name: delete + :identifier: cloud_volume_snapshot_delete :cloud_volume_types: :description: Cloud Volume Types :identifier: cloud_volume_type diff --git a/spec/requests/cloud_volume_snapshots_spec.rb b/spec/requests/cloud_volume_snapshots_spec.rb index df41f17f0a..7b0075ce33 100644 --- a/spec/requests/cloud_volume_snapshots_spec.rb +++ b/spec/requests/cloud_volume_snapshots_spec.rb @@ -77,5 +77,16 @@ expect_bad_request(/Feature not .*supported/) end end + + describe "DELETE /api/cloud_volumes/:c_id/cloud_volume_snapshots/:s_id" do + it "create & delete cloud volume snapshot" do + api_basic_authorize('cloud_volume_snapshot_delete') + + stub_supports(CloudVolumeSnapshot, :delete) + post(api_cloud_volume_snapshot_url(nil, cloud_volume_snapshot), :params => gen_request(:delete)) + + expect_single_action_result(:success => true, :message => /Deleting Cloud Volume Snapshot id: #{cloud_volume_snapshot.id} name: '#{cloud_volume_snapshot.name}'/) + end + end end end