fog-profitbricks 2.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/.travis.yml +11 -4
  4. data/README.md +8 -5
  5. data/Rakefile +1 -1
  6. data/examples/pb_demo.rb +49 -49
  7. data/fog-profitbricks.gemspec +4 -5
  8. data/gemfiles/Gemfile.1.9.2+ +1 -0
  9. data/lib/fog/bin/profitbricks.rb +5 -5
  10. data/lib/fog/profitbricks.rb +3 -3
  11. data/lib/fog/profitbricks/compute.rb +209 -204
  12. data/lib/fog/profitbricks/helpers/compute/data_helper.rb +1 -1
  13. data/lib/fog/profitbricks/models/compute/datacenter.rb +1 -1
  14. data/lib/fog/profitbricks/models/compute/datacenters.rb +6 -7
  15. data/lib/fog/profitbricks/models/compute/firewall_rule.rb +2 -2
  16. data/lib/fog/profitbricks/models/compute/firewall_rules.rb +5 -8
  17. data/lib/fog/profitbricks/models/compute/flavors.rb +1 -4
  18. data/lib/fog/profitbricks/models/compute/image.rb +4 -0
  19. data/lib/fog/profitbricks/models/compute/images.rb +2 -5
  20. data/lib/fog/profitbricks/models/compute/ip_block.rb +1 -1
  21. data/lib/fog/profitbricks/models/compute/ip_blocks.rb +3 -8
  22. data/lib/fog/profitbricks/models/compute/lan.rb +1 -1
  23. data/lib/fog/profitbricks/models/compute/lans.rb +4 -7
  24. data/lib/fog/profitbricks/models/compute/load_balancer.rb +6 -7
  25. data/lib/fog/profitbricks/models/compute/load_balancers.rb +5 -9
  26. data/lib/fog/profitbricks/models/compute/locations.rb +2 -5
  27. data/lib/fog/profitbricks/models/compute/nic.rb +6 -3
  28. data/lib/fog/profitbricks/models/compute/nics.rb +2 -5
  29. data/lib/fog/profitbricks/models/compute/regions.rb +1 -4
  30. data/lib/fog/profitbricks/models/compute/request.rb +0 -1
  31. data/lib/fog/profitbricks/models/compute/requests.rb +2 -4
  32. data/lib/fog/profitbricks/models/compute/server.rb +10 -13
  33. data/lib/fog/profitbricks/models/compute/servers.rb +3 -6
  34. data/lib/fog/profitbricks/models/compute/snapshot.rb +2 -2
  35. data/lib/fog/profitbricks/models/compute/snapshots.rb +3 -6
  36. data/lib/fog/profitbricks/models/compute/volume.rb +11 -9
  37. data/lib/fog/profitbricks/models/compute/volumes.rb +3 -6
  38. data/lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb +26 -13
  39. data/lib/fog/profitbricks/requests/compute/attach_cdrom.rb +25 -16
  40. data/lib/fog/profitbricks/requests/compute/attach_volume.rb +25 -16
  41. data/lib/fog/profitbricks/requests/compute/create_datacenter.rb +22 -23
  42. data/lib/fog/profitbricks/requests/compute/create_firewall_rule.rb +24 -26
  43. data/lib/fog/profitbricks/requests/compute/create_flavor.rb +34 -34
  44. data/lib/fog/profitbricks/requests/compute/create_ip_block.rb +18 -20
  45. data/lib/fog/profitbricks/requests/compute/create_lan.rb +151 -150
  46. data/lib/fog/profitbricks/requests/compute/create_load_balancer.rb +67 -26
  47. data/lib/fog/profitbricks/requests/compute/create_nic.rb +24 -26
  48. data/lib/fog/profitbricks/requests/compute/create_server.rb +70 -61
  49. data/lib/fog/profitbricks/requests/compute/create_volume.rb +122 -122
  50. data/lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb +42 -45
  51. data/lib/fog/profitbricks/requests/compute/delete_datacenter.rb +34 -36
  52. data/lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb +8 -11
  53. data/lib/fog/profitbricks/requests/compute/delete_image.rb +7 -9
  54. data/lib/fog/profitbricks/requests/compute/delete_ip_block.rb +8 -10
  55. data/lib/fog/profitbricks/requests/compute/delete_lan.rb +7 -9
  56. data/lib/fog/profitbricks/requests/compute/delete_load_balancer.rb +8 -10
  57. data/lib/fog/profitbricks/requests/compute/delete_nic.rb +7 -10
  58. data/lib/fog/profitbricks/requests/compute/delete_server.rb +6 -10
  59. data/lib/fog/profitbricks/requests/compute/delete_snapshot.rb +7 -10
  60. data/lib/fog/profitbricks/requests/compute/delete_volume.rb +36 -38
  61. data/lib/fog/profitbricks/requests/compute/detach_cdrom.rb +11 -13
  62. data/lib/fog/profitbricks/requests/compute/detach_volume.rb +16 -13
  63. data/lib/fog/profitbricks/requests/compute/get_all_datacenters.rb +1 -1
  64. data/lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb +6 -7
  65. data/lib/fog/profitbricks/requests/compute/get_all_flavors.rb +72 -72
  66. data/lib/fog/profitbricks/requests/compute/get_all_images.rb +62 -62
  67. data/lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb +5 -5
  68. data/lib/fog/profitbricks/requests/compute/get_all_lans.rb +113 -113
  69. data/lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb +15 -9
  70. data/lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb +9 -9
  71. data/lib/fog/profitbricks/requests/compute/get_all_locations.rb +6 -6
  72. data/lib/fog/profitbricks/requests/compute/get_all_nic.rb +94 -94
  73. data/lib/fog/profitbricks/requests/compute/get_all_requests.rb +38 -38
  74. data/lib/fog/profitbricks/requests/compute/get_all_servers.rb +8 -9
  75. data/lib/fog/profitbricks/requests/compute/get_all_snapshots.rb +4 -4
  76. data/lib/fog/profitbricks/requests/compute/get_all_volumes.rb +71 -71
  77. data/lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb +11 -11
  78. data/lib/fog/profitbricks/requests/compute/get_attached_volume.rb +16 -11
  79. data/lib/fog/profitbricks/requests/compute/get_datacenter.rb +4 -6
  80. data/lib/fog/profitbricks/requests/compute/get_firewall_rule.rb +8 -11
  81. data/lib/fog/profitbricks/requests/compute/get_flavor.rb +9 -9
  82. data/lib/fog/profitbricks/requests/compute/get_image.rb +7 -9
  83. data/lib/fog/profitbricks/requests/compute/get_ip_block.rb +8 -10
  84. data/lib/fog/profitbricks/requests/compute/get_lan.rb +7 -10
  85. data/lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb +16 -12
  86. data/lib/fog/profitbricks/requests/compute/get_load_balancer.rb +7 -9
  87. data/lib/fog/profitbricks/requests/compute/get_location.rb +7 -9
  88. data/lib/fog/profitbricks/requests/compute/get_nic.rb +8 -11
  89. data/lib/fog/profitbricks/requests/compute/get_request.rb +55 -57
  90. data/lib/fog/profitbricks/requests/compute/get_request_status.rb +44 -46
  91. data/lib/fog/profitbricks/requests/compute/get_server.rb +7 -10
  92. data/lib/fog/profitbricks/requests/compute/get_snapshot.rb +7 -9
  93. data/lib/fog/profitbricks/requests/compute/get_volume.rb +7 -9
  94. data/lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb +8 -8
  95. data/lib/fog/profitbricks/requests/compute/list_attached_volumes.rb +18 -8
  96. data/lib/fog/profitbricks/requests/compute/reboot_server.rb +7 -11
  97. data/lib/fog/profitbricks/requests/compute/remove_nic_association.rb +9 -11
  98. data/lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb +15 -17
  99. data/lib/fog/profitbricks/requests/compute/start_server.rb +7 -11
  100. data/lib/fog/profitbricks/requests/compute/stop_server.rb +7 -11
  101. data/lib/fog/profitbricks/requests/compute/update_datacenter.rb +20 -15
  102. data/lib/fog/profitbricks/requests/compute/update_firewall_rule.rb +9 -11
  103. data/lib/fog/profitbricks/requests/compute/update_image.rb +15 -15
  104. data/lib/fog/profitbricks/requests/compute/update_lan.rb +6 -8
  105. data/lib/fog/profitbricks/requests/compute/update_load_balancer.rb +10 -12
  106. data/lib/fog/profitbricks/requests/compute/update_nic.rb +10 -12
  107. data/lib/fog/profitbricks/requests/compute/update_server.rb +10 -13
  108. data/lib/fog/profitbricks/requests/compute/update_snapshot.rb +10 -13
  109. data/lib/fog/profitbricks/requests/compute/update_volume.rb +10 -13
  110. data/lib/fog/profitbricks/version.rb +1 -1
  111. data/spec/minitest_helper.rb +1 -3
  112. data/tests/helpers/formats_helper.rb +8 -8
  113. data/tests/profitbricks/models/compute/compute_tests.rb +529 -0
  114. data/tests/profitbricks/requests/compute/composite_create_tests.rb +16 -83
  115. data/tests/profitbricks/requests/compute/flavor_tests.rb +1 -4
  116. data/tests/profitbricks/requests/compute/location_tests.rb +14 -17
  117. data/tests/profitbricks/requests/compute/nic_tests.rb +60 -70
  118. data/tests/profitbricks/requests/compute/request_tests.rb +1 -3
  119. data/tests/profitbricks/requests/compute/server_tests.rb +163 -161
  120. metadata +5 -18
