apache_felix_webconsole_client 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -66,18 +66,10 @@ module ApacheFelix
66
66
  end
67
67
 
68
68
  unless response.success?
69
- if response.timed_out?
70
- fail ApiError.new('Connection timed out')
71
- elsif response.code == 0
72
- # Errors from libcurl will be made visible here
73
- fail ApiError.new(:code => 0,
74
- :message => response.return_message)
75
- else
76
- fail ApiError.new(:code => response.code,
77
- :response_headers => response.headers,
78
- :response_body => response.body),
79
- response.status_message
80
- end
69
+ fail ApiError.new(:code => response.code,
70
+ :response_headers => response.headers,
71
+ :response_body => response.body),
72
+ response.status_message
81
73
  end
82
74
 
83
75
  if opts[:return_type]
@@ -142,11 +134,10 @@ module ApacheFelix
142
134
  # application/json
143
135
  # application/json; charset=UTF8
144
136
  # APPLICATION/JSON
145
- # */*
146
137
  # @param [String] mime MIME
147
- # @return [Boolean] True if the MIME is application/json
138
+ # @return [Boolean] True if the MIME is applicaton/json
148
139
  def json_mime?(mime)
149
- (mime == "*/*") || !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil?
140
+ !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil?
150
141
  end
151
142
 
152
143
  # Deserialize the response to the given return type.
@@ -297,7 +288,7 @@ module ApacheFelix
297
288
  # Update hearder and query params based on authentication settings.
298
289
  #
299
290
  # @param [Hash] header_params Header parameters
300
- # @param [Hash] query_params Query parameters
291
+ # @param [Hash] form_params Query parameters
301
292
  # @param [String] auth_names Authentication scheme name
302
293
  def update_params_for_auth!(header_params, query_params, auth_names)
303
294
  Array(auth_names).each do |auth_name|
@@ -32,14 +32,12 @@ module ApacheFelix
32
32
  # ApiError.new(:code => 404, :message => "Not Found")
33
33
  def initialize(arg = nil)
34
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
35
  arg.each do |k, v|
42
- instance_variable_set "@#{k}", v
36
+ if k.to_s == 'message'
37
+ super v
38
+ else
39
+ instance_variable_set "@#{k}", v
40
+ end
43
41
  end
44
42
  else
45
43
  super arg
@@ -24,7 +24,7 @@ limitations under the License.
24
24
  require 'date'
25
25
 
26
26
  module ApacheFelix
27
-
27
+ # Details about a bundle.
28
28
  class Bundle
29
29
  attr_accessor :id
30
30
 
@@ -203,7 +203,7 @@ module ApacheFelix
203
203
  def build_from_hash(attributes)
204
204
  return nil unless attributes.is_a?(Hash)
205
205
  self.class.swagger_types.each_pair do |key, type|
206
- if type =~ /\AArray<(.*)>/i
206
+ if type =~ /^Array<(.*)>/i
207
207
  # check to ensure the input is an array given that the the attribute
208
208
  # is documented as an array but the input is not
209
209
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -234,7 +234,7 @@ module ApacheFelix
234
234
  when :Float
235
235
  value.to_f
236
236
  when :BOOLEAN
237
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
237
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
238
238
  true
239
239
  else
240
240
  false
@@ -245,7 +245,7 @@ module ApacheFelix
245
245
  when /\AArray<(?<inner_type>.+)>\z/
246
246
  inner_type = Regexp.last_match[:inner_type]
247
247
  value.map { |v| _deserialize(inner_type, v) }
248
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
248
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
249
249
  k_type = Regexp.last_match[:k_type]
250
250
  v_type = Regexp.last_match[:v_type]
251
251
  {}.tap do |hash|
@@ -24,7 +24,7 @@ limitations under the License.
24
24
  require 'date'
25
25
 
26
26
  module ApacheFelix
27
-
27
+ # List of bundles
28
28
  class BundleList
29
29
  attr_accessor :status
30
30
 
