fog-aliyun 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/.rubocop_todo.yml +149 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Rakefile +3 -3
  7. data/fog-aliyun.gemspec +16 -13
  8. data/lib/fog/aliyun.rb +8 -8
  9. data/lib/fog/aliyun/compute.rb +99 -113
  10. data/lib/fog/aliyun/models/compute/eip_address.rb +23 -29
  11. data/lib/fog/aliyun/models/compute/eip_addresses.rb +3 -5
  12. data/lib/fog/aliyun/models/compute/image.rb +26 -28
  13. data/lib/fog/aliyun/models/compute/images.rb +2 -6
  14. data/lib/fog/aliyun/models/compute/route_entry.rb +9 -11
  15. data/lib/fog/aliyun/models/compute/route_entrys.rb +7 -7
  16. data/lib/fog/aliyun/models/compute/route_table.rb +10 -11
  17. data/lib/fog/aliyun/models/compute/route_tables.rb +2 -2
  18. data/lib/fog/aliyun/models/compute/security_group.rb +24 -24
  19. data/lib/fog/aliyun/models/compute/security_group_rule.rb +20 -20
  20. data/lib/fog/aliyun/models/compute/security_group_rules.rb +4 -4
  21. data/lib/fog/aliyun/models/compute/security_groups.rb +6 -7
  22. data/lib/fog/aliyun/models/compute/server.rb +42 -43
  23. data/lib/fog/aliyun/models/compute/servers.rb +9 -11
  24. data/lib/fog/aliyun/models/compute/snapshot.rb +15 -15
  25. data/lib/fog/aliyun/models/compute/snapshots.rb +6 -10
  26. data/lib/fog/aliyun/models/compute/volume.rb +36 -40
  27. data/lib/fog/aliyun/models/compute/volumes.rb +7 -11
  28. data/lib/fog/aliyun/models/compute/vpc.rb +18 -19
  29. data/lib/fog/aliyun/models/compute/vpcs.rb +5 -6
  30. data/lib/fog/aliyun/models/compute/vrouter.rb +13 -13
  31. data/lib/fog/aliyun/models/compute/vrouters.rb +4 -5
  32. data/lib/fog/aliyun/models/compute/vswitch.rb +18 -20
  33. data/lib/fog/aliyun/models/compute/vswitches.rb +6 -6
  34. data/lib/fog/aliyun/models/storage/directories.rb +10 -16
  35. data/lib/fog/aliyun/models/storage/directory.rb +8 -8
  36. data/lib/fog/aliyun/models/storage/file.rb +58 -64
  37. data/lib/fog/aliyun/models/storage/files.rb +95 -115
  38. data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +18 -44
  39. data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +12 -36
  40. data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +16 -40
  41. data/lib/fog/aliyun/requests/compute/attach_disk.rb +19 -22
  42. data/lib/fog/aliyun/requests/compute/create_disk.rb +33 -63
  43. data/lib/fog/aliyun/requests/compute/create_image.rb +21 -21
  44. data/lib/fog/aliyun/requests/compute/create_security_group.rb +16 -16
  45. data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +22 -63
  46. data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +23 -61
  47. data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +22 -63
  48. data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +23 -61
  49. data/lib/fog/aliyun/requests/compute/create_server.rb +76 -78
  50. data/lib/fog/aliyun/requests/compute/create_snapshot.rb +12 -26
  51. data/lib/fog/aliyun/requests/compute/create_vpc.rb +11 -38
  52. data/lib/fog/aliyun/requests/compute/create_vswitch.rb +13 -40
  53. data/lib/fog/aliyun/requests/compute/delete_disk.rb +8 -35
  54. data/lib/fog/aliyun/requests/compute/delete_image.rb +6 -33
  55. data/lib/fog/aliyun/requests/compute/delete_security_group.rb +13 -13
  56. data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +22 -63
  57. data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +23 -61
  58. data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +22 -62
  59. data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +23 -61
  60. data/lib/fog/aliyun/requests/compute/delete_server.rb +15 -15
  61. data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +6 -20
  62. data/lib/fog/aliyun/requests/compute/delete_vpc.rb +9 -26
  63. data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +9 -25
  64. data/lib/fog/aliyun/requests/compute/detach_disk.rb +11 -27
  65. data/lib/fog/aliyun/requests/compute/join_security_group.rb +15 -16
  66. data/lib/fog/aliyun/requests/compute/leave_security_group.rb +15 -16
  67. data/lib/fog/aliyun/requests/compute/list_disks.rb +24 -43
  68. data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +26 -52
  69. data/lib/fog/aliyun/requests/compute/list_images.rb +21 -24
  70. data/lib/fog/aliyun/requests/compute/list_route_tables.rb +16 -19
  71. data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +22 -23
  72. data/lib/fog/aliyun/requests/compute/list_security_groups.rb +21 -24
  73. data/lib/fog/aliyun/requests/compute/list_server_types.rb +50 -50
  74. data/lib/fog/aliyun/requests/compute/list_servers.rb +25 -28
  75. data/lib/fog/aliyun/requests/compute/list_snapshots.rb +20 -37
  76. data/lib/fog/aliyun/requests/compute/list_vpcs.rb +12 -29
  77. data/lib/fog/aliyun/requests/compute/list_vrouters.rb +13 -16
  78. data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +14 -31
  79. data/lib/fog/aliyun/requests/compute/list_zones.rb +16 -16
  80. data/lib/fog/aliyun/requests/compute/modify_vpc.rb +17 -17
  81. data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +11 -39
  82. data/lib/fog/aliyun/requests/compute/reboot_server.rb +15 -16
  83. data/lib/fog/aliyun/requests/compute/release_eip_address.rb +12 -36
  84. data/lib/fog/aliyun/requests/compute/start_server.rb +14 -15
  85. data/lib/fog/aliyun/requests/compute/stop_server.rb +13 -14
  86. data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +16 -41
  87. data/lib/fog/aliyun/requests/storage/copy_object.rb +11 -14
  88. data/lib/fog/aliyun/requests/storage/delete_bucket.rb +30 -30
  89. data/lib/fog/aliyun/requests/storage/delete_container.rb +11 -14
  90. data/lib/fog/aliyun/requests/storage/delete_object.rb +20 -22
  91. data/lib/fog/aliyun/requests/storage/get_bucket.rb +141 -148
  92. data/lib/fog/aliyun/requests/storage/get_container.rb +26 -38
  93. data/lib/fog/aliyun/requests/storage/get_containers.rb +20 -32
  94. data/lib/fog/aliyun/requests/storage/get_object.rb +12 -12
  95. data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +11 -11
  96. data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +11 -11
  97. data/lib/fog/aliyun/requests/storage/head_object.rb +11 -11
  98. data/lib/fog/aliyun/requests/storage/list_buckets.rb +40 -47
  99. data/lib/fog/aliyun/requests/storage/list_objects.rb +91 -104
  100. data/lib/fog/aliyun/requests/storage/put_bucket.rb +22 -23
  101. data/lib/fog/aliyun/requests/storage/put_container.rb +12 -12
  102. data/lib/fog/aliyun/requests/storage/put_object.rb +100 -110
  103. data/lib/fog/aliyun/storage.rb +209 -214
  104. data/lib/fog/aliyun/version.rb +1 -1
  105. data/lib/fog/bin/aliyun.rb +5 -5
  106. metadata +55 -4