@@ -33,16 +33,16 @@ module Fog
33
33
  # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-ip-blocks]
34
34
  def get_all_ip_blocks
35
35
  request(
36
- :expects => [200],
37
- :method => 'GET',
38
- :path => "/ipblocks?depth=5"
36
+ :expects => [200],
37
+ :method => 'GET',
38
+ :path => "/ipblocks?depth=5"
39
39
  )
40
40
  end
41
41
  end
42
42
 
43
43
  class Mock
44
44
  def get_all_ip_blocks
45
- ip_blocks = self.data[:ip_blocks]
45
+ ip_blocks = data[:ip_blocks]
46
46
 
47
47
  response = Excon::Response.new
48
48
  response.status = 200
@@ -53,4 +53,4 @@ module Fog
53
53
  end
54
54
  end
55
55
  end
56
- end
56
+ end
@@ -1,120 +1,120 @@
1
1
  module Fog
2
- module Compute
3
- class ProfitBricks
4
- class Real
5
- # Retrieves a list of LANs
6
- #
7
- # ==== Parameters
8
- # * datacenter_id<~String> - UUID of the datacenter
9
- #
10
- # ==== Returns
11
- # * response<~Excon::Response>:
12
- # * body<~Hash>:
13
- # * id<~String> - The resource's unique identifier
14
- # * type<~String> - The type of the created resource
15
- # * href<~String> - URL to the object’s representation (absolute path)
16
- # * items<~Hash> - Collection of individual lan objects
17
- # * id<~String> - The resource's unique identifier
18
- # * type<~String> - The type of the created resource
19
- # * href<~String> - URL to the object’s representation (absolute path)
20
- # * metadata<~Hash> - Hash containing the LAN metadata
21
- # * createdDate<~String> - The date the resource was created
22
- # * createdBy<~String> - The user who created the resource
23
- # * etag<~String> - The etag for the resource
24
- # * lastModifiedDate<~String> - The last time the resource has been modified
25
- # * lastModifiedBy<~String> - The user who last modified the resource
26
- # * state<~String> - LAN state
27
- # * properties<~Hash> - Hash containing the LAN properties
28
- # * name<~String> - The name of the LAN
29
- # * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not
30
- # * entities<~Hash> - Hash containing the LAN entities
31
- # * nics<~Hash> - Hash containing the NIC properties
32
- # * id<~String> - The resource's unique identifier
33
- # * type<~String> - The type of the created resource
34
- # * href<~String> - URL to the object’s representation (absolute path)
35
- # * items<~Hash> - Collection of individual nic objects
36
- # * id<~String> - The resource's unique identifier
37
- # * type<~String> - The type of the created resource
38
- # * href<~String> - URL to the object’s representation (absolute path)
39
- # * metadata<~Hash> - Hash containing the NIC metadata
40
- # * createdDate<~String> - The date the resource was created
41
- # * createdBy<~String> - The user who created the resource
42
- # * etag<~String> - The etag for the resource
43
- # * lastModifiedDate<~String> - The last time the resource has been modified
44
- # * lastModifiedBy<~String> - The user who last modified the resource
45
- # * state<~String> - NIC state
46
- # * properties<~Hash> - Hash containing the NIC properties
47
- # * name<~String> - The name of the NIC
48
- # * mac<~String> - The MAC address of the NIC
49
- # * ips<~Array> - IPs assigned to the NIC represented as a collection
50
- # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
51
- # * lan<~Integer> - The LAN ID the NIC sits on
52
- # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value
53
- # * entities<~Hash> - Hash containing the NIC entities
54
- # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection
55
- # * id<~String> - The resource's unique identifier
56
- # * type<~String> - The type of the resource
57
- # * href<~String> - URL to the object’s representation (absolute path)
58
- # * items<~Array> - Collection of individual firewall rules objects
59
- # * id<~String> - The resource's unique identifier
60
- # * type<~String> - The type of the resource
61
- # * href<~String> - URL to the object’s representation (absolute path)
62
- # * metadata<~Hash> - Hash containing the Firewall Rule metadata
63
- # * createdDate<~String> - The date the resource was created
64
- # * createdBy<~String> - The user who created the resource
65
- # * etag<~String> - The etag for the resource
66
- # * lastModifiedDate<~String> - The last time the resource has been modified
67
- # * lastModifiedBy<~String> - The user who last modified the resource
68
- # * state<~String> - Firewall Rule state
69
- # * properties<~Hash> - Hash containing the Firewall Rule properties
70
- # * name<~String> - The name of the Firewall Rule
71
- # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
72
- # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed.
73
- # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
74
- # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed.
75
- # Value null allows all source IPs
76
- # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed
77
- # to the respective IP address of the NIC is allowed. Value null allows all target IPs
78
- # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen.
79
- # Value null allows all codes.
80
- # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen.
81
- # Value null allows all types
82
- # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534)
83
- # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd
84
- # value null to allow all ports
85
- # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534)
86
- # if the protocol TCP or UDP is chosen. Leave portRangeStart and
87
- # portRangeEnd value null to allow all ports
88
- #
89
- # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-lans]
90
- def get_all_lans(datacenter_id)
91
- request(
92
- :expects => [200],
93
- :method => 'GET',
94
- :path => "/datacenters/#{datacenter_id}/lans?depth=1"
95
- )
96
- end
97
- end
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Retrieves a list of LANs
6
+ #
7
+ # ==== Parameters
8
+ # * datacenter_id<~String> - UUID of the datacenter
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * id<~String> - The resource's unique identifier
14
+ # * type<~String> - The type of the created resource
15
+ # * href<~String> - URL to the object’s representation (absolute path)
16
+ # * items<~Hash> - Collection of individual lan objects
17
+ # * id<~String> - The resource's unique identifier
18
+ # * type<~String> - The type of the created resource
19
+ # * href<~String> - URL to the object’s representation (absolute path)
20
+ # * metadata<~Hash> - Hash containing the LAN metadata
21
+ # * createdDate<~String> - The date the resource was created
22
+ # * createdBy<~String> - The user who created the resource
23
+ # * etag<~String> - The etag for the resource
24
+ # * lastModifiedDate<~String> - The last time the resource has been modified
25
+ # * lastModifiedBy<~String> - The user who last modified the resource
26
+ # * state<~String> - LAN state
27
+ # * properties<~Hash> - Hash containing the LAN properties
28
+ # * name<~String> - The name of the LAN
29
+ # * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not
30
+ # * entities<~Hash> - Hash containing the LAN entities
31
+ # * nics<~Hash> - Hash containing the NIC properties
32
+ # * id<~String> - The resource's unique identifier
33
+ # * type<~String> - The type of the created resource
34
+ # * href<~String> - URL to the object’s representation (absolute path)
35
+ # * items<~Hash> - Collection of individual nic objects
36
+ # * id<~String> - The resource's unique identifier
37
+ # * type<~String> - The type of the created resource
38
+ # * href<~String> - URL to the object’s representation (absolute path)
39
+ # * metadata<~Hash> - Hash containing the NIC metadata
40
+ # * createdDate<~String> - The date the resource was created
41
+ # * createdBy<~String> - The user who created the resource
42
+ # * etag<~String> - The etag for the resource
43
+ # * lastModifiedDate<~String> - The last time the resource has been modified
44
+ # * lastModifiedBy<~String> - The user who last modified the resource
45
+ # * state<~String> - NIC state
46
+ # * properties<~Hash> - Hash containing the NIC properties
47
+ # * name<~String> - The name of the NIC
48
+ # * mac<~String> - The MAC address of the NIC
49
+ # * ips<~Array> - IPs assigned to the NIC represented as a collection
50
+ # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
51
+ # * lan<~Integer> - The LAN ID the NIC sits on
52
+ # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value
53
+ # * entities<~Hash> - Hash containing the NIC entities
54
+ # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection
55
+ # * id<~String> - The resource's unique identifier
56
+ # * type<~String> - The type of the resource
57
+ # * href<~String> - URL to the object’s representation (absolute path)
58
+ # * items<~Array> - Collection of individual firewall rules objects
59
+ # * id<~String> - The resource's unique identifier
60
+ # * type<~String> - The type of the resource
61
+ # * href<~String> - URL to the object’s representation (absolute path)
62
+ # * metadata<~Hash> - Hash containing the Firewall Rule metadata
63
+ # * createdDate<~String> - The date the resource was created
64
+ # * createdBy<~String> - The user who created the resource
65
+ # * etag<~String> - The etag for the resource
66
+ # * lastModifiedDate<~String> - The last time the resource has been modified
67
+ # * lastModifiedBy<~String> - The user who last modified the resource
68
+ # * state<~String> - Firewall Rule state
69
+ # * properties<~Hash> - Hash containing the Firewall Rule properties
70
+ # * name<~String> - The name of the Firewall Rule
71
+ # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
72
+ # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed.
73
+ # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
74
+ # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed.
75
+ # Value null allows all source IPs
76
+ # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed
77
+ # to the respective IP address of the NIC is allowed. Value null allows all target IPs
78
+ # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen.
79
+ # Value null allows all codes.
80
+ # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen.
81
+ # Value null allows all types
82
+ # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534)
83
+ # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd
84
+ # value null to allow all ports
85
+ # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534)
86
+ # if the protocol TCP or UDP is chosen. Leave portRangeStart and
87
+ # portRangeEnd value null to allow all ports
88
+ #
89
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-lans]
90
+ def get_all_lans(datacenter_id)
91
+ request(
92
+ :expects => [200],
93
+ :method => 'GET',
94
+ :path => "/datacenters/#{datacenter_id}/lans?depth=1"
95
+ )
96
+ end
97
+ end
98
98
 
