@@ -3,53 +3,10 @@ class SyslogDrainUrlsInternalController < RestController::BaseController
33 # Endpoint uses mutual tls for auth, handled by nginx
44 allow_unauthenticated_access
55
6- get '/internal/v4 /syslog_drain_urls' , :list
6+ get '/internal/v5 /syslog_drain_urls' , :list
77
88 def list
99 prepare_aggregate_function
10- guid_to_drain_maps = AppModel .
11- join ( ServiceBinding . table_name , app_guid : :guid ) .
12- join ( Space . table_name , guid : :apps__space_guid ) .
13- join ( Organization . table_name , id : :spaces__organization_id ) .
14- where ( Sequel . lit ( 'syslog_drain_url IS NOT NULL' ) ) .
15- where ( Sequel . lit ( "syslog_drain_url != ''" ) ) .
16- group (
17- :"#{ AppModel . table_name } __guid" ,
18- :"#{ AppModel . table_name } __name" ,
19- :"#{ Space . table_name } __name" ,
20- :"#{ Organization . table_name } __name"
21- ) .
22- select (
23- :"#{ AppModel . table_name } __guid" ,
24- :"#{ AppModel . table_name } __name" ,
25- aggregate_function ( :"#{ ServiceBinding . table_name } __syslog_drain_url" ) . as ( :syslog_drain_urls )
26- ) .
27- select_append ( :"#{ Space . table_name } __name___space_name" ) .
28- select_append ( :"#{ Organization . table_name } __name___organization_name" ) .
29- order ( :guid ) .
30- limit ( batch_size ) .
31- offset ( last_id ) .
32- all
33-
34- next_page_token = nil
35- drain_urls = { }
36-
37- guid_to_drain_maps . each do |guid_and_drains |
38- drain_urls [ guid_and_drains [ :guid ] ] = {
39- drains : guid_and_drains [ :syslog_drain_urls ] . split ( ',' ) ,
40- hostname : hostname_from_app_name ( guid_and_drains [ :organization_name ] , guid_and_drains [ :space_name ] , guid_and_drains [ :name ] )
41- }
42- end
43-
44- next_page_token = last_id + batch_size unless guid_to_drain_maps . empty?
45-
46- [ HTTP ::OK , Oj . dump ( { results : drain_urls , next_id : next_page_token , v5_available : true } , mode : :compat ) ]
47- end
48-
49- get '/internal/v5/syslog_drain_urls' , :listv5
50-
51- def listv5
52- prepare_aggregate_function
5310
5411 bindings = ServiceBinding .
5512 join ( :apps , guid : :app_guid ) .
0 commit comments