Sha256: 81bb6f59922b4427921195ef252fc3b5dc2b95cfbbca46b99a7303e5979451f7

Contents?: true

Size: 812 Bytes

Versions: 2

Compression:

Stored size: 812 Bytes

Contents

require 'aws-sdk'

Aws.use_bundled_cert!

module AwsLogCleaner
  # Class responsible for interacting with the AWS ApiGatewayClient
  class ApiGateway
    def initialize(credentials)
      @api_client = Aws::APIGateway::Client.new(
        region: credentials.region,
        credentials: credentials.credentials
      )
    end

    def list_all_apis
      @rest_apis = get_rest_apis if @rest_apis.nil?
      @rest_apis
    end

    private

    def get_rest_apis
      Enumerator.new do |enum|
        request = { limit: 25 }
        loop do
          response = @api_client.get_rest_apis(request)
          response.items.each do |item|
            enum.yield item
          end
          break if response.position.nil?
          request[:position] = response.position
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aws_log_cleaner-0.2.0 lib/aws_log_cleaner/api_gateway.rb
aws_log_cleaner-0.1.8 lib/aws_log_cleaner/api_gateway.rb