@@ -4,49 +4,32 @@ module Fog
4
4
  class Real
5
5
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vpc&deletevpc]
6
6
  def delete_vpc(vpc_id)
7
-
8
7
  action = 'DeleteVpc'
9
- sigNonce = randonStr()
8
+ sigNonce = randonStr
10
9
  time = Time.new.utc
11
10
 
12
11
  parameters = defalutParameters(action, sigNonce, time)
13
12
  pathUrl = defaultAliyunUri(action, sigNonce, time)
14
13
 
15
14
  if vpc_id
16
- parameters["VpcId"] = vpc_id
15
+ parameters['VpcId'] = vpc_id
17
16
  pathUrl += '&VpcId='
18
- pathUrl += vpc_id
17
+ pathUrl += vpc_id
19
18
  else
20
- raise ArgumentError, "Missing required vpc_id"
19
+ raise ArgumentError, 'Missing required vpc_id'
21
20
  end
22
21
 
23
22
  signature = sign(@aliyun_accesskey_secret, parameters)
24
23
  pathUrl += '&Signature='
25
24
  pathUrl += signature
26
-
25
+
27
26
  request(
28
- :expects => [200, 203],
29
- :method => 'GET',
30
- :path => pathUrl
27
+ expects: [200, 203],
28
+ method: 'GET',
29
+ path: pathUrl
31
30
  )
