File: instance_profile.rb

package info (click to toggle)
ruby-fog-aws 3.18.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,140 kB
  • sloc: ruby: 73,328; javascript: 14; makefile: 9; sh: 4
file content (40 lines) | stat: -rw-r--r-- 1,140 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module Fog
  module AWS
    class IAM
      class InstanceProfile < Fog::Model
        identity :name, :aliases => 'InstanceProfileName'

        attribute :id,          :aliases => 'InstanceProfileId'
        attribute :roles,       :aliases => 'Roles',              :type => :array
        attribute :arn,         :aliases => 'Arn'
        attribute :path,        :aliases => 'Path'
        attribute :create_date, :aliases => 'CreateDate',         :type => :time

        def add_role(role_name)
          requires :identity
          service.add_role_to_instance_profile(role_name, self.name)
          true
        end

        def remove_role(role_name)
          requires :identity
          service.remove_role_from_instance_profile(role_name, self.name)
          true
        end

        def destroy
          requires :identity
          service.delete_instance_profile(self.identity)
          true
        end

        def save
          requires :identity

          data = service.create_instance_profile(self.name, self.path).body['InstanceProfile']
          merge_attributes(data)
        end
      end
    end
  end
end