cfoundry 3.0.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjI0MzQ5OWE5Y2FkMjc0MjAyZjVmNGU1OTIyOTFmYWEzYzk2YTcwZQ==
5
+ data.tar.gz: !binary |-
6
+ NjE2NWYyNTViZWZjZGZhNzQyODNiZDA1N2ZkNDg5ZjMxNzJkMWRlYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OGVlMmQzMzNlZjczYzQxMzg1OTNmZDVlZTBmMTQwNmZiZTU1OTY4NjI0NzNh
10
+ NGEwZTY3MzE4MGQ1ODBhYmY3MzJlNmFiNjc0ZTAzNTNiZTg0YWI0MDRkMzcy
11
+ NmRlOTJiNjE1ZTAxNWI3OWYxNDM1NWE3NTkxYTViZjkxZDYwYjU=
12
+ data.tar.gz: !binary |-
13
+ MzQ1NTkzZjE1YTUyNTc5NGM3MzA2NThkMmE0ZjNkNTI2MmUwZDM2Zjk3NmYz
14
+ ZTkzNzYwMmJkNjc3MDYxMzFmODU3ZWYzYWQ3NTFlZjJiNTZjMzcyZDFhYTNk
15
+ YTc2MWNkMDYzYWMyZDRhYjI1YjAxMWFjNWEyZmI1Y2UxYjdmMGM=
@@ -6,6 +6,7 @@ require "cfoundry/v2/app"
6
6
  require "cfoundry/v2/service"
7
7
  require "cfoundry/v2/service_binding"
8
8
  require "cfoundry/v2/service_instance"
9
+ require "cfoundry/v2/user_provided_service_instance"
9
10
  require "cfoundry/v2/service_plan"
10
11
  require "cfoundry/v2/service_auth_token"
11
12
  require "cfoundry/v2/user"
@@ -81,5 +81,11 @@ module CFoundry::V2
81
81
  def stream_url(url, &blk)
82
82
  @base.stream_url(url, &blk)
83
83
  end
84
+
85
+ # client.service_instances override
86
+ def service_instances(opts={})
87
+ opts[:user_provided] = !!(opts[:user_provided] || opts[:user_provided].nil?)
88
+ super(opts)
89
+ end
84
90
  end
85
91
  end
@@ -82,6 +82,8 @@ module CFoundry::V2
82
82
  params[:"inline-relations-depth"] = v
83
83
  when :query
84
84
  params[:q] = v.join(":")
85
+ when :user_provided
86
+ params[:"return_user_provided_service_instances"] = v
85
87
  end
86
88
  end
87
89
 
@@ -0,0 +1,11 @@
1
+ require "cfoundry/v2/model"
2
+
3
+ module CFoundry::V2
4
+ class UserProvidedServiceInstance < Model
5
+ attribute :name, :string
6
+ attribute :credentials, :hash
7
+ to_one :space
8
+
9
+ scoped_to_space
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "3.0.1".freeze
3
+ VERSION = "4.0.0".freeze
4
4
  end
@@ -10,4 +10,23 @@ describe CFoundry::Client do
10
10
  it "returns a v2 client" do
11
11
  subject.should be_a(CFoundry::V2::Client)
12
12
  end
13
+
14
+ describe "service_instances" do
15
+ let(:client) { build(:client) }
16
+
17
+ it "defaults to true when the :user_provided option is not provided" do
18
+ client.base.should_receive(:service_instances).with(user_provided: true).and_return([])
19
+ client.service_instances
20
+ end
21
+
22
+ it "calls super with true when :user_provded=true" do
23
+ client.base.should_receive(:service_instances).with(user_provided: true).and_return([])
24
+ client.service_instances(user_provided: true)
25
+ end
26
+
27
+ it "calls super with false when :user_provided=false" do
28
+ client.base.should_receive(:service_instances).with(user_provided: false).and_return([])
29
+ client.service_instances(user_provided: false)
30
+ end
31
+ end
13
32
  end
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ module CFoundry
4
+ module V2
5
+ describe UserProvidedServiceInstance do
6
+ let(:client) { build(:client) }
7
+ subject { build(:user_provided_service_instance, :client => client) }
8
+
9
+ describe "space" do
10
+ let(:space) { build(:space) }
11
+
12
+ it "has a space" do
13
+ subject.space = space
14
+ expect(subject.space).to eq(space)
15
+ end
16
+
17
+ context "when an invalid value is assigned" do
18
+ it "raises a Mismatch exception" do
19
+ expect {
20
+ subject.space = [build(:organization)]
21
+ }.to raise_error(CFoundry::Mismatch)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -40,6 +40,100 @@ module CFoundry
40
40
  end
