deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "marios@redhat.com" <mandr...@redhat.com>
Subject Re: [PATCH core] CIMI: Added MachineAdmin model operations (rev 2)
Date Wed, 07 Dec 2011 12:40:07 GMT
ACK - whitespace nit (deltacloud/.git/rebase-apply/patch:46: new blank
line at EOF) + minor comment below:

On 07/12/11 12:08, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mfojtik@redhat.com>
> 
> 
> Signed-off-by: Michal fojtik <mfojtik@redhat.com>
> ---
>  server/lib/cimi/model.rb               |    1 +
>  server/lib/cimi/model/base.rb          |    8 -----
>  server/lib/cimi/model/errors.rb        |   40 ++++++++++++++++++++++++++
>  server/lib/cimi/model/machine_admin.rb |   27 +++++++++++++++++-
>  server/lib/cimi/server.rb              |   49 ++++++++++++++++++++++++++++++-
>  5 files changed, 114 insertions(+), 11 deletions(-)
>  create mode 100644 server/lib/cimi/model/errors.rb
> 

<snip>

do we want to keep the 'with_capability' stuff below - we aren't using
that for any other CIMI collections. It makes sense most for the
'create' operation, but CIMI addresses this through the *_Collection
entity, i.e. you GET the MachineAdminCollection and discover the link
for 'add' (to create new MachineAdmin) from there, if this is allowed.

marios

> +global_collection :machine_admins do
> +  description 'Machine Admin entity'
> +
> +  operation :index do
> +    description "List all machine admins"
> +    with_capability :keys
> +    control do
> +      machine_admins = MachineAdmin.all(self)
> +      respond_to do |format|
> +        format.xml { machine_admins.to_xml_cimi_collection(self) }
> +        format.json { machine_admins.to_json_cimi_collection(self) }
> +      end
> +    end
> +  end
> +
> +  operation :show do
> +    description "Show specific machine admin"
> +    param :id,          :string,    :required
> +    with_capability :key
> +    control do
> +      machine_admin = MachineAdmin.find(params[:id], self)
> +      respond_to do |format|
> +        format.xml { machine_admin.to_xml }
> +        format.json { machine_admin.to_json }
> +      end
> +    end
> +  end
> +
> +  operation :create do
> +    description "Show specific machine admin"
> +    with_capability :create_key
> +    control do
> +      if request.content_type.end_with?("+json")
> +        new_admin = MachineAdmin.create_from_json(request.body.read, self)
> +      else
> +        new_admin = MachineAdmin.create_from_xml(request.body.read, self)
> +      end
> +      status 201 # Created
> +      respond_to do |format|
> +        format.json { new_admin.to_json }
> +        format.xml { new_admin.to_xml }
> +      end
> +    end
> +  end
> +
> +end

Mime
View raw message