99
- class Mock
100
- def get_all_lans(datacenter_id)
101
- lans = self.data[:lans]
99
+ class Mock
100
+ def get_all_lans(datacenter_id)
101
+ lans = data[:lans]
102
102
 
103
- if lns = self.data[:lans]['items'].select {
104
- |attrib| attrib['datacenter_id'] == datacenter_id
105
- }
106
- else
107
- raise Fog::Errors::NotFound.new('The resource could not be found')
108
- end
103
+ if lns = data[:lans]['items'].select do |attrib|
104
+ attrib['datacenter_id'] == datacenter_id
105
+ end
106
+ else
107
+ raise Fog::Errors::NotFound, 'The resource could not be found'
108
+ end
109
109
 
110
- lans['items'] = lns
111
- response = Excon::Response.new
112
- response.status = 200
113
- response.body = lans
110
+ lans['items'] = lns
111
+ response = Excon::Response.new
112
+ response.status = 200
113
+ response.body = lans
114
114
 
115
- response
116
- end
117
- end
115
+ response
118
116
  end
117
+ end
119
118
  end
120
- end
119
+ end
120
+ end
@@ -71,23 +71,29 @@ module Fog
71
71
  # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-load-balanced-nics]
72
72
  def get_all_load_balanced_nics(datacenter_id, load_balancer_id)
