File: list_eip_addresses.rb

package info (click to toggle)
ruby-fog-aliyun 0.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 720 kB
  • sloc: ruby: 5,804; makefile: 6; sh: 3
file content (57 lines) | stat: -rw-r--r-- 1,698 bytes parent folder | download
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
# frozen_string_literal: true

module Fog
  module Compute
    class Aliyun
      class Real
        # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/network&describeeipaddress]
        def list_eip_addresses(options = {})
          _action = 'DescribeEipAddresses'
          _sigNonce = randonStr
          _time = Time.new.utc

          _parameters = defaultParameters(_action, _sigNonce, _time)
          _pathURL = defaultAliyunUri(_action, _sigNonce, _time)

          _Status = options[:state]
          if _Status
            _parameters['Status'] = _Status
            _pathURL += '&Status=' + _Status
          end

          _EipAddress = options[:ip_address]
          if _EipAddress
            _parameters['EipAddress'] = _EipAddress
            _pathURL += '&EipAddress=' + _EipAddress
          end

          _AllocationId = options[:allocation_id]
          if _AllocationId
            _parameters['AllocationId'] = _AllocationId
            _pathURL += '&AllocationId=' + _AllocationId
          end

          _PageNumber = options[:page_number]
          if _PageNumber
            _parameters['PageNumber'] = _PageNumber
            _pathURL += '&PageNumber=' + _PageNumber
          end

          _PageSize = options[:page_size]
          _PageSize ||= '50'
          _parameters['PageSize'] = _PageSize
          _pathURL += '&PageSize=' + _PageSize

          _signature = sign(@aliyun_accesskey_secret, _parameters)
          _pathURL += '&Signature=' + _signature

          request(
            expects: [200, 204],
            method: 'GET',
            path: _pathURL
          )
        end
      end
    end
  end
end