41
41
  end
42
42
 
43
+ describe "fetching the service instances" do
44
+ let(:example_response) do
45
+ '{
46
+ "total_results": 2,
47
+ "total_pages": 1,
48
+ "prev_url": null,
49
+ "next_url": null,
50
+ "resources": [
51
+ {
52
+ "metadata": {
53
+ "guid": "2148b3c4-3d3d-4361-87a3-1b4bf834cdea",
54
+ "url": "/v2/service_instances/2148b3c4-3d3d-4361-87a3-1b4bf834cdea",
55
+ "created_at": "2013-07-24 00:32:23 +0000",
56
+ "updated_at": null
57
+ },
58
+ "entity": {
59
+ "name": "user-provided-6a19d",
60
+ "credentials": {
61
+ "thing": "a"
62
+ },
63
+ "space_guid": "15ee90c2-8654-40c9-a311-ecfef8cbc921",
64
+ "space_url": "/v2/spaces/15ee90c2-8654-40c9-a311-ecfef8cbc921",
65
+ "service_bindings_url": "/v2/service_instances/2148b3c4-3d3d-4361-87a3-1b4bf834cdea/service_bindings"
66
+ }
67
+ },
68
+ {
69
+ "metadata": {
70
+ "guid": "746c36b0-4b5f-4e46-876a-2948804ef464",
71
+ "url": "/v2/service_instances/746c36b0-4b5f-4e46-876a-2948804ef464",
72
+ "created_at": "2013-07-24 00:32:33 +0000",
73
+ "updated_at": null
74
+ },
75
+ "entity": {
76
+ "name": "rds-mysql-3991f",
77
+ "credentials": {
78
+ "name": "da2f110d519d848a1a677f8df77890cc3",
79
+ "hostname": "mysql-service-public.cze9ndyywtkf.us-east-1.rds.amazonaws.com",
80
+ "host": "mysql-service-public.cze9ndyywtkf.us-east-1.rds.amazonaws.com",
81
+ "port": 3306,
82
+ "user": "ufZEqKvAXQogC",
83
+ "username": "ufZEqKvAXQogC",
84
+ "password": "p8QGNHykcSTu2",
85
+ "node_id": "rds_mysql_node_10mb_0"
86
+ },
87
+ "service_plan_guid": "2c7ab67d-4354-46b5-8423-b19ef6e4b50a",
88
+ "space_guid": "15ee90c2-8654-40c9-a311-ecfef8cbc921",
89
+ "gateway_data": {
90
+ "plan": "10mb",
91
+ "version": "n/a"
92
+ },
93
+ "dashboard_url": null,
94
+ "space_url": "/v2/spaces/15ee90c2-8654-40c9-a311-ecfef8cbc921",
95
+ "service_plan_url": "/v2/service_plans/2c7ab67d-4354-46b5-8423-b19ef6e4b50a",
96
+ "service_bindings_url": "/v2/service_instances/746c36b0-4b5f-4e46-876a-2948804ef464/service_bindings"
97
+ }
98
+ }
99
+ ]
100
+ }'
101
+ end
102
+
103
+ context "when there is no current org or current space" do
104
+ it "gets both user-provided and cf-managed service instances" do
105
+ http_stub = stub_request(:get, "#{client.target}/v2/service_instances?inline-relations-depth=1&return_user_provided_service_instances=true").to_return(:status => 200, :body => example_response)
106
+ client.service_instances
107
+ http_stub.should have_been_requested
108
+ end
109
+
110
+ it "gets only cf-managed service instances if the user explicitly sets :user_provided to false" do
111
+ http_stub = stub_request(:get, "#{client.target}/v2/service_instances?inline-relations-depth=1&return_user_provided_service_instances=false").to_return(:status => 200, :body => example_response)
112
+ client.service_instances(user_provided: false)
113
+ http_stub.should have_been_requested
114
+ end
115
+ end
116
+
117
+ it "defaults to true when user_provided is set to a bogus value (not true or false)" do
118
+ http_stub = stub_request(:get, "#{client.target}/v2/service_instances?inline-relations-depth=1&return_user_provided_service_instances=true").to_return(:status => 200, :body => example_response)
119
+ client.service_instances(user_provided: 'some_non-boolean_value')
120
+ http_stub.should have_been_requested
121
+ end
122
+
123
+
124
+ context "when there is a current org and a current space" do
125
+ let(:org) { build(:organization) }
126
+ let(:space) { build(:space, organization: org) }
127
+ let(:client) { build(:client, current_organization: org, current_space: space) }
128
+ it "gets both user-provided and cf-managed service instances" do
129
+ http_stub = stub_request(:get, "#{client.target}/v2/spaces/#{space.guid}/service_instances?inline-relations-depth=1&return_user_provided_service_instances=true").to_return(:status => 200, :body => example_response)
130
+ client.service_instances
131
+ http_stub.should have_been_requested
132
+ end
133
+ end
134
+
135
+ end
136
+
43
137
  describe 'query params' do