73
73
  request(
74
- :expects => [200],
75
- :method => 'GET',
76
- :path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}/balancednics?depth=5"
74
+ :expects => [200],
75
+ :method => 'GET',
76
+ :path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}/balancednics?depth=5"
77
77
  )
78
78
  end
79
79
  end
80
80
 
81
81
  class Mock
82
82
  def get_all_load_balanced_nics(datacenter_id, load_balancer_id)
83
- if load_balancer = self.data[:load_balancers]['items'].find {
84
- |lb| lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id
85
- }
83
+ if load_balancer = data[:load_balancers]['items'].find do |lb|
84
+ lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id
85
+ end
86
86
  else
87
- raise Fog::Errors::NotFound.new("The requested resource could not be found")
87
+ raise Fog::Errors::NotFound, "The requested resource could not be found"
88
88
  end
89
89
 
90
- load_balanced_nics = load_balancer['entities'][:balancednics]
90
+ load_balanced_nics = nil
91
+
92
+ load_balanced_nics = if load_balancer['entities']
93
+ load_balancer['entities']['balancednics']
94
+ else
95
+ load_balancer['balancednics']
96
+ end
91
97
 
92
98
  response = Excon::Response.new
93
99
  response.status = 200
@@ -97,4 +103,4 @@ module Fog
97
103
  end
