Sha256: aa837eadcf0b94b414106b06c5a49deab82cabc9336fb12f23905d89fe2e1725

Contents?: true

Size: 1.83 KB

Versions: 12

Compression:

Stored size: 1.83 KB

Contents

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 :url_map, :aliases => "urlMap"

        def save
          requires :name

          options = {
            "description" => description,
            "urlMap"      => url_map
          }

          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)
          unless 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?
          service.get_target_http_proxy(name)
          true
        rescue Fog::Errors::NotFound
          false
        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

12 entries across 12 versions & 1 rubygems

Version Path
fog-google-0.5.4 lib/fog/compute/google/models/target_http_proxy.rb
fog-google-0.5.3 lib/fog/compute/google/models/target_http_proxy.rb
fog-google-0.5.2 lib/fog/compute/google/models/target_http_proxy.rb
fog-google-0.5.1 lib/fog/compute/google/models/target_http_proxy.rb
fog-google-0.5.0 lib/fog/compute/google/models/target_http_proxy.rb
fog-google-0.4.2 lib/fog/compute/google/models/target_http_proxy.rb
fog-google-0.4.1 lib/fog/compute/google/models/target_http_proxy.rb
fog-google-0.4.0 lib/fog/compute/google/models/target_http_proxy.rb
fog-google-0.3.2 lib/fog/compute/google/models/target_http_proxy.rb
fog-google-0.3.1 lib/fog/compute/google/models/target_http_proxy.rb
fog-google-0.3.0 lib/fog/compute/google/models/target_http_proxy.rb
fog-google-0.2.0 lib/fog/compute/google/models/target_http_proxy.rb