32
31
  end
33
32
  end
34
-
35
- class Mock
36
- def delete_security_group(security_group_id)
37
- self.data[:security_groups].delete security_group_id.to_s
38
-
39
- response = Excon::Response.new
40
- response.status = 202
41
- response.headers = {
42
- "Content-Type" => "text/html; charset=UTF-8",
43
- "Content-Length" => "0",
44
- "Date" => Date.new
45
- }
46
- response.body = {}
47
- response
48
- end
49
- end # mock
50
33
  end # aliyun
51
34
  end # compute
52
- end #fog
35
+ end # fog
@@ -5,47 +5,31 @@ module Fog
5
5
  def delete_vswitch(vswitch_id)
6
6
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/vswitch&deletevswitch]
7
7
  action = 'DeleteVSwitch'
8
- sigNonce = randonStr()
8
+ sigNonce = randonStr
9
9
  time = Time.new.utc
10
10
 
11
11
  parameters = defalutParameters(action, sigNonce, time)
12
12
  pathUrl = defaultAliyunUri(action, sigNonce, time)
13
13
 
14
14
  if vswitch_id
15
- parameters["VSwitchId"] = vswitch_id
15
+ parameters['VSwitchId'] = vswitch_id
16
16
  pathUrl += '&VSwitchId='
17
- pathUrl += vswitch_id
17
+ pathUrl += vswitch_id
18
18
  else
19
- raise ArgumentError, "Missing required vswitch_id"
19
+ raise ArgumentError, 'Missing required vswitch_id'
20
20
  end
21
21
 
22
22
  signature = sign(@aliyun_accesskey_secret, parameters)
23
23
  pathUrl += '&Signature='
24
24
  pathUrl += signature
25
-
25
+
26
26
  request(
27
- :expects => [200, 203],
28
- :method => 'GET',
29
- :path => pathUrl
27
+ expects: [200, 203],
28
+ method: 'GET',
29
+ path: pathUrl
30
30
  )
31
31
  end
32
32
  end
33
-
34
- class Mock
35
- def delete_security_group(security_group_id)
36
- self.data[:security_groups].delete security_group_id.to_s
37
-
38
- response = Excon::Response.new
39
- response.status = 202
40
- response.headers = {
41
- "Content-Type" => "text/html; charset=UTF-8",
42
- "Content-Length" => "0",
43
- "Date" => Date.new
44
- }
45
- response.body = {}
46
- response
47
- end
48
- end # mock
49
33
  end # aliyun
50
34
  end # compute
51
- end #fog
35
+ end # fog
@@ -3,54 +3,38 @@ module Fog
3
3
  class Aliyun
4
4
  class Real
5
5
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/disk&detachdisk]
6
- def detach_disk(instanceId, diskId,options={})
6
+ def detach_disk(instanceId, diskId, _options = {})
7
7
  action = 'DetachDisk'
