Sha256: d888d5ef2f5004d567213db8f6b34919944ae244a5a0a07d7efc3ccf07417853

Contents?: true

Size: 1.4 KB

Versions: 14

Compression:

Stored size: 1.4 KB

Contents

module Fog
  module Compute
    class Google
      class Mock
        def insert_firewall(_firewall_name, _allowed, _network = GOOGLE_COMPUTE_DEFAULT_NETWORK, _options = {})
          Fog::Mock.not_implemented
        end
      end

      class Real
        def insert_firewall(firewall_name, allowed, network = GOOGLE_COMPUTE_DEFAULT_NETWORK, options = {})
          unless network.start_with? "http"
            network = "#{@api_url}#{@project}/global/networks/#{network}"
          end

          api_method = @compute.firewalls.insert
          parameters = {
            "project" => @project
          }
          body_object = {
            "name" => firewall_name,
            "network" => network,
            "allowed" => allowed
          }
          unless options[:description].nil?
            body_object["description"] = options[:description]
          end
          unless options[:source_ranges].nil? || options[:source_ranges].empty?
            body_object["sourceRanges"] = options[:source_ranges]
          end
          unless options[:source_tags].nil? || options[:source_tags].empty?
            body_object["sourceTags"] = options[:source_tags]
          end
          unless options[:target_tags].nil? || options[:target_tags].empty?
            body_object["targetTags"] = options[:target_tags]
          end

          request(api_method, parameters, body_object)
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-google-0.6.0 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.5.5 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.5.4 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.5.3 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.5.2 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.5.1 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.5.0 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.4.2 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.4.1 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.4.0 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.3.2 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.3.1 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.3.0 lib/fog/compute/google/requests/insert_firewall.rb
fog-google-0.2.0 lib/fog/compute/google/requests/insert_firewall.rb