Class: CloudFoundry::Client

Inherits:
Object
  • Object
show all
Includes:
Apps, Info, Request, Resources, Services, Users
Defined in:
lib/cloudfoundry/client.rb,
lib/cloudfoundry/version.rb,
lib/cloudfoundry/constants.rb,
lib/cloudfoundry/exception.rb,
lib/cloudfoundry/client/apps.rb,
lib/cloudfoundry/client/info.rb,
lib/cloudfoundry/client/users.rb,
lib/cloudfoundry/client/request.rb,
lib/cloudfoundry/client/response.rb,
lib/cloudfoundry/client/services.rb,
lib/cloudfoundry/client/resources.rb

Overview

This is a Ruby wrapper for the CloudFoundry API, the industry’s first open Platform as a Service (PaaS) offering.

Defined Under Namespace

Modules: Apps, Exception, Info, Request, Resources, Response, Services, Users

Constant Summary collapse

VERSION =

CloudFoundry::Client Version.

[major, minor, patch, pre].compact.join(".")
DEFAULT_ADAPTER =

The HTTP connection adapter that will be used to connect if none is set.

:net_http
DEFAULT_TARGET =

Default CloudFoundry API Target URL.

"http://api.vcap.me"
CLOUD_INFO_PATH =

CloudFoundry API Info Path.

"/info"
CLOUD_SERVICES_INFO_PATH =

CloudFoundry API System Services Info Path.

"/info/services"
CLOUD_RUNTIMES_INFO_PATH =

CloudFoundry API Runtimes Info Path.

"/info/runtimes"
APPS_PATH =

CloudFoundry API Applications Path.

"/apps"
RESOURCES_PATH =

CloudFoundry API Resources Path.

"/resources"
SERVICES_PATH =

CloudFoundry API Services Path.

"/services"
USERS_PATH =

CloudFoundry API Users Path.

"/users"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Users

#create_user, #delete_user, #list_users, #logged_in?, #login, #set_proxy_user, #unset_proxy_user, #update_user, #user_info

Methods included from Services

#bind_service, #create_service, #delete_service, #list_services, #service_info, #unbind_service

Methods included from Resources

#check_resources

Methods included from Request

#delete, #get, #post, #put

Methods included from Info

#cloud_info, #cloud_runtimes_info, #cloud_services_info

Methods included from Apps

#app_crashes, #app_files, #app_info, #app_instances, #app_stats, #create_app, #delete_app, #download_app, #list_apps, #update_app, #update_app_info, #upload_app

Constructor Details

#initialize(options = {}) ⇒ CloudFoundry::Client

Creates a new CloudFoundry::Client object.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :adapter (Faraday::Adapter)

    The HTTP connection adapter that will be used to connect.

  • :proxy_url (String)

    The Proxy URL that will be used to connect.

  • :target_url (String)

    The CloudFoundry API Target URL.

  • :trace_key (String)

    The CloudFoundry API Trace Key.

  • :auth_token (String)

    The CloudFoundry API Authorization Token.

Raises:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/cloudfoundry/client.rb', line 45

def initialize(options = {})
  @net_adapter = options[:adapter] || DEFAULT_ADAPTER
  @proxy_url = options[:proxy_url] || nil
  @target_url = options[:target_url] || DEFAULT_TARGET
  @target_url = sanitize_url(@target_url)
  @trace_key = options[:trace_key] || nil
  @auth_token = options[:auth_token] || nil
  @user = nil
  @proxy_user = nil

  raise CloudFoundry::Client::Exception::BadParams, "Invalid CloudFoundry API URL: " + @target_url unless valid_target_url?
  if @auth_token
    raise CloudFoundry::Client::Exception::AuthError, "Invalid CloudFoundry API authorization token" unless logged_in?
  end
end

Instance Attribute Details

#auth_tokenObject (readonly)

Returns the CloudFoundry API Authorization Token.



28
29
30
# File 'lib/cloudfoundry/client.rb', line 28

def auth_token
  @auth_token
end

#net_adapterObject (readonly)

Returns the HTTP connection adapter that will be used to connect.



20
21
22
# File 'lib/cloudfoundry/client.rb', line 20

def net_adapter
  @net_adapter
end

#proxy_urlObject (readonly)

Returns the Proxy URL that will be used to connect.



22
23
24
# File 'lib/cloudfoundry/client.rb', line 22

def proxy_url
  @proxy_url
end

#proxy_userObject (readonly)

Returns the CloudFoundry Proxied User.



32
33
34
# File 'lib/cloudfoundry/client.rb', line 32

def proxy_user
  @proxy_user
end

#target_urlObject (readonly)

Returns the CloudFoundry API Target URL.



24
25
26
# File 'lib/cloudfoundry/client.rb', line 24

def target_url
  @target_url
end

#trace_keyObject (readonly)

Returns the CloudFoundry API Trace Key.



26
27
28
# File 'lib/cloudfoundry/client.rb', line 26

def trace_key
  @trace_key
end

#userObject (readonly)

Returns the CloudFoundry Logged User.



30
31
32
# File 'lib/cloudfoundry/client.rb', line 30

def user
  @user
end

Class Method Details

.majorObject

Major CloudFoundry::Client Version.



5
6
7
# File 'lib/cloudfoundry/version.rb', line 5

def self.major
  0
end

.minorObject

Minor CloudFoundry::Client Version.



10
11
12
# File 'lib/cloudfoundry/version.rb', line 10

def self.minor
  3
end

.patchObject

Patch CloudFoundry::Client Version.



15
16
17
# File 'lib/cloudfoundry/version.rb', line 15

def self.patch
  0
end

.preObject

Pre CloudFoundry::Client Version.



20
21
22
# File 'lib/cloudfoundry/version.rb', line 20

def self.pre
  nil
end