@api private
@api private services
@return [Hash] Returns a hash of default configuration options shared
by all constructed clients.
Registers a new service.
Aws.add_service('SvcName', api: '/path/to/svc.api.json', paginators: '/path/to/svc.paginators.json', waiters: '/path/to/svc.waiters.json', resources: '/path/to/svc.resources.json') Aws::SvcName::Client.new #=> #<Aws::SvcName::Client>
@param [String] svc_name The name of the service. This will also be
the namespace under {Aws}. This must be a valid constant name.
@option options :api @option options :paginators @option options :waiters @option options :resources @return [Module<Service>] Returns the new service module.
# File lib/aws-sdk-core.rb, line 429 def add_service(svc_name, options = {}) svc_module = Module.new { extend Service } const_set(svc_name, svc_module) @services[svc_name] = [svc_module, options] @service_added_callbacks.each do |callback| callback.call(svc_name.to_s, *@services[svc_name]) end svc_module end
@param [Hash] config
# File lib/aws-sdk-core.rb, line 280 def config=(config) if Hash === config @config = config else raise ArgumentError, 'configuration object must be a hash' end end
Loads modules that are normally loaded with Ruby's `autoload`. This can avoid thread-safety issues that some Ruby versions have with `autoload`.
# loads ALL services Aws.eager_autoload!
Loading all services can be slow. You can specify what services you want to load with the `:services` option. All services not named will continue to autoload as normal.
Aws.eager_autoload!(services: %w(S3 EC2))
@return [void]
# File lib/aws-sdk-core.rb, line 376 def eager_autoload!(options = {}) eager_loader = EagerLoader.new eager_loader.load(JMESPath) eager_loader.load(Seahorse) sub_modules(options).each do |module_or_class| eager_loader.load(module_or_class) end eager_loader end
Return the partition with the given name. A partition describes the services and regions available in that partition.
aws = Aws.partition('aws') puts "Regions available in the aws partition:\n" aws.regions.each do |region| puts region.name end puts "Services available in the aws partition:\n" aws.services.each do |services| puts services.name end
See {Partitions} for more information and examples.
@param [String] partition_name The name of the partition to return.
Valid names include "aws", "aws-cn", and "aws-us-gov".
@return [Partitions::Partition]
@raise [ArgumentError] Raises an `ArgumentError` if a partition is
not found with the given name. The error message contains a list of valid partition names.
# File lib/aws-sdk-core.rb, line 313 def partition(partition_name) Partitions.default_list.partition(partition_name) end
Return an array of partitions. A partition describes the services and regions available in that partition.
Aws.partitions.each do |partition| puts "Regions available in #{partition.name}:\n" partition.regions.each do |region| puts region.name end puts "Services available in #{partition.name}:\n" partition.services.each do |service| puts service.name end end
See {Partitions} for more information and examples.
@return [Array<Partitions::Partition>] Returns an array of all
known partitions.
# File lib/aws-sdk-core.rb, line 337 def partitions Partitions.default_list.partitions end
Yields to the given block for each service that has already been defined via {add_service}. Also yields to the given block for each new service added after the callback is registered. @api private
# File lib/aws-sdk-core.rb, line 403 def service_added(&block) callback = Proc.new @services.each do |svc_name, (svc_module, options)| yield(svc_name, svc_module, options) end @service_added_callbacks << callback end
# File lib/aws-sdk-core.rb, line 386 def sub_modules(options = {}) constants = Aws.constants.map(&:to_s) if options[:services] constants -= SERVICE_MODULE_NAMES constants += options[:services] || SERVICE_MODULE_NAMES end constants.inject([]) do |modules, const_name| constant = Aws.const_get(const_name) modules << constant if Module === constant modules end end
The SDK ships with a ca certificate bundle to use when verifying SSL peer certificates. By default, this cert bundle is NOT used. The SDK will rely on the default cert available to OpenSSL. This ensures the cert provided by your OS is used.
For cases where the default cert is unavailable, e.g. Windows, you can call this method.
Aws.use_bundled_cert!
@return [String] Returns the path to the bundled cert.
# File lib/aws-sdk-core.rb, line 352 def use_bundled_cert! config.delete(:ssl_ca_directory) config.delete(:ssl_ca_store) config[:ssl_ca_bundle] = File.expand_path(File.join( File.dirname(__FILE__), '..', 'ca-bundle.crt' )) end