Sha256: 436bc9c7619854d0f4a74d3186388c5385bb732f6ee901fb2d956f0b05dafea8

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# 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/instance&joinsecuritygroup]
        def join_security_group(server_id, group_id)
          _action = 'JoinSecurityGroup'
          _sigNonce = randonStr
          _time = Time.new.utc

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

          _parameters['InstanceId'] = server_id
          _pathURL += '&InstanceId=' + server_id

          _parameters['SecurityGroupId'] = group_id
          _pathURL += '&SecurityGroupId=' + group_id

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

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

      class Mock
        def join_security_group(_server_id, _group_id)
          response = Excon::Response.new
          response.status = 200
          response
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-aliyun-0.3.1 lib/fog/aliyun/requests/compute/join_security_group.rb