apache_felix_webconsole_client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,49 @@
1
+ =begin
2
+ Apache Felix WebConsole
3
+
4
+ Client for Apache Felix Web Console API. List bundles, configure services, etc.
5
+
6
+ OpenAPI spec version: 4.3.0
7
+ Contact: bryan.stopp@gmail.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
+ module ApacheFelix
25
+ class ApiError < StandardError
26
+ attr_reader :code, :response_headers, :response_body
27
+
28
+ # Usage examples:
29
+ # ApiError.new
30
+ # ApiError.new("message")
31
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
32
+ # ApiError.new(:code => 404, :message => "Not Found")
33
+ def initialize(arg = nil)
34
+ if arg.is_a? Hash
35
+ if arg.key?(:message) || arg.key?('message')
36
+ super(arg[:message] || arg['message'])
37
+ else
38
+ super arg
39
+ end
40
+
41
+ arg.each do |k, v|
42
+ instance_variable_set "@#{k}", v
43
+ end
44
+ else
45
+ super arg
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,214 @@
1
+ =begin
2
+ Apache Felix WebConsole
3
+
4
+ Client for Apache Felix Web Console API. List bundles, configure services, etc.
5
+
6
+ OpenAPI spec version: 4.3.0
7
+ Contact: bryan.stopp@gmail.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 'uri'
25
+
26
+ module ApacheFelix
27
+ class Configuration
28
+ # Defines url scheme
29
+ attr_accessor :scheme
30
+
31
+ # Defines url host
32
+ attr_accessor :host
33
+
34
+ # Defines url base path
35
+ attr_accessor :base_path
36
+
37
+ # Defines API keys used with API Key authentications.
38
+ #
39
+ # @return [Hash] key: parameter name, value: parameter value (API key)
40
+ #
41
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
42
+ # config.api_key['api_key'] = 'xxx'
43
+ attr_accessor :api_key
44
+
45
+ # Defines API key prefixes used with API Key authentications.
46
+ #
47
+ # @return [Hash] key: parameter name, value: API key prefix
48
+ #
49
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
50
+ # config.api_key_prefix['api_key'] = 'Token'
51
+ attr_accessor :api_key_prefix
52
+
53
+ # Defines the username used with HTTP basic authentication.
54
+ #
55
+ # @return [String]
56
+ attr_accessor :username
57
+
58
+ # Defines the password used with HTTP basic authentication.
59
+ #
60
+ # @return [String]
61
+ attr_accessor :password
62
+
63
+ # Defines the access token (Bearer) used with OAuth2.
64
+ attr_accessor :access_token
65
+
66
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
67
+ # details will be logged with `logger.debug` (see the `logger` attribute).
68
+ # Default to false.
69
+ #
70
+ # @return [true, false]
71
+ attr_accessor :debugging
72
+
73
+ # Defines the logger used for debugging.
74
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
75
+ #
76
+ # @return [#debug]
77
+ attr_accessor :logger
78
+
79
+ # Defines the temporary folder to store downloaded files
80
+ # (for API endpoints that have file response).
81
+ # Default to use `Tempfile`.
82
+ #
83
+ # @return [String]
84
+ attr_accessor :temp_folder_path
85
+
86
+ # The time limit for HTTP request in seconds.
87
+ # Default to 0 (never times out).
88
+ attr_accessor :timeout
89
+
90
+ ### TLS/SSL setting
91
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
92
+ # Default to true.
93
+ #
94
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
95
+ #
96
+ # @return [true, false]
97
+ attr_accessor :verify_ssl
98
+
99
+ ### TLS/SSL setting
100
+ # Set this to false to skip verifying SSL host name
101
+ # Default to true.
102
+ #
103
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
104
+ #
105
+ # @return [true, false]
106
+ attr_accessor :verify_ssl_host
107
+
108
+ ### TLS/SSL setting
109
+ # Set this to customize the certificate file to verify the peer.
110
+ #
111
+ # @return [String] the path to the certificate file
112
+ #
113
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
114
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
115
+ attr_accessor :ssl_ca_cert
116
+
117
+ ### TLS/SSL setting
118
+ # Client certificate file (for client certificate)
119
+ attr_accessor :cert_file
120
+
121
+ ### TLS/SSL setting
122
+ # Client private key file (for client certificate)
123
+ attr_accessor :key_file
124
+
125
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
126
+ # Default to nil.
127
+ #
128
+ # @see The params_encoding option of Ethon. Related source code:
129
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
130
+ attr_accessor :params_encoding
131
+
132
+ attr_accessor :inject_format
133
+
134
+ attr_accessor :force_ending_format
135
+
136
+ def initialize
137
+ @scheme = 'http'
138
+ @host = 'localhost:8080'
139
+ @base_path = '/system/console'
140
+ @api_key = {}
141
+ @api_key_prefix = {}
142
+ @timeout = 0
143
+ @verify_ssl = true
144
+ @verify_ssl_host = true
145
+ @params_encoding = nil
146
+ @cert_file = nil
147
+ @key_file = nil
148
+ @debugging = false
149
+ @inject_format = false
150
+ @force_ending_format = false
151
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
152
+
153
+ yield(self) if block_given?
154
+ end
155
+
156
+ # The default Configuration object.
157
+ def self.default
158
+ @@default ||= Configuration.new
159
+ end
160
+
161
+ def configure
162
+ yield(self) if block_given?
163
+ end
164
+
165
+ def scheme=(scheme)
166
+ # remove :// from scheme
167
+ @scheme = scheme.sub(/:\/\//, '')
168
+ end
169
+
170
+ def host=(host)
171
+ # remove http(s):// and anything after a slash
172
+ @host = host.sub(/https?:\/\//, '').split('/').first
173
+ end
174
+
175
+ def base_path=(base_path)
176
+ # Add leading and trailing slashes to base_path
177
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
178
+ @base_path = "" if @base_path == "/"
179
+ end
180
+
181
+ def base_url
182
+ url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
183
+ URI.encode(url)
184
+ end
185
+
186
+ # Gets API key (with prefix if set).
187
+ # @param [String] param_name the parameter name of API key auth
188
+ def api_key_with_prefix(param_name)
189
+ if @api_key_prefix[param_name]
190
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
191
+ else
192
+ @api_key[param_name]
193
+ end
194
+ end
195
+
196
+ # Gets Basic Auth token string
197
+ def basic_auth_token
198
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
199
+ end
200
+
201
+ # Returns Auth Settings hash for api client.
202
+ def auth_settings
203
+ {
204
+ 'basic' =>
205
+ {
206
+ type: 'basic',
207
+ in: 'header',
208
+ key: 'Authorization',
209
+ value: basic_auth_token
210
+ },
211
+ }
212
+ end
213
+ end
214
+ end
@@ -0,0 +1,306 @@
1
+ =begin
2
+ Apache Felix WebConsole
3
+
4
+ Client for Apache Felix Web Console API. List bundles, configure services, etc.
5
+
6
+ OpenAPI spec version: 4.3.0
7
+ Contact: bryan.stopp@gmail.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 ApacheFelix
27
+
28
+ class Bundle
29
+ attr_accessor :id
30
+
31
+ attr_accessor :name
32
+
33
+ attr_accessor :fragment
34
+
35
+ attr_accessor :state_raw
36
+
37
+ attr_accessor :state
38
+
39
+ attr_accessor :version
40
+
41
+ attr_accessor :symbolic_name
42
+
43
+ attr_accessor :category
44
+
45
+ attr_accessor :props
46
+
47
+ class EnumAttributeValidator
48
+ attr_reader :datatype
49
+ attr_reader :allowable_values
50
+
51
+ def initialize(datatype, allowable_values)
52
+ @allowable_values = allowable_values.map do |value|
53
+ case datatype.to_s
54
+ when /Integer/i
55
+ value.to_i
56
+ when /Float/i
57
+ value.to_f
58
+ else
59
+ value
60
+ end
61
+ end
62
+ end
63
+
64
+ def valid?(value)
65
+ !value || allowable_values.include?(value)
66
+ end
67
+ end
68
+
69
+ # Attribute mapping from ruby-style variable name to JSON key.
70
+ def self.attribute_map
71
+ {
72
+ :'id' => :'id',
73
+ :'name' => :'name',
74
+ :'fragment' => :'fragment',
75
+ :'state_raw' => :'stateRaw',
76
+ :'state' => :'state',
77
+ :'version' => :'version',
78
+ :'symbolic_name' => :'symbolicName',
79
+ :'category' => :'category',
80
+ :'props' => :'props'
81
+ }
82
+ end
83
+
84
+ # Attribute type mapping.
85
+ def self.swagger_types
86
+ {
87
+ :'id' => :'Integer',
88
+ :'name' => :'String',
89
+ :'fragment' => :'BOOLEAN',
90
+ :'state_raw' => :'Integer',
91
+ :'state' => :'String',
92
+ :'version' => :'String',
93
+ :'symbolic_name' => :'String',
94
+ :'category' => :'String',
95
+ :'props' => :'Array<BundleProps>'
96
+ }
97
+ end
98
+
99
+ # Initializes the object
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ def initialize(attributes = {})
102
+ return unless attributes.is_a?(Hash)
103
+
104
+ # convert string to symbol for hash key
105
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
106
+
107
+ if attributes.has_key?(:'id')
108
+ self.id = attributes[:'id']
109
+ end
110
+
111
+ if attributes.has_key?(:'name')
112
+ self.name = attributes[:'name']
113
+ end
114
+
115
+ if attributes.has_key?(:'fragment')
116
+ self.fragment = attributes[:'fragment']
117
+ end
118
+
119
+ if attributes.has_key?(:'stateRaw')
120
+ self.state_raw = attributes[:'stateRaw']
121
+ end
122
+
123
+ if attributes.has_key?(:'state')
124
+ self.state = attributes[:'state']
125
+ end
126
+
127
+ if attributes.has_key?(:'version')
128
+ self.version = attributes[:'version']
129
+ end
130
+
131
+ if attributes.has_key?(:'symbolicName')
132
+ self.symbolic_name = attributes[:'symbolicName']
133
+ end
134
+
135
+ if attributes.has_key?(:'category')
136
+ self.category = attributes[:'category']
137
+ end
138
+
139
+ if attributes.has_key?(:'props')
140
+ if (value = attributes[:'props']).is_a?(Array)
141
+ self.props = value
142
+ end
143
+ end
144
+
145
+ end
146
+
147
+ # Show invalid properties with the reasons. Usually used together with valid?
148
+ # @return Array for valid properies with the reasons
149
+ def list_invalid_properties
150
+ invalid_properties = Array.new
151
+ return invalid_properties
152
+ end
153
+
154
+ # Check to see if the all the properties in the model are valid
155
+ # @return true if the model is valid
156
+ def valid?
157
+ state_validator = EnumAttributeValidator.new('String', ["Uninstalled", "Installed", "Resolved", "Starting", "Stopping", "Active", "Fragment"])
158
+ return false unless state_validator.valid?(@state)
159
+ return true
160
+ end
161
+
162
+ # Custom attribute writer method checking allowed values (enum).
163
+ # @param [Object] state Object to be assigned
164
+ def state=(state)
165
+ validator = EnumAttributeValidator.new('String', ["Uninstalled", "Installed", "Resolved", "Starting", "Stopping", "Active", "Fragment"])
166
+ unless validator.valid?(state)
167
+ fail ArgumentError, "invalid value for 'state', must be one of #{validator.allowable_values}."
168
+ end
169
+ @state = state
170
+ end
171
+
172
+ # Checks equality by comparing each attribute.
173
+ # @param [Object] Object to be compared
174
+ def ==(o)
175
+ return true if self.equal?(o)
176
+ self.class == o.class &&
177
+ id == o.id &&
178
+ name == o.name &&
179
+ fragment == o.fragment &&
180
+ state_raw == o.state_raw &&
181
+ state == o.state &&
182
+ version == o.version &&
183
+ symbolic_name == o.symbolic_name &&
184
+ category == o.category &&
185
+ props == o.props
186
+ end
187
+
188
+ # @see the `==` method
189
+ # @param [Object] Object to be compared
190
+ def eql?(o)
191
+ self == o
192
+ end
193
+
194
+ # Calculates hash code according to all attributes.
195
+ # @return [Fixnum] Hash code
196
+ def hash
197
+ [id, name, fragment, state_raw, state, version, symbolic_name, category, props].hash
198
+ end
199
+
200
+ # Builds the object from hash
201
+ # @param [Hash] attributes Model attributes in the form of hash
202
+ # @return [Object] Returns the model itself
203
+ def build_from_hash(attributes)
204
+ return nil unless attributes.is_a?(Hash)
205
+ self.class.swagger_types.each_pair do |key, type|
206
+ if type =~ /\AArray<(.*)>/i
207
+ # check to ensure the input is an array given that the the attribute
208
+ # is documented as an array but the input is not
209
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
210
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
211
+ end
212
+ elsif !attributes[self.class.attribute_map[key]].nil?
213
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
214
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
215
+ end
216
+
217
+ self
218
+ end
219
+
220
+ # Deserializes the data based on type
221
+ # @param string type Data type
222
+ # @param string value Value to be deserialized
223
+ # @return [Object] Deserialized data
224
+ def _deserialize(type, value)
225
+ case type.to_sym
226
+ when :DateTime
227
+ DateTime.parse(value)
228
+ when :Date
229
+ Date.parse(value)
230
+ when :String
231
+ value.to_s
232
+ when :Integer
233
+ value.to_i
234
+ when :Float
235
+ value.to_f
236
+ when :BOOLEAN
237
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
238
+ true
239
+ else
240
+ false
241
+ end
242
+ when :Object
243
+ # generic object (usually a Hash), return directly
244
+ value
245
+ when /\AArray<(?<inner_type>.+)>\z/
246
+ inner_type = Regexp.last_match[:inner_type]
247
+ value.map { |v| _deserialize(inner_type, v) }
248
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
249
+ k_type = Regexp.last_match[:k_type]
250
+ v_type = Regexp.last_match[:v_type]
251
+ {}.tap do |hash|
252
+ value.each do |k, v|
253
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
254
+ end
255
+ end
256
+ else # model
257
+ temp_model = ApacheFelix.const_get(type).new
258
+ temp_model.build_from_hash(value)
259
+ end
260
+ end
261
+
262
+ # Returns the string representation of the object
263
+ # @return [String] String presentation of the object
264
+ def to_s
265
+ to_hash.to_s
266
+ end
267
+
268
+ # to_body is an alias to to_hash (backward compatibility)
269
+ # @return [Hash] Returns the object in the form of hash
270
+ def to_body
271
+ to_hash
272
+ end
273
+
274
+ # Returns the object in the form of hash
275
+ # @return [Hash] Returns the object in the form of hash
276
+ def to_hash
277
+ hash = {}
278
+ self.class.attribute_map.each_pair do |attr, param|
279
+ value = self.send(attr)
280
+ next if value.nil?
281
+ hash[param] = _to_hash(value)
282
+ end
283
+ hash
284
+ end
285
+
286
+ # Outputs non-array value in the form of hash
287
+ # For object, use to_hash. Otherwise, just return the value
288
+ # @param [Object] value Any valid value
289
+ # @return [Hash] Returns the value in the form of hash
290
+ def _to_hash(value)
291
+ if value.is_a?(Array)
292
+ value.compact.map{ |v| _to_hash(v) }
293
+ elsif value.is_a?(Hash)
294
+ {}.tap do |hash|
295
+ value.each { |k, v| hash[k] = _to_hash(v) }
296
+ end
297
+ elsif value.respond_to? :to_hash
298
+ value.to_hash
299
+ else
300
+ value
301
+ end
302
+ end
303
+
304
+ end
305
+
306
+ end