/
space.rb
36 lines (32 loc) · 1 KB
/
space.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Copyright (c) 2009-2012 VMware, Inc.
module VCAP::CloudController
rest_controller :Space do
permissions_required do
full Permissions::CFAdmin
full Permissions::OrgManager
read Permissions::SpaceManager
update Permissions::SpaceManager
read Permissions::SpaceDeveloper
read Permissions::SpaceAuditor
end
define_attributes do
attribute :name, String
to_one :organization
to_many :developers
to_many :managers
to_many :auditors
to_many :apps
to_many :domains
to_many :service_instances
end
query_parameters :name, :organization_guid, :developer_guid, :app_guid
def self.translate_validation_exception(e, attributes)
name_errors = e.errors.on([:organization_id, :name])
if name_errors && name_errors.include?(:unique)
Errors::SpaceNameTaken.new(attributes["name"])
else
Errors::SpaceInvalid.new(e.errors.full_messages)
end
end
end
end