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
@@ -3,7 +3,7 @@ module Fog
3
3
  class Aliyun
4
4
  class Real
5
5
  def get_container(container, options = {})
6
- options = options.reject {|key, value| value.nil?}
6
+ options = options.reject { |_key, value| value.nil? }
7
7
 
8
8
  bucket = options[:bucket]
9
9
  bucket ||= @aliyun_oss_bucket
@@ -12,57 +12,45 @@ module Fog
12
12
  maxKeys = options[:maxKeys]
13
13
  delimiter = '/'
14
14
 
15
- path = ""
15
+ path = ''
16
16
 
17
- if container == "" || container == "." || container == nil
18
- prefix = nil
19
- else
20
- prefix = container+'/'
21
- end
17
+ prefix = if container == '' || container == '.' || container.nil?
18
+ nil
19
+ else
20
+ container + '/'
21
+ end
22
22
 
23
23
  if prefix
24
- path+="?prefix="+prefix
25
- if marker
26
- path+="&marker="+marker
27
- end
28
- if maxKeys
29
- path+="&max-keys="+maxKeys
30
- end
31
- if delimiter
32
- path+="&delimiter="+delimiter
33
- end
24
+ path += '?prefix=' + prefix
25
+ path += '&marker=' + marker if marker
26
+ path += '&max-keys=' + maxKeys if maxKeys
27
+ path += '&delimiter=' + delimiter if delimiter
34
28
  elsif marker
35
- path+="?marker="+marker
36
- if maxKeys
37
- path+="&max-keys="+maxKeys
38
- end
39
- if delimiter
40
- path+="&delimiter="+delimiter
41
- end
29
+ path += '?marker=' + marker
30
+ path += '&max-keys=' + maxKeys if maxKeys
31
+ path += '&delimiter=' + delimiter if delimiter
42
32
  elsif maxKeys
43
- path+="?max-keys="+maxKeys
44
- if delimiter
45
- path+="&delimiter="+delimiter
46
- end
33
+ path += '?max-keys=' + maxKeys
34
+ path += '&delimiter=' + delimiter if delimiter
47
35
  elsif delimiter
48
- path+="?delimiter="+delimiter
36
+ path += '?delimiter=' + delimiter
49
37
  end
50
38
 
51
39
  location = get_bucket_location(bucket)
52
- endpoint = "http://"+location+".aliyuncs.com"
53
- resource = bucket+'/'
40
+ endpoint = 'http://' + location + '.aliyuncs.com'
41
+ resource = bucket + '/'
54
42
  ret = request(
55
- :expects => [200, 203, 400],
56
- :method => 'GET',
57
- :path => path,
58
- :resource => resource,
59
- :bucket => bucket
43
+ expects: [200, 203, 400],
44
+ method: 'GET',
45
+ path: path,
46
+ resource: resource,
47
+ bucket: bucket
60
48
  )
61
49
  xml = ret.data[:body]
62
- result = XmlSimple.xml_in(xml)["CommonPrefixes"]
50
+ result = XmlSimple.xml_in(xml)['CommonPrefixes']
63
51
  end
64
52
  end
65
-
53
+
66
54
  class Mock
67
55
  def get_container(container, options = {})
68
56
  end
@@ -12,7 +12,7 @@ module Fog
12
12
  # ==== Returns
13
13
  #
14
14
  def get_containers(options = {})
15
- options = options.reject {|key, value| value.nil?}
15
+ options = options.reject { |_key, value| value.nil? }
16
16
  bucket = options[:bucket]
17
17
  bucket ||= @aliyun_oss_bucket
18
18
  prefix = options[:prefix]
@@ -20,50 +20,38 @@ module Fog
20
20
  maxKeys = options[:maxKeys]
21
21
  delimiter = '/'
22
22
 
23
- path = ""
23
+ path = ''
24
24
  if prefix
25
- path+="?prefix="+prefix
26
- if marker
27
- path+="&marker="+marker
28
- end
29
- if maxKeys
30
- path+="&max-keys="+maxKeys
31
- end
32
- if delimiter
33
- path+="&delimiter="+delimiter
34
- end
25
+ path += '?prefix=' + prefix
26
+ path += '&marker=' + marker if marker
27
+ path += '&max-keys=' + maxKeys if maxKeys
28
+ path += '&delimiter=' + delimiter if delimiter
35
29
 