98
104
  end
99
105
  end
100
- end
106
+ end
@@ -90,28 +90,28 @@ module Fog
90
90
  # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-load-balancers]
91
91
  def get_all_load_balancers(datacenter_id)
92
92
  request(
93
- :expects => [200],
94
- :method => 'GET',
95
- :path => "/datacenters/#{datacenter_id}/loadbalancers?depth=5"
93
+ :expects => [200],
94
+ :method => 'GET',
95
+ :path => "/datacenters/#{datacenter_id}/loadbalancers?depth=5"
96
96
  )
97
97
  end
98
98
  end
99
99
 
100
100
  class Mock
101
101
  def get_all_load_balancers(datacenter_id)
102
- if load_balancers = self.data[:load_balancers]['items'].select {
103
- |attrib| attrib['datacenter_id'] == datacenter_id
104
- }
102
+ if load_balancers = data[:load_balancers]['items'].select do |attrib|
103
+ attrib['datacenter_id'] == datacenter_id
104
+ end
105
105
  else
106
- raise Fog::Errors::NotFound.new('The requested Load Balancer resource could not be found')
106
+ raise Fog::Errors::NotFound, 'The requested Load Balancer resource could not be found'
107
107
  end
108
108
 
109
109
  response = Excon::Response.new
110
110
  response.status = 200
