misty 0.9.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a18dd08ce931589520a2cffc3a0680fc43e97d1
4
- data.tar.gz: cc92b5a1fa75a36b6702094f2fdaf88aa5153879
3
+ metadata.gz: '08884c370b4d79670e9d2b9c8adbbed79f1663a5'
4
+ data.tar.gz: 121229f87354ccfd1c492cc168b9e5ccaed57363
5
5
  SHA512:
6
- metadata.gz: b4e83f60c35a1a28fd96a9b3066d90d2fab52b5bad92ececbe35c690add1cc2c07118b5f6c50b789d43a136a28860a7fe1ce4602aabe58095414cd18978465cb
7
- data.tar.gz: 51295685e0f48004e97216b5423b6f32c8ac2ac3861c226efe4c6af834567b50fafb2dd559493e78cd505da9fcb7da0af49038345e200d7778a1983be7569c76
6
+ metadata.gz: d537db25e7d1bcbf6d3e6d55bd480367261d5a6011351c8d0f32dddba91c12af99e2141db3a58051ed1c9a4040c3cdbf5a7f2d9a2ab138e8f72f6ff7f3e8825f
7
+ data.tar.gz: c32da00cd2ba16c7d5a559ff3905a6e3fdca8a4e97d868a6594f6fc0ae1858b0f3eb84f03a6882bec4c8036206ca14c721bf8ef2d925ba1d415d1e329dfbd638
data/README.md CHANGED
@@ -1,16 +1,18 @@
1
1
  # Introduction
2
- Misty is a HTTP client for OpenStack APIs, aiming to be fast and to provide a flexible and at same time exhaustive
3
- APIs experience.
2
+ Misty is a HTTP client for OpenStack APIs, aiming to be fast, flexible and exhaustive.
3
+ Misty acts as a conduit to OpenStack APIs by handling requests as transparently as possible.
4
4
 
5
5
  ## Features
6
6
  * Flexible Openstack APIs integration
