File: get_distribution_list.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 (81 lines) | stat: -rw-r--r-- 3,384 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
module Fog
  module AWS
    class CDN
      class Real
        require 'fog/aws/parsers/cdn/get_distribution_list'

        # List information about distributions in CloudFront.
        #
        # @param options [Hash] Config arguments for list.
         # @option options Marker [String] Limits object keys to only those that appear lexicographically after its value.
        # @option options MaxItems [Integer] Limits number of object keys returned.
        #
        # @return [Excon::Response]
        #   * body [Hash]:
        #     * IsTruncated [Boolean] - Whether or not the listing is truncated.
        #     * Marker [String] Marker specified for query.
        #     * MaxItems [Integer] - Maximum number of keys specified for query.
        #     * NextMarker [String] - Marker to specify for next page (id of last result of current page).
        #     * DistributionSummary [Array]:
        #       * S3Origin [Hash]:
        #         * DNSName [String] - Origin to associate with distribution, ie 'mybucket.s3.amazonaws.com'.
        #         * OriginAccessIdentity [String] - Optional: Used when serving private content.
        #       or
        #       * CustomOrigin [Hash]:
        #         * DNSName [String] - Origin to associate with distribution, ie 'www.example.com'.
        #         * HTTPPort [Integer] - HTTP port of origin, in [80, 443] or (1024...65535).
        #         * HTTPSPort [Integer] - HTTPS port of origin, in [80, 443] or (1024...65535).
        #       * OriginProtocolPolicy [String] - Policy on using http vs https, in ['http-only', 'match-viewer'].
        #       * Comment [String] - Comment associated with distribution.
        #       * CNAME [Array] - Array of associated cnames.
        #       * Enabled [Boolean] - Whether or not distribution is enabled.
        #       * Id [String] - Id of distribution.
        #       * LastModifiedTime [String] - Timestamp of last modification of distribution.
        #       * Origin [String] - S3 origin bucket.
        #       * Status [String] - Status of distribution.
        #       * TrustedSigners [Array] - Trusted signers.
        #
        # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListDistributions.html
        #
        def get_distribution_list(options = {})
          request({
            :expects    => 200,
            :idempotent => true,
            :method   => 'GET',
            :parser   => Fog::Parsers::AWS::CDN::GetDistributionList.new,
            :path       => "/distribution",
            :query      => options
          })
        end
      end

      class Mock
        def get_distribution_list(options = {})
          response = Excon::Response.new
          response.status = 200

          distributions = self.data[:distributions].values

          response.body = {
            'Marker' => Fog::Mock.random_hex(16),
            'IsTruncated' => false,
            'MaxItems' => 100,
            'DistributionSummary' => distributions.map { |d| to_distribution_summary(d) }
          }

          response
        end

        private

        def to_distribution_summary(d)
          {
            'DomainName' => d['DomainName'],
            'Id' => d['Id'],
            'LastModifiedTime' => d['LastModifiedTime']
          }.merge(d['DistributionConfig'])
        end
      end
    end
  end
end