webapi-active-query-builder 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/LICENSE +201 -0
  2. data/README.md +55 -0
  3. data/docs/ActiveQueryBuilderApi.md +102 -0
  4. data/docs/Condition.md +10 -0
  5. data/docs/ConditionGroup.md +10 -0
  6. data/docs/HiddenColumn.md +8 -0
  7. data/docs/Pagination.md +9 -0
  8. data/docs/QueryColumn.md +9 -0
  9. data/docs/Sorting.md +9 -0
  10. data/docs/SqlQuery.md +9 -0
  11. data/docs/Totals.md +9 -0
  12. data/docs/Transform.md +14 -0
  13. data/docs/TransformResult.md +10 -0
  14. data/git_push.sh +67 -0
  15. data/lib/webapi-active-query-builder.rb +61 -0
  16. data/lib/webapi-active-query-builder/api/active_query_builder_api.rb +148 -0
  17. data/lib/webapi-active-query-builder/api_client.rb +378 -0
  18. data/lib/webapi-active-query-builder/api_error.rb +47 -0
  19. data/lib/webapi-active-query-builder/configuration.rb +207 -0
  20. data/lib/webapi-active-query-builder/models/condition.rb +255 -0
  21. data/lib/webapi-active-query-builder/models/condition_group.rb +257 -0
  22. data/lib/webapi-active-query-builder/models/hidden_column.rb +200 -0
  23. data/lib/webapi-active-query-builder/models/pagination.rb +210 -0
  24. data/lib/webapi-active-query-builder/models/query_column.rb +210 -0
  25. data/lib/webapi-active-query-builder/models/sorting.rb +243 -0
  26. data/lib/webapi-active-query-builder/models/sql_query.rb +210 -0
  27. data/lib/webapi-active-query-builder/models/totals.rb +243 -0
  28. data/lib/webapi-active-query-builder/models/transform.rb +261 -0
  29. data/lib/webapi-active-query-builder/models/transform_result.rb +220 -0
  30. data/lib/webapi-active-query-builder/version.rb +26 -0
  31. data/spec/api/active_query_builder_api_spec.rb +70 -0
  32. data/spec/api_client_spec.rb +237 -0
  33. data/spec/configuration_spec.rb +53 -0
  34. data/spec/models/condition_group_spec.rb +69 -0
  35. data/spec/models/condition_spec.rb +69 -0
  36. data/spec/models/hidden_column_spec.rb +53 -0
  37. data/spec/models/pagination_spec.rb +59 -0
  38. data/spec/models/query_column_spec.rb +59 -0
  39. data/spec/models/sorting_spec.rb +63 -0
  40. data/spec/models/sql_query_spec.rb +59 -0
  41. data/spec/models/totals_spec.rb +63 -0
  42. data/spec/models/transform_result_spec.rb +65 -0
  43. data/spec/models/transform_spec.rb +89 -0
  44. data/spec/spec_helper.rb +122 -0
  45. data/webapi-active-query-builder.gemspec +55 -0
  46. metadata +307 -0