44
138
  it 'allows query by name' do
45
139
  client.should respond_to(:service_instance_by_name)
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+ factory :user_provided_service_instance, :class => CFoundry::V2::UserProvidedServiceInstance do
3
+ sequence(:guid) { |n| "user-provided-service-instance-guid-#{n}" }
4
+ ignore do
5
+ client { FactoryGirl.build(:client) }
6
+ end
7
+
8
+ initialize_with { new(guid, client) }
9
+ end
10
+ end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfoundry
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
5
- prerelease:
4
+ version: 4.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Cloud Foundry Team
@@ -10,12 +9,11 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-07-22 00:00:00.000000000 Z
12
+ date: 2013-07-24 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: activemodel
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ~>
21
19
  - !ruby/object:Gem::Version
@@ -23,7 +21,6 @@ dependencies:
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ~>
29
26
  - !ruby/object:Gem::Version
@@ -31,7 +28,6 @@ dependencies:
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: cf-uaa-lib
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
32
  - - ~>
37
33
  - !ruby/object:Gem::Version
@@ -39,7 +35,6 @@ dependencies:
39
35
  type: :runtime
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
39
  - - ~>
45
40
  - !ruby/object:Gem::Version
@@ -47,7 +42,6 @@ dependencies:
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: multi_json
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
46
  - - ~>
53
47
  - !ruby/object:Gem::Version
@@ -55,7 +49,6 @@ dependencies:
55
49
  type: :runtime
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
53
  - - ~>
61
54
  - !ruby/object:Gem::Version
@@ -63,7 +56,6 @@ dependencies:
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: multipart-post
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
60
  - - ~>
69
61
  - !ruby/object:Gem::Version
@@ -71,7 +63,6 @@ dependencies:
71
63
  type: :runtime
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
67
  - - ~>
77
68
  - !ruby/object:Gem::Version
@@ -79,7 +70,6 @@ dependencies:
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: rubyzip
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
74
  - - ~>
85
75
  - !ruby/object:Gem::Version
@@ -87,7 +77,6 @@ dependencies:
87
77
  type: :runtime
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
81
  - - ~>
93
82
  - !ruby/object:Gem::Version
@@ -95,7 +84,6 @@ dependencies:
95
84
  - !ruby/object:Gem::Dependency
96
85
  name: anchorman
97
86
  requirement: !ruby/object:Gem::Requirement
98
- none: false
99
87
  requirements:
100
88
  - - ! '>='
101
89
  - !ruby/object:Gem::Version
@@ -103,7 +91,6 @@ dependencies:
103
91
  type: :development
104
92
  prerelease: false
105
93
  version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
94
  requirements:
108
95
  - - ! '>='
109
96
  - !ruby/object:Gem::Version
@@ -111,7 +98,6 @@ dependencies:
111
98
  - !ruby/object:Gem::Dependency
112
99
  name: factory_girl
113
100
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
101
  requirements:
116
102
  - - ! '>='
117
103
  - !ruby/object:Gem::Version
@@ -119,7 +105,6 @@ dependencies:
119
105
  type: :development
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
108
  requirements:
124
109
  - - ! '>='
125
110
  - !ruby/object:Gem::Version
