/
organization.rb
38 lines (34 loc) · 1.1 KB
/
organization.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
37
38
# Copyright (c) 2009-2012 VMware, Inc.
module VCAP::CloudController
rest_controller :Organization do
permissions_required do
full Permissions::CFAdmin
read Permissions::OrgManager
update Permissions::OrgManager
read Permissions::OrgUser
read Permissions::BillingManager
read Permissions::Auditor
end
define_attributes do
attribute :name, String
attribute :billing_enabled, Message::Boolean, :default => false
to_many :spaces, :exclude_in => :create
to_many :domains
to_many :users
to_many :managers
to_many :billing_managers
to_many :auditors
end
query_parameters :name, :space_guid,
:user_guid, :manager_guid, :billing_manager_guid,
:auditor_guid
def self.translate_validation_exception(e, attributes)
name_errors = e.errors.on(:name)
if name_errors && name_errors.include?(:unique)
Errors::OrganizationNameTaken.new(attributes["name"])
else
Errors::OrganizationInvalid.new(e.errors.full_messages)
end
end
end
end