@@ -0,0 +1,261 @@
1
+ =begin
2
+ #QueryBuilderApi
3
+
4
+ #Active Query Builder Web API lets create, analyze and modify SQL queries for different database servers using RESTful HTTP requests to a cloud-based service. It requires SQL execution context (information about database schema and used database server) to be stored under the registered account at https://webapi.activequerybuilder.com/.
5
+
6
+ OpenAPI spec version: 1.1.3
7
+ Contact: support@activedbsoft.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module WebApiActivequerybuilder
27
+ # SQL transformation parameters and commands.
28
+ class Transform
29
+ # Unique identifier that defines SQL execution context for the given query, i.e. database server (SQL syntax rules), database schema. The context itself must be saved in the user account on https://webapi.activequerybuilder.com/.
30
+ attr_accessor :guid
31
+
32
+ # Text of original SQL query to be transformed.
33
+ attr_accessor :sql
34
+
35
+ attr_accessor :pagination
36
+
37
+ attr_accessor :totals
38
+
39
+ attr_accessor :sortings
40
+
41
+ attr_accessor :filter
42
+
43
+ attr_accessor :hidden_columns
44
+
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'guid' => :'Guid',
50
+ :'sql' => :'Sql',
51
+ :'pagination' => :'Pagination',
52
+ :'totals' => :'Totals',
53
+ :'sortings' => :'Sortings',
54
+ :'filter' => :'Filter',
55
+ :'hidden_columns' => :'HiddenColumns'
56
+ }
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.swagger_types
61
+ {
62
+ :'guid' => :'String',
63
+ :'sql' => :'String',
64
+ :'pagination' => :'Pagination',
65
+ :'totals' => :'Array<Totals>',
66
+ :'sortings' => :'Array<Sorting>',
67
+ :'filter' => :'ConditionGroup',
68
+ :'hidden_columns' => :'Array<HiddenColumn>'
69
+ }
70
+ end
71
+
72
+ # Initializes the object
73
+ # @param [Hash] attributes Model attributes in the form of hash
74
+ def initialize(attributes = {})
75
+ return unless attributes.is_a?(Hash)
76
+
77
+ # convert string to symbol for hash key
78
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
79
+
80
+ if attributes.has_key?(:'Guid')
81
+ self.guid = attributes[:'Guid']
82
+ end
83
+
84
+ if attributes.has_key?(:'Sql')
85
+ self.sql = attributes[:'Sql']
86
+ end
87
+
88
+ if attributes.has_key?(:'Pagination')
89
+ self.pagination = attributes[:'Pagination']
90
+ end
91
+
92
+ if attributes.has_key?(:'Totals')
93
+ if (value = attributes[:'Totals']).is_a?(Array)
94
+ self.totals = value
95
+ end
96
+ end
97
+
98
+ if attributes.has_key?(:'Sortings')
99
+ if (value = attributes[:'Sortings']).is_a?(Array)
100
+ self.sortings = value
101
+ end
102
+ end
103
+
104
+ if attributes.has_key?(:'Filter')
105
+ self.filter = attributes[:'Filter']
106
+ end
107
+
108
+ if attributes.has_key?(:'HiddenColumns')
109
+ if (value = attributes[:'HiddenColumns']).is_a?(Array)
110
+ self.hidden_columns = value
111
+ end
112
+ end
113
+
114
+ end
115
+
116
+ # Show invalid properties with the reasons. Usually used together with valid?
117
+ # @return Array for valid properies with the reasons
118
+ def list_invalid_properties
119
+ invalid_properties = Array.new
120
+ return invalid_properties
121
+ end
122
+
123
+ # Check to see if the all the properties in the model are valid
124
+ # @return true if the model is valid
125
+ def valid?
126
+ return true
127
+ end
128
+
129
+ # Checks equality by comparing each attribute.
130
+ # @param [Object] Object to be compared
131
+ def ==(o)
132
+ return true if self.equal?(o)
133
+ self.class == o.class &&
134
+ guid == o.guid &&
135
+ sql == o.sql &&
136
+ pagination == o.pagination &&
137
+ totals == o.totals &&
138
+ sortings == o.sortings &&
139
+ filter == o.filter &&
140
+ hidden_columns == o.hidden_columns
141
+ end
142
+
143
+ # @see the `==` method
144
+ # @param [Object] Object to be compared
145
+ def eql?(o)
146
+ self == o
147
+ end
148
+
149
+ # Calculates hash code according to all attributes.
150
+ # @return [Fixnum] Hash code
151
+ def hash
152
+ [guid, sql, pagination, totals, sortings, filter, hidden_columns].hash
153
+ end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def build_from_hash(attributes)
159
+ return nil unless attributes.is_a?(Hash)
160
+ self.class.swagger_types.each_pair do |key, type|
161
+ if type =~ /^Array<(.*)>/i
162
+ # check to ensure the input is an array given that the the attribute
163
+ # is documented as an array but the input is not
164
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
165
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
166
+ end
167
+ elsif !attributes[self.class.attribute_map[key]].nil?
168
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
169
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
170
+ end
171
+
172
+ self
173
+ end
174
+
175
+ # Deserializes the data based on type
176
+ # @param string type Data type
177
+ # @param string value Value to be deserialized
178
+ # @return [Object] Deserialized data
179
+ def _deserialize(type, value)
180
+ case type.to_sym
181
+ when :DateTime
182
+ DateTime.parse(value)
183
+ when :Date
184
+ Date.parse(value)
185
+ when :String
186
+ value.to_s
187
+ when :Integer
188
+ value.to_i
189
+ when :Float
190
+ value.to_f
191
+ when :BOOLEAN
192
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
193
+ true
194
+ else
195
+ false
196
+ end
197
+ when :Object
198
+ # generic object (usually a Hash), return directly
199
+ value
200
+ when /\AArray<(?<inner_type>.+)>\z/
201
+ inner_type = Regexp.last_match[:inner_type]
202
+ value.map { |v| _deserialize(inner_type, v) }
203
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
204
+ k_type = Regexp.last_match[:k_type]
205
+ v_type = Regexp.last_match[:v_type]
206
+ {}.tap do |hash|
207
+ value.each do |k, v|
208
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
209
+ end
210
+ end
211
+ else # model
212
+ temp_model = WebApiActivequerybuilder.const_get(type).new
213
+ temp_model.build_from_hash(value)
214
+ end
215
+ end
216
+
217
+ # Returns the string representation of the object
218
+ # @return [String] String presentation of the object
219
+ def to_s
220
+ to_hash.to_s
221
+ end
222
+
223
+ # to_body is an alias to to_hash (backward compatibility)
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_body
226
+ to_hash
227
+ end
228
+
229
+ # Returns the object in the form of hash
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_hash
232
+ hash = {}
233
+ self.class.attribute_map.each_pair do |attr, param|
234
+ value = self.send(attr)
235
+ next if value.nil?
236
+ hash[param] = _to_hash(value)
237
+ end
238
+ hash
239
+ end
240
+
241
+ # Outputs non-array value in the form of hash
242
+ # For object, use to_hash. Otherwise, just return the value
243
+ # @param [Object] value Any valid value
244
+ # @return [Hash] Returns the value in the form of hash
245
+ def _to_hash(value)
246
+ if value.is_a?(Array)
247
+ value.compact.map{ |v| _to_hash(v) }
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.each { |k, v| hash[k] = _to_hash(v) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash
254
+ else
255
+ value
256
+ end
257
+ end
258
+
259
+ end
260
+
261
+ end
@@ -0,0 +1,220 @@
1
+ =begin
2
+ #QueryBuilderApi
3
+
4
+ #Active Query Builder Web API lets create, analyze and modify SQL queries for different database servers using RESTful HTTP requests to a cloud-based service. It requires SQL execution context (information about database schema and used database server) to be stored under the registered account at https://webapi.activequerybuilder.com/.
5
+
6
+ OpenAPI spec version: 1.1.3
7
+ Contact: support@activedbsoft.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module WebApiActivequerybuilder
27
+ # Returns transformed SQL text in case of successful transformation. Otherwise returns error message.
28
+ class TransformResult
29
+ # Transformed SQL text.
30
+ attr_accessor :sql
31
+
32
+ # Transformed SQL text for totals.
33
+ attr_accessor :totals
34
+
35
+ # Error message text.
36
+ attr_accessor :error
37
+
38
+
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :'sql' => :'sql',
43
+ :'totals' => :'totals',
44
+ :'error' => :'error'
45
+ }
46
+ end
47
+
48
+ # Attribute type mapping.
49
+ def self.swagger_types
50
+ {
51
+ :'sql' => :'String',
52
+ :'totals' => :'String',
53
+ :'error' => :'String'
54
+ }
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ return unless attributes.is_a?(Hash)
61
+
62
+ # convert string to symbol for hash key
63
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
64
+
65
+ if attributes.has_key?(:'sql')
66
+ self.sql = attributes[:'sql']
67
+ end
68
+
69
+ if attributes.has_key?(:'totals')
70
+ self.totals = attributes[:'totals']
71
+ end
72
+
73
+ if attributes.has_key?(:'error')
74
+ self.error = attributes[:'error']
75
+ end
76
+
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properies with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ return invalid_properties
84
+ end
85
+
86
+ # Check to see if the all the properties in the model are valid
87
+ # @return true if the model is valid
88
+ def valid?
89
+ return true
90
+ end
91
+
92
+ # Checks equality by comparing each attribute.
93
+ # @param [Object] Object to be compared
94
+ def ==(o)
95
+ return true if self.equal?(o)
96
+ self.class == o.class &&
97
+ sql == o.sql &&
98
+ totals == o.totals &&
99
+ error == o.error
100
+ end
101
+
102
+ # @see the `==` method
103
+ # @param [Object] Object to be compared
104
+ def eql?(o)
105
+ self == o
106
+ end
107
+
108
+ # Calculates hash code according to all attributes.
109
+ # @return [Fixnum] Hash code
110
+ def hash
111
+ [sql, totals, error].hash
112
+ end
113
+
114
+ # Builds the object from hash
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ # @return [Object] Returns the model itself
117
+ def build_from_hash(attributes)
118
+ return nil unless attributes.is_a?(Hash)
119
+ self.class.swagger_types.each_pair do |key, type|
120
+ if type =~ /^Array<(.*)>/i
121
+ # check to ensure the input is an array given that the the attribute
122
+ # is documented as an array but the input is not
123
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
124
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
125
+ end
126
+ elsif !attributes[self.class.attribute_map[key]].nil?
127
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
128
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
129
+ end
130
+
131
+ self
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def _deserialize(type, value)
139
+ case type.to_sym
140
+ when :DateTime
141
+ DateTime.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :String
145
+ value.to_s
146
+ when :Integer
147
+ value.to_i
148
+ when :Float
149
+ value.to_f
150
+ when :BOOLEAN
151
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
152
+ true
153
+ else
154
+ false
155
+ end
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ else # model
171
+ temp_model = WebApiActivequerybuilder.const_get(type).new
172
+ temp_model.build_from_hash(value)
173
+ end
174
+ end
175
+
176
+ # Returns the string representation of the object
177
+ # @return [String] String presentation of the object
178
+ def to_s
179
+ to_hash.to_s
180
+ end
181
+
182
+ # to_body is an alias to to_hash (backward compatibility)
183
+ # @return [Hash] Returns the object in the form of hash
184
+ def to_body
185
+ to_hash
186
+ end
187
+
188
+ # Returns the object in the form of hash
189
+ # @return [Hash] Returns the object in the form of hash
190
+ def to_hash
191
+ hash = {}
192
+ self.class.attribute_map.each_pair do |attr, param|
193
+ value = self.send(attr)
194
+ next if value.nil?
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map{ |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to? :to_hash
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ end
219
+
220
+ end