Sha256: 70d215af41df9237b2bf3acca1af2a0caf1d8587146c881d290cd006a9fd1d5b

Contents?: true

Size: 1.9 KB

Versions: 14

Compression:

Stored size: 1.9 KB

Contents

# frozen_string_literal: true

module Fog
  module Compute
    class Aliyun
      class Real
        # Allocate an eip IP address.
        #
        # ==== Notes
        # The new eip Ip address would be avalable
        # The allocated eip Ip address can only associate to the instance of the vpc in the same region
        # Now the eip can support ICMP,TCP,UDP
        # ==== Parameters
        # * server_id<~String> - id of the instance
        # * allocationId<~String> - id of the EIP
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'EipAddress'<~String> - the allocated eip address
        #     * 'AllocationId'<~String> - the instance id on the public ip
        #     * 'RequestId'<~String> - Id of the request
        #
        # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.201.106.DGkmH7#/pub/ecs/open-api/network&allocateeipaddress]
        def allocate_eip_address(options = {})
          _action = 'AllocateEipAddress'
          _sigNonce = randonStr
          _time = Time.new.utc

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

          # optional parameters
          _Bandwidth = options[:bandwidth]
          if _Bandwidth
            _parameters['Bandwidth'] = _Bandwidth
            _pathURL += '&Bandwidth=' + _Bandwidth
          end

          _InternetChargeType = options[:internet_charge_type]
          _InternetChargeType ||= 'PayByTraffic'
          _parameters['InternetChargeType'] = _InternetChargeType
          _pathURL += '&InternetChargeType=' + _InternetChargeType

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

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-aliyun-0.4.0 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.19 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.18 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.17 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.16 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.15 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.13 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.12 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.11 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.10 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.9 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.8 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.7 lib/fog/aliyun/requests/compute/allocate_eip_address.rb
fog-aliyun-0.3.6 lib/fog/aliyun/requests/compute/allocate_eip_address.rb