Sha256: 39f8f41dc34fb729d897f0c4a3e3c1665df1a6f25a2709e22295c7a2947b398f

Contents?: true

Size: 1.7 KB

Versions: 49

Compression:

Stored size: 1.7 KB

Contents

module Fog
  module AWS
    class IAM
      class ManagedPolicy < Fog::Model
        identity  :id, :aliases => 'PolicyId'

        attribute :arn,             :aliases => 'Arn'
        attribute :attachable,      :aliases => 'IsAttachable', :type => :boolean
        attribute :attachments,     :aliases => 'AttachmentCount', :type => :integer
        attribute :created_at,      :aliases => 'CreateDate', :type => :time
        attribute :default_version, :aliases => 'DefaultVersionId'
        attribute :description,     :aliases => 'Description'
        attribute :name,            :aliases => 'PolicyName'
        attribute :path,            :aliases => 'Path'
        attribute :updated_at,      :aliases => 'UpdateDate', :type => :time

        attr_accessor :policy_document

        def attach(user_or_username)
          requires :arn

          username = if user_or_username.respond_to?(:identity)
                       user_or_username.identity
                     else
                       user_or_username
                     end

          service.attach_user_policy(username, self.arn)
        end

        def document
          requires :arn, :default_version

          service.get_policy_version(self.arn, self.default_version).
            body['PolicyVersion']['Document']
        end

        def reload
          service.managed_policies.get(self.arn)
        end

        def save
          requires :name, :policy_document

          merge_attributes(service.create_policy(self.name, self.policy_document, self.path, self.description).body["Policy"])
        end

        def destroy
          requires :arn

          service.delete_policy(self.arn)

          true
        end
      end
    end
  end
end

Version data entries

49 entries across 47 versions & 2 rubygems

Version Path
fog-aws-3.11.0 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.10.0 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.9.0 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.8.0 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.7.0 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.6.7 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.6.6 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.6.5 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.6.4 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.6.3 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.6.2 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.5.2 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.5.1 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.5.0 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.4.0 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.3.0 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.2.0 lib/fog/aws/models/iam/managed_policy.rb
fog-aws-3.1.0 lib/fog/aws/models/iam/managed_policy.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aws-2.0.1/lib/fog/aws/models/iam/managed_policy.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aws-2.0.1/lib/fog/aws/models/iam/managed_policy.rb