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
@@ -0,0 +1,243 @@
|
|
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 Resource
|
17
|
+
# the unique id of the resource of a given type.
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
attr_accessor :type
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
|
26
|
+
:'id' => :'id',
|
27
|
+
|
28
|
+
:'type' => :'type'
|
29
|
+
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Attribute type mapping.
|
34
|
+
def self.swagger_types
|
35
|
+
{
|
36
|
+
|
37
|
+
:'id' => :'String',
|
38
|
+
|
39
|
+
:'type' => :'String'
|
40
|
+
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
# Initializes the object
|
45
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
46
|
+
def initialize(attributes = {})
|
47
|
+
return unless attributes.is_a?(Hash)
|
48
|
+
|
49
|
+
# convert string to symbol for hash key
|
50
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
51
|
+
|
52
|
+
|
53
|
+
if attributes.has_key?(:'id')
|
54
|
+
|
55
|
+
|
56
|
+
self.id = attributes[:'id']
|
57
|
+
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
if attributes.has_key?(:'type')
|
63
|
+
|
64
|
+
|
65
|
+
self.type = attributes[:'type']
|
66
|
+
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
74
|
+
# @return Array for valid properies with the reasons
|
75
|
+
def list_invalid_properties
|
76
|
+
invalid_properties = Array.new
|
77
|
+
|
78
|
+
|
79
|
+
return invalid_properties
|
80
|
+
end
|
81
|
+
|
82
|
+
# Check to see if the all the properties in the model are valid
|
83
|
+
# @return true if the model is valid
|
84
|
+
def valid?
|
85
|
+
|
86
|
+
|
87
|
+
if @id.nil?
|
88
|
+
return false
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
if @type.nil?
|
97
|
+
return false
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
# Checks equality by comparing each attribute.
|
118
|
+
# @param [Object] Object to be compared
|
119
|
+
def ==(o)
|
120
|
+
return true if self.equal?(o)
|
121
|
+
self.class == o.class &&
|
122
|
+
id == o.id &&
|
123
|
+
type == o.type
|
124
|
+
end
|
125
|
+
|
126
|
+
# @see the `==` method
|
127
|
+
# @param [Object] Object to be compared
|
128
|
+
def eql?(o)
|
129
|
+
self == o
|
130
|
+
end
|
131
|
+
|
132
|
+
# Calculates hash code according to all attributes.
|
133
|
+
# @return [Fixnum] Hash code
|
134
|
+
def hash
|
135
|
+
[id, type].hash
|
136
|
+
end
|
137
|
+
|
138
|
+
# Builds the object from hash
|
139
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
140
|
+
# @return [Object] Returns the model itself
|
141
|
+
def build_from_hash(attributes)
|
142
|
+
return nil unless attributes.is_a?(Hash)
|
143
|
+
self.class.swagger_types.each_pair do |key, type|
|
144
|
+
if type =~ /^Array<(.*)>/i
|
145
|
+
# check to ensure the input is an array given that the the attribute
|
146
|
+
# is documented as an array but the input is not
|
147
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
148
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
149
|
+
end
|
150
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
151
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
152
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
153
|
+
end
|
154
|
+
|
155
|
+
self
|
156
|
+
end
|
157
|
+
|
158
|
+
# Deserializes the data based on type
|
159
|
+
# @param string type Data type
|
160
|
+
# @param string value Value to be deserialized
|
161
|
+
# @return [Object] Deserialized data
|
162
|
+
def _deserialize(type, value)
|
163
|
+
case type.to_sym
|
164
|
+
when :DateTime
|
165
|
+
DateTime.parse(value)
|
166
|
+
when :Date
|
167
|
+
Date.parse(value)
|
168
|
+
when :String
|
169
|
+
value.to_s
|
170
|
+
when :Integer
|
171
|
+
value.to_i
|
172
|
+
when :Float
|
173
|
+
value.to_f
|
174
|
+
when :BOOLEAN
|
175
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
176
|
+
true
|
177
|
+
else
|
178
|
+
false
|
179
|
+
end
|
180
|
+
when :Object
|
181
|
+
# generic object (usually a Hash), return directly
|
182
|
+
value
|
183
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
184
|
+
inner_type = Regexp.last_match[:inner_type]
|
185
|
+
value.map { |v| _deserialize(inner_type, v) }
|
186
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
187
|
+
k_type = Regexp.last_match[:k_type]
|
188
|
+
v_type = Regexp.last_match[:v_type]
|
189
|
+
{}.tap do |hash|
|
190
|
+
value.each do |k, v|
|
191
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
else # model
|
195
|
+
temp_model = BlueprintClient.const_get(type).new
|
196
|
+
temp_model.build_from_hash(value)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
# Returns the string representation of the object
|
201
|
+
# @return [String] String presentation of the object
|
202
|
+
def to_s
|
203
|
+
to_hash.to_s
|
204
|
+
end
|
205
|
+
|
206
|
+
# to_body is an alias to to_hash (backward compatibility)
|
207
|
+
# @return [Hash] Returns the object in the form of hash
|
208
|
+
def to_body
|
209
|
+
to_hash
|
210
|
+
end
|
211
|
+
|
212
|
+
# Returns the object in the form of hash
|
213
|
+
# @return [Hash] Returns the object in the form of hash
|
214
|
+
def to_hash
|
215
|
+
hash = {}
|
216
|
+
self.class.attribute_map.each_pair do |attr, param|
|
217
|
+
value = self.send(attr)
|
218
|
+
next if value.nil?
|
219
|
+
hash[param] = _to_hash(value)
|
220
|
+
end
|
221
|
+
hash
|
222
|
+
end
|
223
|
+
|
224
|
+
# Outputs non-array value in the form of hash
|
225
|
+
# For object, use to_hash. Otherwise, just return the value
|
226
|
+
# @param [Object] value Any valid value
|
227
|
+
# @return [Hash] Returns the value in the form of hash
|
228
|
+
def _to_hash(value)
|
229
|
+
if value.is_a?(Array)
|
230
|
+
value.compact.map{ |v| _to_hash(v) }
|
231
|
+
elsif value.is_a?(Hash)
|
232
|
+
{}.tap do |hash|
|
233
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
234
|
+
end
|
235
|
+
elsif value.respond_to? :to_hash
|
236
|
+
value.to_hash
|
237
|
+
else
|
238
|
+
value
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
end
|
data/spec/api/assets_api_spec.rb
CHANGED
@@ -95,7 +95,7 @@ describe 'AssetsApi' do
|
|
95
95
|
# @param type Plural form of node type (adds an 's' to the end of the type) todo - allow configuration of plurals
|
96
96
|
# @param id id identifying a domain model
|
97
97
|
# @param [Hash] opts the optional parameters
|
98
|
-
# @option opts [String] :filter_asset_type type of asset to return
|
98
|
+
# @option opts [Array<String>] :filter_asset_type type of asset to return
|
99
99
|
# @option opts [Float] :offset index to start result set from
|
100
100
|
# @option opts [Float] :limit number of records to return
|
101
101
|
# @return [AssetResultSet]
|
@@ -136,6 +136,7 @@ describe 'AssetsApi' do
|
|
136
136
|
# @param asset_id id of an asset
|
137
137
|
# @param asset_type Plural form of asset type (adds an 's' to the end of the type) todo - allow configuration of plurals
|
138
138
|
# @param [Hash] opts the optional parameters
|
139
|
+
# @option opts [AssetBody] :body asset
|
139
140
|
# @return [AssetBody]
|
140
141
|
describe 'replace_asset test' do
|
141
142
|
it "should work" do
|
@@ -166,7 +166,7 @@ describe 'HierarchyApi' do
|
|
166
166
|
# @param id id identifying a domain model
|
167
167
|
# @param type Plural form of node type (adds an 's' to the end of the type) todo - allow configuration of plurals
|
168
168
|
# @param [Hash] opts the optional parameters
|
169
|
-
# @option opts [String] :
|
169
|
+
# @option opts [Array<String>] :include comma separated list of elements to hydrate. Can include children, parents, and/or assets
|
170
170
|
# @return [NodeBody]
|
171
171
|
describe 'get_node test' do
|
172
172
|
it "should work" do
|
@@ -224,13 +224,14 @@ describe 'HierarchyApi' do
|
|
224
224
|
# @param [Hash] opts the optional parameters
|
225
225
|
# @option opts [Float] :offset index to start result set from
|
226
226
|
# @option opts [Float] :limit number of records to return
|
227
|
-
# @option opts [String] :
|
228
|
-
# @option opts [String] :
|
229
|
-
# @option opts [String] :
|
230
|
-
# @option opts [String] :
|
231
|
-
# @option opts [String] :
|
227
|
+
# @option opts [Array<String>] :include comma separated list of elements to hydrate. Can include children, parents, and/or assets
|
228
|
+
# @option opts [Array<String>] :filter_node_type type of nodes to return
|
229
|
+
# @option opts [Array<String>] :filter_child limit to nodes with children matching type/code
|
230
|
+
# @option opts [Array<String>] :filter_parent limit to nodes with parent matching type/code
|
231
|
+
# @option opts [Array<String>] :filter_ancestor limit to nodes with ancestor matching type/code
|
232
|
+
# @option opts [Array<String>] :filter_descendant limit to nodes with descendant matching type/code
|
232
233
|
# @option opts [BOOLEAN] :filter_has_assets limit to either nodes that have assets (true) nodes that have no assets (false) or omit to consider both nodes with and without assets
|
233
|
-
# @option opts [String] :filter_asset_type type of asset to return
|
234
|
+
# @option opts [Array<String>] :filter_asset_type type of asset to return
|
234
235
|
# @option opts [Date] :filter_from limit to results valid after this date, format is ISO8601 date
|
235
236
|
# @option opts [Date] :filter_to limit to results valid before this date, format is ISO8601
|
236
237
|
# @return [NodeResultSet]
|
@@ -0,0 +1,46 @@
|
|
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 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
require 'date'
|
16
|
+
|
17
|
+
# Unit tests for BlueprintClient::AssetAttributes
|
18
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
19
|
+
# Please update as you see appropriate
|
20
|
+
describe 'AssetAttributes' do
|
21
|
+
before do
|
22
|
+
# run before each test
|
23
|
+
@instance = BlueprintClient::AssetAttributes.new
|
24
|
+
end
|
25
|
+
|
26
|
+
after do
|
27
|
+
# run after each test
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'test an instance of AssetAttributes' do
|
31
|
+
it 'should create an instact of AssetAttributes' do
|
32
|
+
@instance.should be_a(BlueprintClient::AssetAttributes)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
describe 'test attribute "attributes"' do
|
36
|
+
it 'should work' do
|
37
|
+
# assertion here
|
38
|
+
# should be_a()
|
39
|
+
# should be_nil
|
40
|
+
# should ==
|
41
|
+
# should_not ==
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
data/spec/models/asset_spec.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
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 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
require 'date'
|
16
|
+
|
17
|
+
# Unit tests for BlueprintClient::MixedResourceResultSet
|
18
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
19
|
+
# Please update as you see appropriate
|
20
|
+
describe 'MixedResourceResultSet' do
|
21
|
+
before do
|
22
|
+
# run before each test
|
23
|
+
@instance = BlueprintClient::MixedResourceResultSet.new
|
24
|
+
end
|
25
|
+
|
26
|
+
after do
|
27
|
+
# run after each test
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'test an instance of MixedResourceResultSet' do
|
31
|
+
it 'should create an instact of MixedResourceResultSet' do
|
32
|
+
@instance.should be_a(BlueprintClient::MixedResourceResultSet)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,56 @@
|
|
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 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
require 'date'
|
16
|
+
|
17
|
+
# Unit tests for BlueprintClient::Resource
|
18
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
19
|
+
# Please update as you see appropriate
|
20
|
+
describe 'Resource' do
|
21
|
+
before do
|
22
|
+
# run before each test
|
23
|
+
@instance = BlueprintClient::Resource.new
|
24
|
+
end
|
25
|
+
|
26
|
+
after do
|
27
|
+
# run after each test
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'test an instance of Resource' do
|
31
|
+
it 'should create an instact of Resource' do
|
32
|
+
@instance.should be_a(BlueprintClient::Resource)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
describe 'test attribute "id"' do
|
36
|
+
it 'should work' do
|
37
|
+
# assertion here
|
38
|
+
# should be_a()
|
39
|
+
# should be_nil
|
40
|
+
# should ==
|
41
|
+
# should_not ==
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'test attribute "type"' do
|
46
|
+
it 'should work' do
|
47
|
+
# assertion here
|
48
|
+
# should be_a()
|
49
|
+
# should be_nil
|
50
|
+
# should ==
|
51
|
+
# should_not ==
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|