-
Notifications
You must be signed in to change notification settings - Fork 356
/
services_controller.rb
65 lines (51 loc) · 1.56 KB
/
services_controller.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'ext/validation_error_message_overrides'
module VCAP::CloudController
class ServicesController < RestController::ModelController
define_attributes do
to_many :service_plans
end
query_parameters :active, :label, :provider, :service_broker_guid, :unique_id
def self.dependencies
[:services_event_repository]
end
def create
404
end
def update(_)
404
end
def inject_dependencies(dependencies)
super
@services_event_repository = dependencies.fetch(:services_event_repository)
end
allow_unauthenticated_access only: :enumerate
def enumerate
if SecurityContext.missing_token?
raise CloudController::Errors::NotAuthenticated if VCAP::CloudController::FeatureFlag.enabled?(:hide_marketplace_from_unauthenticated_users)
@opts.delete(:inline_relations_depth)
elsif SecurityContext.invalid_token?
raise CloudController::Errors::InvalidAuthToken
end
super
end
def self.translate_validation_exception(e, _attributes)
CloudController::Errors::ApiError.new_from_details('ServiceInvalid', e.errors.full_messages)
end
def delete(guid)
service = find_guid_and_validate_access(:delete, guid)
if purge?
service.purge(@services_event_repository)
@services_event_repository.record_service_purge_event(service)
[HTTP::NO_CONTENT, nil]
else
do_delete(service)
end
end
define_messages
define_routes
private
def purge?
params['purge'] == 'true'
end
end
end