@@ -118,7 +118,7 @@ module ApacheFelix
118
118
  def build_from_hash(attributes)
119
119
  return nil unless attributes.is_a?(Hash)
120
120
  self.class.swagger_types.each_pair do |key, type|
121
- if type =~ /\AArray<(.*)>/i
121
+ if type =~ /^Array<(.*)>/i
122
122
  # check to ensure the input is an array given that the the attribute
123
123
  # is documented as an array but the input is not
124
124
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -149,7 +149,7 @@ module ApacheFelix
149
149
  when :Float
150
150
  value.to_f
151
151
  when :BOOLEAN
152
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
153
153
  true
154
154
  else
155
155
  false
@@ -160,7 +160,7 @@ module ApacheFelix
160
160
  when /\AArray<(?<inner_type>.+)>\z/
161
161
  inner_type = Regexp.last_match[:inner_type]
162
162
  value.map { |v| _deserialize(inner_type, v) }
163
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
164
164
  k_type = Regexp.last_match[:k_type]
165
165
  v_type = Regexp.last_match[:v_type]
166
166
  {}.tap do |hash|
@@ -107,7 +107,7 @@ module ApacheFelix
107
107
  def build_from_hash(attributes)
108
108
  return nil unless attributes.is_a?(Hash)
109
109
  self.class.swagger_types.each_pair do |key, type|
110
- if type =~ /\AArray<(.*)>/i
110
+ if type =~ /^Array<(.*)>/i
111
111
  # check to ensure the input is an array given that the the attribute
112
112
  # is documented as an array but the input is not
113
113
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -138,7 +138,7 @@ module ApacheFelix
138
138
  when :Float
139
139
  value.to_f
140
140
  when :BOOLEAN
141
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
141
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
142
142
  true
143
143
  else
144
144
  false
@@ -149,7 +149,7 @@ module ApacheFelix
149
149
  when /\AArray<(?<inner_type>.+)>\z/
150
150
  inner_type = Regexp.last_match[:inner_type]
151
151
  value.map { |v| _deserialize(inner_type, v) }
152
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
152
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
153
153
  k_type = Regexp.last_match[:k_type]
154
154
  v_type = Regexp.last_match[:v_type]
155
155
  {}.tap do |hash|
@@ -0,0 +1,208 @@
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
+ # State of a bundle; see `org.osgi.framework.Bundle.java` for meaning of state values.
28
+ class BundleState
29
+ attr_accessor :fragment
30
+
31
+ attr_accessor :state_raw
32
+
33
+
34
+ # Attribute mapping from ruby-style variable name to JSON key.
35
+ def self.attribute_map
36
+ {
37
+ :'fragment' => :'fragment',
38
+ :'state_raw' => :'stateRaw'
39
+ }
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.swagger_types
44
+ {
45
+ :'fragment' => :'BOOLEAN',
46
+ :'state_raw' => :'Integer'
47
+ }
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ return unless attributes.is_a?(Hash)
54
+
55
+ # convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
57
+
58
+ if attributes.has_key?(:'fragment')
59
+ self.fragment = attributes[:'fragment']
60
+ end
61
+
62
+ if attributes.has_key?(:'stateRaw')
63
+ self.state_raw = attributes[:'stateRaw']
64
+ end
65
+
66
+ end
67
+
68
+ # Show invalid properties with the reasons. Usually used together with valid?
69
+ # @return Array for valid properies with the reasons
70
+ def list_invalid_properties
71
+ invalid_properties = Array.new
72
+ return invalid_properties
73
+ end
74
+
75
+ # Check to see if the all the properties in the model are valid
76
+ # @return true if the model is valid
77
+ def valid?
78
+ return true
79
+ end
80
+
81
+ # Checks equality by comparing each attribute.
82
+ # @param [Object] Object to be compared
83
+ def ==(o)
84
+ return true if self.equal?(o)
85
+ self.class == o.class &&
86
+ fragment == o.fragment &&
87
+ state_raw == o.state_raw
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
+ [fragment, state_raw].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 = ApacheFelix.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
+
208
+ end
@@ -22,5 +22,5 @@ limitations under the License.
22
22
  =end