@@ -127,7 +112,6 @@ dependencies:
127
112
  - !ruby/object:Gem::Dependency
128
113
  name: gem-release
129
114
  requirement: !ruby/object:Gem::Requirement
130
- none: false
131
115
  requirements:
132
116
  - - ! '>='
133
117
  - !ruby/object:Gem::Version
@@ -135,7 +119,6 @@ dependencies:
135
119
  type: :development
136
120
  prerelease: false
137
121
  version_requirements: !ruby/object:Gem::Requirement
138
- none: false
139
122
  requirements:
140
123
  - - ! '>='
141
124
  - !ruby/object:Gem::Version
@@ -143,7 +126,6 @@ dependencies:
143
126
  - !ruby/object:Gem::Dependency
144
127
  name: json_pure
145
128
  requirement: !ruby/object:Gem::Requirement
146
- none: false
147
129
  requirements:
148
130
  - - ~>
149
131
  - !ruby/object:Gem::Version
@@ -151,7 +133,6 @@ dependencies:
151
133
  type: :development
152
134
  prerelease: false
153
135
  version_requirements: !ruby/object:Gem::Requirement
154
- none: false
155
136
  requirements:
156
137
  - - ~>
157
138
  - !ruby/object:Gem::Version
@@ -159,7 +140,6 @@ dependencies:
159
140
  - !ruby/object:Gem::Dependency
160
141
  name: rake
161
142
  requirement: !ruby/object:Gem::Requirement
162
- none: false
163
143
  requirements:
164
144
  - - ! '>='
165
145
  - !ruby/object:Gem::Version
@@ -167,7 +147,6 @@ dependencies:
167
147
  type: :development
168
148
  prerelease: false
169
149
  version_requirements: !ruby/object:Gem::Requirement
170
- none: false
171
150
  requirements:
172
151
  - - ! '>='
173
152
  - !ruby/object:Gem::Version
@@ -175,7 +154,6 @@ dependencies:
175
154
  - !ruby/object:Gem::Dependency
176
155
  name: rspec
177
156
  requirement: !ruby/object:Gem::Requirement
178
- none: false
179
157
  requirements:
180
158
  - - ~>
181
159
  - !ruby/object:Gem::Version
@@ -183,7 +161,6 @@ dependencies:
183
161
  type: :development
184
162
  prerelease: false
185
163
  version_requirements: !ruby/object:Gem::Requirement
186
- none: false
187
164
  requirements:
188
165
  - - ~>
189
166
  - !ruby/object:Gem::Version
@@ -191,7 +168,6 @@ dependencies:
191
168
  - !ruby/object:Gem::Dependency
192
169
  name: shoulda-matchers
193
170
  requirement: !ruby/object:Gem::Requirement
194
- none: false
195
171
  requirements:
196
172
  - - ~>
197
173
  - !ruby/object:Gem::Version
@@ -199,7 +175,6 @@ dependencies:
199
175
  type: :development
200
176
  prerelease: false
201
177
  version_requirements: !ruby/object:Gem::Requirement
202
- none: false
203
178
  requirements:
204
179
  - - ~>
205
180
  - !ruby/object:Gem::Version
@@ -207,7 +182,6 @@ dependencies:
207
182
  - !ruby/object:Gem::Dependency
208
183
  name: timecop
209
184
  requirement: !ruby/object:Gem::Requirement
210
- none: false
211
185
  requirements:
212
186
  - - ~>
213
187
  - !ruby/object:Gem::Version
@@ -215,7 +189,6 @@ dependencies:
215
189
  type: :development
216
190
  prerelease: false
217
191
  version_requirements: !ruby/object:Gem::Requirement
218
- none: false
219
192
  requirements:
220
193
  - - ~>
221
194
  - !ruby/object:Gem::Version
@@ -223,7 +196,6 @@ dependencies:
223
196
  - !ruby/object:Gem::Dependency
224
197
  name: webmock
225
198
  requirement: !ruby/object:Gem::Requirement
226
- none: false
227
199
  requirements:
228
200
  - - ~>
229
201
  - !ruby/object:Gem::Version
@@ -231,7 +203,6 @@ dependencies:
231
203
  type: :development
232
204
  prerelease: false
233
205
  version_requirements: !ruby/object:Gem::Requirement
