Module: JCF::CF

Included in:
JCF::CLI::Commands::CF::Organizations, JCF::CLI::Commands::CF::ServiceBrokers
Defined in:
lib/jcf/cf.rb,
lib/jcf/cf/base.rb,
lib/jcf/cf/user.rb,
lib/jcf/cf/quota.rb,
lib/jcf/cf/space.rb,
lib/jcf/cf/services.rb,
lib/jcf/cf/organization.rb,
lib/jcf/cf/service_plan.rb,
lib/jcf/cf/relationships.rb,
lib/jcf/cf/service_broker.rb,
lib/jcf/cf/service_instance.rb,
lib/jcf/cf/service_offering.rb

Defined Under Namespace

Classes: Base, Organization, Quota, Relationships, ServiceBroker, ServiceInstance, ServiceOffering, ServicePlan, Services, Space, User

Class Method Summary collapse

Class Method Details

.curl(endpoint, params: {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/jcf/cf.rb', line 5

def self.curl(endpoint, params: {})
  params[:per_page] ||= 5000 if params
  url = sanitize_url(endpoint, params)

  response = do_curl(url)

  raise(JCF::CLI::NotLoggedInError, response) if response == "\n" || response.include?("FAILED")

  JSON.parse(response).deep_symbolize_keys
end

.do_curl(url) ⇒ Object



22
23
24
25
26
27
# File 'lib/jcf/cf.rb', line 22

def self.do_curl(url)
  JCF.cache.get_or_set("cf curl \"/v3/#{url}\"".parameterize) do
    puts "cf curl \"/v3/#{url}\"" if ENV["DEBUG"]
    `cf curl \"/v3/#{url}\"`
  end
end

.sanitize_url(endpoint, params) ⇒ Object



16
17
18
19
20
# File 'lib/jcf/cf.rb', line 16

def self.sanitize_url(endpoint, params)
  url = endpoint.dup
  url << "?#{params.to_query}" if params && params != {}
  url
end