Adds RESTlike methods to Plan of Planning service

Adds destroy, save, create and update methods to Plan
model of OpenStack Planning service.
This commit is contained in:
Petr Blaho 2015-03-25 17:08:06 +01:00
parent e4547ad987
commit 5c8457d7e0
2 changed files with 39 additions and 0 deletions

View File

@ -52,6 +52,29 @@ module Fog
def remove_role(role_uuid)
service.remove_role_from_plan(uuid, role_uuid)
end
def destroy
requires :uuid
service.delete_plan(uuid)
true
end
def save
requires :name
identity ? update : create
end
def create
requires :name
merge_attributes(service.create_plan(self.attributes).body)
self
end
def update(parameters=nil)
requires :uuid
merge_attributes(service.patch_plan(uuid, parameters).body)
self
end
end
end
end

View File

@ -31,5 +31,21 @@ Shindo.tests("Fog::Openstack[:planning] | plan", ['openstack']) do
tests('#remove_role').succeeds do
@instance.remove_role(@role['uuid'])
end
tests('#save').succeeds do
@instance.save
end
tests('#update').succeeds do
@instance.update
end
tests('#destroy').succeeds do
@instance.destroy
end
tests('#create').succeeds do
@instance.create
end
end
end