Sha256: 03f69537e0339ddf7c518cd230b48010b88d4acf7ae491174256d9e9ac615123

Contents?: true

Size: 1.8 KB

Versions: 5

Compression:

Stored size: 1.8 KB

Contents

module Fog
  module AWS
    class Compute

      class Real

        require 'fog/compute/parsers/aws/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
        def unmonitor_instances(instance_ids)
          params = 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 = @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].inject([]) { |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

5 entries across 5 versions & 1 rubygems

Version Path
fog-0.8.1 lib/fog/compute/requests/aws/unmonitor_instances.rb
fog-0.8.0 lib/fog/compute/requests/aws/unmonitor_instances.rb
fog-0.7.2 lib/fog/compute/requests/aws/unmonitor_instances.rb
fog-0.7.1 lib/fog/compute/requests/aws/unmonitor_instances.rb
fog-0.7.0 lib/fog/compute/requests/aws/unmonitor_instances.rb