From 94d441606ad7c616c49c286e65a74776b9953e34 Mon Sep 17 00:00:00 2001 From: Nick Schwaderer Date: Mon, 23 Sep 2024 17:36:01 +0100 Subject: [PATCH] Introduces autoloading strategy for service gems (#3105) --- .github/workflows/benchmark.yml | 3 + .../lib/aws-sdk-code-generator/helper.rb | 12 +- .../views/errors_module.rb | 21 ++ .../views/resource_class.rb | 22 +++ .../views/root_resource_class.rb | 19 ++ .../views/service_module.rb | 64 +++--- .../views/types_module.rb | 12 ++ .../templates/client_api_module.mustache | 1 + .../templates/errors_module.mustache | 5 + .../templates/resource_class.mustache | 5 + .../templates/root_resource_class.mustache | 5 + .../templates/service_module.mustache | 16 +- .../templates/types_module.mustache | 4 + .../lib/aws-sdk-cloudfront/customizations.rb | 10 +- .../aws-sdk-cognitoidentity/customizations.rb | 6 +- gems/aws-sdk-core/CHANGELOG.md | 2 + gems/aws-sdk-core/lib/aws-defaults.rb | 5 +- gems/aws-sdk-core/lib/aws-sdk-core.rb | 183 ++++++++---------- .../aws-sdk-core/client_side_monitoring.rb | 9 + gems/aws-sdk-core/lib/aws-sdk-core/log.rb | 10 + gems/aws-sdk-core/lib/aws-sdk-core/plugins.rb | 10 + .../lib/aws-sdk-core/resources.rb | 8 + .../aws-sdk-core/lib/aws-sdk-core/stubbing.rb | 22 +++ .../lib/aws-sdk-sts/customizations.rb | 6 +- .../spec/aws/cbor/cbor_engine_spec.rb | 3 +- .../spec/aws/cbor/decoder_spec.rb | 1 + .../spec/aws/cbor/encoder_spec.rb | 1 + gems/aws-sdk-core/spec/aws/cbor_spec.rb | 1 + .../aws-sdk-dynamodbstreams/customizations.rb | 8 +- .../lib/aws-sdk-ec2/customizations.rb | 22 --- .../aws-sdk-ec2/customizations/instance.rb | 17 ++ .../lib/aws-sdk-ec2/customizations/tag.rb | 13 ++ .../lib/aws-sdk-iam/customizations.rb | 3 - .../lib/aws-sdk-polly/customizations.rb | 6 +- .../lib/aws-sdk-s3/customizations.rb | 62 +++--- .../lib/aws-sdk-s3/customizations/object.rb | 6 + .../customizations/object_summary.rb | 5 + .../customizations/object_version.rb | 13 ++ .../lib/aws-sdk-sns/customizations.rb | 6 +- .../lib/aws-sdk-sqs/customizations.rb | 6 +- .../lib/aws-sdk-translate/customizations.rb | 8 + 41 files changed, 432 insertions(+), 209 deletions(-) create mode 100644 gems/aws-sdk-core/lib/aws-sdk-core/client_side_monitoring.rb create mode 100644 gems/aws-sdk-core/lib/aws-sdk-core/log.rb create mode 100644 gems/aws-sdk-core/lib/aws-sdk-core/plugins.rb create mode 100644 gems/aws-sdk-core/lib/aws-sdk-core/resources.rb create mode 100644 gems/aws-sdk-core/lib/aws-sdk-core/stubbing.rb create mode 100644 gems/aws-sdk-ec2/lib/aws-sdk-ec2/customizations/tag.rb create mode 100644 gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_version.rb diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 22f4458d5c5..a308765e71f 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -52,13 +52,16 @@ jobs: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 + continue-on-error: true with: role-to-assume: arn:aws:iam::373952703873:role/BenchmarkReporter role-session-name: benchmark-reporter aws-region: us-east-1 - name: Upload benchmark report + if: ${{ env.AWS_ACCESS_KEY_ID != '' }} run: bundle exec rake benchmark:upload-report - name: Put benchmark metrics + if: ${{ env.AWS_ACCESS_KEY_ID != '' }} run: bundle exec rake benchmark:put-metrics diff --git a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/helper.rb b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/helper.rb index ead8b228fb4..0e8f562610e 100644 --- a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/helper.rb +++ b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/helper.rb @@ -175,8 +175,18 @@ def wrap_string(str, width, indent = '') str.gsub(/(.{1,#{width}})(\s+|\Z)/, "#{indent}\\1\n").chomp end + def gem_lib_path(gem_name) + File.expand_path( + File.join( + __dir__, + "../../../../gems/#{gem_name}/lib/" + ) + ) + end + module_function :deep_copy, :operation_streaming?, :downcase_first, :wrap_string, :apig_prefix, - :eventstream_output?, :eventstream_input?, :operation_eventstreaming?, :pascal_case + :eventstream_output?, :eventstream_input?, :operation_eventstreaming?, :pascal_case, + :gem_lib_path end end diff --git a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/errors_module.rb b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/errors_module.rb index 94360550a97..794d193d289 100644 --- a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/errors_module.rb +++ b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/errors_module.rb @@ -23,10 +23,31 @@ def generated_src_warning GENERATED_SRC_WARNING end + # @return [String] def module_name @service.module_name end + # @return [Boolean] + def customization_file_exists? + File.exist?( + File.join( + Helper.gem_lib_path(gem_name), "#{customization_file_path}.rb" + ) + ) + end + + # @return [String] + def customization_file_path + "#{gem_name}/customizations/errors" + end + + private + + # @return [String] + def gem_name + "aws-sdk-#{module_name.split('::').last.downcase}" + end end end end diff --git a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/resource_class.rb b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/resource_class.rb index 09e2ee9465b..c4c05dcf044 100644 --- a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/resource_class.rb +++ b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/resource_class.rb @@ -106,8 +106,30 @@ def identifiers? @identifiers.size > 0 end + # @return [Boolean] + def customization_file_exists? + File.exist?( + File.join( + Helper.gem_lib_path(gem_name), "#{resource_customization}.rb" + ) + ) + end + + # @return [String] + def resource_customization + "#{gem_name}/customizations/#{underscored_name}" + end + private + def gem_name + "aws-sdk-#{module_name.split('::').last.downcase}" + end + + def underscored_name + class_name.gsub(/([a-z])([A-Z])/, '\1_\2').downcase + end + def build_associations(options) ResourceAssociation.build_list( class_name: options.fetch(:class_name), diff --git a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/root_resource_class.rb b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/root_resource_class.rb index 9540769d608..5eed979787c 100644 --- a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/root_resource_class.rb +++ b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/root_resource_class.rb @@ -53,6 +53,25 @@ def documentation? actions? || associations? end + # @return [Boolean] + def customization_file_exists? + File.exist?( + File.join( + Helper.gem_lib_path(gem_name), "#{customization_file_path}.rb" + ) + ) + end + + # @return [String] + def customization_file_path + "#{gem_name}/customizations/resource" + end + + private + + def gem_name + "aws-sdk-#{module_name.split('::').last.downcase}" + end end end end diff --git a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/service_module.rb b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/service_module.rb index b78f133c7a3..733d6a8fdc5 100644 --- a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/service_module.rb +++ b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/service_module.rb @@ -11,7 +11,7 @@ class ServiceModule < View def initialize(options) @service = options.fetch(:service) @prefix = options.fetch(:prefix) - @codegenerated_plugins = options.fetch(:codegenerated_plugins) + @codegenerated_plugins = options.fetch(:codegenerated_plugins) || [] end # @return [String|nil] @@ -60,47 +60,56 @@ def require_core_guard? @service.included_in_core? end - # @return [Array] - def relative_requires - paths = Set.new - paths << "#{@prefix}/types" - paths << "#{@prefix}/client_api" + # @return [Array] list of autoload path hashes with :path, :class_name and + # :is_plugin keys. + def autoloads + paths = [] + paths << auto_load("#{@prefix}/types", :Types) + paths << auto_load("#{@prefix}/client_api", :ClientApi) # these must be required before the client - if @codegenerated_plugins - paths += @codegenerated_plugins.map { | p| p.path } + paths += @codegenerated_plugins.map do |p| + auto_load(p.path, p.class_name.split('::').last, true) end - paths << "#{@prefix}/client" - paths << "#{@prefix}/errors" - paths << "#{@prefix}/waiters" if @service.waiters - paths << "#{@prefix}/resource" + paths << auto_load("#{@prefix}/client", :Client) + paths << auto_load("#{@prefix}/errors", :Errors) + paths << auto_load("#{@prefix}/waiters", :Waiters) if @service.waiters + paths << auto_load("#{@prefix}/resource", :Resource) unless @service.legacy_endpoints? - paths << "#{@prefix}/endpoint_parameters" - paths << "#{@prefix}/endpoint_provider" - paths << "#{@prefix}/endpoints" + paths << auto_load("#{@prefix}/endpoint_parameters", :EndpointParameters) + paths << auto_load("#{@prefix}/endpoint_provider", :EndpointProvider) + paths << auto_load("#{@prefix}/endpoints", :Endpoints) end if @service.resources && @service.resources['resources'] @service.resources['resources'].keys.each do |resource_name| path = "#{@prefix}/#{underscore(resource_name)}" - if paths.include?(path) - raise "resource path conflict for `#{resource_name}'" - else - paths << path - end + paths << auto_load(path, resource_name) end end - paths << "#{@prefix}/customizations" if @service.api['metadata']['protocolSettings'] && - @service.api['metadata']['protocolSettings']['h2'] == 'eventstream' - paths << "#{@prefix}/async_client" - paths << "#{@prefix}/event_streams" + @service.api['metadata']['protocolSettings']['h2'] == 'eventstream' + paths << auto_load("#{@prefix}/async_client", :AsyncClient) + paths << auto_load("#{@prefix}/event_streams", :EventStreams) elsif eventstream_shape? - paths << "#{@prefix}/event_streams" + paths << auto_load("#{@prefix}/event_streams", :EventStreams) end - paths.to_a + + paths + end + + def auto_load(path, class_name, is_plugin = false) + { + file_path: path, + class_name: class_name, + is_plugin: is_plugin + } + end + + def service_identifier + @prefix end def example_var_name @@ -108,7 +117,8 @@ def example_var_name end def example_operation_name - raise "no operations found for the service" if @service.api['operations'].empty? + raise 'no operations found for the service' if @service.api['operations'].empty? + underscore(@service.api['operations'].keys.first) end diff --git a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/types_module.rb b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/types_module.rb index 492c9e76faa..134294d663f 100644 --- a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/types_module.rb +++ b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/types_module.rb @@ -80,8 +80,20 @@ def eventstreams end end + # @return [Array] + def types_customizations + Dir.glob(File.join(Helper.gem_lib_path(gem_name), "#{gem_name}/customizations/types", '*.rb')).map do |file| + filename = File.basename(file, '.rb') + "#{gem_name}/customizations/types/#{filename}" + end + end + private + def gem_name + "aws-sdk-#{module_name.split('::').last.downcase}" + end + def struct_members(shape) return if shape['members'].nil? members = shape['members'].map do |member_name, member_ref| diff --git a/build_tools/aws-sdk-code-generator/templates/client_api_module.mustache b/build_tools/aws-sdk-code-generator/templates/client_api_module.mustache index c2d3b37d280..a8f79f38df5 100644 --- a/build_tools/aws-sdk-code-generator/templates/client_api_module.mustache +++ b/build_tools/aws-sdk-code-generator/templates/client_api_module.mustache @@ -3,6 +3,7 @@ {{#generated_src_warning}} {{generated_src_warning}} {{/generated_src_warning}} + module {{module_name}} # @api private module ClientApi diff --git a/build_tools/aws-sdk-code-generator/templates/errors_module.mustache b/build_tools/aws-sdk-code-generator/templates/errors_module.mustache index f73c0484d8c..74ea2c830b5 100644 --- a/build_tools/aws-sdk-code-generator/templates/errors_module.mustache +++ b/build_tools/aws-sdk-code-generator/templates/errors_module.mustache @@ -68,3 +68,8 @@ module {{module_name}} {{/errors}} end end +{{#customization_file_exists?}} + +# Load customizations if they exist +require '{{customization_file_path}}' +{{/customization_file_exists?}} diff --git a/build_tools/aws-sdk-code-generator/templates/resource_class.mustache b/build_tools/aws-sdk-code-generator/templates/resource_class.mustache index 9a4e40074e8..a0809c86a6f 100644 --- a/build_tools/aws-sdk-code-generator/templates/resource_class.mustache +++ b/build_tools/aws-sdk-code-generator/templates/resource_class.mustache @@ -304,3 +304,8 @@ module {{module_name}} {{/batch_actions?}} end end +{{#customization_file_exists?}} + +# Load customizations if they exist +require '{{resource_customization}}' +{{/customization_file_exists?}} diff --git a/build_tools/aws-sdk-code-generator/templates/root_resource_class.mustache b/build_tools/aws-sdk-code-generator/templates/root_resource_class.mustache index 6c5e437435e..2e81a762f41 100644 --- a/build_tools/aws-sdk-code-generator/templates/root_resource_class.mustache +++ b/build_tools/aws-sdk-code-generator/templates/root_resource_class.mustache @@ -49,3 +49,8 @@ module {{module_name}} end end +{{#customization_file_exists?}} + +# Load customizations if they exist +require '{{customization_file_path}}' +{{/customization_file_exists?}} diff --git a/build_tools/aws-sdk-code-generator/templates/service_module.mustache b/build_tools/aws-sdk-code-generator/templates/service_module.mustache index da90252cc0e..4f543324d88 100644 --- a/build_tools/aws-sdk-code-generator/templates/service_module.mustache +++ b/build_tools/aws-sdk-code-generator/templates/service_module.mustache @@ -17,10 +17,6 @@ require '{{.}}' {{/requires}} {{/require_core_guard?}} -{{#relative_requires}} -require_relative '{{.}}' -{{/relative_requires}} - # This module provides support for {{full_name}}. This module is available in the # `{{gem_name}}` gem. # @@ -52,7 +48,19 @@ require_relative '{{.}}' # # @!group service module {{module_name}} + {{#autoloads}} + {{#is_plugin}} + module Plugins + autoload :{{class_name}}, '{{file_path}}' + end + {{/is_plugin}} + {{^is_plugin}} + autoload :{{class_name}}, '{{file_path}}' + {{/is_plugin}} + {{/autoloads}} GEM_VERSION = '{{gem_version}}' end + +require_relative '{{service_identifier}}/customizations' diff --git a/build_tools/aws-sdk-code-generator/templates/types_module.mustache b/build_tools/aws-sdk-code-generator/templates/types_module.mustache index 0fab503b64a..12a6fae9133 100644 --- a/build_tools/aws-sdk-code-generator/templates/types_module.mustache +++ b/build_tools/aws-sdk-code-generator/templates/types_module.mustache @@ -51,3 +51,7 @@ module {{module_name}} end end + +{{#types_customizations}} +require "{{.}}" +{{/types_customizations}} diff --git a/gems/aws-sdk-cloudfront/lib/aws-sdk-cloudfront/customizations.rb b/gems/aws-sdk-cloudfront/lib/aws-sdk-cloudfront/customizations.rb index 94f58989d45..c68664bdf7a 100644 --- a/gems/aws-sdk-cloudfront/lib/aws-sdk-cloudfront/customizations.rb +++ b/gems/aws-sdk-cloudfront/lib/aws-sdk-cloudfront/customizations.rb @@ -1,6 +1,10 @@ # frozen_string_literal: true # utility classes -require 'aws-sdk-cloudfront/signer' -require 'aws-sdk-cloudfront/url_signer' -require 'aws-sdk-cloudfront/cookie_signer' +module Aws + module CloudFront + autoload :Signer, 'aws-sdk-cloudfront/signer' + autoload :UrlSigner, 'aws-sdk-cloudfront/url_signer' + autoload :CookieSigner, 'aws-sdk-cloudfront/cookie_signer' + end +end diff --git a/gems/aws-sdk-cognitoidentity/lib/aws-sdk-cognitoidentity/customizations.rb b/gems/aws-sdk-cognitoidentity/lib/aws-sdk-cognitoidentity/customizations.rb index 08d6646c96e..c2820259bec 100644 --- a/gems/aws-sdk-cognitoidentity/lib/aws-sdk-cognitoidentity/customizations.rb +++ b/gems/aws-sdk-cognitoidentity/lib/aws-sdk-cognitoidentity/customizations.rb @@ -1,3 +1,7 @@ # frozen_string_literal: true -require 'aws-sdk-cognitoidentity/customizations/cognito_identity_credentials' \ No newline at end of file +module Aws + module CognitoIdentity + autoload :CognitoIdentityCredentials, 'aws-sdk-cognitoidentity/customizations/cognito_identity_credentials' + end +end diff --git a/gems/aws-sdk-core/CHANGELOG.md b/gems/aws-sdk-core/CHANGELOG.md index df4938ad3f0..944afdc0b4d 100644 --- a/gems/aws-sdk-core/CHANGELOG.md +++ b/gems/aws-sdk-core/CHANGELOG.md @@ -1,6 +1,8 @@ Unreleased Changes ------------------ +* Feature - Use autoloading at the service level to load service clients and resources. + 3.207.0 (2024-09-20) ------------------ diff --git a/gems/aws-sdk-core/lib/aws-defaults.rb b/gems/aws-sdk-core/lib/aws-defaults.rb index 94050821ba1..0961c86fa69 100644 --- a/gems/aws-sdk-core/lib/aws-defaults.rb +++ b/gems/aws-sdk-core/lib/aws-defaults.rb @@ -1,3 +1,6 @@ # frozen_string_literal: true -require_relative 'aws-defaults/default_configuration' \ No newline at end of file +module Aws + autoload :DefaultsModeConfiguration, 'aws-defaults/default_configuration' + autoload :DefaultsModeConfigResolver, 'aws-defaults/defaults_mode_config_resolver' +end diff --git a/gems/aws-sdk-core/lib/aws-sdk-core.rb b/gems/aws-sdk-core/lib/aws-sdk-core.rb index c1c6a45a278..e03196d5fec 100644 --- a/gems/aws-sdk-core/lib/aws-sdk-core.rb +++ b/gems/aws-sdk-core/lib/aws-sdk-core.rb @@ -5,113 +5,77 @@ require 'jmespath' require_relative 'aws-sdk-core/deprecations' - -# credential providers -require_relative 'aws-sdk-core/credential_provider' -require_relative 'aws-sdk-core/refreshing_credentials' -require_relative 'aws-sdk-core/assume_role_credentials' -require_relative 'aws-sdk-core/assume_role_web_identity_credentials' -require_relative 'aws-sdk-core/credentials' -require_relative 'aws-sdk-core/credential_provider_chain' -require_relative 'aws-sdk-core/ecs_credentials' -require_relative 'aws-sdk-core/instance_profile_credentials' -require_relative 'aws-sdk-core/shared_credentials' -require_relative 'aws-sdk-core/process_credentials' -require_relative 'aws-sdk-core/sso_credentials' - -# tokens and token providers -require_relative 'aws-sdk-core/token' -require_relative 'aws-sdk-core/token_provider' -require_relative 'aws-sdk-core/static_token_provider' -require_relative 'aws-sdk-core/refreshing_token' -require_relative 'aws-sdk-core/sso_token_provider' -require_relative 'aws-sdk-core/token_provider_chain' -require_relative 'aws-sdk-core/plugins/bearer_authorization' - -# client modules -require_relative 'aws-sdk-core/client_stubs' -require_relative 'aws-sdk-core/async_client_stubs' -require_relative 'aws-sdk-core/eager_loader' -require_relative 'aws-sdk-core/errors' -require_relative 'aws-sdk-core/pageable_response' -require_relative 'aws-sdk-core/pager' -require_relative 'aws-sdk-core/param_converter' -require_relative 'aws-sdk-core/param_validator' -require_relative 'aws-sdk-core/shared_config' -require_relative 'aws-sdk-core/structure' -require_relative 'aws-sdk-core/type_builder' -require_relative 'aws-sdk-core/util' - -# resource classes -require_relative 'aws-sdk-core/resources/collection' - -# logging -require_relative 'aws-sdk-core/log/formatter' -require_relative 'aws-sdk-core/log/param_filter' -require_relative 'aws-sdk-core/log/param_formatter' - -# stubbing -require_relative 'aws-sdk-core/stubbing/empty_stub' -require_relative 'aws-sdk-core/stubbing/data_applicator' -require_relative 'aws-sdk-core/stubbing/stub_data' -require_relative 'aws-sdk-core/stubbing/xml_error' - -# stubbing protocols -require_relative 'aws-sdk-core/stubbing/protocols/json' -require_relative 'aws-sdk-core/stubbing/protocols/rest' -require_relative 'aws-sdk-core/stubbing/protocols/rest_json' -require_relative 'aws-sdk-core/stubbing/protocols/rest_xml' -require_relative 'aws-sdk-core/stubbing/protocols/query' -require_relative 'aws-sdk-core/stubbing/protocols/ec2' -require_relative 'aws-sdk-core/stubbing/protocols/rpc_v2' -require_relative 'aws-sdk-core/stubbing/protocols/api_gateway' - -# protocols -require_relative 'aws-sdk-core/error_handler' -require_relative 'aws-sdk-core/rest' -require_relative 'aws-sdk-core/xml' -require_relative 'aws-sdk-core/json' -require_relative 'aws-sdk-core/query' -require_relative 'aws-sdk-core/rpc_v2' - -# event stream -require_relative 'aws-sdk-core/binary' -require_relative 'aws-sdk-core/event_emitter' - -# endpoint discovery -require_relative 'aws-sdk-core/endpoint_cache' - -# client metrics / telemetry -require_relative 'aws-sdk-core/client_side_monitoring/request_metrics' -require_relative 'aws-sdk-core/client_side_monitoring/publisher' -require_relative 'aws-sdk-core/telemetry' - -# utilities -require_relative 'aws-sdk-core/arn' -require_relative 'aws-sdk-core/arn_parser' -require_relative 'aws-sdk-core/ec2_metadata' -require_relative 'aws-sdk-core/lru_cache' - -# dynamic endpoints -require_relative 'aws-sdk-core/endpoints' -require_relative 'aws-sdk-core/plugins/signature_v4' - # defaults require_relative 'aws-defaults' -# plugins -# loaded through building STS or SSO .. - -# aws-sdk-sts is included to support Aws::AssumeRoleCredentials -require_relative 'aws-sdk-sts' - -# aws-sdk-sso is included to support Aws::SSOCredentials -require_relative 'aws-sdk-sso' -require_relative 'aws-sdk-ssooidc' - module Aws - CORE_GEM_VERSION = File.read(File.expand_path('../../VERSION', __FILE__)).strip + autoload :IniParser, 'aws-sdk-core/ini_parser' + + # Credentials and credentials providers + autoload :Credentials, 'aws-sdk-core/credentials' + autoload :CredentialProvider, 'aws-sdk-core/credential_provider' + autoload :RefreshingCredentials, 'aws-sdk-core/refreshing_credentials' + autoload :AssumeRoleCredentials, 'aws-sdk-core/assume_role_credentials' + autoload :AssumeRoleWebIdentityCredentials, 'aws-sdk-core/assume_role_web_identity_credentials' + autoload :CredentialProviderChain, 'aws-sdk-core/credential_provider_chain' + autoload :ECSCredentials, 'aws-sdk-core/ecs_credentials' + autoload :InstanceProfileCredentials, 'aws-sdk-core/instance_profile_credentials' + autoload :SharedCredentials, 'aws-sdk-core/shared_credentials' + autoload :ProcessCredentials, 'aws-sdk-core/process_credentials' + autoload :SSOCredentials, 'aws-sdk-core/sso_credentials' + + + # tokens and token providers + autoload :Token, 'aws-sdk-core/token' + autoload :TokenProvider, 'aws-sdk-core/token_provider' + autoload :StaticTokenProvider, 'aws-sdk-core/static_token_provider' + autoload :RefreshingToken, 'aws-sdk-core/refreshing_token' + autoload :SSOTokenProvider, 'aws-sdk-core/sso_token_provider' + autoload :TokenProviderChain, 'aws-sdk-core/token_provider_chain' + + # client modules + autoload :ClientStubs, 'aws-sdk-core/client_stubs' + autoload :AsyncClientStubs, 'aws-sdk-core/async_client_stubs' + autoload :EagerLoader, 'aws-sdk-core/eager_loader' + autoload :Errors, 'aws-sdk-core/errors' + autoload :PageableResponse, 'aws-sdk-core/pageable_response' + autoload :Pager, 'aws-sdk-core/pager' + autoload :ParamConverter, 'aws-sdk-core/param_converter' + autoload :ParamValidator, 'aws-sdk-core/param_validator' + autoload :SharedConfig, 'aws-sdk-core/shared_config' + autoload :Structure, 'aws-sdk-core/structure' + autoload :EmptyStructure, 'aws-sdk-core/structure' + autoload :TypeBuilder, 'aws-sdk-core/type_builder' + autoload :Util, 'aws-sdk-core/util' + + # protocols + autoload :ErrorHandler, 'aws-sdk-core/error_handler' + autoload :Rest, 'aws-sdk-core/rest' + autoload :Xml, 'aws-sdk-core/xml' + autoload :Json, 'aws-sdk-core/json' + autoload :Query, 'aws-sdk-core/query' + autoload :RpcV2, 'aws-sdk-core/rpc_v2' + + # event stream + autoload :Binary, 'aws-sdk-core/binary' + autoload :EventEmitter, 'aws-sdk-core/event_emitter' + + # endpoint discovery + autoload :EndpointCache, 'aws-sdk-core/endpoint_cache' + + autoload :Telemetry, 'aws-sdk-core/telemetry' + + # utilities + autoload :ARN, 'aws-sdk-core/arn' + autoload :ARNParser, 'aws-sdk-core/arn_parser' + autoload :EC2Metadata, 'aws-sdk-core/ec2_metadata' + autoload :LRUCache, 'aws-sdk-core/lru_cache' + + # dynamic endpoints + autoload :Endpoints, 'aws-sdk-core/endpoints' + + CORE_GEM_VERSION = File.read(File.expand_path('../VERSION', __dir__)).strip @config = {} @@ -195,3 +159,18 @@ def eager_autoload!(*args) end end + +# Setup additional autoloads/modules +require_relative 'aws-sdk-core/client_side_monitoring' +require_relative 'aws-sdk-core/log' +require_relative 'aws-sdk-core/plugins' +require_relative 'aws-sdk-core/resources' +require_relative 'aws-sdk-core/stubbing' +require_relative 'aws-sdk-core/waiters' + +# aws-sdk-sts is included to support Aws::AssumeRoleCredentials +require_relative 'aws-sdk-sts' + +# aws-sdk-sso is included to support Aws::SSOCredentials +require_relative 'aws-sdk-sso' +require_relative 'aws-sdk-ssooidc' diff --git a/gems/aws-sdk-core/lib/aws-sdk-core/client_side_monitoring.rb b/gems/aws-sdk-core/lib/aws-sdk-core/client_side_monitoring.rb new file mode 100644 index 00000000000..3079edb2cd6 --- /dev/null +++ b/gems/aws-sdk-core/lib/aws-sdk-core/client_side_monitoring.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Aws + # setup autoloading for ClientSideMonitoring module + module ClientSideMonitoring + autoload :RequestMetrics, 'aws-sdk-core/client_side_monitoring/request_metrics' + autoload :Publisher, 'aws-sdk-core/client_side_monitoring/publisher' + end +end diff --git a/gems/aws-sdk-core/lib/aws-sdk-core/log.rb b/gems/aws-sdk-core/lib/aws-sdk-core/log.rb new file mode 100644 index 00000000000..25f9adfe0f0 --- /dev/null +++ b/gems/aws-sdk-core/lib/aws-sdk-core/log.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Aws + # setup autoloading for Log module + module Log + autoload :Formatter, 'aws-sdk-core/log/formatter' + autoload :ParamFilter, 'aws-sdk-core/log/param_filter' + autoload :ParamFormatter, 'aws-sdk-core/log/param_formatter' + end +end \ No newline at end of file diff --git a/gems/aws-sdk-core/lib/aws-sdk-core/plugins.rb b/gems/aws-sdk-core/lib/aws-sdk-core/plugins.rb new file mode 100644 index 00000000000..9552af01201 --- /dev/null +++ b/gems/aws-sdk-core/lib/aws-sdk-core/plugins.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Aws + # setup autoloading for Plugins + # Most plugins are required explicitly from service clients + module Plugins + autoload :BearerAuthorization, 'aws-sdk-core/plugins/bearer_authorization' + autoload :SignatureV4, 'aws-sdk-core/plugins/signature_v4' + end +end \ No newline at end of file diff --git a/gems/aws-sdk-core/lib/aws-sdk-core/resources.rb b/gems/aws-sdk-core/lib/aws-sdk-core/resources.rb new file mode 100644 index 00000000000..d70a43b827b --- /dev/null +++ b/gems/aws-sdk-core/lib/aws-sdk-core/resources.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module Aws + # setup autoloading for Resources module + module Resources + autoload :Collection, 'aws-sdk-core/resources/collection' + end +end \ No newline at end of file diff --git a/gems/aws-sdk-core/lib/aws-sdk-core/stubbing.rb b/gems/aws-sdk-core/lib/aws-sdk-core/stubbing.rb new file mode 100644 index 00000000000..29f67cf05dd --- /dev/null +++ b/gems/aws-sdk-core/lib/aws-sdk-core/stubbing.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Aws + # setup autoloading for Stubbing module + module Stubbing + autoload :EmptyStub, 'aws-sdk-core/stubbing/empty_stub' + autoload :DataApplicator, 'aws-sdk-core/stubbing/data_applicator' + autoload :StubData, 'aws-sdk-core/stubbing/stub_data' + autoload :XmlError, 'aws-sdk-core/stubbing/xml_error' + + module Protocols + autoload :Json, 'aws-sdk-core/stubbing/protocols/json' + autoload :Rest, 'aws-sdk-core/stubbing/protocols/rest' + autoload :RestJson, 'aws-sdk-core/stubbing/protocols/rest_json' + autoload :RestXml, 'aws-sdk-core/stubbing/protocols/rest_xml' + autoload :Query, 'aws-sdk-core/stubbing/protocols/query' + autoload :EC2, 'aws-sdk-core/stubbing/protocols/ec2' + autoload :RpcV2, 'aws-sdk-core/stubbing/protocols/rpc_v2' + autoload :ApiGateway, 'aws-sdk-core/stubbing/protocols/api_gateway' + end + end +end \ No newline at end of file diff --git a/gems/aws-sdk-core/lib/aws-sdk-sts/customizations.rb b/gems/aws-sdk-core/lib/aws-sdk-sts/customizations.rb index 9f3daa3f90e..4f13f02deca 100644 --- a/gems/aws-sdk-core/lib/aws-sdk-sts/customizations.rb +++ b/gems/aws-sdk-core/lib/aws-sdk-sts/customizations.rb @@ -1,4 +1,8 @@ # frozen_string_literal: true # utility classes -require 'aws-sdk-sts/presigner' +module Aws + module STS + autoload :Presigner, 'aws-sdk-sts/presigner' + end +end diff --git a/gems/aws-sdk-core/spec/aws/cbor/cbor_engine_spec.rb b/gems/aws-sdk-core/spec/aws/cbor/cbor_engine_spec.rb index cfa75eb4bf3..1a6c8f13138 100644 --- a/gems/aws-sdk-core/spec/aws/cbor/cbor_engine_spec.rb +++ b/gems/aws-sdk-core/spec/aws/cbor/cbor_engine_spec.rb @@ -1,4 +1,5 @@ require_relative '../../spec_helper' +require 'aws-sdk-core/cbor/cbor_engine' module Aws module Cbor @@ -75,4 +76,4 @@ def assert(actual, expected) end end end -end \ No newline at end of file +end diff --git a/gems/aws-sdk-core/spec/aws/cbor/decoder_spec.rb b/gems/aws-sdk-core/spec/aws/cbor/decoder_spec.rb index 1c53353c469..916c005ba9b 100644 --- a/gems/aws-sdk-core/spec/aws/cbor/decoder_spec.rb +++ b/gems/aws-sdk-core/spec/aws/cbor/decoder_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative '../../spec_helper' +require 'aws-sdk-core/cbor/decoder' module Aws module Cbor diff --git a/gems/aws-sdk-core/spec/aws/cbor/encoder_spec.rb b/gems/aws-sdk-core/spec/aws/cbor/encoder_spec.rb index ce94ba9241a..abf58e2a4cc 100644 --- a/gems/aws-sdk-core/spec/aws/cbor/encoder_spec.rb +++ b/gems/aws-sdk-core/spec/aws/cbor/encoder_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative '../../spec_helper' +require 'aws-sdk-core/cbor/encoder' module Aws module Cbor diff --git a/gems/aws-sdk-core/spec/aws/cbor_spec.rb b/gems/aws-sdk-core/spec/aws/cbor_spec.rb index 54998f303e4..6e3a3c445c8 100644 --- a/gems/aws-sdk-core/spec/aws/cbor_spec.rb +++ b/gems/aws-sdk-core/spec/aws/cbor_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative '../spec_helper' +require 'aws-sdk-core/cbor' module Aws describe Cbor do diff --git a/gems/aws-sdk-dynamodbstreams/lib/aws-sdk-dynamodbstreams/customizations.rb b/gems/aws-sdk-dynamodbstreams/lib/aws-sdk-dynamodbstreams/customizations.rb index 6a2dc62b2ee..1b73b8979a0 100644 --- a/gems/aws-sdk-dynamodbstreams/lib/aws-sdk-dynamodbstreams/customizations.rb +++ b/gems/aws-sdk-dynamodbstreams/lib/aws-sdk-dynamodbstreams/customizations.rb @@ -1,5 +1,9 @@ # frozen_string_literal: true # utility classes -require 'aws-sdk-dynamodbstreams/attribute_translator' -require 'aws-sdk-dynamodbstreams/attribute_value' +module Aws + module DynamoDBStreams + autoload :AttributeTranslator, 'aws-sdk-dynamodbstreams/attribute_translator' + autoload :AttributeValue, 'aws-sdk-dynamodbstreams/attribute_value' + end +end diff --git a/gems/aws-sdk-ec2/lib/aws-sdk-ec2/customizations.rb b/gems/aws-sdk-ec2/lib/aws-sdk-ec2/customizations.rb index dd92f4ecf76..8e9b8f90fa4 100644 --- a/gems/aws-sdk-ec2/lib/aws-sdk-ec2/customizations.rb +++ b/gems/aws-sdk-ec2/lib/aws-sdk-ec2/customizations.rb @@ -1,23 +1 @@ # frozen_string_literal: true - -# customizations to generated classes -require 'aws-sdk-ec2/customizations/resource' -require 'aws-sdk-ec2/customizations/instance' - -Aws::EC2::Instance::Collection.extend Aws::Deprecations -{ - create_tags: :batch_create_tags, - monitor: :batch_create_tags, - reboot: :batch_reboot, - start: :batch_start, - stop: :batch_stop, - terminate: :batch_terminate!, - unmonitor: :batch_unmonitor, -}.each do |old, new| - Aws::EC2::Instance::Collection.send(:alias_method, old, new) - Aws::EC2::Instance::Collection.send(:deprecated, old, use: new) -end - -Aws::EC2::Tag::Collection.send(:alias_method, :delete, :batch_delete!) -Aws::EC2::Tag::Collection.extend Aws::Deprecations -Aws::EC2::Tag::Collection.send(:deprecated, :delete, use: :batch_delete!) diff --git a/gems/aws-sdk-ec2/lib/aws-sdk-ec2/customizations/instance.rb b/gems/aws-sdk-ec2/lib/aws-sdk-ec2/customizations/instance.rb index 5dc3ba19dda..f80dc11be5c 100644 --- a/gems/aws-sdk-ec2/lib/aws-sdk-ec2/customizations/instance.rb +++ b/gems/aws-sdk-ec2/lib/aws-sdk-ec2/customizations/instance.rb @@ -15,6 +15,23 @@ def decrypt_windows_password(key_pair_path) private_key.private_decrypt(decoded) end + class Collection < Aws::Resources::Collection + extend Aws::Deprecations + + { + create_tags: :batch_create_tags, + monitor: :batch_create_tags, + reboot: :batch_reboot, + start: :batch_start, + stop: :batch_stop, + terminate: :batch_terminate!, + unmonitor: :batch_unmonitor + }.each do |old_method, new_method| + alias_method old_method, new_method + deprecated old_method, use: new_method + end + end + private def encrypted_password diff --git a/gems/aws-sdk-ec2/lib/aws-sdk-ec2/customizations/tag.rb b/gems/aws-sdk-ec2/lib/aws-sdk-ec2/customizations/tag.rb new file mode 100644 index 00000000000..4979dd373b9 --- /dev/null +++ b/gems/aws-sdk-ec2/lib/aws-sdk-ec2/customizations/tag.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Aws + module EC2 + class Tag + class Collection < Aws::Resources::Collection + alias_method :delete, :batch_delete! + extend Aws::Deprecations + deprecated :delete, use: :batch_delete! + end + end + end +end \ No newline at end of file diff --git a/gems/aws-sdk-iam/lib/aws-sdk-iam/customizations.rb b/gems/aws-sdk-iam/lib/aws-sdk-iam/customizations.rb index 18df3e09568..8e9b8f90fa4 100644 --- a/gems/aws-sdk-iam/lib/aws-sdk-iam/customizations.rb +++ b/gems/aws-sdk-iam/lib/aws-sdk-iam/customizations.rb @@ -1,4 +1 @@ # frozen_string_literal: true - -# customizations to generated classes -require 'aws-sdk-iam/customizations/resource' diff --git a/gems/aws-sdk-polly/lib/aws-sdk-polly/customizations.rb b/gems/aws-sdk-polly/lib/aws-sdk-polly/customizations.rb index 2c0111c719d..81774844718 100644 --- a/gems/aws-sdk-polly/lib/aws-sdk-polly/customizations.rb +++ b/gems/aws-sdk-polly/lib/aws-sdk-polly/customizations.rb @@ -1,4 +1,8 @@ # frozen_string_literal: true # utility classes -require 'aws-sdk-polly/presigner' +module Aws + module Polly + autoload :Presigner, 'aws-sdk-polly/presigner' + end +end diff --git a/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations.rb b/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations.rb index b16dca35841..153b80844b2 100644 --- a/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations.rb +++ b/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations.rb @@ -1,44 +1,30 @@ # frozen_string_literal: true -# utility classes -require 'aws-sdk-s3/bucket_region_cache' -require 'aws-sdk-s3/encryption' -require 'aws-sdk-s3/encryption_v2' -require 'aws-sdk-s3/file_part' -require 'aws-sdk-s3/file_uploader' -require 'aws-sdk-s3/file_downloader' -require 'aws-sdk-s3/legacy_signer' -require 'aws-sdk-s3/multipart_file_uploader' -require 'aws-sdk-s3/multipart_stream_uploader' -require 'aws-sdk-s3/multipart_upload_error' -require 'aws-sdk-s3/object_copier' -require 'aws-sdk-s3/object_multipart_copier' -require 'aws-sdk-s3/presigned_post' -require 'aws-sdk-s3/presigner' +module Aws + module S3 + # utility classes + autoload :BucketRegionCache, 'aws-sdk-s3/bucket_region_cache' + autoload :Encryption, 'aws-sdk-s3/encryption' + autoload :EncryptionV2, 'aws-sdk-s3/encryption_v2' + autoload :FilePart, 'aws-sdk-s3/file_part' + autoload :FileUploader, 'aws-sdk-s3/file_uploader' + autoload :FileDownloader, 'aws-sdk-s3/file_downloader' + autoload :LegacySigner, 'aws-sdk-s3/legacy_signer' + autoload :MultipartFileUploader, 'aws-sdk-s3/multipart_file_uploader' + autoload :MultipartStreamUploader, 'aws-sdk-s3/multipart_stream_uploader' + autoload :MultipartUploadError, 'aws-sdk-s3/multipart_upload_error' + autoload :ObjectCopier, 'aws-sdk-s3/object_copier' + autoload :ObjectMultipartCopier, 'aws-sdk-s3/object_multipart_copier' + autoload :PresignedPost, 'aws-sdk-s3/presigned_post' + autoload :Presigner, 'aws-sdk-s3/presigner' -# s3 express session auth -require 'aws-sdk-s3/express_credentials' -require 'aws-sdk-s3/express_credentials_provider' + # s3 express session auth + autoload :ExpressCredentials, 'aws-sdk-s3/express_credentials' + autoload :ExpressCredentialsProvider, 'aws-sdk-s3/express_credentials_provider' -# s3 access grants auth -require 'aws-sdk-s3/access_grants_credentials' -require 'aws-sdk-s3/access_grants_credentials_provider' + # s3 access grants auth -# customizations to generated classes -require 'aws-sdk-s3/customizations/bucket' -require 'aws-sdk-s3/customizations/errors' -require 'aws-sdk-s3/customizations/object' -require 'aws-sdk-s3/customizations/object_summary' -require 'aws-sdk-s3/customizations/multipart_upload' -require 'aws-sdk-s3/customizations/types/list_object_versions_output' -require 'aws-sdk-s3/customizations/types/permanent_redirect' - -[ - Aws::S3::Object::Collection, - Aws::S3::ObjectSummary::Collection, - Aws::S3::ObjectVersion::Collection, -].each do |klass| - klass.send(:alias_method, :delete, :batch_delete!) - klass.extend Aws::Deprecations - klass.send(:deprecated, :delete, use: :batch_delete!) + autoload :AccessGrantsCredentials, 'aws-sdk-s3/access_grants_credentials' + autoload :AccessGrantsCredentialsProvider, 'aws-sdk-s3/access_grants_credentials_provider' + end end diff --git a/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object.rb b/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object.rb index fe1bb4b0d2d..2abe7e997fc 100644 --- a/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object.rb +++ b/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object.rb @@ -559,6 +559,12 @@ def download_file(destination, options = {}) end true end + + class Collection < Aws::Resources::Collection + alias_method :delete, :batch_delete! + extend Aws::Deprecations + deprecated :delete, use: :batch_delete! + end end end end diff --git a/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb b/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb index 94565f01cee..8c87ddd9c24 100644 --- a/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb +++ b/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb @@ -80,6 +80,11 @@ def download_file(destination, options = {}) object.download_file(destination, options) end + class Collection < Aws::Resources::Collection + alias_method :delete, :batch_delete! + extend Aws::Deprecations + deprecated :delete, use: :batch_delete! + end end end end diff --git a/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_version.rb b/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_version.rb new file mode 100644 index 00000000000..8c426be196d --- /dev/null +++ b/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_version.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Aws + module S3 + class ObjectVersion + class Collection < Aws::Resources::Collection + alias_method :delete, :batch_delete! + extend Aws::Deprecations + deprecated :delete, use: :batch_delete! + end + end + end +end diff --git a/gems/aws-sdk-sns/lib/aws-sdk-sns/customizations.rb b/gems/aws-sdk-sns/lib/aws-sdk-sns/customizations.rb index 6dcda5e2743..33fd5b70e52 100644 --- a/gems/aws-sdk-sns/lib/aws-sdk-sns/customizations.rb +++ b/gems/aws-sdk-sns/lib/aws-sdk-sns/customizations.rb @@ -1,4 +1,8 @@ # frozen_string_literal: true # utility classes -require 'aws-sdk-sns/message_verifier' +module Aws + module SNS + autoload :MessageVerifier, 'aws-sdk-sns/message_verifier' + end +end diff --git a/gems/aws-sdk-sqs/lib/aws-sdk-sqs/customizations.rb b/gems/aws-sdk-sqs/lib/aws-sdk-sqs/customizations.rb index 190176d8cc1..2b4726b9435 100644 --- a/gems/aws-sdk-sqs/lib/aws-sdk-sqs/customizations.rb +++ b/gems/aws-sdk-sqs/lib/aws-sdk-sqs/customizations.rb @@ -1,4 +1,8 @@ # frozen_string_literal: true # utility classes -require 'aws-sdk-sqs/queue_poller' +module Aws + module SQS + autoload :QueuePoller, 'aws-sdk-sqs/queue_poller' + end +end diff --git a/gems/aws-sdk-translate/lib/aws-sdk-translate/customizations.rb b/gems/aws-sdk-translate/lib/aws-sdk-translate/customizations.rb index e69de29bb2d..792c6da81b4 100644 --- a/gems/aws-sdk-translate/lib/aws-sdk-translate/customizations.rb +++ b/gems/aws-sdk-translate/lib/aws-sdk-translate/customizations.rb @@ -0,0 +1,8 @@ + +module Aws + module Translate + module Plugins + autoload :TranslateDocumentEncoding, 'aws-sdk-translate/plugins/translate_document_encoding' + end + end +end