Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utilities for getting service by service_id #2939

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ def included_in_core?
# @return [Boolean] true if any operation requires endpoint_discovery
attr_reader :require_endpoint_discovery

# @return [String] the service_id
def service_id
metadata = @api['metadata']
return metadata['serviceId'] if metadata['serviceId']

name = metadata['serviceAbbreviation'] || metadata['serviceFullName']
name = name.gsub(/AWS/, '').gsub(/Amazon/, '')
name = name.gsub(/[^a-zA-Z0-9 ]+/, '')
name = name.gsub(/^[0-9]+/, '')
name = name.strip

name
end

# @return [Boolean] true if the service is deprecated
def deprecated?
@deprecated
Expand Down
6 changes: 6 additions & 0 deletions build_tools/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def [](identifier)
end
alias service []

def for_service_id(service_id)
services.values.find do |service|
service.service_id == service_id
end
end

def each(&block)
services.values.each(&block)
end
Expand Down