36
30
  elsif marker
37
- path+="?marker="+marker
38
- if maxKeys
39
- path+="&max-keys="+maxKeys
40
- end
41
- if delimiter
42
- path+="&delimiter="+delimiter
43
- end
31
+ path += '?marker=' + marker
32
+ path += '&max-keys=' + maxKeys if maxKeys
33
+ path += '&delimiter=' + delimiter if delimiter
44
34
 
45
35
  elsif maxKeys
46
- path+="?max-keys="+maxKeys
47
- if delimiter
48
- path+="&delimiter="+delimiter
49
- end
36
+ path += '?max-keys=' + maxKeys
37
+ path += '&delimiter=' + delimiter if delimiter
50
38
 
51
39
  elsif delimiter
52
- path+="?delimiter="+delimiter
40
+ path += '?delimiter=' + delimiter
53
41
  end
54
42
 
55
43
  location = get_bucket_location(bucket)
56
- endpoint = "http://"+location+".aliyuncs.com"
57
- resource = bucket+'/'
44
+ endpoint = 'http://' + location + '.aliyuncs.com'
45
+ resource = bucket + '/'
58
46
  ret = request(
59
- :expects => [200, 203, 400],
60
- :method => 'GET',
61
- :path => path,
62
- :resource => resource,
63
- :bucket => bucket
47
+ expects: [200, 203, 400],
48
+ method: 'GET',
49
+ path: path,
50
+ resource: resource,
51
+ bucket: bucket
64
52
  )
65
53
  xml = ret.data[:body]
66
- result = XmlSimple.xml_in(xml)["CommonPrefixes"]
54
+ result = XmlSimple.xml_in(xml)['CommonPrefixes']
67
55
  end
68
56
  end
69
57
 
@@ -8,27 +8,27 @@ module Fog
8
8
  # * object<~String> - Name of object to look for
9
9
  #
10
10
  def get_object(object, range = nil, options = {})
11
- options = options.reject {|key, value| value.nil?}
11
+ options = options.reject { |_key, value| value.nil? }
12
12
  bucket = options[:bucket]
13
13
  bucket ||= @aliyun_oss_bucket
14
14
  endpoint = options[:endpoint]
15
- if (nil == endpoint)
15
+ if nil == endpoint
16
16
  location = get_bucket_location(bucket)
17
- endpoint = "http://"+location+".aliyuncs.com"
17
+ endpoint = 'http://' + location + '.aliyuncs.com'
18
18
  end
19
- resource = bucket+'/'+object
19
+ resource = bucket + '/' + object
20
20
  para = {
21
- :expects => [200, 206, 404],
22
- :method => 'GET',
23
- :path => object,
24
- :bucket => bucket,
25
- :resource => resource,
26
- :endpoint => endpoint
21
+ expects: [200, 206, 404],
22
+ method: 'GET',
23
+ path: object,
24
+ bucket: bucket,
25
+ resource: resource,
26
+ endpoint: endpoint
27
27
  }
28
28
 
29
29
  if range
30
- rangeStr = "bytes="+range
31
- para[:headers] = {'Range' => rangeStr}
30
+ rangeStr = 'bytes=' + range
31
+ para[:headers] = { 'Range' => rangeStr }
32
32
  end
33
33
 
34
34
  response = request(para)
@@ -13,23 +13,23 @@ module Fog
13
13
  # * response<~Excon::Response>:
14
14
  # * body<~String> - url for object
15
15
  def get_object_http_url_public(object, expires, options = {})
16
- options = options.reject {|key, value| value.nil?}
16
+ options = options.reject { |_key, value| value.nil? }
17
17
  bucket = options[:bucket]
18
18
  bucket ||= @aliyun_oss_bucket
19
19
  acl = get_bucket_acl(bucket)
20
20
  location = get_bucket_location(bucket)
21
-
22
- if "private" == acl
21
+
22
+ if 'private' == acl
23
23
  expires_time = (Time.now.to_i + expires).to_s