7
7
  * Standardized Openstack APIs: [Based upon API-ref](https://developer.openstack.org/api-guide/quick-start/)
8
- * Multiple Service versions and Microversions
8
+ * Automatically generated API schemas - Any request can be overridden
9
+ * Versions and Microversions
10
+ * Transparent Request data hanlding
11
+ * Response data format of choice: JSON or raw (Ruby)
12
+ * Custom HTTP Methods for special needs
9
13
  * On demand services - Auto loads required versions
10
- * Low dependency - Use standard Net/HTTP and JSON gem only
11
- * I/O format choice: JSON or Ruby structures for queries and responses
12
- * Persistent HTTP connections (default since HTTP 1.1 anyway) but for the authentication bootstrapping
13
- * Direct HTTP Methods for custom needs
14
+ * Low dependency - Use standard Net/HTTP and JSON gem only
15
+ * Persistent HTTP connections (default since HTTP 1.1 anyway)
14
16
 
15
17
  ## A solid KISS
16
18
  For REST transactions Misty relies on standard Net/HTTP library.
@@ -76,7 +78,8 @@ Each service name (i.e. `compute`) is the object handling API requests.
76
78
  openstack = Misty::Cloud.new(:auth => { ... })
77
79
  openstack.compute.list_servers
78
80
  openstack.network.list_networks
79
- openstack.network.create_network('network': {'name': 'my-network'})
81
+ data = Misty.to_json('network': {'name': 'my-network'})
82
+ openstack.network.create_network(data)
80
83
  ```
81
84
 
82
85
  To obtain the list of supported services:
@@ -316,6 +319,7 @@ openstack.network.post('/v2.0/qos/policies/48985e6b8da145699d411f12a3459fca/dscp
316
319
  # Requirements
317
320
 
318
321
  ## Ruby versions tested
322
+ * Ruby MRI 2.4.2
319
323
  * Ruby MRI 2.4.1
320
324
  * Ruby MRI 2.4.0
321
325
  * Ruby MRI 2.3.4
@@ -74,7 +74,7 @@ module Misty
74
74
 
75
75
  def headers
76
76
  header = {}
77
- header.merge!({'Content-Type' => 'application/json', 'Accept' => 'application/json'})
77
+ header.merge!({'Accept' => 'application/json; q=1.0'})
78
78
  header.merge!('X-Auth-Token' => @auth.get_token.to_s)
79
79
  header.merge!(@config.headers) if @config.headers
80
80
  header.merge!(@options.headers) if @options.headers
@@ -54,21 +54,21 @@ module Misty
54
54
  def http_patch(path, headers, data)
55
55
  @config.log.info(http_to_s(path, headers, data))
56
56
  request = Net::HTTP::Patch.new(path, headers)
57
- request.body = Misty.to_json(data)
57
+ request.body = data
58
58
  http(request)
59
59
  end
60
60
 
61
61
  def http_post(path, headers, data)
62
62
  @config.log.info(http_to_s(path, headers, data))
63
63
  request = Net::HTTP::Post.new(path, headers)
64
- request.body = Misty.to_json(data)
64
+ request.body = data
65
65
  http(request)
66
66
  end
67
67
 
68
68
  def http_put(path, headers, data)
69
69
  @config.log.info(http_to_s(path, headers, data))
70
70
  request = Net::HTTP::Put.new(path, headers)
71
- request.body = Misty.to_json(data)
71
+ request.body = data
72
72
  http(request)
73
73
  end
74
74
 
@@ -1,3 +1,3 @@
1
1
  module Misty
2
- VERSION = '0.9.2'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -7,7 +7,8 @@ describe 'Compute Service Nova v2.1 features' do
7
7
 
8
8
  # POST with body data
9
9
  server = { 'name': 'test_create_server', 'flavorRef': '1', 'imageRef': 'c091ccf2-a4ae-4fa0-a716-defd6376b5dc', 'networks': [{'uuid': '9c6e43b6-3d1d-4106-ad45-5fc3f5e371ee'}]}
10
- response = cloud.compute.create_server('server' => server)
10
+ data = Misty.to_json('server' => server)
11
+ response = cloud.compute.create_server(data)
11
12
  response.code.must_equal '202'
12
13
  id = response.body['server']['id']
13
14
  id.wont_be_empty
@@ -24,7 +25,8 @@ describe 'Compute Service Nova v2.1 features' do
24
25
 
25
26
  # PUT with URI value and body data
26
27
  update_server = { 'name': 'test_updated_server' }
27
- response = cloud.compute.update_server(id, 'server' => update_server)
28
+ data = Misty.to_json('server' => update_server)
29
+ response = cloud.compute.update_server(id, data)
28
30
  response.code.must_equal '200'
29
31
  response.body['server']['name'].must_equal 'test_updated_server'
30
32
 
@@ -6,7 +6,8 @@ describe 'Network Service Neutron v2.0 features' do
6
6
  cloud = Misty::Cloud.new(:auth => auth, :network => {:api_version => 'v2.0'})
7
7
 
8
8
  # POST with body data
9
- response = cloud.network.create_network('network' => { 'name': 'test_network' })
9
+ data = Misty.to_json('network' => { 'name': 'test_network' })
10
+ response = cloud.network.create_network(data)
10
11
  response.code.must_equal '201'
11
12
  id = response.body['network']['id']
12
13
  id.wont_be_empty
@@ -22,8 +23,8 @@ describe 'Network Service Neutron v2.0 features' do
22
23
  response.body['network']['name'].must_equal 'test_network'
23
24
 
24
25
  # PUT with URI value and body data
25
- update_network = { 'name': 'test_updated_network' }
26
- response = cloud.network.update_network(id, 'network' => update_network)
26
+ data = Misty.to_json('network' => { 'name': 'test_updated_network' })
27
+ response = cloud.network.update_network(id, data)
27
28
  response.code.must_equal '200'
28
29
  response.body['network']['name'].must_equal 'test_updated_network'
29
30
 
@@ -53,12 +53,14 @@ describe 'Orchestration Service using Heat v1' do
53
53
  cloud = Misty::Cloud.new(:auth => auth, :orchestration => {:api_version => 'v1'})
54
54
 
55
55
  # POST with body data
56
- response = cloud.orchestration.create_stack(heat_template1)
56
+ data_heat_template1 = Misty.to_json(heat_template1)
57
+ response = cloud.orchestration.create_stack(data_heat_template1)
57
58
  response.code.must_equal '201'
58
59
  id1 = response.body['stack']['id']
59
60
  id1.wont_be_empty
60
61
 
61
- response = cloud.orchestration.create_stack(heat_template2)
62
+ data_heat_template2 = Misty.to_json(heat_template2)
63
+ response = cloud.orchestration.create_stack(data_heat_template2)
62
64
  response.code.must_equal '201'
63
65
  id2 = response.body['stack']['id']
64
66
  id2.wont_be_empty
@@ -77,11 +79,13 @@ describe 'Orchestration Service using Heat v1' do
77
79
  # Updating the network template because it's faster to execute
78
80
  # therefore more likely to be in ready state before updating
79
81
  heat_template1[:template][:description] = 'Updated test template'
80
- response = cloud.orchestration.update_stack('test_stack1', id1, heat_template1)
82
+ data_heat_template1 = Misty.to_json(heat_template1)
83
+ response = cloud.orchestration.update_stack('test_stack1', id1, data_heat_template1)
81
84
  response.code.must_equal '202'
82
85
 
83
86
  # PATCH with URI values
84
- response = cloud.orchestration.update_stack_patch('test_stack1', id1, 'disable_rollback': false)
87
+ data = Misty.to_json('disable_rollback': false)
88
+ response = cloud.orchestration.update_stack_patch('test_stack1', id1, data)
85
89
  response.code.must_equal '202'
86
90
 
87
91
  # DELETE with URI value
@@ -61,19 +61,19 @@ describe Misty::HTTP::Direct do
61
61
  describe '#post' do
62
62
  it 'successful without providing a base url' do
63
63
  stub_request(:post, 'http://localhost/resource/test').
64
- with(:body => "{\"data\":\"value\"}", :headers => request_header).
64
+ with(:body => 'data', :headers => request_header).
65
65
  to_return(:status => 201, :body => '', :headers => {})
66
66
 
67
- response = service.post('/resource/test', 'data' => 'value')
67
+ response = service.post('/resource/test', 'data')
68
68
  response.must_be_kind_of Net::HTTPCreated
69
69
  response.body.must_be_nil
70
70
  end
71
71
 
72
72
  it 'successful with a base url' do
73
73
  stub_request(:post, 'http://localhost/another-base/resource/test').
74
- with(:body => "{\"data\":\"value\"}", :headers => request_header).
74
+ with(:body => 'data', :headers => request_header).
75
75
  to_return(:status => 201, :body => '', :headers => {})
76
- response = service.post('/resource/test', {'data' => 'value'}, '/another-base')
76
+ response = service.post('/resource/test', 'data', '/another-base')
77
77
  response.must_be_kind_of Net::HTTPCreated
78
78
  response.body.must_be_nil
79
79
  end
@@ -82,20 +82,20 @@ describe Misty::HTTP::Direct do
82
82
  describe '#put' do
83
83
  it 'successful without providing a base url' do
84
84
  stub_request(:put, 'http://localhost/resource/test').
85
- with(:body => "{\"data\":\"value\"}", :headers => request_header).
85
+ with(:body => 'data', :headers => request_header).
86
86
  to_return(:status => 200, :body => '', :headers => {})
87
87
 
88
- response = service.put('/resource/test', 'data' => 'value')
88
+ response = service.put('/resource/test', 'data')
89
89
  response.must_be_kind_of Net::HTTPOK
90
90
  response.body.must_be_nil
91
91
  end
92
92
 
93
93
  it 'successful with a base url' do
94
94
  stub_request(:put, 'http://localhost/another-base/resource/test').
95
- with(:body => "{\"data\":\"value\"}", :headers => request_header).
95
+ with(:body => 'data', :headers => request_header).
96
96
  to_return(:status => 200, :body => '', :headers => {})
97
97
 
98
- response = service.put('/resource/test', {'data' => 'value'}, '/another-base')
98
+ response = service.put('/resource/test', 'data', '/another-base')
99
99
  response.must_be_kind_of Net::HTTPOK
100
100
  response.body.must_be_nil
101
101
  end
@@ -1,7 +1,7 @@
1
1
  require 'misty/http/client'
2
2
 
3
3
  def request_header
4
- {'Accept' => 'application/json'}
4
+ {'Accept' => 'application/json; q=1.0'}
5
5
  end
6
6
 
7
7
  def service(content_type = :ruby)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: misty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilles Dubreuil
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-04 00:00:00.000000000 Z
11
+ date: 2017-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json