8
- sigNonce = randonStr()
8
+ sigNonce = randonStr
9
9
  time = Time.new.utc
10
10
 
11
11
  parameters = defalutParameters(action, sigNonce, time)
12
12
  pathUrl = defaultAliyunUri(action, sigNonce, time)
13
-
14
- parameters["InstanceId"] = instanceId
13
+
14
+ parameters['InstanceId'] = instanceId
15
15
  pathUrl += '&InstanceId='
16
- pathUrl += instanceId
16
+ pathUrl += instanceId
17
17
 
18
- parameters["DiskId"] = diskId
18
+ parameters['DiskId'] = diskId
19
19
  pathUrl += '&DiskId='
20
20
  pathUrl += diskId
21
21
 
22
22
  if device
23
- parameters["Device"] = device
23
+ parameters['Device'] = device
24
24
  pathUrl += '&Device='
25
- pathUrl += URI.encode(device,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
25
+ pathUrl += URI.encode(device, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
26
26
  end
27
27
  signature = sign(@aliyun_accesskey_secret, parameters)
28
28
  pathUrl += '&Signature='
29
29
  pathUrl += signature
30
30
 
31
31
  request(
32
- :expects => [200, 203],
33
- :method => 'GET',
34
- :path => pathUrl
32
+ expects: [200, 203],
33
+ method: 'GET',
34
+ path: pathUrl
35
35
  )
36
36
  end
37
37
  end
38
-
39
- class Mock
40
- def attach_volume(volume_id, server_id, device)
41
- response = Excon::Response.new
42
- response.status = 200
43
- data = {
44
- 'id' => volume_id,
45
- 'volumeId' => volume_id,
46
- 'serverId' => server_id,
47
- 'device' => device
48
- }
49
- self.data[:volumes][volume_id]['attachments'] << data
50
- response.body = { 'volumeAttachment' => data }
51
- response
52
- end
53
- end
54
38
  end
55
39
  end
56
40
  end
@@ -4,33 +4,32 @@ module Fog
4
4
  class Real
5
5
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&joinsecuritygroup]
6
6
  def join_security_group(server_id, group_id)
7
-
8
7
  _action = 'JoinSecurityGroup'
9
- _sigNonce = randonStr()
8
+ _sigNonce = randonStr
10
9
  _time = Time.new.utc
11
10
 
12
11
  _parameters = defalutParameters(_action, _sigNonce, _time)
13
- _pathURL = defaultAliyunUri(_action, _sigNonce, _time)
14
-
15
- _parameters['InstanceId']=server_id
16
- _pathURL += '&InstanceId='+server_id
17
-
18
- _parameters['SecurityGroupId']=group_id
19
- _pathURL += '&SecurityGroupId='+group_id
20
-
12
+ _pathURL = defaultAliyunUri(_action, _sigNonce, _time)
13
+
14
+ _parameters['InstanceId'] = server_id
15
+ _pathURL += '&InstanceId=' + server_id
16
+
17
+ _parameters['SecurityGroupId'] = group_id
18
+ _pathURL += '&SecurityGroupId=' + group_id
19
+
21
20
  _signature = sign(@aliyun_accesskey_secret, _parameters)
22
- _pathURL += '&Signature='+_signature
23
-
21
+ _pathURL += '&Signature=' + _signature
22
+
24
23
  request(
25
- :expects => [200, 204],
26
- :method => 'GET',
27
- :path => _pathURL
24
+ expects: [200, 204],
25
+ method: 'GET',
26
+ path: _pathURL
28
27
  )
29
28
  end
30
29
  end
31
30
 
32
31
  class Mock
33
- def join_security_group(server_id, group_id)
32
+ def join_security_group(_server_id, _group_id)
34
33
  response = Excon::Response.new
35
34
  response.status = 200
36
35
  response
@@ -4,33 +4,32 @@ module Fog
4
4
  class Real
5
5
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/instance&leavesecuritygroup]
6
6
  def leave_security_group(server_id, group_id)
