Sha256: 18200ee5fdb4679b3437a3b14ea11994dea79312e1403f815bad5d49003139af

Contents?: true

Size: 1.7 KB

Versions: 19

Compression:

Stored size: 1.7 KB

Contents

require "multi_json"

require "cfoundry/baseclient"
require "cfoundry/uaaclient"

require "cfoundry/errors"

module CFoundry::V1
  class Base < CFoundry::BaseClient
    include BaseClientMethods

    def system_services
      get("services", "v1", "offerings", :content => :json, :accept => :json)
    end

    def system_runtimes
      get("info", "runtimes", :accept => :json)
    end

    # Users
    def create_user(payload)
      p payload
      # no JSON response
      post("users", :content => :json, :payload => payload)
    end

    def create_token(payload, email)
      post("users", email, "tokens", :content => :json, :accept => :json, :payload => payload)
    end

    # Applications
    def instances(name)
      get("apps", name, "instances", :accept => :json)[:instances]
    end

    def crashes(name)
      get("apps", name, "crashes", :accept => :json)[:crashes]
    end

    def files(name, instance, *path)
      get("apps", name, "instances", instance, "files", *path)
    end
    alias :file :files

    def stats(name)
      get("apps", name, "stats", :accept => :json)
    end

    def resource_match(fingerprints)
      post("resources", :content => :json, :accept => :json, :payload => fingerprints)
    end

    def upload_app(name, zipfile = nil, resources = [])
      payload = {
        :_method => "put",
        :resources => MultiJson.dump(resources),
        :application =>
          UploadIO.new(
            if zipfile.is_a? File
              zipfile
            elsif zipfile.is_a? String
              File.new(zipfile, "rb")
            end,
            "application/zip")
      }

      post("apps", name, "application", :payload => payload)
    rescue EOFError
      retry
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
cloulu-1.0.0 lib/cfoundry/v1/base.rb
cloulu-0.7.0 lib/cfoundry/v1/base.rb
cloulu-0.6.6 lib/cfoundry/v1/base.rb
cloulu-0.6.5 lib/cfoundry/v1/base.rb
cloulu-0.6.1 lib/cfoundry/v1/base.rb
cloulu-0.6.0 lib/cfoundry/v1/base.rb
cloulu-0.5.1 lib/cfoundry/v1/base.rb
cloulu-0.5.0 lib/cfoundry/v1/base.rb
cloulu-0.3.0 lib/cfoundry/v1/base.rb
cloulu-0.2.6 lib/cfoundry/v1/base.rb
cloulu-0.2.5 lib/cfoundry/v1/base.rb
cloulu-0.2.4 lib/cfoundry/v1/base.rb
cloulu-0.2.3 lib/cfoundry/v1/base.rb
cloulu-0.2.1 lib/cfoundry/v1/base.rb
cloulu-0.2.0 lib/cfoundry/v1/base.rb
cloulu-0.1.6 lib/cfoundry/v1/base.rb
cloulu-0.1.5 lib/cfoundry/v1/base.rb
cloulu-0.1.2 lib/cfoundry/v1/base.rb
cloulu-0.1.1 lib/cfoundry/v1/base.rb