yao 0.15.0 → 0.18.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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rubocop.yml +2 -2
  3. data/.github/workflows/ubuntu-rvm.yml +1 -1
  4. data/.github/workflows/ubuntu.yml +2 -2
  5. data/lib/yao/error.rb +1 -1
  6. data/lib/yao/resources/base.rb +17 -5
  7. data/lib/yao/resources/flavor.rb +10 -0
  8. data/lib/yao/resources/floating_ip.rb +26 -5
  9. data/lib/yao/resources/loadbalancer_pool.rb +10 -20
  10. data/lib/yao/resources/meter.rb +1 -1
  11. data/lib/yao/resources/network.rb +1 -1
  12. data/lib/yao/resources/old_sample.rb +1 -1
  13. data/lib/yao/resources/port.rb +17 -1
  14. data/lib/yao/resources/{tenant_associationable.rb → project_associationable.rb} +5 -5
  15. data/lib/yao/resources/resource.rb +1 -1
  16. data/lib/yao/resources/restfully_accessible.rb +11 -6
  17. data/lib/yao/resources/role_assignment.rb +2 -2
  18. data/lib/yao/resources/router.rb +19 -10
  19. data/lib/yao/resources/security_group.rb +1 -1
  20. data/lib/yao/resources/server.rb +6 -1
  21. data/lib/yao/resources/subnet.rb +1 -1
  22. data/lib/yao/resources/volume.rb +2 -0
  23. data/lib/yao/resources.rb +1 -1
  24. data/lib/yao/version.rb +1 -1
  25. data/test/yao/resources/test_base.rb +21 -0
  26. data/test/yao/resources/test_flavor.rb +67 -33
  27. data/test/yao/resources/test_floating_ip.rb +96 -5
  28. data/test/yao/resources/test_loadbalancer_pool.rb +146 -1
  29. data/test/yao/resources/test_meter.rb +5 -5
  30. data/test/yao/resources/test_network.rb +6 -6
  31. data/test/yao/resources/test_port.rb +54 -6
  32. data/test/yao/resources/test_restfully_accessible.rb +87 -5
  33. data/test/yao/resources/test_role_assignment.rb +3 -3
  34. data/test/yao/resources/test_router.rb +33 -12
  35. data/test/yao/resources/test_security_group.rb +5 -5
  36. data/test/yao/resources/test_server.rb +52 -6
  37. data/test/yao/resources/test_subnet.rb +6 -6
  38. data/test/yao/resources/test_volume.rb +21 -0
  39. data/yao.gemspec +1 -1
  40. metadata +6 -6
@@ -25,12 +25,12 @@ class TestSecurityGroup < TestYaoResource
25
25
 
26
26
  def test_sg_to_tenant
27
27
 
