Sha256: 247719c854db62549dd0516f3f48b8226d841aa82a572ec636508ee99b9c21cd

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

module Fog
  module Compute
    class ProfitBricks
      class Real
        # Get all locations
        #
        # ==== Parameters
        # * location_id<~String>  - UUID of the location
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * id<~String>                   - The resource's unique identifier consisting of country/city
        #     * type<~String>                 - The type of the requested resource
        #     * href<~String>                 - URL to the object’s representation (absolute path)
        #     * properties<~Hash>             - A hash containing the location properties
        #       * name<~String>               - A descriptive name for the location
        #       * features<~Array>            - Features available at this location
        #
        # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-location]
        def get_location(location_id)
          request(
              :expects => [200],
              :method  => 'GET',
              :path    => "/locations/#{location_id}?depth=5"
          )
        rescue => error
          Fog::Errors::NotFound.new(error)
        end
      end

      class Mock
        def get_location(location_id)
          if loc = self.data[:locations]["items"].find {
              |location| location["id"] == location_id
          }
          else
            raise Fog::Errors::NotFound.new("The requested resource could not be found")
          end

          response        = Excon::Response.new
          response.status = 200
          response.body   = loc
          response
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-profitbricks-2.0.1 lib/fog/profitbricks/requests/compute/get_location.rb