Sha256: 4ab6ab8f0d8e12684a3d149e0ac0d8f29f7991c8c744d56f1c68e64a28334c8d

Contents?: true

Size: 1.31 KB

Versions: 43

Compression:

Stored size: 1.31 KB

Contents

require 'awspec/error'

module Awspec::Type
  class IamPolicy < ResourceBase
    def resource_via_client
      @resource_via_client ||= find_iam_policy(@display_name)
    end

    def id
      @id ||= resource_via_client.policy_id if resource_via_client
    end

    def attachable?
      check_existence
      resource_via_client.is_attachable
    end

    def attached_to_user?(user_id = nil)
      check_existence
      users = select_attached_users(id)
      if user_id
        user = find_iam_user(user_id)
        return false unless user
        users.any? do |u|
          u.user_name == user.user_name
        end
      else
        !users.empty?
      end
    end

    def attached_to_group?(group_id = nil)
      check_existence
      groups = select_attached_groups(@id)
      if group_id
        group = find_iam_group(group_id)
        return false unless group
        groups.any? do |g|
          g.group_name == group.group_name
        end
      else
        !groups.empty?
      end
    end

    def attached_to_role?(role_id = nil)
      check_existence
      roles = select_attached_roles(@id)
      if role_id
        role = find_iam_role(role_id)
        return false unless role
        roles.any? do |r|
          r.role_name == role.role_name
        end
      else
        !roles.empty?
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 3 rubygems

Version Path
awspec-1.25.1 lib/awspec/type/iam_policy.rb
awspec-1.25.0 lib/awspec/type/iam_policy.rb
awspec-1.24.4 lib/awspec/type/iam_policy.rb
awspec-1.24.3 lib/awspec/type/iam_policy.rb
awspec-1.24.2 lib/awspec/type/iam_policy.rb
awspec-1.24.1 lib/awspec/type/iam_policy.rb
awspec-1.24.0 lib/awspec/type/iam_policy.rb
awspec-1.23.0 lib/awspec/type/iam_policy.rb
awspec-1.22.1 lib/awspec/type/iam_policy.rb
awspec-1.22.0 lib/awspec/type/iam_policy.rb
awspec-1.21.1 lib/awspec/type/iam_policy.rb
awspec-1.21.0 lib/awspec/type/iam_policy.rb
awspec-1.20.0 lib/awspec/type/iam_policy.rb
awspec-1.19.2 lib/awspec/type/iam_policy.rb
awspec-1.19.1 lib/awspec/type/iam_policy.rb
awspec-1.19.0 lib/awspec/type/iam_policy.rb
cthiesfork-awspec-1.2.4 lib/awspec/type/iam_policy.rb
awspec-api_gateway_extended-1.2.4 lib/awspec/type/iam_policy.rb
awspec-api_gateway_extended-1.2.3 lib/awspec/type/iam_policy.rb
awspec-1.18.6 lib/awspec/type/iam_policy.rb