28
- stub = stub_request(:get, "https://example.com:12345/tenants/0123456789abcdef0123456789abcdef")
28
+ stub = stub_request(:get, "https://example.com:12345/projects/0123456789abcdef0123456789abcdef")
29
29
  .to_return(
30
30
  status: 200,
31
31
  body: <<-JSON,
32
32
  {
33
- "tenant": {
33
+ "project": {
34
34
  "id": "0123456789abcdef0123456789abcdef"
35
35
  }
36
36
  }
@@ -38,9 +38,9 @@ class TestSecurityGroup < TestYaoResource
38
38
  headers: {'Content-Type' => 'application/json'}
39
39
  )
40
40
 
41
- sg = Yao::SecurityGroup.new('tenant_id' => '0123456789abcdef0123456789abcdef')
42
- assert_instance_of(Yao::Tenant, sg.tenant)
43
- assert_equal('0123456789abcdef0123456789abcdef', sg.tenant.id)
41
+ sg = Yao::SecurityGroup.new('project_id' => '0123456789abcdef0123456789abcdef')
42
+ assert_instance_of(Yao::Project, sg.project)
43
+ assert_equal('0123456789abcdef0123456789abcdef', sg.project.id)
44
44
 
45
45
  assert_requested(stub)
46
46
  end
@@ -206,14 +206,14 @@ class TestServer < TestYaoResource
206
206
  assert_equal(Yao::Server.method(:list), Yao::Server.method(:list_detail))
207
207
  end
208
208
 
209
- def test_tenant
209
+ def test_project
210
210
 
211
- stub = stub_request(:get, "https://example.com:12345/tenants/0123456789abcdef0123456789abcdef")
211
+ stub = stub_request(:get, "https://example.com:12345/projects/0123456789abcdef0123456789abcdef")
212
212
  .to_return(
213
213
  status: 200,
214
214
  body: <<-JSON,
215
215
  {
216
- "tenant": {
216
+ "project": {
217
217
  "id": "0123456789abcdef0123456789abcdef"
218
218
  }
219
219
  }
@@ -221,10 +221,56 @@ class TestServer < TestYaoResource
221
221
  headers: {'Content-Type' => 'application/json'}
222
222
  )
223
223
 
224
- server = Yao::Server.new('tenant_id' => '0123456789abcdef0123456789abcdef')
225
- assert_instance_of(Yao::Tenant, server.tenant)
226
- assert_equal('0123456789abcdef0123456789abcdef', server.tenant.id)
224
+ server = Yao::Server.new('project_id' => '0123456789abcdef0123456789abcdef')
225
+ assert_instance_of(Yao::Project, server.project)
226
+ assert_equal('0123456789abcdef0123456789abcdef', server.project.id)
227
227
 
228
228
  assert_requested(stub)
229
229
  end
230
+
231
+ def test_ports
232
+
233
+ stub = stub_request(:get, "https://example.com:12345/ports?device_id")
234
+ .to_return(
235
+ status: 200,
236
+ body: <<-JSON,
237
+ {
238
+ "ports": [{
239
+ "id": "0123456789abcdef0123456789abcdef"
240
+ }]
241
+ }
242
+ JSON
243
+ headers: {'Content-Type' => 'application/json'}
244
+ )
245
+
246
+ server = Yao::Server.new('project_id' => '0123456789abcdef0123456789abcdef')
247
+ ports = server.ports
248
+
249
+ assert_instance_of(Array, ports)
250
+ assert_instance_of(Yao::Port, ports.first)
251
+ assert_equal('0123456789abcdef0123456789abcdef', ports.first.id)
252
+
253
+ assert_requested(stub)
254
+ end
255
+
256
+ def test_ports_empty
257
+
258
+ stub = stub_request(:get, "https://example.com:12345/ports?device_id")
259
+ .to_return(
260
+ status: 200,
261
+ body: <<-JSON,
262
+ {
263
+ "ports": []
264
+ }
265
+ JSON
266
+ headers: {'Content-Type' => 'application/json'}
267
+ )
268
+
269
+ server = Yao::Server.new('project_id' => '0123456789abcdef0123456789abcdef')
270
+ ports = server.ports
271
+
272
+ assert_instance_of(Array, ports)
273
+ assert_equal(0, ports.size)
274
+ assert_requested(stub)
275
+ end
230
276
  end
@@ -76,13 +76,13 @@ class TestSubnet < TestYaoResource
76
76
  assert_requested(stub)
77
77
  end
78
78
 
79
- def test_tenant
80
- stub = stub_request(:get, "https://example.com:12345/tenants/0123456789abcdef0123456789abcdef")
79
+ def test_project
80
+ stub = stub_request(:get, "https://example.com:12345/projects/0123456789abcdef0123456789abcdef")
81
81
  .to_return(
82
82
  status: 200,
83
83
  body: <<-JSON,
84
84
  {
85
- "tenant": {
85
+ "project": {
86
86
  "id": "0123456789abcdef0123456789abcdef"
87
87
  }
88
88
  }
@@ -90,9 +90,9 @@ class TestSubnet < TestYaoResource
90
90
  headers: {'Content-Type' => 'application/json'}
91
91
  )
92
92
 
93
- subnet = Yao::Subnet.new('tenant_id' => '0123456789abcdef0123456789abcdef')
94
- assert_instance_of(Yao::Tenant, subnet.tenant)
95
- assert_equal('0123456789abcdef0123456789abcdef', subnet.tenant.id)
93
+ subnet = Yao::Subnet.new('project_id' => '0123456789abcdef0123456789abcdef')
94
+ assert_instance_of(Yao::Project, subnet.project)
95
+ assert_equal('0123456789abcdef0123456789abcdef', subnet.project.id)
96
96
 
97
97
  assert_requested(stub)
98
98
  end
@@ -98,4 +98,25 @@ class TestVolume < TestYaoResource
98
98
  volume.status = 'error'
99
99
  assert_requested(stub)
100
100
  end
101
+
102
+ def test_project
103
+ stub = stub_request(:get, "https://example.com:12345/projects/0123456789abcdef0123456789abcdef")
104
+ .to_return(
105
+ status: 200,
106
+ body: <<-JSON,
107
+ {
108
+ "project": {
109
+ "id": "0123456789abcdef0123456789abcdef"
110
+ }
111
+ }
112
+ JSON
113
+ headers: {'Content-Type' => 'application/json'}
114
+ )
115
+
116
+ volume = Yao::Volume.new('project_id' => '0123456789abcdef0123456789abcdef')
117
+ assert_instance_of(Yao::Project, volume.project)
118
+ assert_equal('0123456789abcdef0123456789abcdef', volume.project.id)
119
+
120
+ assert_requested(stub)
121
+ end
101
122
  end
data/yao.gemspec CHANGED
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_dependency "json"
21
21
  spec.add_dependency "deep_merge"
22
- spec.add_dependency "faraday", "~> 1.8.0"
22
+ spec.add_dependency "faraday", ">= 1.8.0"
23
23
  spec.add_dependency "faraday_middleware"
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yao
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uchio, KONDO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-10 00:00:00.000000000 Z
11
+ date: 2022-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -42,14 +42,14 @@ dependencies:
42
42
  name: faraday
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.8.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.8.0
55
55
  - !ruby/object:Gem::Dependency
@@ -122,6 +122,7 @@ files:
122
122
  - lib/yao/resources/port.rb
123
123
  - lib/yao/resources/port_associationable.rb
124
124
  - lib/yao/resources/project.rb
125
+ - lib/yao/resources/project_associationable.rb
125
126
  - lib/yao/resources/resource.rb
126
127
  - lib/yao/resources/restfully_accessible.rb
127
128
  - lib/yao/resources/role.rb
@@ -135,7 +136,6 @@ files:
135
136
  - lib/yao/resources/server_usage_associationable.rb
136
137
  - lib/yao/resources/subnet.rb
137
138
  - lib/yao/resources/tenant.rb
138
- - lib/yao/resources/tenant_associationable.rb
139
139
  - lib/yao/resources/user.rb
140
140
  - lib/yao/resources/volume.rb
141
141
  - lib/yao/resources/volume_action.rb
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  - !ruby/object:Gem::Version
217
217
  version: '0'
218
218
  requirements: []
219
- rubygems_version: 3.2.32
219
+ rubygems_version: 3.3.7
220
220
  signing_key:
221
221
  specification_version: 4
222
222
  summary: Yet Another OpenStack API Wrapper that rocks!!