Sha256: 72e4e9d0e5a97887ecb290c78eb09697409c2314bfee6305da399bba6ee179d0

Contents?: true

Size: 1.92 KB

Versions: 11

Compression:

Stored size: 1.92 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class Google
      class TargetHttpProxy < Fog::Model
        identity :name

        attribute :kind, :aliases => 'kind'
        attribute :self_link, :aliases => 'selfLink'
        attribute :id, :aliases => 'id'
        attribute :creation_timestamp, :aliases => 'creationTimestamp'
        attribute :description, :aliases => 'description'
        attribute :urlMap, :aliases => ["urlMap", :url_map]

        def save
          requires :name

          options = {
            'description' => description,
            'urlMap'      => urlMap
          }

          data = service.insert_target_http_proxy(name,  options).body
          operation = Fog::Compute::Google::Operations.new(:service => service).get(data['name'], data['zone'])
          operation.wait_for { !pending? }
          reload
        end

        def destroy(async=true)
          requires :name
          operation = service.delete_target_http_proxy(name)
          if not async
            # wait until "DONE" to ensure the operation doesn't fail, raises
            # exception on error
            Fog.wait_for do
              operation.body["status"] == "DONE"
            end
          end
          operation
        end
        
        def set_url_map urlMap
          operation = service.set_target_http_proxy_url_map(self, urlMap)
          reload
        end

        def ready?
          begin
            service.get_target_http_proxy(self.name)
            true
          rescue Fog::Errors::NotFound
            false
          end
        end

        def reload
          requires :name

          return unless data = begin
            collection.get(name)
          rescue Excon::Errors::SocketError
            nil
          end

          new_attributes = data.attributes
          merge_attributes(new_attributes)
          self
        end

        RUNNING_STATE = "READY"
      end
    end
  end
end

Version data entries

11 entries across 9 versions & 3 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-google-0.1.0/lib/fog/google/models/compute/target_http_proxy.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-google-0.1.0/lib/fog/google/models/compute/target_http_proxy.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-google-0.1.0/lib/fog/google/models/compute/target_http_proxy.rb
fog-google-0.1.3 lib/fog/google/models/compute/target_http_proxy.rb
fog-google-0.1.2 lib/fog/google/models/compute/target_http_proxy.rb
fog-google-0.1.1 lib/fog/google/models/compute/target_http_proxy.rb
fog-google-0.1.0 lib/fog/google/models/compute/target_http_proxy.rb
fog-google-0.0.9 lib/fog/google/models/compute/target_http_proxy.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-google-0.0.7/lib/fog/google/models/compute/target_http_proxy.rb
fog-google-0.0.7 lib/fog/google/models/compute/target_http_proxy.rb
fog-google-0.0.6 lib/fog/google/models/compute/target_http_proxy.rb