Sha256: 84a52e8e919184d67c11c0954c6000e3dd3b81cd0dfd260d2d634e222591c5ed

Contents?: true

Size: 1.22 KB

Versions: 22

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 = 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 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

22 entries across 22 versions & 5 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/aws/models/iam/users.rb
fog-aws-0.1.1 lib/fog/aws/models/iam/users.rb
fog-aws-0.1.0 lib/fog/aws/models/iam/users.rb
fog-aws-0.0.8 lib/fog/aws/models/iam/users.rb
fog-aws-0.0.7 lib/fog/aws/models/iam/users.rb
fog-aws-0.0.6 lib/fog/aws/models/iam/users.rb
fog-aws-0.0.5 lib/fog/aws/models/iam/users.rb
fog-1.26.0 lib/fog/aws/models/iam/users.rb
fog-1.25.0 lib/fog/aws/models/iam/users.rb
nsidc-fog-1.24.1 lib/fog/aws/models/iam/users.rb
fog-1.24.0 lib/fog/aws/models/iam/users.rb
ns-fog-1.22.11 lib/fog/aws/models/iam/users.rb
ns-fog-1.22.10 lib/fog/aws/models/iam/users.rb
ns-fog-1.22.9 lib/fog/aws/models/iam/users.rb
ns-fog-1.22.8 lib/fog/aws/models/iam/users.rb
ns-fog-1.22.7 lib/fog/aws/models/iam/users.rb
ns-fog-1.22.6 lib/fog/aws/models/iam/users.rb
fog-1.23.0 lib/fog/aws/models/iam/users.rb
ns-fog-1.22.4 lib/fog/aws/models/iam/users.rb
ns-fog-1.22.3 lib/fog/aws/models/iam/users.rb