Sha256: 558fe007c75e311022316c3ebd0908e57f7b805e364edf6b6eaaf7b67017cf22

Contents?: true

Size: 1.22 KB

Versions: 12

Compression:

Stored size: 1.22 KB

Contents

require 'fog/core/collection'
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 = connection.list_users(options).body
          merge_attributes('IsTruncated' => data['IsTruncated'], 'Marker' => data['Marker'])
          load(data['Users']) # data is an array of attribute hashes
        end

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

        alias :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

12 entries across 12 versions & 7 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/aws/models/iam/users.rb
fog-nirvanix-1.8.1 lib/fog/aws/models/iam/users.rb
fog-parser-fix-1.6.1 lib/fog/aws/models/iam/users.rb
fog-test-again-1.6.0 lib/fog/aws/models/iam/users.rb
fog-parser-fix-1.6.0 lib/fog/aws/models/iam/users.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/aws/models/iam/users.rb
fog-sgonyea-1.8.1 lib/fog/aws/models/iam/users.rb
fog-1.8.0 lib/fog/aws/models/iam/users.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/aws/models/iam/users.rb
fog-1.7.0 lib/fog/aws/models/iam/users.rb
fog-1.6.0 lib/fog/aws/models/iam/users.rb
fog-1.5.0 lib/fog/aws/models/iam/users.rb