Class: BitsService::ResourcePool

Inherits:
Object
  • Object
show all
Defined in:
lib/bits_service_client/resource_pool.rb

Instance Method Summary collapse

Constructor Details

#initialize(endpoint:, request_timeout_in_seconds:, vcap_request_id: '', ca_cert_path: nil, username:, password:) ⇒ ResourcePool

Returns a new instance of ResourcePool.



5
6
7
8
9
10
11
12
13
# File 'lib/bits_service_client/resource_pool.rb', line 5

def initialize(endpoint:, request_timeout_in_seconds:, vcap_request_id: '', ca_cert_path: nil, username:, password:)
  @endpoint = URI.parse(endpoint)
  @request_timeout_in_seconds = request_timeout_in_seconds
  @vcap_request_id = vcap_request_id
  @logger = Steno.logger('cc.bits_service_client')
  @ca_cert_path = ca_cert_path
  @username = username
  @password = password
end

Instance Method Details

#bundles(resources_json, entries_path) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bits_service_client/resource_pool.rb', line 29

def bundles(resources_json, entries_path)
  if entries_path.to_s == ''
    post('/app_stash/bundles', resources_json, @vcap_request_id).tap do |response|
      validate_response_code!(200, response)
    end
  else
    validate_file! entries_path
    body = {
      resources: UploadIO.new(StringIO.new(resources_json), 'application/json', 'resources.json'),
      application: UploadIO.new(entries_path, 'application/octet-stream', 'entries.zip')
    }
    multipart_post('/app_stash/bundles', body, @vcap_request_id).tap do |response|
      validate_response_code!(200, response)
    end
  end
end

#matches(resources_json) ⇒ Object



15
16
17
18
19
# File 'lib/bits_service_client/resource_pool.rb', line 15

def matches(resources_json)
  post('/app_stash/matches', resources_json, @vcap_request_id).tap do |response|
    validate_response_code!(200, response)
  end
end

#signed_matches_urlObject



21
22
23
24
25
26
27
# File 'lib/bits_service_client/resource_pool.rb', line 21

def signed_matches_url()
  req = Net::HTTP::Get.new('/sign/app_stash/matches?verb=post')
  req.basic_auth(@username, @password)
  response = do_request(http_client, req, @vcap_request_id)
  validate_response_code!(200, response)
  response.body
end