Sha256: 979bab97b9945dc74d567528c6e54fcc6c61c534eed06026346e7d9400b1e878
Contents?: true
Size: 1.93 KB
Versions: 12
Compression:
Stored size: 1.93 KB
Contents
# frozen_string_literal: true module Aws # Create and provide access to components of Amazon Resource Names (ARN). # # You can create an ARN and access it's components like the following: # # arn = Aws::ARN.new( # partition: 'aws', # service: 's3', # region: 'us-west-2', # account_id: '12345678910', # resource: 'foo/bar' # ) # # => #<Aws::ARN ...> # # arn.to_s # # => "arn:aws:s3:us-west-2:12345678910:foo/bar" # # arn.partition # # => 'aws' # arn.service # # => 's3' # arn.resource # # => foo/bar # # # Note: parser available for parsing resource details # @see Aws::ARNParser#parse_resource # # @see https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#genref-arns class ARN # @param [Hash] options # @option options [String] :partition # @option options [String] :service # @option options [String] :region # @option options [String] :account_id # @option options [String] :resource def initialize(options = {}) @partition = options[:partition] @service = options[:service] @region = options[:region] @account_id = options[:account_id] @resource = options[:resource] end # @return [String] attr_reader :partition # @return [String] attr_reader :service # @return [String] attr_reader :region # @return [String] attr_reader :account_id # @return [String] attr_reader :resource # Validates ARN contains non-empty required components. # Region and account_id can be optional. # # @return [Boolean] def valid? !partition.nil? && !partition.empty? && !service.nil? && !service.empty? && !resource.nil? && !resource.empty? end # Return the ARN format in string # # @return [String] def to_s "arn:#{partition}:#{service}:#{region}:#{account_id}:#{resource}" end end end
Version data entries
12 entries across 12 versions & 1 rubygems