23
23
 
24
24
  module ApacheFelix
25
- VERSION = "0.0.1"
25
+ VERSION = "0.1.1"
26
26
  end
@@ -0,0 +1,110 @@
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 'spec_helper'
25
+ require 'json'
26
+
27
+ # Unit tests for ApacheFelix::BundleApi
28
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
29
+ # Please update as you see appropriate
30
+ describe 'BundleApi' do
31
+ before do
32
+ # run before each test
33
+ @instance = ApacheFelix::BundleApi.new
34
+ end
35
+
36
+ after do
37
+ # run after each test
38
+ end
39
+
40
+ describe 'test an instance of BundleApi' do
41
+ it 'should create an instact of BundleApi' do
42
+ expect(@instance).to be_instance_of(ApacheFelix::BundleApi)
43
+ end
44
+ end
45
+
46
+ # unit tests for info
47
+ # Bundle Info
48
+ # Display all information about a bundle, including properties. The returned list will contain one entry, the requested bundle. (See org.apache.felix.webconsole.internal.core.BundlesServlet.java)
49
+ # @param bundle_id The symbolic name or id of the bundle.
50
+ # @param [Hash] opts the optional parameters
51
+ # @return [BundleList]
52
+ describe 'info test' do
53
+ it "should work" do
54
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
55
+ end
56
+ end
57
+
58
+ # unit tests for install
59
+ # Upload a bundle.
60
+ # Install the provided bundle. (See org.apache.felix.webconsole.internal.core.BundlesServlet.java)
61
+ # @param bundlefile The bundle to upload.
62
+ # @param action The action to execute. Only allowed value is &#39;install&#39;, must be provided. Limitation of Swagger.
63
+ # @param [Hash] opts the optional parameters
64
+ # @option opts [BOOLEAN] :bundlestart Flag to indicate whether or not bundle should be started.
65
+ # @option opts [Integer] :bundlestartlevel The start level of the provided bundle.
66
+ # @option opts [BOOLEAN] :refresh_packages Flag to indicate whether or not to refresh all pacakges once installed.
67
+ # @return [nil]
68
+ describe 'install test' do
69
+ it "should work" do
70
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
71
+ end
72
+ end
73
+
74
+ # unit tests for list
75
+ # List bundles
76
+ # List all the bundles in the Felix system. Properties for a bundle will not be populated. (See org.apache.felix.webconsole.internal.core.BundlesServlet.java)
77
+ # @param [Hash] opts the optional parameters
78
+ # @return [BundleList]
79
+ describe 'list test' do
80
+ it "should work" do
81
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
82
+ end
83
+ end
84
+
85
+ # unit tests for modify
86
+ # Modify bundles operation.
87
+ # Take action on a bundle; start, stop, update, refresh, uninstall. (See org.apache.felix.webconsole.internal.core.BundlesServlet.java)
88
+ # @param bundle_symbolic_name The OSGi Symbolic name of the bundle.
89
+ # @param action The action to execute.
90
+ # @param [Hash] opts the optional parameters
91
+ # @return [BundleState]
92
+ describe 'modify test' do
93
+ it "should work" do
94
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
95
+ end
96
+ end
97
+
98
+ # unit tests for refresh_packages
99
+ # Modify bundles operation.
100
+ # Take action on all bundles - refresh packages. (See org.apache.felix.webconsole.internal.core.BundlesServlet.java)
101
+ # @param action The action to execute. Only allowed value is &#39;refreshPackages&#39;, must be provided. Limitation of Swagger.
102
+ # @param [Hash] opts the optional parameters
103
+ # @return [BundleList]
104
+ describe 'refresh_packages test' do
105
+ it "should work" do
106
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
107
+ end
108
+ end
109
+
110
+ end