234
- none: false
235
206
  requirements:
236
207
  - - ~>
237
208
  - !ruby/object:Gem::Version
@@ -295,6 +266,7 @@ files:
295
266
  - lib/cfoundry/v2/space.rb
296
267
  - lib/cfoundry/v2/stack.rb
297
268
  - lib/cfoundry/v2/user.rb
269
+ - lib/cfoundry/v2/user_provided_service_instance.rb
298
270
  - lib/cfoundry/validator.rb
299
271
  - lib/cfoundry/version.rb
300
272
  - lib/cfoundry/zip.rb
@@ -333,6 +305,7 @@ files:
333
305
  - spec/cfoundry/v2/model_magic/model_magic/has_summary_spec.rb
334
306
  - spec/cfoundry/v2/model_magic/model_magic/to_many_spec.rb
335
307
  - spec/cfoundry/v2/model_magic/model_magic/to_one_spec.rb
308
+ - spec/cfoundry/v2/model_magic/user_provided_service_instance_spec.rb
336
309
  - spec/cfoundry/v2/model_spec.rb
337
310
  - spec/cfoundry/v2/organization_spec.rb
338
311
  - spec/cfoundry/v2/quota_definition_spec.rb
@@ -351,6 +324,7 @@ files:
351
324
  - spec/factories/service_instances_factory.rb
352
325
  - spec/factories/service_plans_factory.rb
353
326
  - spec/factories/spaces_factory.rb
327
+ - spec/factories/user_provided_service_instances_factory.rb
354
328
  - spec/factories/users_factory.rb
355
329
  - spec/fixtures/apps/with_cfignore/ambiguous_ignored
356
330
  - spec/fixtures/apps/with_cfignore/ignored_dir/file_in_ignored_dir.txt
@@ -407,33 +381,26 @@ files:
407
381
  - spec/support/test_model_builder.rb
408
382
  homepage: http://github.com/cloudfoundry/cfoundry
409
383
  licenses: []
384
+ metadata: {}
410
385
  post_install_message:
411
386
  rdoc_options: []
412
387
  require_paths:
413
388
  - lib
414
389
  required_ruby_version: !ruby/object:Gem::Requirement
415
- none: false
416
390
  requirements:
417
391
  - - ! '>='
418
392
  - !ruby/object:Gem::Version
419
393
  version: '0'
420
- segments:
421
- - 0
422
- hash: 3662156757126524907
423
394
  required_rubygems_version: !ruby/object:Gem::Requirement
424
- none: false
425
395
  requirements:
426
396
  - - ! '>='
427
397
  - !ruby/object:Gem::Version
428
398
  version: '0'
429
- segments:
430
- - 0
431
- hash: 3662156757126524907
432
399
  requirements: []
433
400
  rubyforge_project: cfoundry
434
- rubygems_version: 1.8.25
401
+ rubygems_version: 2.0.5
435
402
  signing_key:
436
- specification_version: 3
403
+ specification_version: 4
437
404
  summary: High-level library for working with the Cloud Foundry API.
438
405
  test_files:
439
406
  - spec/cc_api_stub/applications_spec.rb
@@ -466,6 +433,7 @@ test_files:
466
433
  - spec/cfoundry/v2/model_magic/model_magic/has_summary_spec.rb
467
434
  - spec/cfoundry/v2/model_magic/model_magic/to_many_spec.rb
468
435
  - spec/cfoundry/v2/model_magic/model_magic/to_one_spec.rb
436
+ - spec/cfoundry/v2/model_magic/user_provided_service_instance_spec.rb
469
437
  - spec/cfoundry/v2/model_spec.rb
470
438
  - spec/cfoundry/v2/organization_spec.rb
471
439
  - spec/cfoundry/v2/quota_definition_spec.rb
@@ -484,6 +452,7 @@ test_files:
484
452
  - spec/factories/service_instances_factory.rb
485
453
  - spec/factories/service_plans_factory.rb
486
454
  - spec/factories/spaces_factory.rb
455
+ - spec/factories/user_provided_service_instances_factory.rb
487
456
  - spec/factories/users_factory.rb
488
457
  - spec/fixtures/apps/with_cfignore/ambiguous_ignored
489
458
  - spec/fixtures/apps/with_cfignore/ignored_dir/file_in_ignored_dir.txt