cfoundry 0.3.23 → 0.3.24
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/uaaclient.rb +1 -1
- data/lib/cfoundry/v2/app.rb +8 -8
- data/lib/cfoundry/v2/domain.rb +1 -1
- data/lib/cfoundry/v2/framework.rb +2 -2
- data/lib/cfoundry/v2/model.rb +48 -2
- data/lib/cfoundry/v2/organization.rb +1 -1
- data/lib/cfoundry/v2/runtime.rb +2 -2
- data/lib/cfoundry/v2/service.rb +10 -9
- data/lib/cfoundry/v2/service_auth_token.rb +3 -3
- data/lib/cfoundry/v2/service_instance.rb +1 -1
- data/lib/cfoundry/v2/service_plan.rb +2 -2
- data/lib/cfoundry/v2/space.rb +1 -1
- data/lib/cfoundry/v2/user.rb +2 -2
- data/lib/cfoundry/version.rb +1 -1
- metadata +15 -10
data/lib/cfoundry/uaaclient.rb
CHANGED
data/lib/cfoundry/v2/app.rb
CHANGED
@@ -17,17 +17,17 @@ module CFoundry::V2
|
|
17
17
|
class App < Model
|
18
18
|
include CFoundry::UploadHelpers
|
19
19
|
|
20
|
-
attribute :name
|
21
|
-
attribute :production
|
20
|
+
attribute :name, :string
|
21
|
+
attribute :production, :boolean, :default => false
|
22
22
|
to_one :space
|
23
23
|
to_one :runtime
|
24
24
|
to_one :framework
|
25
|
-
attribute :environment_json, :default => {}
|
26
|
-
attribute :memory,
|
27
|
-
attribute :instances,
|
28
|
-
attribute :file_descriptors,
|
29
|
-
attribute :disk_quota,
|
30
|
-
attribute :state,
|
25
|
+
attribute :environment_json, :hash, :default => {}
|
26
|
+
attribute :memory, :integer, :default => 256
|
27
|
+
attribute :instances, :integer, :default => 1
|
28
|
+
attribute :file_descriptors, :integer, :default => 256
|
29
|
+
attribute :disk_quota, :integer, :default => 256
|
30
|
+
attribute :state, :integer, :default => "STOPPED"
|
31
31
|
to_many :service_bindings
|
32
32
|
|
33
33
|
alias :total_instances :instances
|
data/lib/cfoundry/v2/domain.rb
CHANGED
data/lib/cfoundry/v2/model.rb
CHANGED
@@ -3,19 +3,57 @@ require "multi_json"
|
|
3
3
|
module CFoundry::V2
|
4
4
|
class Model
|
5
5
|
class << self
|
6
|
+
def value_matches?(val, type)
|
7
|
+
case type
|
8
|
+
when Class
|
9
|
+
val.is_a?(type)
|
10
|
+
when Regexp
|
11
|
+
val.is_a?(String) && val =~ type
|
12
|
+
when :url
|
13
|
+
value_matches?(val, URI::regexp(%w(http https)))
|
14
|
+
when :https_url
|
15
|
+
value_matches?(val, URI::regexp("https"))
|
16
|
+
when :boolean
|
17
|
+
val.is_a?(TrueClass) || val.is_a?(FalseClass)
|
18
|
+
when Array
|
19
|
+
val.all? do |x|
|
20
|
+
value_matches?(x, type.first)
|
21
|
+
end
|
22
|
+
when Hash
|
23
|
+
val.is_a?(Hash) &&
|
24
|
+
type.all? { |name, subtype|
|
25
|
+
val.key?(name) && value_matches?(val[name], subtype)
|
26
|
+
}
|
27
|
+
else
|
28
|
+
val.is_a?(Object.const_get(type.to_s.capitalize))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def validate_type(val, type)
|
33
|
+
unless value_matches?(val, type)
|
34
|
+
raise "invalid attribute; expected #{type.inspect} but got #{val.inspect}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
6
38
|
def defaults
|
7
39
|
@defaults ||= {}
|
8
40
|
end
|
9
41
|
|
10
|
-
def attribute(name, opts = {})
|
42
|
+
def attribute(name, type, opts = {})
|
11
43
|
default = opts[:default] || nil
|
12
|
-
|
44
|
+
|
45
|
+
has_default = opts.key?(:default)
|
46
|
+
defaults[name] = default if has_default
|
13
47
|
|
14
48
|
define_method(name) {
|
15
49
|
manifest[:entity][name] || default
|
16
50
|
}
|
17
51
|
|
18
52
|
define_method(:"#{name}=") { |val|
|
53
|
+
unless has_default && val == default
|
54
|
+
Model.validate_type(val, type)
|
55
|
+
end
|
56
|
+
|
19
57
|
@manifest ||= {}
|
20
58
|
@manifest[:entity] ||= {}
|
21
59
|
@manifest[:entity][name] = val
|
@@ -25,6 +63,7 @@ module CFoundry::V2
|
|
25
63
|
|
26
64
|
def to_one(name, opts = {})
|
27
65
|
obj = opts[:as] || name
|
66
|
+
kls = obj.to_s.capitalize
|
28
67
|
|
29
68
|
define_method(name) {
|
30
69
|
if @manifest && @manifest[:entity].key?(name)
|
@@ -42,6 +81,8 @@ module CFoundry::V2
|
|
42
81
|
}
|
43
82
|
|
44
83
|
define_method(:"#{name}=") { |x|
|
84
|
+
Model.validate_type(x, CFoundry::V2.const_get(kls))
|
85
|
+
|
45
86
|
@manifest ||= {}
|
46
87
|
@manifest[:entity] ||= {}
|
47
88
|
@manifest[:entity][:"#{name}_guid"] =
|
@@ -51,6 +92,7 @@ module CFoundry::V2
|
|
51
92
|
|
52
93
|
def to_many(plural, opts = {})
|
53
94
|
singular = plural.to_s.sub(/s$/, "").to_sym
|
95
|
+
kls = singular.to_s.capitalize
|
54
96
|
|
55
97
|
object = opts[:as] || singular
|
56
98
|
plural_object = :"#{object}s"
|
@@ -85,6 +127,8 @@ module CFoundry::V2
|
|
85
127
|
|
86
128
|
# TODO: these are hacky
|
87
129
|
define_method(:"add_#{singular}") { |x|
|
130
|
+
Model.validate_type(x, CFoundry::V2.const_get(kls))
|
131
|
+
|
88
132
|
@client.base.request_path(
|
89
133
|
:put,
|
90
134
|
["v2", "#{object_name}s", @guid, plural, x.guid],
|
@@ -99,6 +143,8 @@ module CFoundry::V2
|
|
99
143
|
}
|
100
144
|
|
101
145
|
define_method(:"#{plural}=") { |xs|
|
146
|
+
Model.validate_type(x, [CFoundry::V2.const_get(kls)])
|
147
|
+
|
102
148
|
@manifest ||= {}
|
103
149
|
@manifest[:entity] ||= {}
|
104
150
|
@manifest[:entity][:"#{singular}_guids"] =
|
data/lib/cfoundry/v2/runtime.rb
CHANGED
data/lib/cfoundry/v2/service.rb
CHANGED
@@ -2,15 +2,16 @@ require "cfoundry/v2/model"
|
|
2
2
|
|
3
3
|
module CFoundry::V2
|
4
4
|
class Service < Model
|
5
|
-
attribute :label
|
6
|
-
attribute :provider
|
7
|
-
attribute :url
|
8
|
-
attribute :description
|
9
|
-
attribute :version
|
10
|
-
attribute :info_url
|
11
|
-
attribute :acls
|
12
|
-
|
13
|
-
attribute :
|
5
|
+
attribute :label, String
|
6
|
+
attribute :provider, String
|
7
|
+
attribute :url, :url
|
8
|
+
attribute :description, String
|
9
|
+
attribute :version, String
|
10
|
+
attribute :info_url, :url
|
11
|
+
attribute :acls, { "users" => [String], "wildcards" => [String] },
|
12
|
+
:default => nil
|
13
|
+
attribute :timeout, Integer, :default => nil
|
14
|
+
attribute :active, :boolean, :default => false
|
14
15
|
to_many :service_plans
|
15
16
|
end
|
16
17
|
end
|
data/lib/cfoundry/v2/space.rb
CHANGED
data/lib/cfoundry/v2/user.rb
CHANGED
@@ -9,10 +9,10 @@ module CFoundry::V2
|
|
9
9
|
to_many :audited_organizations, :as => :organization
|
10
10
|
to_many :managed_spaces, :as => :space
|
11
11
|
to_many :audited_spaces, :as => :space
|
12
|
-
attribute :admin
|
12
|
+
attribute :admin, :boolean
|
13
13
|
to_one :default_space, :as => :space
|
14
14
|
|
15
|
-
attribute :guid # guid is explicitly set for users
|
15
|
+
attribute :guid, :string # guid is explicitly set for users
|
16
16
|
|
17
17
|
def guid
|
18
18
|
@guid
|
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: 35
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 24
|
10
|
+
version: 0.3.24
|
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-08-
|
18
|
+
date: 2012-08-29 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rest-client
|
@@ -71,12 +71,15 @@ dependencies:
|
|
71
71
|
requirement: &id004 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
hash:
|
76
|
+
hash: 11
|
77
77
|
segments:
|
78
78
|
- 0
|
79
|
-
|
79
|
+
- 9
|
80
|
+
- 2
|
81
|
+
- 2
|
82
|
+
version: 0.9.2.2
|
80
83
|
type: :development
|
81
84
|
version_requirements: *id004
|
82
85
|
- !ruby/object:Gem::Dependency
|
@@ -85,12 +88,14 @@ dependencies:
|
|
85
88
|
requirement: &id005 !ruby/object:Gem::Requirement
|
86
89
|
none: false
|
87
90
|
requirements:
|
88
|
-
- -
|
91
|
+
- - ~>
|
89
92
|
- !ruby/object:Gem::Version
|
90
|
-
hash:
|
93
|
+
hash: 35
|
91
94
|
segments:
|
95
|
+
- 2
|
96
|
+
- 11
|
92
97
|
- 0
|
93
|
-
version:
|
98
|
+
version: 2.11.0
|
94
99
|
type: :development
|
95
100
|
version_requirements: *id005
|
96
101
|
description:
|