fog-aliyun 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +309 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +7 -0
  12. data/fog-aliyun.gemspec +30 -0
  13. data/lib/fog/aliyun.rb +19 -0
  14. data/lib/fog/aliyun/compute.rb +346 -0
  15. data/lib/fog/aliyun/models/compute/vpc.rb +69 -0
  16. data/lib/fog/aliyun/models/compute/vpcs.rb +89 -0
  17. data/lib/fog/aliyun/models/compute/vswitch.rb +70 -0
  18. data/lib/fog/aliyun/models/compute/vswitches.rb +87 -0
  19. data/lib/fog/aliyun/models/storage/directories.rb +45 -0
  20. data/lib/fog/aliyun/models/storage/directory.rb +48 -0
  21. data/lib/fog/aliyun/models/storage/file.rb +197 -0
  22. data/lib/fog/aliyun/models/storage/files.rb +178 -0
  23. data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +79 -0
  24. data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +63 -0
  25. data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +66 -0
  26. data/lib/fog/aliyun/requests/compute/attach_disk.rb +82 -0
  27. data/lib/fog/aliyun/requests/compute/create_disk.rb +135 -0
  28. data/lib/fog/aliyun/requests/compute/create_image.rb +79 -0
  29. data/lib/fog/aliyun/requests/compute/create_security_group.rb +77 -0
  30. data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +86 -0
  31. data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +86 -0
  32. data/lib/fog/aliyun/requests/compute/create_server.rb +188 -0
  33. data/lib/fog/aliyun/requests/compute/create_snapshot.rb +60 -0
  34. data/lib/fog/aliyun/requests/compute/create_vpc.rb +73 -0
  35. data/lib/fog/aliyun/requests/compute/create_vswitch.rb +81 -0
  36. data/lib/fog/aliyun/requests/compute/delete_disk.rb +58 -0
  37. data/lib/fog/aliyun/requests/compute/delete_image.rb +58 -0
  38. data/lib/fog/aliyun/requests/compute/delete_security_group.rb +51 -0
  39. data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +85 -0
  40. data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +86 -0
  41. data/lib/fog/aliyun/requests/compute/delete_server.rb +48 -0
  42. data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +45 -0
  43. data/lib/fog/aliyun/requests/compute/delete_vpc.rb +52 -0
  44. data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +51 -0
  45. data/lib/fog/aliyun/requests/compute/detach_disk.rb +51 -0
  46. data/lib/fog/aliyun/requests/compute/join_security_group.rb +41 -0
  47. data/lib/fog/aliyun/requests/compute/leave_security_group.rb +41 -0
  48. data/lib/fog/aliyun/requests/compute/list_disks.rb +75 -0
  49. data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +81 -0
  50. data/lib/fog/aliyun/requests/compute/list_images.rb +85 -0
  51. data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +74 -0
  52. data/lib/fog/aliyun/requests/compute/list_security_groups.rb +81 -0
  53. data/lib/fog/aliyun/requests/compute/list_server_types.rb +77 -0
  54. data/lib/fog/aliyun/requests/compute/list_servers.rb +74 -0
  55. data/lib/fog/aliyun/requests/compute/list_snapshots.rb +86 -0
  56. data/lib/fog/aliyun/requests/compute/list_vpcs.rb +64 -0
  57. data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +67 -0
  58. data/lib/fog/aliyun/requests/compute/list_zones.rb +44 -0
  59. data/lib/fog/aliyun/requests/compute/modify_vpc.rb +73 -0
  60. data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +73 -0
  61. data/lib/fog/aliyun/requests/compute/reboot_server.rb +44 -0
  62. data/lib/fog/aliyun/requests/compute/release_eip_address.rb +53 -0
  63. data/lib/fog/aliyun/requests/compute/start_server.rb +42 -0
  64. data/lib/fog/aliyun/requests/compute/stop_server.rb +42 -0
  65. data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +56 -0
  66. data/lib/fog/aliyun/requests/storage/copy_object.rb +42 -0
  67. data/lib/fog/aliyun/requests/storage/delete_bucket.rb +30 -0
  68. data/lib/fog/aliyun/requests/storage/delete_container.rb +38 -0
  69. data/lib/fog/aliyun/requests/storage/delete_object.rb +53 -0
  70. data/lib/fog/aliyun/requests/storage/get_bucket.rb +148 -0
  71. data/lib/fog/aliyun/requests/storage/get_container.rb +72 -0
  72. data/lib/fog/aliyun/requests/storage/get_containers.rb +76 -0
  73. data/lib/fog/aliyun/requests/storage/get_object.rb +45 -0
  74. data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +43 -0
  75. data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +43 -0
  76. data/lib/fog/aliyun/requests/storage/head_object.rb +34 -0
  77. data/lib/fog/aliyun/requests/storage/list_buckets.rb +47 -0
  78. data/lib/fog/aliyun/requests/storage/list_objects.rb +104 -0
  79. data/lib/fog/aliyun/requests/storage/put_bucket.rb +23 -0
  80. data/lib/fog/aliyun/requests/storage/put_container.rb +35 -0
  81. data/lib/fog/aliyun/requests/storage/put_object.rb +199 -0
  82. data/lib/fog/aliyun/storage.rb +214 -0
  83. data/lib/fog/aliyun/version.rb +5 -0
  84. data/lib/fog/bin/aliyun.rb +31 -0
  85. metadata +227 -0
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Storage
3
+ class Aliyun
4
+ class Real
5
+ # Delete an existing bucket
6
+ #
7
+ # ==== Parameters
8
+ # * bucket<~String> - Name of bucket to delete
9
+ #
10
+ def delete_bucket(bucket)
11
+ location = get_bucket_location(bucket)
12
+ endpoint = "http://"+location+".aliyuncs.com"
13
+ resource = bucket+'/'
14
+ request(
15
+ :expects => 204,
16
+ :method => 'DELETE',
17
+ :bucket => bucket,
18
+ :resource => resource,
19
+ :endpoint => endpoint
20
+ )
21
+ end
22
+ end
23
+
24
+ class Mock
25
+ def delete_bucket(bucket)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,38 @@
1
+ module Fog
2
+ module Storage
3
+ class Aliyun
4
+ class Real
5
+ # Delete an existing container
6
+ #
7
+ # ==== Parameters
8
+ # * container<~String> - Name of container to delete
9
+ # * options
10
+ #
11
+ def delete_container(container, options={})
12
+
13
+ bucket = options[:bucket]
14
+ bucket ||= @aliyun_oss_bucket
15
+ location = get_bucket_location(bucket)
16
+ endpoint = "http://"+location+".aliyuncs.com"
17
+ object = container+'/'
18
+ resource = bucket+'/'+object
19
+
20
+ request(
21
+ :expects => 204,
22
+ :method => 'DELETE',
23
+ :path => object,
24
+ :bucket => bucket,
25
+ :resource => resource,
26
+ :endpoint => endpoint
27
+ )
28
+ end
29
+ end
30
+ class Mock
31
+
32
+ def delete_container(container, options={})
33
+
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,53 @@
1
+ module Fog
2
+ module Storage
3
+ class Aliyun
4
+ class Real
5
+ # Delete an existing object
6
+ #
7
+ # ==== Parameters
8
+ # * object<~String> - Name of object to delete
9
+ #
10
+ def delete_object(object, options={})
11
+ bucket = options[:bucket]
12
+ bucket ||= @aliyun_oss_bucket
13
+ location = get_bucket_location(bucket)
14
+ endpoint = "http://"+location+".aliyuncs.com"
15
+ resource = bucket+'/'+object
16
+ request(
17
+ :expects => 204,
18
+ :method => 'DELETE',
19
+ :path => object,
20
+ :bucket => bucket,
21
+ :resource => resource,
22
+ :endpoint => endpoint
23
+ )
24
+ end
25
+
26
+
27
+ def abort_multipart_upload(bucket, object, endpoint, uploadid)
28
+ if (nil == endpoint)
29
+ location = get_bucket_location(bucket)
30
+ endpoint = "http://"+location+".aliyuncs.com"
31
+ end
32
+ path = object+"?uploadId="+uploadid
33
+ resource = bucket+'/'+path
34
+
35
+ ret = request(
36
+ :expects => 204,
37
+ :method => 'DELETE',
38
+ :path => path,
39
+ :bucket => bucket,
40
+ :resource => resource,
41
+ :endpoint => endpoint
42
+ )
43
+
44
+ end
45
+ end
46
+
47
+ class Mock
48
+ def delete_object(object, options={})
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,148 @@
1
+ module Fog
2
+ module Storage
3
+ class Aliyun
4
+ class Real
5
+ def get_bucket(bucket)
6
+ location = get_bucket_location(bucket)
7
+ endpoint = "http://"+location+".aliyuncs.com"
8
+ resource = bucket+'/'
9
+ ret = request(
10
+ :expects => [200, 203],
11
+ :method => 'GET',
12
+ :bucket => bucket,
13
+ :resource => resource,
14
+ :endpoint => endpoint
15
+ )
16
+ xml = ret.data[:body]
17
+ result = XmlSimple.xml_in(xml)
18
+ end
19
+
20
+ def get_bucket_location(bucket)
21
+ attribute = '?location'
22
+ resource = bucket+'/'+attribute
23
+ ret = request(
24
+ :expects => [200, 203],
25
+ :method => 'GET',
26
+ :path => attribute,
27
+ :bucket => bucket,
28
+ :resource => resource
29
+ )
30
+ location = XmlSimple.xml_in(ret.data[:body])
31
+ end
32
+
33
+ def get_bucket_acl(bucket)
34
+ location = get_bucket_location(bucket)
35
+ endpoint = "http://"+location+".aliyuncs.com"
36
+ attribute = '?acl'
37
+ resource = bucket+'/'+attribute
38
+ ret = request(
39
+ :expects => [200, 203],
40
+ :method => 'GET',
41
+ :path => attribute,
42
+ :bucket => bucket,
43
+ :resource => resource,
44
+ :endpoint => endpoint
45
+ )
46
+ acl = XmlSimple.xml_in(ret.data[:body])["AccessControlList"][0]["Grant"][0]
47
+ end
48
+
49
+ def get_bucket_CORSRules(bucket)
50
+ location = get_bucket_location(bucket)
51
+ endpoint = "http://"+location+".aliyuncs.com"
52
+ attribute = '?cors'
53
+ resource = bucket+'/'+attribute
54
+ ret = request(
55
+ :expects => [200, 203, 404],
56
+ :method => 'GET',
57
+ :path => attribute,
58
+ :bucket => bucket,
59
+ :resource => resource,
60
+ :endpoint => endpoint
61
+ )
62
+ if 404 != ret.data[:status]
63
+ cors = XmlSimple.xml_in(ret.data[:body])["CORSRule"][0]
64
+ else
65
+ nil
66
+ end
67
+ end
68
+
69
+ def get_bucket_lifecycle(bucket)
70
+ location = get_bucket_location(bucket)
71
+ endpoint = "http://"+location+".aliyuncs.com"
72
+ attribute = '?lifecycle'
73
+ resource = bucket+'/'+attribute
74
+ ret = request(
75
+ :expects => [200, 203, 404],
76
+ :method => 'GET',
77
+ :path => attribute,
78
+ :bucket => bucket,
79
+ :resource => resource,
80
+ :endpoint => endpoint
81
+ )
82
+ if 404 != ret.data[:status]
83
+ lifecycle = XmlSimple.xml_in(ret.data[:body])["Rule"][0]
84
+ else
85
+ nil
86
+ end
87
+ end
88
+
89
+ def get_bucket_logging(bucket)
90
+ location = get_bucket_location(bucket)
91
+ endpoint = "http://"+location+".aliyuncs.com"
92
+ attribute = '?logging'
93
+ resource = bucket+'/'+attribute
94
+ ret = request(
95
+ :expects => [200, 203],
96
+ :method => 'GET',
97
+ :path => attribute,
98
+ :bucket => bucket,
99
+ :resource => resource,
100
+ :endpoint => endpoint
101
+ )
102
+ logging = XmlSimple.xml_in(ret.data[:body])["LoggingEnabled"][0]["TargetPrefix"]
103
+ end
104
+
105
+ def get_bucket_referer(bucket)
106
+ location = get_bucket_location(bucket)
107
+ endpoint = "http://"+location+".aliyuncs.com"
108
+ attribute = '?referer'
109
+ resource = bucket+'/'+attribute
110
+ ret = request(
111
+ :expects => [200, 203],
112
+ :method => 'GET',
113
+ :path => attribute,
114
+ :bucket => bucket,
115
+ :resource => resource,
116
+ :endpoint => endpoint
117
+ )
118
+ referer = XmlSimple.xml_in(ret.data[:body])
119
+ end
120
+
121
+ def get_bucket_website(bucket)
122
+ location = get_bucket_location(bucket)
123
+ endpoint = "http://"+location+".aliyuncs.com"
124
+ attribute = '?website'
125
+ resource = bucket+'/'+attribute
126
+ ret = request(
127
+ :expects => [200, 203, 404],
128
+ :method => 'GET',
129
+ :path => attribute,
130
+ :bucket => bucket,
131
+ :resource => resource,
132
+ :endpoint => endpoint
133
+ )
134
+ if 404 != ret.data[:status]
135
+ website = XmlSimple.xml_in(ret.data[:body])
136
+ else
137
+ nil
138
+ end
139
+ end
140
+
141
+ end
142
+ class Mock
143
+ def get_bucket(bucket)
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,72 @@
1
+ module Fog
2
+ module Storage
3
+ class Aliyun
4
+ class Real
5
+ def get_container(container, options = {})
6
+ options = options.reject {|key, value| value.nil?}
7
+
8
+ bucket = options[:bucket]
9
+ bucket ||= @aliyun_oss_bucket
10
+
11
+ marker = options[:marker]
12
+ maxKeys = options[:maxKeys]
13
+ delimiter = '/'
14
+
15
+ path = ""
16
+
17
+ if container == "" || container == "." || container == nil
18
+ prefix = nil
19
+ else
20
+ prefix = container+'/'
21
+ end
22
+
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
34
+ 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
42
+ elsif maxKeys
43
+ path+="?max-keys="+maxKeys
44
+ if delimiter
45
+ path+="&delimiter="+delimiter
46
+ end
47
+ elsif delimiter
48
+ path+="?delimiter="+delimiter
49
+ end
50
+
51
+ location = get_bucket_location(bucket)
52
+ endpoint = "http://"+location+".aliyuncs.com"
53
+ resource = bucket+'/'
54
+ ret = request(
55
+ :expects => [200, 203, 400],
56
+ :method => 'GET',
57
+ :path => path,
58
+ :resource => resource,
59
+ :bucket => bucket
60
+ )
61
+ xml = ret.data[:body]
62
+ result = XmlSimple.xml_in(xml)["CommonPrefixes"]
63
+ end
64
+ end
65
+
66
+ class Mock
67
+ def get_container(container, options = {})
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,76 @@
1
+ module Fog
2
+ module Storage
3
+ class Aliyun
4
+ class Real
5
+ # List existing storage containers
6
+ #
7
+ # ==== Parameters
8
+ # * options<~Hash>:
9
+ # * 'maxKeys'<~Integer> - Upper limit to number of results returned
10
+ # * 'marker'<~String> - Only return objects with name greater than this value
11
+ #
12
+ # ==== Returns
13
+ #
14
+ def get_containers(options = {})
15
+ options = options.reject {|key, value| value.nil?}
16
+ bucket = options[:bucket]
17
+ bucket ||= @aliyun_oss_bucket
18
+ prefix = options[:prefix]
19
+ marker = options[:marker]
20
+ maxKeys = options[:maxKeys]
21
+ delimiter = '/'
22
+
23
+ path = ""
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
35
+
36
+ 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
44
+
45
+ elsif maxKeys
46
+ path+="?max-keys="+maxKeys
47
+ if delimiter
48
+ path+="&delimiter="+delimiter
49
+ end
50
+
51
+ elsif delimiter
52
+ path+="?delimiter="+delimiter
53
+ end
54
+
55
+ location = get_bucket_location(bucket)
56
+ endpoint = "http://"+location+".aliyuncs.com"
57
+ resource = bucket+'/'
58
+ ret = request(
59
+ :expects => [200, 203, 400],
60
+ :method => 'GET',
61
+ :path => path,
62
+ :resource => resource,
63
+ :bucket => bucket
64
+ )
65
+ xml = ret.data[:body]
66
+ result = XmlSimple.xml_in(xml)["CommonPrefixes"]
67
+ end
68
+ end
69
+
70
+ class Mock
71
+ def get_containers(options = {})
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,45 @@
1
+ module Fog
2
+ module Storage
3
+ class Aliyun
4
+ class Real
5
+ # Get details for object
6
+ #
7
+ # ==== Parameters
8
+ # * object<~String> - Name of object to look for
9
+ #
10
+ def get_object(object, range = nil, options = {})
11
+ options = options.reject {|key, value| value.nil?}
12
+ bucket = options[:bucket]
13
+ bucket ||= @aliyun_oss_bucket
14
+ endpoint = options[:endpoint]
15
+ if (nil == endpoint)
16
+ location = get_bucket_location(bucket)
17
+ endpoint = "http://"+location+".aliyuncs.com"
18
+ end
19
+ resource = bucket+'/'+object
20
+ para = {
21
+ :expects => [200, 206, 404],
22
+ :method => 'GET',
23
+ :path => object,
24
+ :bucket => bucket,
25
+ :resource => resource,
26
+ :endpoint => endpoint
27
+ }
28
+
29
+ if range
30
+ rangeStr = "bytes="+range
31
+ para[:headers] = {'Range' => rangeStr}
32
+ end
33
+
34
+ response = request(para)
35
+ response.data
36
+ end
37
+ end
38
+
39
+ class Mock
40
+ def get_object(object, range = nil, options = {})
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end