7
-
8
7
  _action = 'LeaveSecurityGroup'
9
- _sigNonce = randonStr()
8
+ _sigNonce = randonStr
10
9
  _time = Time.new.utc
11
10
 
12
11
  _parameters = defalutParameters(_action, _sigNonce, _time)
13
- _pathURL = defaultAliyunUri(_action, _sigNonce, _time)
14
-
15
- _parameters['InstanceId']=server_id
16
- _pathURL += '&InstanceId='+server_id
17
-
18
- _parameters['SecurityGroupId']=group_id
19
- _pathURL += '&SecurityGroupId='+group_id
20
-
12
+ _pathURL = defaultAliyunUri(_action, _sigNonce, _time)
13
+
14
+ _parameters['InstanceId'] = server_id
15
+ _pathURL += '&InstanceId=' + server_id
16
+
17
+ _parameters['SecurityGroupId'] = group_id
18
+ _pathURL += '&SecurityGroupId=' + group_id
19
+
21
20
  _signature = sign(@aliyun_accesskey_secret, _parameters)
22
- _pathURL += '&Signature='+_signature
23
-
21
+ _pathURL += '&Signature=' + _signature
22
+
24
23
  request(
25
- :expects => [200, 204],
26
- :method => 'GET',
27
- :path => _pathURL
24
+ expects: [200, 204],
25
+ method: 'GET',
26
+ path: _pathURL
28
27
  )
29
28
  end
30
29
  end
31
30
 
32
31
  class Mock
33
- def add_security_group(server_id, group_name)
32
+ def add_security_group(_server_id, _group_name)
34
33
  response = Excon::Response.new
35
34
  response.status = 200
36
35
  response
@@ -14,7 +14,7 @@ module Fog
14
14
  # * :snapshotId - id of snapshot which used to create disk.
15
15
  # * :name - name of disk
16
16
  # * :portable - If ture, can exist dependently,which means it can be mount or umont in available zones.
17
- # Else, it must be created or destroyed with a instance.
17
+ # Else, it must be created or destroyed with a instance.
18
18
  # The value for ocal disks and system disks on the cloud and cloud disks paid by month must be false.
19
19
  # * :delWithIns - If ture, the disk will be released when the instance is released.
20
20
  # * :delAutoSna - If ture, the auto created snapshot will be destroyed when the disk is destroyed
@@ -27,9 +27,9 @@ module Fog
27
27
  # * 'Disks'<~Hash> - list of Disk,and the parameter of disk refer to the Volume model
28
28
  #
29
29
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/disk&describedisks]
30
- def list_disks(options={})
30
+ def list_disks(options = {})
31
31
  action = 'DescribeDisks'
32
- sigNonce = randonStr()
32
+ sigNonce = randonStr
33
33
  time = Time.new.utc
34
34
 
35
35
  parameters = defalutParameters(action, sigNonce, time)
@@ -51,116 +51,97 @@ module Fog
51
51
  diskChargeType = options[:diskChargeType]
52
52
 
53
53
  if diskChargeType
54
- parameters["DiskChargeType"] = diskChargeType
54
+ parameters['DiskChargeType'] = diskChargeType
55
55
  pathUrl += '&DiskChargeType='
56
56
  pathUrl += diskChargeType
57
57
  end
58
58
 
59
59
  if enAutoSna
60
- parameters["EnableAutoSnapshot"] = enAutoSna
60
+ parameters['EnableAutoSnapshot'] = enAutoSna
61
61
  pathUrl += '&EnableAutoSnapshot='
62
62
  pathUrl += enAutoSna
63
63
  end
64
64
 
65
65
  if delAutoSna
66
- parameters["DeleteAutoSnapshot"] = delAutoSna
66
+ parameters['DeleteAutoSnapshot'] = delAutoSna
67
67
  pathUrl += '&DeleteAutoSnapshot='
