Sha256: 9df4ac7394b854deaa3cdbd46ed0a42038d7ce227eb6a1683ffa9615fe6ffc55

Contents?: true

Size: 1.85 KB

Versions: 118

Compression:

Stored size: 1.85 KB

Contents

module Awspec::Helper
  module Finder
    module AccountAttributes
      def find_ec2_account_attributes
        attributes = {}
        ec2_client.describe_account_attributes.account_attributes.each do |attr|
          values = attr[:attribute_values].map do |v|
            v[:attribute_value]
          end
          if attr[:attribute_name] == 'supported-platforms'
            # supported-platforms
            attributes[attr[:attribute_name].tr('-', '_').to_sym] = values
          else
            value = values.first
            if value =~ /\A\d+\z/
              attributes[attr[:attribute_name].tr('-', '_').to_sym] = value.to_i
            else
              attributes[attr[:attribute_name].tr('-', '_').to_sym] = value
            end
          end
        end
        attributes.to_struct
      end

      def find_rds_account_attributes
        attributes = {}
        rds_client.describe_account_attributes.account_quotas.each do |attr|
          values = {
            used: attr[:used],
            max: attr[:max]
          }
          attributes[attr[:account_quota_name].to_sym] = values.to_struct
        end
        attributes.to_struct
      end

      def find_lambda_account_settings
        attributes = {}
        settings = lambda_client.get_account_settings
        settings.account_limit.members.each do |key|
          attributes[key] = { limit: settings.account_limit[key] }
        end
        settings.account_usage.members.each do |key|
          if attributes.include?(key)
            attributes[key][:usage] = settings.account_usage[key]
          else
            attributes[key] = { usage: settings.account_usage[key] }
          end
        end
        attributes.to_struct
      end

      def find_ses_send_quota
        ses_client.get_send_quota
      rescue
        # Aws::Errors::NoSuchEndpointError
        nil
      end
    end
  end
end

Version data entries

118 entries across 118 versions & 4 rubygems

Version Path
awspec-0.79.1 lib/awspec/helper/finder/account_attributes.rb
awspec-0.79.0 lib/awspec/helper/finder/account_attributes.rb
awspec-0.78.1 lib/awspec/helper/finder/account_attributes.rb
awspec-0.77.1 lib/awspec/helper/finder/account_attributes.rb
awspec-0.77.0 lib/awspec/helper/finder/account_attributes.rb
awspec-0.76.1 lib/awspec/helper/finder/account_attributes.rb
awspec-0.76.0 lib/awspec/helper/finder/account_attributes.rb
awspec-0.75.2 lib/awspec/helper/finder/account_attributes.rb
awspec-0.75.1 lib/awspec/helper/finder/account_attributes.rb
awspec-0.75.0 lib/awspec/helper/finder/account_attributes.rb
awspec-0.74.1 lib/awspec/helper/finder/account_attributes.rb
awspec-0.74.0 lib/awspec/helper/finder/account_attributes.rb
awspec-0.73.2 lib/awspec/helper/finder/account_attributes.rb
awspec-0.73.1 lib/awspec/helper/finder/account_attributes.rb
awspec-0.73.0 lib/awspec/helper/finder/account_attributes.rb
awspec-0.72.0 lib/awspec/helper/finder/account_attributes.rb
awspec-0.71.0 lib/awspec/helper/finder/account_attributes.rb
awspec-0.70.0 lib/awspec/helper/finder/account_attributes.rb