Sha256: 9c5f5c4e6a8f8bed63d1de2694c34b4846f51f40e9d21aa9e7b3af617cc02c94

Contents?: true

Size: 1.27 KB

Versions: 73

Compression:

Stored size: 1.27 KB

Contents

require 'fog/aws/models/iam/user'

module Fog
  module AWS
    class IAM
      class Users < Fog::Collection
        attribute :is_truncated,    :aliases => 'IsTruncated'
        attribute :marker,          :aliases => 'Marker'

        model Fog::AWS::IAM::User

        def all(options = {})
          merge_attributes(options)
          data = service.list_users(options).body
          merge_attributes('IsTruncated' => data['IsTruncated'], 'Marker' => data['Marker'])
          load(data['Users']) # data is an array of attribute hashes
        end

        def current
          new(service.get_user.body['User'])
        end

        def get(identity)
          data = service.get_user(identity).body['User']
          new(data) # data is an attribute hash
        rescue Fog::AWS::IAM::NotFound
          nil
        end

        alias_method :each_user_this_page, :each

        def each
          if !block_given?
            self
          else
            subset = dup.all

            subset.each_user_this_page {|f| yield f}
            while subset.is_truncated
              subset = subset.all('Marker' => subset.marker, 'MaxItems' => 1000)
              subset.each_user_this_page {|f| yield f}
            end

            self
          end
        end
      end
    end
  end
end

Version data entries

73 entries across 71 versions & 3 rubygems

Version Path
fog-aws-3.30.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.29.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.28.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.27.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.26.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.25.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.24.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.23.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.22.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.21.1 lib/fog/aws/models/iam/users.rb
fog-aws-3.21.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.20.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.19.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.18.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.17.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.16.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.15.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.14.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.13.0 lib/fog/aws/models/iam/users.rb
fog-aws-3.12.0 lib/fog/aws/models/iam/users.rb