blueprint_ruby_client 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/README.md +8 -5
- data/config.json +1 -1
- data/docs/Asset.md +2 -1
- data/docs/AssetAttributes.md +8 -0
- data/docs/AssetResultSet.md +1 -0
- data/docs/AssetsApi.md +8 -4
- data/docs/HierarchyApi.md +16 -14
- data/docs/MixedResourceResultSet.md +7 -0
- data/docs/Node.md +1 -1
- data/docs/NodeResultSet.md +1 -1
- data/docs/Resource.md +9 -0
- data/lib/blueprint_ruby_client.rb +3 -0
- data/lib/blueprint_ruby_client/api/assets_api.rb +12 -4
- data/lib/blueprint_ruby_client/api/hierarchy_api.rb +30 -25
- data/lib/blueprint_ruby_client/models/asset.rb +30 -4
- data/lib/blueprint_ruby_client/models/asset_attributes.rb +207 -0
- data/lib/blueprint_ruby_client/models/asset_result_set.rb +31 -4
- data/lib/blueprint_ruby_client/models/mixed_resource_result_set.rb +182 -0
- data/lib/blueprint_ruby_client/models/node.rb +1 -1
- data/lib/blueprint_ruby_client/models/node_result_set.rb +1 -1
- data/lib/blueprint_ruby_client/models/resource.rb +243 -0
- data/lib/blueprint_ruby_client/version.rb +1 -1
- data/spec/api/assets_api_spec.rb +2 -1
- data/spec/api/hierarchy_api_spec.rb +8 -7
- data/spec/models/asset_attributes_spec.rb +46 -0
- data/spec/models/asset_result_set_spec.rb +10 -0
- data/spec/models/asset_spec.rb +10 -0
- data/spec/models/mixed_resource_result_set_spec.rb +36 -0
- data/spec/models/resource_spec.rb +56 -0
- metadata +15 -3
- data/Gemfile.lock +0 -65
@@ -14,17 +14,22 @@ require 'date'
|
|
14
14
|
|
15
15
|
module BlueprintClient
|
16
16
|
class Asset
|
17
|
+
# the unique id of the resource of a given type.
|
17
18
|
attr_accessor :id
|
18
19
|
|
19
20
|
attr_accessor :type
|
20
21
|
|
22
|
+
attr_accessor :attributes
|
23
|
+
|
21
24
|
# Attribute mapping from ruby-style variable name to JSON key.
|
22
25
|
def self.attribute_map
|
23
26
|
{
|
24
27
|
|
25
28
|
:'id' => :'id',
|
26
29
|
|
27
|
-
:'type' => :'type'
|
30
|
+
:'type' => :'type',
|
31
|
+
|
32
|
+
:'attributes' => :'attributes'
|
28
33
|
|
29
34
|
}
|
30
35
|
end
|
@@ -35,7 +40,9 @@ module BlueprintClient
|
|
35
40
|
|
36
41
|
:'id' => :'String',
|
37
42
|
|
38
|
-
:'type' => :'String'
|
43
|
+
:'type' => :'String',
|
44
|
+
|
45
|
+
:'attributes' => :'Object'
|
39
46
|
|
40
47
|
}
|
41
48
|
end
|
@@ -67,6 +74,15 @@ module BlueprintClient
|
|
67
74
|
end
|
68
75
|
|
69
76
|
|
77
|
+
if attributes.has_key?(:'attributes')
|
78
|
+
|
79
|
+
|
80
|
+
self.attributes = attributes[:'attributes']
|
81
|
+
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
70
86
|
end
|
71
87
|
|
72
88
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -100,6 +116,10 @@ module BlueprintClient
|
|
100
116
|
|
101
117
|
|
102
118
|
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
103
123
|
end
|
104
124
|
|
105
125
|
|
@@ -113,13 +133,19 @@ module BlueprintClient
|
|
113
133
|
|
114
134
|
|
115
135
|
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
116
141
|
# Checks equality by comparing each attribute.
|
117
142
|
# @param [Object] Object to be compared
|
118
143
|
def ==(o)
|
119
144
|
return true if self.equal?(o)
|
120
145
|
self.class == o.class &&
|
121
146
|
id == o.id &&
|
122
|
-
type == o.type
|
147
|
+
type == o.type &&
|
148
|
+
attributes == o.attributes
|
123
149
|
end
|
124
150
|
|
125
151
|
# @see the `==` method
|
@@ -131,7 +157,7 @@ module BlueprintClient
|
|
131
157
|
# Calculates hash code according to all attributes.
|
132
158
|
# @return [Fixnum] Hash code
|
133
159
|
def hash
|
134
|
-
[id, type].hash
|
160
|
+
[id, type, attributes].hash
|
135
161
|
end
|
136
162
|
|
137
163
|
# Builds the object from hash
|
@@ -0,0 +1,207 @@
|
|
1
|
+
=begin
|
2
|
+
Talis Blueprint API
|
3
|
+
|
4
|
+
This is the API documentation for [Blueprint](https://github.com/talis/blueprint-server), a primitive for institutional structure and time periods
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module BlueprintClient
|
16
|
+
class AssetAttributes
|
17
|
+
attr_accessor :attributes
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
|
23
|
+
:'attributes' => :'attributes'
|
24
|
+
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.swagger_types
|
30
|
+
{
|
31
|
+
|
32
|
+
:'attributes' => :'Object'
|
33
|
+
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# Initializes the object
|
38
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
39
|
+
def initialize(attributes = {})
|
40
|
+
return unless attributes.is_a?(Hash)
|
41
|
+
|
42
|
+
# convert string to symbol for hash key
|
43
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
44
|
+
|
45
|
+
|
46
|
+
if attributes.has_key?(:'attributes')
|
47
|
+
|
48
|
+
|
49
|
+
self.attributes = attributes[:'attributes']
|
50
|
+
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
58
|
+
# @return Array for valid properies with the reasons
|
59
|
+
def list_invalid_properties
|
60
|
+
invalid_properties = Array.new
|
61
|
+
|
62
|
+
|
63
|
+
return invalid_properties
|
64
|
+
end
|
65
|
+
|
66
|
+
# Check to see if the all the properties in the model are valid
|
67
|
+
# @return true if the model is valid
|
68
|
+
def valid?
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
# Checks equality by comparing each attribute.
|
83
|
+
# @param [Object] Object to be compared
|
84
|
+
def ==(o)
|
85
|
+
return true if self.equal?(o)
|
86
|
+
self.class == o.class &&
|
87
|
+
attributes == o.attributes
|
88
|
+
end
|
89
|
+
|
90
|
+
# @see the `==` method
|
91
|
+
# @param [Object] Object to be compared
|
92
|
+
def eql?(o)
|
93
|
+
self == o
|
94
|
+
end
|
95
|
+
|
96
|
+
# Calculates hash code according to all attributes.
|
97
|
+
# @return [Fixnum] Hash code
|
98
|
+
def hash
|
99
|
+
[attributes].hash
|
100
|
+
end
|
101
|
+
|
102
|
+
# Builds the object from hash
|
103
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
104
|
+
# @return [Object] Returns the model itself
|
105
|
+
def build_from_hash(attributes)
|
106
|
+
return nil unless attributes.is_a?(Hash)
|
107
|
+
self.class.swagger_types.each_pair do |key, type|
|
108
|
+
if type =~ /^Array<(.*)>/i
|
109
|
+
# check to ensure the input is an array given that the the attribute
|
110
|
+
# is documented as an array but the input is not
|
111
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
112
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
113
|
+
end
|
114
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
115
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
116
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
117
|
+
end
|
118
|
+
|
119
|
+
self
|
120
|
+
end
|
121
|
+
|
122
|
+
# Deserializes the data based on type
|
123
|
+
# @param string type Data type
|
124
|
+
# @param string value Value to be deserialized
|
125
|
+
# @return [Object] Deserialized data
|
126
|
+
def _deserialize(type, value)
|
127
|
+
case type.to_sym
|
128
|
+
when :DateTime
|
129
|
+
DateTime.parse(value)
|
130
|
+
when :Date
|
131
|
+
Date.parse(value)
|
132
|
+
when :String
|
133
|
+
value.to_s
|
134
|
+
when :Integer
|
135
|
+
value.to_i
|
136
|
+
when :Float
|
137
|
+
value.to_f
|
138
|
+
when :BOOLEAN
|
139
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
140
|
+
true
|
141
|
+
else
|
142
|
+
false
|
143
|
+
end
|
144
|
+
when :Object
|
145
|
+
# generic object (usually a Hash), return directly
|
146
|
+
value
|
147
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
148
|
+
inner_type = Regexp.last_match[:inner_type]
|
149
|
+
value.map { |v| _deserialize(inner_type, v) }
|
150
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
151
|
+
k_type = Regexp.last_match[:k_type]
|
152
|
+
v_type = Regexp.last_match[:v_type]
|
153
|
+
{}.tap do |hash|
|
154
|
+
value.each do |k, v|
|
155
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
else # model
|
159
|
+
temp_model = BlueprintClient.const_get(type).new
|
160
|
+
temp_model.build_from_hash(value)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# Returns the string representation of the object
|
165
|
+
# @return [String] String presentation of the object
|
166
|
+
def to_s
|
167
|
+
to_hash.to_s
|
168
|
+
end
|
169
|
+
|
170
|
+
# to_body is an alias to to_hash (backward compatibility)
|
171
|
+
# @return [Hash] Returns the object in the form of hash
|
172
|
+
def to_body
|
173
|
+
to_hash
|
174
|
+
end
|
175
|
+
|
176
|
+
# Returns the object in the form of hash
|
177
|
+
# @return [Hash] Returns the object in the form of hash
|
178
|
+
def to_hash
|
179
|
+
hash = {}
|
180
|
+
self.class.attribute_map.each_pair do |attr, param|
|
181
|
+
value = self.send(attr)
|
182
|
+
next if value.nil?
|
183
|
+
hash[param] = _to_hash(value)
|
184
|
+
end
|
185
|
+
hash
|
186
|
+
end
|
187
|
+
|
188
|
+
# Outputs non-array value in the form of hash
|
189
|
+
# For object, use to_hash. Otherwise, just return the value
|
190
|
+
# @param [Object] value Any valid value
|
191
|
+
# @return [Hash] Returns the value in the form of hash
|
192
|
+
def _to_hash(value)
|
193
|
+
if value.is_a?(Array)
|
194
|
+
value.compact.map{ |v| _to_hash(v) }
|
195
|
+
elsif value.is_a?(Hash)
|
196
|
+
{}.tap do |hash|
|
197
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
198
|
+
end
|
199
|
+
elsif value.respond_to? :to_hash
|
200
|
+
value.to_hash
|
201
|
+
else
|
202
|
+
value
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
end
|
207
|
+
end
|
@@ -18,13 +18,17 @@ module BlueprintClient
|
|
18
18
|
|
19
19
|
attr_accessor :data
|
20
20
|
|
21
|
+
attr_accessor :included
|
22
|
+
|
21
23
|
# Attribute mapping from ruby-style variable name to JSON key.
|
22
24
|
def self.attribute_map
|
23
25
|
{
|
24
26
|
|
25
27
|
:'meta' => :'meta',
|
26
28
|
|
27
|
-
:'data' => :'data'
|
29
|
+
:'data' => :'data',
|
30
|
+
|
31
|
+
:'included' => :'included'
|
28
32
|
|
29
33
|
}
|
30
34
|
end
|
@@ -35,7 +39,9 @@ module BlueprintClient
|
|
35
39
|
|
36
40
|
:'meta' => :'Meta',
|
37
41
|
|
38
|
-
:'data' => :'Array<Asset>'
|
42
|
+
:'data' => :'Array<Asset>',
|
43
|
+
|
44
|
+
:'included' => :'Array<MixedResourceResultSet>'
|
39
45
|
|
40
46
|
}
|
41
47
|
end
|
@@ -69,6 +75,17 @@ module BlueprintClient
|
|
69
75
|
end
|
70
76
|
|
71
77
|
|
78
|
+
if attributes.has_key?(:'included')
|
79
|
+
|
80
|
+
if (value = attributes[:'included']).is_a?(Array)
|
81
|
+
self.included = value
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
|
72
89
|
end
|
73
90
|
|
74
91
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -92,6 +109,10 @@ module BlueprintClient
|
|
92
109
|
|
93
110
|
|
94
111
|
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
95
116
|
end
|
96
117
|
|
97
118
|
|
@@ -105,13 +126,19 @@ module BlueprintClient
|
|
105
126
|
|
106
127
|
|
107
128
|
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
108
134
|
# Checks equality by comparing each attribute.
|
109
135
|
# @param [Object] Object to be compared
|
110
136
|
def ==(o)
|
111
137
|
return true if self.equal?(o)
|
112
138
|
self.class == o.class &&
|
113
139
|
meta == o.meta &&
|
114
|
-
data == o.data
|
140
|
+
data == o.data &&
|
141
|
+
included == o.included
|
115
142
|
end
|
116
143
|
|
117
144
|
# @see the `==` method
|
@@ -123,7 +150,7 @@ module BlueprintClient
|
|
123
150
|
# Calculates hash code according to all attributes.
|
124
151
|
# @return [Fixnum] Hash code
|
125
152
|
def hash
|
126
|
-
[meta, data].hash
|
153
|
+
[meta, data, included].hash
|
127
154
|
end
|
128
155
|
|
129
156
|
# Builds the object from hash
|
@@ -0,0 +1,182 @@
|
|
1
|
+
=begin
|
2
|
+
Talis Blueprint API
|
3
|
+
|
4
|
+
This is the API documentation for [Blueprint](https://github.com/talis/blueprint-server), a primitive for institutional structure and time periods
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module BlueprintClient
|
16
|
+
class MixedResourceResultSet
|
17
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
18
|
+
def self.attribute_map
|
19
|
+
{
|
20
|
+
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
# Attribute type mapping.
|
25
|
+
def self.swagger_types
|
26
|
+
{
|
27
|
+
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Initializes the object
|
32
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
33
|
+
def initialize(attributes = {})
|
34
|
+
return unless attributes.is_a?(Hash)
|
35
|
+
|
36
|
+
# convert string to symbol for hash key
|
37
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
38
|
+
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
43
|
+
# @return Array for valid properies with the reasons
|
44
|
+
def list_invalid_properties
|
45
|
+
invalid_properties = Array.new
|
46
|
+
|
47
|
+
|
48
|
+
return invalid_properties
|
49
|
+
end
|
50
|
+
|
51
|
+
# Check to see if the all the properties in the model are valid
|
52
|
+
# @return true if the model is valid
|
53
|
+
def valid?
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
# Checks equality by comparing each attribute.
|
59
|
+
# @param [Object] Object to be compared
|
60
|
+
def ==(o)
|
61
|
+
return true if self.equal?(o)
|
62
|
+
self.class == o.class
|
63
|
+
end
|
64
|
+
|
65
|
+
# @see the `==` method
|
66
|
+
# @param [Object] Object to be compared
|
67
|
+
def eql?(o)
|
68
|
+
self == o
|
69
|
+
end
|
70
|
+
|
71
|
+
# Calculates hash code according to all attributes.
|
72
|
+
# @return [Fixnum] Hash code
|
73
|
+
def hash
|
74
|
+
[].hash
|
75
|
+
end
|
76
|
+
|
77
|
+
# Builds the object from hash
|
78
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
79
|
+
# @return [Object] Returns the model itself
|
80
|
+
def build_from_hash(attributes)
|
81
|
+
return nil unless attributes.is_a?(Hash)
|
82
|
+
self.class.swagger_types.each_pair do |key, type|
|
83
|
+
if type =~ /^Array<(.*)>/i
|
84
|
+
# check to ensure the input is an array given that the the attribute
|
85
|
+
# is documented as an array but the input is not
|
86
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
87
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
88
|
+
end
|
89
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
90
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
91
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
92
|
+
end
|
93
|
+
|
94
|
+
self
|
95
|
+
end
|
96
|
+
|
97
|
+
# Deserializes the data based on type
|
98
|
+
# @param string type Data type
|
99
|
+
# @param string value Value to be deserialized
|
100
|
+
# @return [Object] Deserialized data
|
101
|
+
def _deserialize(type, value)
|
102
|
+
case type.to_sym
|
103
|
+
when :DateTime
|
104
|
+
DateTime.parse(value)
|
105
|
+
when :Date
|
106
|
+
Date.parse(value)
|
107
|
+
when :String
|
108
|
+
value.to_s
|
109
|
+
when :Integer
|
110
|
+
value.to_i
|
111
|
+
when :Float
|
112
|
+
value.to_f
|
113
|
+
when :BOOLEAN
|
114
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
115
|
+
true
|
116
|
+
else
|
117
|
+
false
|
118
|
+
end
|
119
|
+
when :Object
|
120
|
+
# generic object (usually a Hash), return directly
|
121
|
+
value
|
122
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
123
|
+
inner_type = Regexp.last_match[:inner_type]
|
124
|
+
value.map { |v| _deserialize(inner_type, v) }
|
125
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
126
|
+
k_type = Regexp.last_match[:k_type]
|
127
|
+
v_type = Regexp.last_match[:v_type]
|
128
|
+
{}.tap do |hash|
|
129
|
+
value.each do |k, v|
|
130
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
else # model
|
134
|
+
temp_model = BlueprintClient.const_get(type).new
|
135
|
+
temp_model.build_from_hash(value)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# Returns the string representation of the object
|
140
|
+
# @return [String] String presentation of the object
|
141
|
+
def to_s
|
142
|
+
to_hash.to_s
|
143
|
+
end
|
144
|
+
|
145
|
+
# to_body is an alias to to_hash (backward compatibility)
|
146
|
+
# @return [Hash] Returns the object in the form of hash
|
147
|
+
def to_body
|
148
|
+
to_hash
|
149
|
+
end
|
150
|
+
|
151
|
+
# Returns the object in the form of hash
|
152
|
+
# @return [Hash] Returns the object in the form of hash
|
153
|
+
def to_hash
|
154
|
+
hash = {}
|
155
|
+
self.class.attribute_map.each_pair do |attr, param|
|
156
|
+
value = self.send(attr)
|
157
|
+
next if value.nil?
|
158
|
+
hash[param] = _to_hash(value)
|
159
|
+
end
|
160
|
+
hash
|
161
|
+
end
|
162
|
+
|
163
|
+
# Outputs non-array value in the form of hash
|
164
|
+
# For object, use to_hash. Otherwise, just return the value
|
165
|
+
# @param [Object] value Any valid value
|
166
|
+
# @return [Hash] Returns the value in the form of hash
|
167
|
+
def _to_hash(value)
|
168
|
+
if value.is_a?(Array)
|
169
|
+
value.compact.map{ |v| _to_hash(v) }
|
170
|
+
elsif value.is_a?(Hash)
|
171
|
+
{}.tap do |hash|
|
172
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
173
|
+
end
|
174
|
+
elsif value.respond_to? :to_hash
|
175
|
+
value.to_hash
|
176
|
+
else
|
177
|
+
value
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
end
|