File: remove_instance_group_instances.rb

package info (click to toggle)
ruby-fog-google 1.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,568 kB
  • sloc: ruby: 16,711; sh: 40; makefile: 3
file content (37 lines) | stat: -rw-r--r-- 1,095 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
module Fog
  module Compute
    class Google
      class Mock
        def add_instance_group_instances(_group, _zone, _instances)
          # :no-coverage:
          Fog::Mock.not_implemented
          # :no-coverage:
        end
      end

      class Real
        def remove_instance_group_instances(group_name, zone, instances)
          instances.map! do |instance|
            if instance.start_with?("https:")
              ::Google::Apis::ComputeV1::InstanceReference.new(:instance => instance)
            else
              ::Google::Apis::ComputeV1::InstanceReference.new(
                :instance => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone}/instances/#{instance}\n"
              )
            end
          end

          request = ::Google::Apis::ComputeV1::InstanceGroupsRemoveInstancesRequest.new(
            :instances => instances
          )
          @compute.remove_instance_group_instances(
            @project,
            zone,
            group_name,
            request
          )
        end
      end
    end
  end
end