111
- response.body = self.data[:load_balancers]
111
+ response.body = data[:load_balancers]
112
112
  response
113
113
  end
114
114
  end
115
115
  end
116
116
  end
117
- end
117
+ end
@@ -32,12 +32,12 @@ module Fog
32
32
  end
33
33
 
34
34
  class Mock
35
- def get_all_locations(options={})
36
- response = Excon::Response.new
37
- response.status = 200
38
- response.body = self.data[:locations]
39
- response
40
- end
35
+ def get_all_locations(_options = {})
36
+ response = Excon::Response.new
37
+ response.status = 200
38
+ response.body = data[:locations]
39
+ response
40
+ end
41
41
  end
42
42
  end
43
43
  end
@@ -1,102 +1,102 @@
1
1
  module Fog
2
- module Compute
3
- class ProfitBricks
4
- class Real
5
- # Retrieves a list of NICs
6
- #
7
- # ==== Parameters
8
- # * datacenter_id<~String> - UUID of the datacenter
9
- # * server_id<~String> - UUID of the server
10
- #
11
- # ==== Returns
12
- # * response<~Excon::Response>:
13
- # * body<~Hash>:
14
- # * id<~String> - The resource's unique identifier
15
- # * type<~String> - The type of the created resource
16
- # * href<~String> - URL to the object’s representation (absolute path)
17
- # * items<~Hash> - Collection of individual nic objects
18
- # * id<~String> - The resource's unique identifier
19
- # * type<~String> - The type of the created resource
20
- # * href<~String> - URL to the object’s representation (absolute path)
21
- # * metadata<~Hash> - Hash containing the NIC metadata
22
- # * createdDate<~String> - The date the resource was created
23
- # * createdBy<~String> - The user who created the resource
24
- # * etag<~String> - The etag for the resource
25
- # * lastModifiedDate<~String> - The last time the resource has been modified
26
- # * lastModifiedBy<~String> - The user who last modified the resource
27
- # * state<~String> - NIC state
28
- # * properties<~Hash> - Hash containing the NIC properties
29
- # * name<~String> - The name of the NIC
30
- # * mac<~String> - The MAC address of the NIC
31
- # * ips<~Array> - IPs assigned to the NIC represented as a collection
32
- # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
33
- # * lan<~Integer> - The LAN ID the NIC sits on
34
- # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value
35
- # * entities<~Hash> - Hash containing the NIC entities
36
- # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection
37
- # * id<~String> - The resource's unique identifier
38
- # * type<~String> - The type of the resource
39
- # * href<~String> - URL to the object’s representation (absolute path)
40
- # * items<~Array> - Collection of individual firewall rules objects
41
- # * id<~String> - The resource's unique identifier
42
- # * type<~String> - The type of the resource
43
- # * href<~String> - URL to the object’s representation (absolute path)
44
- # * metadata<~Hash> - Hash containing the Firewall Rule metadata
45
- # * createdDate<~String> - The date the resource was created
46
- # * createdBy<~String> - The user who created the resource
47
- # * etag<~String> - The etag for the resource
48
- # * lastModifiedDate<~String> - The last time the resource has been modified
49
- # * lastModifiedBy<~String> - The user who last modified the resource
50
- # * state<~String> - Firewall Rule state
51
- # * properties<~Hash> - Hash containing the Firewall Rule properties
52
- # * name<~String> - The name of the Firewall Rule
53
- # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
54
- # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed.
55
- # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
56
- # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed.
57
- # Value null allows all source IPs
58
- # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed
59
- # to the respective IP address of the NIC is allowed. Value null allows all target IPs
60
- # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen.
61
- # Value null allows all codes.
62
- # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen.
63
- # Value null allows all types
64
- # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534)
65
- # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd
66
- # value null to allow all ports
67
- # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534)
68
- # if the protocol TCP or UDP is chosen. Leave portRangeStart and
69
- # portRangeEnd value null to allow all ports
70
- #
71
- # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-nics]
72
- def get_all_nic(datacenter_id, server_id)
73
- request(
74
- :expects => [200],
75
- :method => 'GET',
76
- :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics?depth=5"
77
- )
78
- end
79
- end
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Retrieves a list of NICs
6
+ #
7
+ # ==== Parameters
8
+ # * datacenter_id<~String> - UUID of the datacenter
9
+ # * server_id<~String> - UUID of the server
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Hash>:
14
+ # * id<~String> - The resource's unique identifier
15
+ # * type<~String> - The type of the created resource
16
+ # * href<~String> - URL to the object’s representation (absolute path)
17
+ # * items<~Hash> - Collection of individual nic objects
18
+ # * id<~String> - The resource's unique identifier
19
+ # * type<~String> - The type of the created resource
20
+ # * href<~String> - URL to the object’s representation (absolute path)
21
+ # * metadata<~Hash> - Hash containing the NIC metadata
22
+ # * createdDate<~String> - The date the resource was created
23
+ # * createdBy<~String> - The user who created the resource
24
+ # * etag<~String> - The etag for the resource
25
+ # * lastModifiedDate<~String> - The last time the resource has been modified
26
+ # * lastModifiedBy<~String> - The user who last modified the resource
27
+ # * state<~String> - NIC state
28
+ # * properties<~Hash> - Hash containing the NIC properties
29
+ # * name<~String> - The name of the NIC
30
+ # * mac<~String> - The MAC address of the NIC
31
+ # * ips<~Array> - IPs assigned to the NIC represented as a collection
32
+ # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
33
+ # * lan<~Integer> - The LAN ID the NIC sits on
34
+ # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value
35
+ # * entities<~Hash> - Hash containing the NIC entities
36
+ # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection
37
+ # * id<~String> - The resource's unique identifier
38
+ # * type<~String> - The type of the resource
39
+ # * href<~String> - URL to the object’s representation (absolute path)
40
+ # * items<~Array> - Collection of individual firewall rules objects
41
+ # * id<~String> - The resource's unique identifier
42
+ # * type<~String> - The type of the resource
43
+ # * href<~String> - URL to the object’s representation (absolute path)
44
+ # * metadata<~Hash> - Hash containing the Firewall Rule metadata
45
+ # * createdDate<~String> - The date the resource was created
46
+ # * createdBy<~String> - The user who created the resource
47
+ # * etag<~String> - The etag for the resource
48
+ # * lastModifiedDate<~String> - The last time the resource has been modified
49
+ # * lastModifiedBy<~String> - The user who last modified the resource
50
+ # * state<~String> - Firewall Rule state
51
+ # * properties<~Hash> - Hash containing the Firewall Rule properties
52
+ # * name<~String> - The name of the Firewall Rule
53
+ # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
54
+ # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed.
55
+ # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
56
+ # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed.
57
+ # Value null allows all source IPs
58
+ # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed
59
+ # to the respective IP address of the NIC is allowed. Value null allows all target IPs
60
+ # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen.
61
+ # Value null allows all codes.
62
+ # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen.
63
+ # Value null allows all types
64
+ # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534)
65
+ # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd
66
+ # value null to allow all ports
67
+ # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534)
68
+ # if the protocol TCP or UDP is chosen. Leave portRangeStart and
69
+ # portRangeEnd value null to allow all ports
70
+ #
71
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-nics]
72
+ def get_all_nic(datacenter_id, server_id)
73
+ request(
74
+ :expects => [200],
75
+ :method => 'GET',
76
+ :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics?depth=5"
77
+ )
78
+ end
79
+ end
80
80
 
81
- class Mock
82
- def get_all_nic(datacenter_id, server_id)
83
- nics = self.data[:nics]
81
+ class Mock
82
+ def get_all_nic(datacenter_id, _server_id)
83
+ interfaces = data[:nics]
84
84
 
85
- if nics = self.data[:nics]['items'].select {
86
- |attrib| attrib['datacenter_id'] == datacenter_id
87
- }
88
- else
89
- raise Fog::Errors::NotFound.new('The resource could not be found')
90
- end
85
+ if nics = interfaces['items'].select do |attrib|
86
+ attrib['datacenter_id'] == datacenter_id
87
+ end
88
+ else
89
+ raise Fog::Errors::NotFound, 'The resource could not be found'
90
+ end
91
91
 
92
- nics['items'] = nics
93
- response = Excon::Response.new
94
- response.status = 200
95
- response.body = interfaces
92
+ interfaces['items'] = nics
93
+ response = Excon::Response.new
94
+ response.status = 200
95
+ response.body = interfaces
96
96
 
97
- response
98
- end
99
- end
97
+ response
100
98
  end
99
+ end
101
100
  end
101
+ end
102
102
  end