68
68
  pathUrl += delAutoSna
69
69
  end
70
70
 
71
71
  if delWithIns
72
- parameters["DeleteWithInstance"] = delWithIns
72
+ parameters['DeleteWithInstance'] = delWithIns
73
73
  pathUrl += '&DeleteWithInstance='
74
74
  pathUrl += delWithIns
75
75
  end
76
76
 
77
77
  if portable
78
- parameters["Portable"] = portable
78
+ parameters['Portable'] = portable
79
79
  pathUrl += '&Portable='
80
80
  pathUrl += portable
81
81
  end
82
82
 
83
83
  if name
84
- parameters["DiskName"] = name
84
+ parameters['DiskName'] = name
85
85
  pathUrl += '&DiskName='
86
86
  pathUrl += name
87
87
  end
88
88
 
89
89
  if snapshotId
90
- parameters["SnapshotId"] = snapshotId
90
+ parameters['SnapshotId'] = snapshotId
91
91
  pathUrl += '&SnapshotId='
92
92
  pathUrl += snapshotId
93
93
  end
94
94
 
95
95
  if state
96
- parameters["Status"] = state
96
+ parameters['Status'] = state
97
97
  pathUrl += '&Status='
98
98
  pathUrl += state
99
99
  end
100
100
 
101
101
  if category
102
- parameters["DiskType"] = diskType
102
+ parameters['DiskType'] = diskType
103
103
  pathUrl += '&DiskType='
104
104
  pathUrl += diskType
105
105
  end
106
106
 
107
107
  if category
108
- parameters["Category"] = category
108
+ parameters['Category'] = category
109
109
  pathUrl += '&Category='
110
110
  pathUrl += category
111
111
  end
112
112
 
113
113
  if instanceId
114
- parameters["InstanceId"] = instanceId
114
+ parameters['InstanceId'] = instanceId
115
115
  pathUrl += '&InstanceId='
116
116
  pathUrl += instanceId
117
117
  end
118
118
 
119
119
  if diskIds
120
- parameters["DiskIds"] = Fog::JSON.encode(diskIds)
120
+ parameters['DiskIds'] = Fog::JSON.encode(diskIds)
121
121
  pathUrl += '&DiskIds='
122
122
  pathUrl += Fog::JSON.encode(diskIds)
123
123
  end
124
-
124
+
125
125
  if pageNumber
126
- parameters["PageNumber"] = pageNumber
126
+ parameters['PageNumber'] = pageNumber
127
127
  pathUrl += '&PageNumber='
128
128
  pathUrl += pageNumber
129
129
  end
130
130
 
131
- pageSize = options[:pageSize]
132
- unless pageSize
133
- pageSize = '50'
134
- end
135
- parameters["PageSize"] = pageSize
131
+ pageSize = options[:pageSize]
132
+ pageSize = '50' unless pageSize
133
+ parameters['PageSize'] = pageSize
136
134
  pathUrl += '&PageSize='
137
- pathUrl += pageSize
135
+ pathUrl += pageSize
138
136
 
139
137
  signature = sign(@aliyun_accesskey_secret, parameters)
140
138
  pathUrl += '&Signature='
141
139
  pathUrl += signature
142
140
 
143
141
  request(
144
- :expects => [200, 203],
145
- :method => 'GET',
146
- :path => pathUrl
147
- )
148
- end
149
- end
150
-
151
- class Mock
152
- def list_zones(*args)
153
- Excon::Response.new(
154
- :body => { "availabilityZoneInfo" => [
155
- {
156
- "zoneState" => {
157
- "available" => true
158
- },
159
- "hosts" => nil,
160
- "zoneName" => "nova"
161
- }
162
- ] },
163
- :status => 200
142
+ expects: [200, 203],
143
+ method: 'GET',
144
+ path: pathUrl
164
145
  )
