hula 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f818eacb2ff4e78c3e2aad44ed5b7abdbe30f070
4
- data.tar.gz: f69be8a6aa424de96a77a7ef65c3131cd07d1578
3
+ metadata.gz: 0df6b7a45fa764bd559b5c51138f833f00f25948
4
+ data.tar.gz: 33bbca0352b42859e1006428f8314356038be4e9
5
5
  SHA512:
6
- metadata.gz: 3938655e257b5db64c6ded080f54ff2919aeeb3582ae4dd1fb5650580275d2264949c2af9a3172226a3fbde8bc6a44f5d64d7ccb31d197970f00b0b7703740a1
7
- data.tar.gz: 225a14dbfe25d03f4ff2e099093b7139a1974241256862919e15822ef4ba15c173f68bb3d250044f0da2b90ce17adc124f904cc6078af0106c2660e08fab1035
6
+ metadata.gz: 4b352e9f0c465425520b833c9691dced0fd77fb65f187909ded79897b76da39508ddbd0ec7aafca9de1f5775c5e55e18635e9b2cf9a9153af540f5f2bb20fb2c
7
+ data.tar.gz: 050f8520509a348ff81961ea223a284e084a487c5332becf3fdb396afc1000c3a60e57f497c6d434e268fcc7d3bafdc3261f8207c83438ba53403921bffe83ff
@@ -22,18 +22,19 @@ module Hula
22
22
  extend Forwardable
23
23
  def_delegators :catalog, :service_plan
24
24
 
25
- def initialize(url:, username:, password:, http_client: HttpJsonClient.new)
25
+ def initialize(url:, username:, password:, http_client: HttpJsonClient.new, broker_api_version:)
26
26
  @http_client = http_client
27
27
 
28
28
  @url = URI(url)
29
29
  @username = username
30
30
  @password = password
31
+ @broker_api_version = broker_api_version
31
32
  end
32
33
 
33
34
  attr_reader :url
34
35
 
35
36
  def catalog
36
- json = http_client.get(url_for('/v2/catalog'), auth: { username: username, password: password })
37
+ json = http_client.get(url_for('/v2/catalog'), auth: { username: username, password: password }, headers: { 'X-Broker-Api-Version': @broker_api_version })
37
38
  Catalog.new(json)
38
39
  end
39
40
 
@@ -72,7 +73,7 @@ module Hula
72
73
  end
73
74
 
74
75
  def debug
75
- http_client.get(url_for('/debug'), auth: { username: username, password: password })
76
+ http_client.get(url_for('/debug'), auth: { username: username, password: password }, headers: { 'X-Broker-Api-Version': @broker_api_version })
76
77
  end
77
78
 
78
79
  private
@@ -84,7 +85,8 @@ module Hula
84
85
  service_id: service_id,
85
86
  plan_id: plan_id,
86
87
  },
87
- auth: { username: username, password: password }
88
+ auth: { username: username, password: password },
89
+ headers: { 'X-Broker-Api-Version': @broker_api_version }
88
90
  )
89
91
  end
90
92
 
@@ -94,7 +96,8 @@ module Hula
94
96
  auth: {
95
97
  username: username,
96
98
  password: password
97
- }
99
+ },
100
+ headers: { 'X-Broker-Api-Version': @broker_api_version }
98
101
  )
99
102
  end
100
103
 
@@ -102,14 +105,16 @@ module Hula
102
105
  http_client.put(
103
106
  url_for("/v2/service_instances/#{service_instance_id}/service_bindings/#{binding_id}"),
104
107
  body: {},
105
- auth: { username: username, password: password }
108
+ auth: { username: username, password: password },
109
+ headers: { 'X-Broker-Api-Version': @broker_api_version }
106
110
  )
107
111
  end
108
112
 
109
113
  def http_unbind_instance(service_instance_id:, binding_id:)
110
114
  http_client.delete(
111
115
  url_for("/v2/service_instances/#{service_instance_id}/service_bindings/#{binding_id}"),
112
- auth: { username: username, password: password }
116
+ auth: { username: username, password: password },
117
+ headers: { 'X-Broker-Api-Version': @broker_api_version }
113
118
  )
114
119
  end
115
120
 
@@ -29,22 +29,39 @@ module Hula
29
29
  @http_proxy = http_proxy
30
30
  end
31
31
 
32
- def get(uri, auth: nil)
32
+ def get(uri, auth: nil, headers: nil)
33
33
  request = Net::HTTP::Get.new(uri)
34
34
  request.basic_auth auth.fetch(:username), auth.fetch(:password) unless auth.nil?
35
+
36
+ if not headers.nil?
37
+ headers.each do |key, value|
38
+ request.add_field(key, value)
39
+ end
40
+ end
41
+
35
42
  send_request(request)
36
43
  end
37
44
 
38
- def put(uri, body: nil, auth: nil)
45
+ def put(uri, body: nil, auth: nil, headers: nil)
39
46
  request = Net::HTTP::Put.new(uri)
40
47
  request.body = JSON.generate(body) if body
41
48
  request.basic_auth auth.fetch(:username), auth.fetch(:password) unless auth.nil?
49
+ if not headers.nil?
50
+ headers.each do |key, value|
51
+ request.add_field(key, value)
52
+ end
53
+ end
42
54
  send_request(request)
43
55
  end
44
56
 
45
- def delete(uri, auth: nil)
57
+ def delete(uri, auth: nil, headers: nil)
46
58
  request = Net::HTTP::Delete.new(uri)
47
59
  request.basic_auth auth.fetch(:username), auth.fetch(:password) unless auth.nil?
60
+ if not headers.nil?
61
+ headers.each do |key, value|
62
+ request.add_field(key, value)
63
+ end
64
+ end
48
65
  send_request(request)
49
66
  end
50
67
 
data/lib/hula/version.rb CHANGED
@@ -9,5 +9,5 @@
9
9
  #
10
10
 
11
11
  module Hula
12
- VERSION = '0.11.1'
12
+ VERSION = '0.12.0'
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hula
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Pragnell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-28 00:00:00.000000000 Z
11
+ date: 2018-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  version: '0'
229
229
  requirements: []
230
230
  rubyforge_project:
231
- rubygems_version: 2.6.11
231
+ rubygems_version: 2.5.1
232
232
  signing_key:
233
233
  specification_version: 4
234
234
  summary: A tasty wrapper around cf, and more...