cfoundry 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cfoundry/v1/client.rb +3 -0
- data/lib/cfoundry/v2/base.rb +3 -2
- data/lib/cfoundry/v2/client.rb +21 -2
- data/lib/cfoundry/v2/model.rb +8 -7
- data/lib/cfoundry/v2/service_binding.rb +11 -0
- data/lib/cfoundry/v2/service_instance.rb +3 -0
- data/lib/cfoundry/v2/space.rb +1 -0
- data/lib/cfoundry/version.rb +1 -1
- metadata +5 -4
data/lib/cfoundry/v1/client.rb
CHANGED
data/lib/cfoundry/v2/base.rb
CHANGED
@@ -46,8 +46,9 @@ module CFoundry::V2
|
|
46
46
|
end
|
47
47
|
|
48
48
|
|
49
|
-
[:app, :organization, :app_space, :
|
50
|
-
:
|
49
|
+
[ :app, :organization, :app_space, :user, :runtime, :framework,
|
50
|
+
:service, :service_plan, :service_binding, :service_instance
|
51
|
+
].each do |obj|
|
51
52
|
plural = "#{obj}s"
|
52
53
|
|
53
54
|
define_method(obj) do |guid, *args|
|
data/lib/cfoundry/v2/client.rb
CHANGED
@@ -5,7 +5,9 @@ require "cfoundry/v2/framework"
|
|
5
5
|
require "cfoundry/v2/organization"
|
6
6
|
require "cfoundry/v2/runtime"
|
7
7
|
require "cfoundry/v2/service"
|
8
|
+
require "cfoundry/v2/service_binding"
|
8
9
|
require "cfoundry/v2/service_instance"
|
10
|
+
require "cfoundry/v2/service_plan"
|
9
11
|
require "cfoundry/v2/space"
|
10
12
|
require "cfoundry/v2/user"
|
11
13
|
|
@@ -113,14 +115,26 @@ module CFoundry::V2
|
|
113
115
|
end
|
114
116
|
|
115
117
|
|
116
|
-
|
117
|
-
|
118
|
+
# TODO: allow direct filtering
|
119
|
+
def app_by_name(name)
|
120
|
+
current_space.apps.find do |a|
|
121
|
+
a.name == name
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
[ :app, :organization, :app_space, :user, :runtime, :framework,
|
127
|
+
:service, :service_plan, :service_binding, :service_instance
|
128
|
+
].each do |singular|
|
118
129
|
klass = singular.to_s.capitalize.gsub(/(.)_(.)/) do
|
119
130
|
$1 + $2.upcase
|
120
131
|
end
|
121
132
|
|
122
133
|
plural = :"#{singular}s"
|
123
134
|
|
135
|
+
has_app_space =
|
136
|
+
CFoundry::V2.const_get(klass).method_defined? :app_space
|
137
|
+
|
124
138
|
define_method(singular) do |*args|
|
125
139
|
id, _ = args
|
126
140
|
CFoundry::V2.const_get(klass).new(id, self)
|
@@ -130,6 +144,11 @@ module CFoundry::V2
|
|
130
144
|
depth, query = args
|
131
145
|
depth ||= 1
|
132
146
|
|
147
|
+
if has_app_space
|
148
|
+
query ||= {}
|
149
|
+
query[:app_space_guid] ||= current_space.id
|
150
|
+
end
|
151
|
+
|
133
152
|
@base.send(plural, depth, query)[:resources].collect do |json|
|
134
153
|
send(:"make_#{singular}", json)
|
135
154
|
end
|
data/lib/cfoundry/v2/model.rb
CHANGED
@@ -17,6 +17,7 @@ module CFoundry::V2
|
|
17
17
|
@manifest ||= {}
|
18
18
|
@manifest[:entity] ||= {}
|
19
19
|
@manifest[:entity][name] = val
|
20
|
+
@diff[name] = val
|
20
21
|
}
|
21
22
|
end
|
22
23
|
|
@@ -38,7 +39,8 @@ module CFoundry::V2
|
|
38
39
|
define_method(:"#{name}=") { |x|
|
39
40
|
@manifest ||= {}
|
40
41
|
@manifest[:entity] ||= {}
|
41
|
-
@manifest[:entity][:"#{name}_guid"] =
|
42
|
+
@manifest[:entity][:"#{name}_guid"] =
|
43
|
+
@diff[:"#{name}_guid"] = x.id
|
42
44
|
}
|
43
45
|
end
|
44
46
|
|
@@ -78,7 +80,8 @@ module CFoundry::V2
|
|
78
80
|
define_method(:"#{plural}=") { |xs|
|
79
81
|
@manifest ||= {}
|
80
82
|
@manifest[:entity] ||= {}
|
81
|
-
@manifest[:entity][:"#{singular}_guids"] =
|
83
|
+
@manifest[:entity][:"#{singular}_guids"] =
|
84
|
+
@diff[:"#{singular}_guids"] = xs.collect(&:id)
|
82
85
|
}
|
83
86
|
end
|
84
87
|
end
|
@@ -89,6 +92,7 @@ module CFoundry::V2
|
|
89
92
|
@id = id
|
90
93
|
@client = client
|
91
94
|
@manifest = manifest
|
95
|
+
@diff = {}
|
92
96
|
end
|
93
97
|
|
94
98
|
def manifest
|
@@ -118,11 +122,8 @@ module CFoundry::V2
|
|
118
122
|
true
|
119
123
|
end
|
120
124
|
|
121
|
-
def update!(diff =
|
122
|
-
@client.base.send(
|
123
|
-
:"update_#{object_name}",
|
124
|
-
@id,
|
125
|
-
diff || manifest[:entity])
|
125
|
+
def update!(diff = @diff)
|
126
|
+
@client.base.send(:"update_#{object_name}", @id, diff)
|
126
127
|
|
127
128
|
@manifest = nil
|
128
129
|
end
|
data/lib/cfoundry/v2/space.rb
CHANGED
data/lib/cfoundry/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfoundry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Suraci
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-07-
|
18
|
+
date: 2012-07-14 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rest-client
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/cfoundry/v2/organization.rb
|
127
127
|
- lib/cfoundry/v2/runtime.rb
|
128
128
|
- lib/cfoundry/v2/service.rb
|
129
|
+
- lib/cfoundry/v2/service_binding.rb
|
129
130
|
- lib/cfoundry/v2/service_instance.rb
|
130
131
|
- lib/cfoundry/v2/service_plan.rb
|
131
132
|
- lib/cfoundry/v2/space.rb
|