File: policies.rb

package info (click to toggle)
ruby-fog-aws 3.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,816 kB
  • sloc: ruby: 68,587; makefile: 6
file content (37 lines) | stat: -rw-r--r-- 1,097 bytes parent folder | download | duplicates (5)
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
require 'fog/aws/models/auto_scaling/policy'

module Fog
  module AWS
    class AutoScaling
      class Policies < Fog::Collection
        model Fog::AWS::AutoScaling::Policy

        attribute :filters

        # Creates a new scaling policy.
        def initialize(attributes={})
          self.filters = attributes
          super(attributes)
        end

        def all(filters_arg = filters)
          data = []
          next_token = nil
          self.filters = filters_arg
          loop do
            result = service.describe_policies(filters.merge('NextToken' => next_token)).body['DescribePoliciesResult']
            data += result['ScalingPolicies']
            next_token = result['NextToken']
            break if next_token.nil?
          end
          load(data)
        end

        def get(identity, auto_scaling_group = nil)
          data = service.describe_policies('PolicyNames' => identity, 'AutoScalingGroupName' => auto_scaling_group).body['DescribePoliciesResult']['ScalingPolicies'].first
          new(data) unless data.nil?
        end
      end
    end
  end
end