165
146
  end
166
147
  end
@@ -3,79 +3,53 @@ module Fog
3
3
  class Aliyun
4
4
  class Real
5
5
  # {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/network&describeeipaddress]
6
- def list_eip_addresses(options={})
7
-
6
+ def list_eip_addresses(options = {})
8
7
  _action = 'DescribeEipAddresses'
9
- _sigNonce = randonStr()
8
+ _sigNonce = randonStr
10
9
  _time = Time.new.utc
11
10
 
12
11
  _parameters = defalutParameters(_action, _sigNonce, _time)
13
- _pathURL = defaultAliyunUri(_action, _sigNonce, _time)
14
-
12
+ _pathURL = defaultAliyunUri(_action, _sigNonce, _time)
13
+
15
14
  _Status = options[:state]
16
15
  if _Status
17
- _parameters['Status']=_Status
18
- _pathURL += '&Status='+_Status
16
+ _parameters['Status'] = _Status
17
+ _pathURL += '&Status=' + _Status
19
18
  end
20
-
19
+
21
20
  _EipAddress = options[:ip_address]
22
21
  if _EipAddress
23
- _parameters['EipAddress']=_EipAddress
24
- _pathURL += '&EipAddress='+_EipAddress
22
+ _parameters['EipAddress'] = _EipAddress
23
+ _pathURL += '&EipAddress=' + _EipAddress
25
24
  end
26
-
25
+
27
26
  _AllocationId = options[:allocation_id]
28
27
  if _AllocationId
29
- _parameters['AllocationId']=_AllocationId
30
- _pathURL += '&AllocationId='+_AllocationId
28
+ _parameters['AllocationId'] = _AllocationId
29
+ _pathURL += '&AllocationId=' + _AllocationId
31
30
  end
32
-
31
+
33
32
  _PageNumber = options[:page_number]
34
33
  if _PageNumber
35
- _parameters['PageNumber']=_PageNumber
36
- _pathURL += '&PageNumber='+_PageNumber
34
+ _parameters['PageNumber'] = _PageNumber
35
+ _pathURL += '&PageNumber=' + _PageNumber
37
36
  end
38
37
 
39
- _PageSize = options[:page_size]
40
- unless _PageSize
41
- _PageSize = '50'
42
- end
43
- _parameters['PageSize']=_PageSize
44
- _pathURL += '&PageSize='+_PageSize
45
-
38
+ _PageSize = options[:page_size]
39
+ _PageSize = '50' unless _PageSize
40
+ _parameters['PageSize'] = _PageSize
41
+ _pathURL += '&PageSize=' + _PageSize
42
+
46
43
  _signature = sign(@aliyun_accesskey_secret, _parameters)
47
- _pathURL += '&Signature='+_signature
48
-
44
+ _pathURL += '&Signature=' + _signature
45
+
49
46
  request(
50
- :expects => [200, 204],
51
- :method => 'GET',
52
- :path => _pathURL
47
+ expects: [200, 204],
48
+ method: 'GET',
49
+ path: _pathURL
53
50
  )
54
51
  end
55
52
  end
56
-
57
- class Mock
58
- def allocate_address(pool = nil)
59
- response = Excon::Response.new
60
- response.status = 200
61
- response.headers = {
62
- "X-Compute-Request-Id" => "req-d4a21158-a86c-44a6-983a-e25645907f26",
63
- "Content-Type" => "application/json",
64
- "Content-Length" => "105",
65
- "Date"=> Date.new
66
- }
67
- response.body = {
68
- "floating_ip" => {
69
- "instance_id" => nil,
70
- "ip" => "192.168.27.132",
71
- "fixed_ip" => nil,
72
- "id" => 4,
73
- "pool"=>"nova"
74
- }
75
- }
76
- response
77
- end
78
- end # mock
79
53
  end # aliyun
80
- end #compute
54
+ end # compute
81
55
  end