Sha256: 9bc574a497f52f274caf705baa2393c9925b6fcdf89291fa8c23089f5b3b6105

Contents?: true

Size: 1.94 KB

Versions: 36

Compression:

Stored size: 1.94 KB

Contents

module Fog
  module AWS
    class Compute
      class Real
        require 'fog/aws/parsers/compute/monitor_unmonitor_instances'

        # UnMonitor specified instance
        # http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-UnmonitorInstances.html
        #
        # ==== Parameters
        # * instance_ids<~Array> - Arrays of instances Ids to monitor
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'requestId'<~String> - Id of request
        #     * 'instancesSet': http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-MonitorInstancesResponseSetItemType.html
        #
        # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-UnmonitorInstances.html]
        def unmonitor_instances(instance_ids)
          params = Fog::AWS.indexed_param('InstanceId', instance_ids)
          request({
                          'Action' => 'UnmonitorInstances',
                          :idempotent => true,
                          :parser => Fog::Parsers::AWS::Compute::MonitorUnmonitorInstances.new
                  }.merge!(params))
        end
      end

      class Mock
        def unmonitor_instances(instance_ids)
          response        = Excon::Response.new
          response.status = 200
          [*instance_ids].each do |instance_id|
            if instance = self.data[:instances][instance_id]
              instance['monitoring']['state'] = 'enabled'
            else
              raise Fog::AWS::Compute::NotFound.new("The instance ID '#{instance_ids}' does not exist")
            end
          end
          instances_set = [*instance_ids].reduce([]) { |memo, id| memo << {'instanceId' => id, 'monitoring' => 'disabled'} }
          response.body = {'requestId' => 'some_request_id', 'instancesSet' => instances_set}
          response
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
fog-aws-3.29.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.28.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.27.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.26.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.25.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.24.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.23.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.22.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.21.1 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.21.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.20.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.19.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.18.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.17.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.16.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.15.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.14.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.13.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.12.0 lib/fog/aws/requests/compute/unmonitor_instances.rb
fog-aws-3.11.0 lib/fog/aws/requests/compute/unmonitor_instances.rb