Skip to content

Commit

Permalink
Deprecated Syslog Binding URL API removal
Browse files Browse the repository at this point in the history
Code clean up after the deprecation of the `/v4` API for the Syslog
Binding URL.
  • Loading branch information
chombium committed Jan 18, 2024
1 parent d002740 commit ba0d68a
Show file tree
Hide file tree
Showing 3 changed files with 311 additions and 330 deletions.
45 changes: 1 addition & 44 deletions app/controllers/internal/syslog_drain_urls_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,10 @@ class SyslogDrainUrlsInternalController < RestController::BaseController
# Endpoint uses mutual tls for auth, handled by nginx
allow_unauthenticated_access

get '/internal/v4/syslog_drain_urls', :list
get '/internal/v5/syslog_drain_urls', :list

def list
prepare_aggregate_function
guid_to_drain_maps = AppModel.
join(ServiceBinding.table_name, app_guid: :guid).
join(Space.table_name, guid: :apps__space_guid).
join(Organization.table_name, id: :spaces__organization_id).
where(Sequel.lit('syslog_drain_url IS NOT NULL')).
where(Sequel.lit("syslog_drain_url != ''")).
group(
:"#{AppModel.table_name}__guid",
:"#{AppModel.table_name}__name",
:"#{Space.table_name}__name",
:"#{Organization.table_name}__name"
).
select(
:"#{AppModel.table_name}__guid",
:"#{AppModel.table_name}__name",
aggregate_function(:"#{ServiceBinding.table_name}__syslog_drain_url").as(:syslog_drain_urls)
).
select_append(:"#{Space.table_name}__name___space_name").
select_append(:"#{Organization.table_name}__name___organization_name").
order(:guid).
limit(batch_size).
offset(last_id).
all

next_page_token = nil
drain_urls = {}

guid_to_drain_maps.each do |guid_and_drains|
drain_urls[guid_and_drains[:guid]] = {
drains: guid_and_drains[:syslog_drain_urls].split(','),
hostname: hostname_from_app_name(guid_and_drains[:organization_name], guid_and_drains[:space_name], guid_and_drains[:name])
}
end

next_page_token = last_id + batch_size unless guid_to_drain_maps.empty?

[HTTP::OK, MultiJson.dump({ results: drain_urls, next_id: next_page_token, v5_available: true }, pretty: true)]
end

get '/internal/v5/syslog_drain_urls', :listv5

def listv5
prepare_aggregate_function

bindings = ServiceBinding.
join(:apps, guid: :app_guid).
Expand Down
9 changes: 1 addition & 8 deletions docs/internal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,8 @@ We do not recommend using internal API endpoints for anything other than their i

**Auth Mechanism:** mTLS

### GET /internal/v4/syslog_drain_urls
**Description:** Return list of syslog drain urls from logging services

**Intended Consumer:** Loggregator

**Auth Mechanism:** mTLS

### GET /internal/v5/syslog_drain_urls
**Description:** Return list of syslog drain urls from logging services. Intends to replace v4 version.
**Description:** Return list of syslog drain urls from logging services.

**Intended Consumer:** Loggregator

Expand Down
Loading

0 comments on commit ba0d68a

Please sign in to comment.