24
- resource = bucket+'/'+object
25
- signature = sign("GET", expires_time, nil, resource)
26
- url = "http://"+bucket+"."+location+".aliyuncs.com/"+object+
27
- "?OSSAccessKeyId="+@aliyun_accesskey_id+"&Expires="+expires_time+
28
- "&Signature="+URI.encode(signature,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
29
- elsif "public-read" == acl or "public-read-write" == acl
30
- url = "http://"+bucket+"."+location+".aliyuncs.com/"+object
24
+ resource = bucket + '/' + object
25
+ signature = sign('GET', expires_time, nil, resource)
26
+ url = 'http://' + bucket + '.' + location + '.aliyuncs.com/' + object +
27
+ '?OSSAccessKeyId=' + @aliyun_accesskey_id + '&Expires=' + expires_time +
28
+ '&Signature=' + URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
29
+ elsif 'public-read' == acl || 'public-read-write' == acl
30
+ url = 'http://' + bucket + '.' + location + '.aliyuncs.com/' + object
31
31
  else
32
- url = "acl is wrong with value:"+acl
32
+ url = 'acl is wrong with value:' + acl
33
33
  end
34
34
  end
35
35
  end
@@ -13,23 +13,23 @@ module Fog
13
13
  # * response<~Excon::Response>:
14
14
  # * body<~String> - url for object
15
15
  def get_object_https_url_public(object, expires, options = {})
16
- options = options.reject {|key, value| value.nil?}
16
+ options = options.reject { |_key, value| value.nil? }
17
17
  bucket = options[:bucket]
18
18
  bucket ||= @aliyun_oss_bucket
19
19
  acl = get_bucket_acl(bucket)
20
20
  location = get_bucket_location(bucket)
21
-
22
- if "private" == acl
21
+
22
+ if 'private' == acl
23
23
  expires_time = (Time.now.to_i + expires).to_s
24
- resource = bucket+'/'+object
25
- signature = sign("GET", expires_time, nil, resource)
26
- url = "https://"+bucket+"."+location+".aliyuncs.com/"+object+
27
- "?OSSAccessKeyId="+@aliyun_accesskey_id+"&Expires="+expires_time+
28
- "&Signature="+URI.encode(signature,'/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
29
- elsif "public-read" == acl or "public-read-write" == acl
30
- url = "https://"+bucket+"."+location+".aliyuncs.com/"+object
24
+ resource = bucket + '/' + object
25
+ signature = sign('GET', expires_time, nil, resource)
26
+ url = 'https://' + bucket + '.' + location + '.aliyuncs.com/' + object +
27
+ '?OSSAccessKeyId=' + @aliyun_accesskey_id + '&Expires=' + expires_time +
28
+ '&Signature=' + URI.encode(signature, '/[^!*\'()\;?:@#&%=+$,{}[]<>`" ')
29
+ elsif 'public-read' == acl || 'public-read-write' == acl
30
+ url = 'https://' + bucket + '.' + location + '.aliyuncs.com/' + object
31
31
  else
32
- url = "acl is wrong with value:"+acl
32
+ url = 'acl is wrong with value:' + acl
33
33
  end
34
34
  end
35
35
  end
@@ -7,26 +7,26 @@ module Fog
7
7
  # ==== Parameters
8
8
  # * object<~String> - Name of object to look for
9
9
  #
10
- def head_object(object, options={})
10
+ def head_object(object, options = {})
11
11
  bucket = options[:bucket]
12
12
  bucket ||= @aliyun_oss_bucket
13
13
  location = get_bucket_location(bucket)
14
- endpoint = "http://"+location+".aliyuncs.com"
15
- resource = bucket+'/'+object
14
+ endpoint = 'http://' + location + '.aliyuncs.com'
15
+ resource = bucket + '/' + object
16
16
  ret = request(
17
- :expects => [200, 404],
18
- :method => 'HEAD',
19
- :path => object,
20
- :bucket => bucket,
21
- :resource => resource,
22
- :endpoint => endpoint
17
+ expects: [200, 404],
18
+ method: 'HEAD',
19
+ path: object,
20
+ bucket: bucket,
21
+ resource: resource,
22
+ endpoint: endpoint
23
23
  )
24
- return ret
24
+ ret
25
25
  end
26
26
  end
27
27
 
28
28
  class Mock
29
- def head_object(object, options={})
29
+ def head_object(object, options = {})
30
30
  end
31
31
  end
32
32
  end
@@ -1,47 +1,40 @@
1
- module Fog
2
- module Storage
3
- class Aliyun
4
- class Real
5
- def list_buckets(options={})
6
- prefix = options[:prefix]
7
- marker = options[:marker]
8
- maxKeys = options[:maxKeys]
9
-
10
- path = ""
11
- if prefix
12
- path+="?prefix="+prefix
13
- if marker
14
- path+="&marker="+marker
15
- end
16
- if maxKeys
17
- path+="&max-keys="+maxKeys
18
- end
19
-
20
- elsif marker
21
- path+="?marker="+marker
22
- if maxKeys
23
- path+="&max-keys="+maxKeys
24
- end
25
-
26
- elsif maxKeys
27
- path+="?max-keys="+maxKeys
28
- end
29
-
30
- ret = request(
31
- :expects => [200, 203],
32
- :method => 'GET',
33
- :path => path
34
- )
35
- xml = ret.data[:body]
36
- result = XmlSimple.xml_in(xml)["Buckets"][0]
37
- end
38
-
39
- end
40
-
41
- class Mock
42
- def list_buckets(options={})
43
- end
44
- end
45
- end
46
- end
47
- end
1
+ module Fog
2
+ module Storage
3
+ class Aliyun
4
+ class Real
5
+ def list_buckets(options = {})
6
+ prefix = options[:prefix]
7
+ marker = options[:marker]
8
+ maxKeys = options[:maxKeys]
9
+
10
+ path = ''
11
+ if prefix
12
+ path += '?prefix=' + prefix
13
+ path += '&marker=' + marker if marker
14
+ path += '&max-keys=' + maxKeys if maxKeys
15
+
16
+ elsif marker
17
+ path += '?marker=' + marker
18
+ path += '&max-keys=' + maxKeys if maxKeys
19
+
20
+ elsif maxKeys
21
+ path += '?max-keys=' + maxKeys
22
+ end
23
+
24
+ ret = request(
25
+ expects: [200, 203],
26
+ method: 'GET',
27
+ path: path
28
+ )
29
+ xml = ret.data[:body]
30
+ result = XmlSimple.xml_in(xml)['Buckets'][0]
31
+ end
32
+ end
33
+
34
+ class Mock
35
+ def list_buckets(options = {})
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,104 +1,91 @@
1
- module Fog
2
- module Storage
3
- class Aliyun
4
- class Real
5
- def list_objects(options={})
6
- bucket = options[:bucket]
7
- bucket ||= @aliyun_oss_bucket
8
- prefix = options[:prefix]
9
- marker = options[:marker]
10
- maxKeys = options[:maxKeys]
11
- delimiter = options[:delimiter]
12
-
13
- path = ""
14
- if prefix
15
- path+="?prefix="+prefix
16
- if marker
17
- path+="&marker="+marker
18
- end
19
- if maxKeys
20
- path+="&max-keys="+maxKeys
21
- end
22
- if delimiter
23
- path+="&delimiter="+delimiter
24
- end
25
-
26
- elsif marker
27
- path+="?marker="+marker
28
- if maxKeys
29
- path+="&max-keys="+maxKeys
30
- end
31
- if delimiter
32
- path+="&delimiter="+delimiter
33
- end
34
-
35
- elsif maxKeys
36
- path+="?max-keys="+maxKeys
37
- if delimiter
38
- path+="&delimiter="+delimiter
39
- end
40
- elsif delimiter
41
- path+="?delimiter="+delimiter
42
- end
43
-
44
- location = get_bucket_location(bucket)
45
- endpoint = "http://"+location+".aliyuncs.com"
46
- resource = bucket+'/'
47
- ret = request(
48
- :expects => [200, 203, 400],
49
- :method => 'GET',
50
- :path => path,
51
- :resource => resource,
52
- :bucket => bucket
53
- )
54
- xml = ret.data[:body]
55
- result = XmlSimple.xml_in(xml)
56
- end
57
-
58
- def list_multipart_uploads(bucket, endpoint, options = {})
59
- if (nil == endpoint)
60
- location = get_bucket_location(bucket)
61
- endpoint = "http://"+location+".aliyuncs.com"
62
- end
63
- path = "?uploads"
64
- resource = bucket+'/'+path
65
-
66
- ret = request(
67
- :expects => 200,
68
- :method => 'GET',
69
- :path => path,
70
- :bucket => bucket,
71
- :resource => resource,
72
- :endpoint => endpoint
73
- )
74
- uploadid = XmlSimple.xml_in(ret.data[:body])["Upload"]
75
- end
76
-
77
- def list_parts(bucket, object, endpoint, uploadid, options = {})
78
- if (nil == endpoint)
79
- location = get_bucket_location(bucket)
80
- endpoint = "http://"+location+".aliyuncs.com"
81
- end
82
- path = object+"?uploadId="+uploadid
83
- resource = bucket+'/'+path
84
-
85
- ret = request(
86
- :expects => 200,
87
- :method => 'GET',
88
- :path => path,
89
- :bucket => bucket,
90
- :resource => resource,
91
- :endpoint => endpoint
92
- )
93
- parts = XmlSimple.xml_in(ret.data[:body])["Part"]
94
- end
95
-
96
- end
97
-
98
- class Mock
99
- def list_objects(options={})
100
- end
101
- end
102
- end
103
- end
104
- end
1
+ module Fog
2
+ module Storage
3
+ class Aliyun
4
+ class Real
5
+ def list_objects(options = {})
6
+ bucket = options[:bucket]
7
+ bucket ||= @aliyun_oss_bucket
8
+ prefix = options[:prefix]
9
+ marker = options[:marker]
10
+ maxKeys = options[:maxKeys]
11
+ delimiter = options[:delimiter]
12
+
13
+ path = ''
14
+ if prefix
15
+ path += '?prefix=' + prefix
16
+ path += '&marker=' + marker if marker
17
+ path += '&max-keys=' + maxKeys if maxKeys
18
+ path += '&delimiter=' + delimiter if delimiter
19
+
20
+ elsif marker
21
+ path += '?marker=' + marker
22
+ path += '&max-keys=' + maxKeys if maxKeys
23
+ path += '&delimiter=' + delimiter if delimiter
24
+
25
+ elsif maxKeys
26
+ path += '?max-keys=' + maxKeys
27
+ path += '&delimiter=' + delimiter if delimiter
28
+ elsif delimiter
29
+ path += '?delimiter=' + delimiter
30
+ end
31
+
32
+ location = get_bucket_location(bucket)
33
+ endpoint = 'http://' + location + '.aliyuncs.com'
34
+ resource = bucket + '/'
35
+ ret = request(
36
+ expects: [200, 203, 400],
37
+ method: 'GET',
38
+ path: path,
39
+ resource: resource,
40
+ bucket: bucket
41
+ )
42
+ xml = ret.data[:body]
43
+ result = XmlSimple.xml_in(xml)
44
+ end
45
+
46
+ def list_multipart_uploads(bucket, endpoint, _options = {})
47
+ if nil == endpoint
48
+ location = get_bucket_location(bucket)
49
+ endpoint = 'http://' + location + '.aliyuncs.com'
50
+ end
51
+ path = '?uploads'
52
+ resource = bucket + '/' + path
53
+
54
+ ret = request(
55
+ expects: 200,
56
+ method: 'GET',
57
+ path: path,
58
+ bucket: bucket,
59
+ resource: resource,
60
+ endpoint: endpoint
61
+ )
62
+ uploadid = XmlSimple.xml_in(ret.data[:body])['Upload']
63
+ end
64
+
65
+ def list_parts(bucket, object, endpoint, uploadid, _options = {})
66
+ if nil == endpoint
67
+ location = get_bucket_location(bucket)
68
+ endpoint = 'http://' + location + '.aliyuncs.com'
69
+ end
70
+ path = object + '?uploadId=' + uploadid
71
+ resource = bucket + '/' + path
72
+
73
+ ret = request(
74
+ expects: 200,
75
+ method: 'GET',
76
+ path: path,
77
+ bucket: bucket,
78
+ resource: resource,
79
+ endpoint: endpoint
80
+ )
81
+ parts = XmlSimple.xml_in(ret.data[:body])['Part']
82
+ end
83
+ end
84
+
85
+ class Mock
86
+ def list_objects(options = {})
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end