fog-xiaozhu 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +149 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +312 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/fog-aliyun.gemspec +33 -0
- data/lib/fog/aliyun/compute.rb +424 -0
- data/lib/fog/aliyun/models/compute/eip_address.rb +57 -0
- data/lib/fog/aliyun/models/compute/eip_addresses.rb +28 -0
- data/lib/fog/aliyun/models/compute/image.rb +66 -0
- data/lib/fog/aliyun/models/compute/images.rb +25 -0
- data/lib/fog/aliyun/models/compute/route_entry.rb +26 -0
- data/lib/fog/aliyun/models/compute/route_entrys.rb +41 -0
- data/lib/fog/aliyun/models/compute/route_table.rb +30 -0
- data/lib/fog/aliyun/models/compute/route_tables.rb +27 -0
- data/lib/fog/aliyun/models/compute/security_group.rb +81 -0
- data/lib/fog/aliyun/models/compute/security_group_rule.rb +47 -0
- data/lib/fog/aliyun/models/compute/security_group_rules.rb +23 -0
- data/lib/fog/aliyun/models/compute/security_groups.rb +32 -0
- data/lib/fog/aliyun/models/compute/server.rb +70 -0
- data/lib/fog/aliyun/models/compute/servers.rb +42 -0
- data/lib/fog/aliyun/models/compute/snapshot.rb +52 -0
- data/lib/fog/aliyun/models/compute/snapshots.rb +38 -0
- data/lib/fog/aliyun/models/compute/volume.rb +101 -0
- data/lib/fog/aliyun/models/compute/volumes.rb +135 -0
- data/lib/fog/aliyun/models/compute/vpc.rb +77 -0
- data/lib/fog/aliyun/models/compute/vpcs.rb +80 -0
- data/lib/fog/aliyun/models/compute/vrouter.rb +35 -0
- data/lib/fog/aliyun/models/compute/vrouters.rb +61 -0
- data/lib/fog/aliyun/models/compute/vswitch.rb +70 -0
- data/lib/fog/aliyun/models/compute/vswitches.rb +80 -0
- data/lib/fog/aliyun/models/storage/directories.rb +39 -0
- data/lib/fog/aliyun/models/storage/directory.rb +48 -0
- data/lib/fog/aliyun/models/storage/file.rb +192 -0
- data/lib/fog/aliyun/models/storage/files.rb +193 -0
- data/lib/fog/aliyun/requests/compute/allocate_eip_address.rb +54 -0
- data/lib/fog/aliyun/requests/compute/allocate_public_ip_address.rb +39 -0
- data/lib/fog/aliyun/requests/compute/associate_eip_address.rb +49 -0
- data/lib/fog/aliyun/requests/compute/attach_disk.rb +79 -0
- data/lib/fog/aliyun/requests/compute/create_disk.rb +137 -0
- data/lib/fog/aliyun/requests/compute/create_image.rb +79 -0
- data/lib/fog/aliyun/requests/compute/create_security_group.rb +77 -0
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +63 -0
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +71 -0
- data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +63 -0
- data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +71 -0
- data/lib/fog/aliyun/requests/compute/create_server.rb +186 -0
- data/lib/fog/aliyun/requests/compute/create_snapshot.rb +46 -0
- data/lib/fog/aliyun/requests/compute/create_vpc.rb +46 -0
- data/lib/fog/aliyun/requests/compute/create_vpn_connection.rb +58 -0
- data/lib/fog/aliyun/requests/compute/create_vpn_customergateway.rb +48 -0
- data/lib/fog/aliyun/requests/compute/create_vswitch.rb +54 -0
- data/lib/fog/aliyun/requests/compute/delete_disk.rb +41 -0
- data/lib/fog/aliyun/requests/compute/delete_image.rb +31 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group.rb +51 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +63 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +71 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +63 -0
- data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +71 -0
- data/lib/fog/aliyun/requests/compute/delete_server.rb +48 -0
- data/lib/fog/aliyun/requests/compute/delete_snapshot.rb +31 -0
- data/lib/fog/aliyun/requests/compute/delete_vpc.rb +35 -0
- data/lib/fog/aliyun/requests/compute/delete_vpn_connection.rb +35 -0
- data/lib/fog/aliyun/requests/compute/delete_vpn_customergateway.rb +35 -0
- data/lib/fog/aliyun/requests/compute/delete_vswitch.rb +35 -0
- data/lib/fog/aliyun/requests/compute/detach_disk.rb +41 -0
- data/lib/fog/aliyun/requests/compute/join_security_group.rb +40 -0
- data/lib/fog/aliyun/requests/compute/leave_security_group.rb +40 -0
- data/lib/fog/aliyun/requests/compute/list_disks.rb +150 -0
- data/lib/fog/aliyun/requests/compute/list_eip_addresses.rb +55 -0
- data/lib/fog/aliyun/requests/compute/list_images.rb +82 -0
- data/lib/fog/aliyun/requests/compute/list_route_tables.rb +64 -0
- data/lib/fog/aliyun/requests/compute/list_security_group_rules.rb +73 -0
- data/lib/fog/aliyun/requests/compute/list_security_groups.rb +78 -0
- data/lib/fog/aliyun/requests/compute/list_server_types.rb +77 -0
- data/lib/fog/aliyun/requests/compute/list_servers.rb +71 -0
- data/lib/fog/aliyun/requests/compute/list_snapshots.rb +97 -0
- data/lib/fog/aliyun/requests/compute/list_vpcs.rb +47 -0
- data/lib/fog/aliyun/requests/compute/list_vpn_connections.rb +49 -0
- data/lib/fog/aliyun/requests/compute/list_vpn_customergateways.rb +43 -0
- data/lib/fog/aliyun/requests/compute/list_vpn_gateways.rb +49 -0
- data/lib/fog/aliyun/requests/compute/list_vrouters.rb +61 -0
- data/lib/fog/aliyun/requests/compute/list_vswitchs.rb +50 -0
- data/lib/fog/aliyun/requests/compute/list_zones.rb +44 -0
- data/lib/fog/aliyun/requests/compute/modify_vpc.rb +73 -0
- data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +45 -0
- data/lib/fog/aliyun/requests/compute/reboot_server.rb +43 -0
- data/lib/fog/aliyun/requests/compute/release_eip_address.rb +29 -0
- data/lib/fog/aliyun/requests/compute/start_server.rb +41 -0
- data/lib/fog/aliyun/requests/compute/stop_server.rb +41 -0
- data/lib/fog/aliyun/requests/compute/unassociate_eip_address.rb +49 -0
- data/lib/fog/aliyun/requests/storage/copy_object.rb +39 -0
- data/lib/fog/aliyun/requests/storage/delete_bucket.rb +30 -0
- data/lib/fog/aliyun/requests/storage/delete_container.rb +35 -0
- data/lib/fog/aliyun/requests/storage/delete_object.rb +51 -0
- data/lib/fog/aliyun/requests/storage/get_bucket.rb +141 -0
- data/lib/fog/aliyun/requests/storage/get_container.rb +60 -0
- data/lib/fog/aliyun/requests/storage/get_containers.rb +64 -0
- data/lib/fog/aliyun/requests/storage/get_object.rb +45 -0
- data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +43 -0
- data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +43 -0
- data/lib/fog/aliyun/requests/storage/head_object.rb +34 -0
- data/lib/fog/aliyun/requests/storage/list_buckets.rb +40 -0
- data/lib/fog/aliyun/requests/storage/list_objects.rb +91 -0
- data/lib/fog/aliyun/requests/storage/put_bucket.rb +22 -0
- data/lib/fog/aliyun/requests/storage/put_container.rb +35 -0
- data/lib/fog/aliyun/requests/storage/put_object.rb +189 -0
- data/lib/fog/aliyun/storage.rb +233 -0
- data/lib/fog/aliyun/version.rb +5 -0
- data/lib/fog/aliyun.rb +19 -0
- data/lib/fog/bin/aliyun.rb +31 -0
- metadata +311 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4ab66dc904b634dd5a0abb2fe0407f7911a0ba5e
|
4
|
+
data.tar.gz: 73941e4d09c8d594ffa29ee489606c32c438edd0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 075aabe14c9415dec10c5b6240b696c5c7629e5c4bc9fa62d0698729bd67b3de786739fb48e2b4440151ff5b86d8077feffe72b28d5626d29148cb85afc81448
|
7
|
+
data.tar.gz: 1d90a461ed5bf521020ba7ac1e383a79af2f9d22f8d35b6dc60e1ddab814428f7aaa1c0f09886c4936e2e1ebc6fc9ff1b62461141febff7fc1ae25a51aa9e9b6
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2016-05-12 13:44:44 +0800 using RuboCop version 0.40.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 4
|
10
|
+
# Configuration parameters: AllowSafeAssignment.
|
11
|
+
Lint/AssignmentInCondition:
|
12
|
+
Exclude:
|
13
|
+
- 'lib/fog/aliyun/requests/compute/create_server.rb'
|
14
|
+
- 'lib/fog/aliyun/requests/compute/delete_server.rb'
|
15
|
+
|
16
|
+
# Offense count: 1
|
17
|
+
# Cop supports --auto-correct.
|
18
|
+
# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect.
|
19
|
+
# SupportedStyles: start_of_line, def
|
20
|
+
Lint/DefEndAlignment:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
# Offense count: 5
|
24
|
+
# Cop supports --auto-correct.
|
25
|
+
# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect.
|
26
|
+
# SupportedStyles: keyword, variable, start_of_line
|
27
|
+
Lint/EndAlignment:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
# Offense count: 4
|
31
|
+
Lint/RandOne:
|
32
|
+
Exclude:
|
33
|
+
- 'lib/fog/aliyun/requests/compute/list_images.rb'
|
34
|
+
- 'lib/fog/aliyun/requests/compute/list_route_tables.rb'
|
35
|
+
- 'lib/fog/aliyun/requests/compute/list_servers.rb'
|
36
|
+
- 'lib/fog/aliyun/requests/compute/list_vrouters.rb'
|
37
|
+
|
38
|
+
# Offense count: 127
|
39
|
+
Lint/UnderscorePrefixedVariableName:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
# Offense count: 1
|
43
|
+
Lint/UnreachableCode:
|
44
|
+
Exclude:
|
45
|
+
- 'lib/fog/aliyun/models/storage/directory.rb'
|
46
|
+
|
47
|
+
# Offense count: 38
|
48
|
+
Lint/UselessAssignment:
|
49
|
+
Exclude:
|
50
|
+
- 'lib/fog/aliyun.rb'
|
51
|
+
- 'lib/fog/aliyun/requests/compute/list_disks.rb'
|
52
|
+
- 'lib/fog/aliyun/requests/compute/list_security_groups.rb'
|
53
|
+
- 'lib/fog/aliyun/requests/storage/delete_object.rb'
|
54
|
+
- 'lib/fog/aliyun/requests/storage/get_bucket.rb'
|
55
|
+
- 'lib/fog/aliyun/requests/storage/get_container.rb'
|
56
|
+
- 'lib/fog/aliyun/requests/storage/get_containers.rb'
|
57
|
+
- 'lib/fog/aliyun/requests/storage/get_object_http_url.rb'
|
58
|
+
- 'lib/fog/aliyun/requests/storage/get_object_https_url.rb'
|
59
|
+
- 'lib/fog/aliyun/requests/storage/list_buckets.rb'
|
60
|
+
- 'lib/fog/aliyun/requests/storage/list_objects.rb'
|
61
|
+
- 'lib/fog/aliyun/requests/storage/put_bucket.rb'
|
62
|
+
- 'lib/fog/aliyun/requests/storage/put_object.rb'
|
63
|
+
- 'lib/fog/aliyun/storage.rb'
|
64
|
+
|
65
|
+
# Offense count: 78
|
66
|
+
Metrics/AbcSize:
|
67
|
+
Max: 100
|
68
|
+
|
69
|
+
# Offense count: 5
|
70
|
+
# Configuration parameters: CountComments.
|
71
|
+
Metrics/ClassLength:
|
72
|
+
Max: 154
|
73
|
+
|
74
|
+
# Offense count: 18
|
75
|
+
Metrics/CyclomaticComplexity:
|
76
|
+
Max: 15
|
77
|
+
|
78
|
+
# Offense count: 257
|
79
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
80
|
+
# URISchemes: http, https
|
81
|
+
Metrics/LineLength:
|
82
|
+
Max: 247
|
83
|
+
|
84
|
+
# Offense count: 110
|
85
|
+
# Configuration parameters: CountComments.
|
86
|
+
Metrics/MethodLength:
|
87
|
+
Max: 97
|
88
|
+
|
89
|
+
# Offense count: 1
|
90
|
+
# Configuration parameters: CountKeywordArgs.
|
91
|
+
Metrics/ParameterLists:
|
92
|
+
Max: 6
|
93
|
+
|
94
|
+
# Offense count: 17
|
95
|
+
Metrics/PerceivedComplexity:
|
96
|
+
Max: 19
|
97
|
+
|
98
|
+
# Offense count: 1
|
99
|
+
Style/ClassVars:
|
100
|
+
Exclude:
|
101
|
+
- 'lib/fog/bin/aliyun.rb'
|
102
|
+
|
103
|
+
# Offense count: 138
|
104
|
+
Style/Documentation:
|
105
|
+
Enabled: false
|
106
|
+
|
107
|
+
# Offense count: 7
|
108
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
109
|
+
# SupportedStyles: for, each
|
110
|
+
Style/For:
|
111
|
+
Enabled: false
|
112
|
+
|
113
|
+
# Offense count: 4
|
114
|
+
# Configuration parameters: AllowedVariables.
|
115
|
+
Style/GlobalVars:
|
116
|
+
Exclude:
|
117
|
+
- 'lib/fog/aliyun/models/compute/server.rb'
|
118
|
+
- 'lib/fog/aliyun/models/compute/vpcs.rb'
|
119
|
+
- 'lib/fog/aliyun/models/compute/vrouter.rb'
|
120
|
+
- 'lib/fog/aliyun/models/compute/vswitch.rb'
|
121
|
+
|
122
|
+
# Offense count: 2
|
123
|
+
# Configuration parameters: MinBodyLength.
|
124
|
+
Style/GuardClause:
|
125
|
+
Exclude:
|
126
|
+
- 'lib/fog/aliyun/requests/compute/delete_vpc.rb'
|
127
|
+
- 'lib/fog/aliyun/requests/compute/delete_vswitch.rb'
|
128
|
+
|
129
|
+
# Offense count: 2
|
130
|
+
Style/IdenticalConditionalBranches:
|
131
|
+
Exclude:
|
132
|
+
- 'lib/fog/aliyun/models/storage/files.rb'
|
133
|
+
|
134
|
+
# Offense count: 1
|
135
|
+
Style/IfInsideElse:
|
136
|
+
Exclude:
|
137
|
+
- 'lib/fog/aliyun/models/compute/security_group_rule.rb'
|
138
|
+
|
139
|
+
# Offense count: 4
|
140
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
141
|
+
# SupportedStyles: snake_case, camelCase
|
142
|
+
Style/MethodName:
|
143
|
+
Enabled: false
|
144
|
+
|
145
|
+
# Offense count: 741
|
146
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
147
|
+
# SupportedStyles: snake_case, camelCase
|
148
|
+
Style/VariableName:
|
149
|
+
Enabled: false
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
fog-aliyun
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 dengqinsi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,312 @@
|
|
1
|
+
# Fog::Aliyun
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'fog-aliyun'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
```shell
|
13
|
+
$ bundle
|
14
|
+
```
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
```shell
|
19
|
+
$ gem install fog-aliyun
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
Before you can use fog-aliyun, you must require it in your application:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'fog/aliyun'
|
27
|
+
```
|
28
|
+
|
29
|
+
Since it's a bad practice to have your credentials in source code, you should load them from default fog configuration file: ```~/.fog```. This file could look like this:
|
30
|
+
|
31
|
+
```
|
32
|
+
default:
|
33
|
+
:aliyun_accesskey_id: <YOUR_ACCESS_KEY_ID>,
|
34
|
+
:aliyun_accesskey_secret: <YOUR_SECRET_ACCESS_KEY>,
|
35
|
+
:aliyun_region_id: <YOUR_TARGET_REGION>
|
36
|
+
```
|
37
|
+
|
38
|
+
### Connecting to OSS
|
39
|
+
```ruby
|
40
|
+
conn = Fog::Storage[:aliyun]
|
41
|
+
```
|
42
|
+
|
43
|
+
If you haven't modified your default fog configuration file or you don't want to use it, you can load your credentials by this way:
|
44
|
+
```ruby
|
45
|
+
opt = {
|
46
|
+
:provider => 'aliyun',
|
47
|
+
:aliyun_accesskey_id => <YOUR_ACCESS_KEY_ID>,
|
48
|
+
:aliyun_accesskey_secret => <YOUR_SECRET_ACCESS_KEY>,
|
49
|
+
:aliyun_oss_bucket => <YOUR_OSS_BUCKET>,
|
50
|
+
:aliyun_region_id => <YOUR_TARGET_REGION>,
|
51
|
+
:aliyun_oss_endpoint => <YOUR_OSS_ENDPOINT>,
|
52
|
+
}
|
53
|
+
conn = Fog::Storage.new(opt)
|
54
|
+
```
|
55
|
+
**-> Note:** `:aliyun_region_id` is optional and default to "cn-hangzhou".
|
56
|
+
**-> Note:** `:aliyun_oss_endpoint` is optional. If it is not specified, it will be generated automatically by `:aliyun_region_id`.
|
57
|
+
Its basic format is "oss-<region-id>.aliyuncs.com" and with default schema "http" and default port "80".
|
58
|
+
If you want to use https or 443 port, you can use a format "<schema>://oss-<region-id>.aliyuncs.com:<port>".
|
59
|
+
|
60
|
+
|
61
|
+
## Fog::Aliyun Abstractions
|
62
|
+
|
63
|
+
Fog::Aliyun provides both a **model** and **request** abstraction. The request abstraction provides the most efficient interface and the model abstraction wraps the request abstraction to provide a convenient `ActiveModel` like interface.
|
64
|
+
|
65
|
+
### Request Layer
|
66
|
+
The Fog::Storage object supports a number of methods that wrap individual HTTP requests to the OSS API.
|
67
|
+
|
68
|
+
To see a list of requests supported by the storage service:
|
69
|
+
|
70
|
+
conn.requests
|
71
|
+
|
72
|
+
This returns:
|
73
|
+
```
|
74
|
+
[[nil, :copy_object], [nil, :delete_bucket], [nil, :delete_object], [nil, :get_bucket], [nil, :get_object], [nil, :get_object_http_url], [nil, :get_object_https_url], [nil, :head_object], [nil, :put_bucket], [nil, :put_object], [nil, :list_buckets], [nil, :list_objects], [nil, :get_containers], [nil, :get_container], [nil, :delete_container], [nil, :put_container]]
|
75
|
+
```
|
76
|
+
|
77
|
+
#### Example Requests(list_buckets)
|
78
|
+
To request all of buckets:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
conn.list_buckets
|
82
|
+
```
|
83
|
+
|
84
|
+
And this returns like the flowing;
|
85
|
+
```
|
86
|
+
[{"Location"=>"oss-cn-beijing", "Name"=>"dt1", "CreationDate"=>"2015-07-30T08:38:02.000Z"}, {"Location"=>"oss-cn-shenzhen", "Name"=>"ruby1", "CreationDate"=>"2015-07-30T02:22:34.000Z"}, {"Location"=>"oss-cn-qingdao", "Name"=>"yuanhang123", "CreationDate"=>"2015-05-18T03:06:31.000Z"}]
|
87
|
+
```
|
88
|
+
|
89
|
+
You can also request in this way;
|
90
|
+
```ruby
|
91
|
+
conn.list_buckets(:prefix=>"pre")
|
92
|
+
```
|
93
|
+
|
94
|
+
Here is a summary of the optional parameters:
|
95
|
+
<table>
|
96
|
+
<tr>
|
97
|
+
<th>Parameters</th>
|
98
|
+
<th>Description</th>
|
99
|
+
</tr>
|
100
|
+
<tr>
|
101
|
+
<td>:prefix</td>
|
102
|
+
<td>
|
103
|
+
The bucket name of the results must start with 'prefix'.It won't filter prefix information if not set<br>
|
104
|
+
Data Types: String<br>
|
105
|
+
Defaults:none
|
106
|
+
</td>
|
107
|
+
</tr>
|
108
|
+
<tr>
|
109
|
+
<td>:marker</td>
|
110
|
+
<td>
|
111
|
+
The result will start from the marker alphabetically.It wil start from the first if not set.<br>
|
112
|
+
Data Types: String<br>
|
113
|
+
Defaults: none
|
114
|
+
</tr>
|
115
|
+
<tr>
|
116
|
+
<td>:maxKeys</td>
|
117
|
+
<td>
|
118
|
+
Set the max number of the results. It will set to 100 if not set. The max value of maxKeys is 1000.<br>
|
119
|
+
Data Types: String<br>
|
120
|
+
Defaults: 100
|
121
|
+
</td>
|
122
|
+
</tr>
|
123
|
+
</table>
|
124
|
+
|
125
|
+
To learn more about `Fog::Aliyun` request methods, you can refer to our source code. To learn more about OSS API, refer to [AliYun OSS API](https://docs.aliyun.com/?spm=5176.383663.9.2.jpghde#/pub/oss/api-reference/abstract).
|
126
|
+
|
127
|
+
### Model Layer
|
128
|
+
Fog models behave in a manner similar to `ActiveModel`. Models will generally respond to `create`, `save`, `destroy`, `reload` and `attributes` methods. Additionally, fog will automatically create attribute accessors.
|
129
|
+
|
130
|
+
Here is a summary of common model methods:
|
131
|
+
|
132
|
+
<table>
|
133
|
+
<tr>
|
134
|
+
<th>Method</th>
|
135
|
+
<th>Description</th>
|
136
|
+
</tr>
|
137
|
+
<tr>
|
138
|
+
<td>create</td>
|
139
|
+
<td>
|
140
|
+
Accepts hash of attributes and creates object.<br>
|
141
|
+
Note: creation is a non-blocking call and you will be required to wait for a valid state before using resulting object.
|
142
|
+
</td>
|
143
|
+
</tr>
|
144
|
+
<tr>
|
145
|
+
<td>save</td>
|
146
|
+
<td>Saves object.<br>
|
147
|
+
Note: not all objects support updating object.</td>
|
148
|
+
</tr>
|
149
|
+
<tr>
|
150
|
+
<td>destroy</td>
|
151
|
+
<td>
|
152
|
+
Destroys object.<br>
|
153
|
+
Note: this is a non-blocking call and object deletion might not be instantaneous.
|
154
|
+
</td>
|
155
|
+
<tr>
|
156
|
+
<td>reload</td>
|
157
|
+
<td>Updates object with latest state from service.</td>
|
158
|
+
<tr>
|
159
|
+
<td>attributes</td>
|
160
|
+
<td>Returns a hash containing the list of model attributes and values.</td>
|
161
|
+
</tr>
|
162
|
+
<td>identity</td>
|
163
|
+
<td>
|
164
|
+
Returns the identity of the object.<br>
|
165
|
+
Note: This might not always be equal to object.id.
|
166
|
+
</td>
|
167
|
+
</tr>
|
168
|
+
</table>
|
169
|
+
|
170
|
+
The remainder of this document details the model abstraction.
|
171
|
+
|
172
|
+
**Note:** Fog sometimes refers to OSS containers as directories.
|
173
|
+
|
174
|
+
## List Directories
|
175
|
+
|
176
|
+
To retrieve a list of directories:
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
dirs = conn.directories
|
180
|
+
```
|
181
|
+
|
182
|
+
This returns a collection of `Fog::Storage::Aliyun::Directory` models:
|
183
|
+
|
184
|
+
## Get Directory
|
185
|
+
|
186
|
+
To retrieve a specific directory:
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
dir = dirs.get "dir"
|
190
|
+
```
|
191
|
+
|
192
|
+
This returns a `Fog::Storage::Aliyun::Directory` instance:
|
193
|
+
|
194
|
+
## Create Directory
|
195
|
+
|
196
|
+
To create a directory:
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
dirs.create :key => 'backups'
|
200
|
+
```
|
201
|
+
|
202
|
+
## Delete Directory
|
203
|
+
|
204
|
+
To delete a directory:
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
directory.destroy
|
208
|
+
```
|
209
|
+
|
210
|
+
**Note**: Directory must be empty before it can be deleted.
|
211
|
+
|
212
|
+
|
213
|
+
## Directory URL
|
214
|
+
|
215
|
+
To get a directory's URL:
|
216
|
+
|
217
|
+
```ruby
|
218
|
+
directory.public_url
|
219
|
+
```
|
220
|
+
|
221
|
+
## List Files
|
222
|
+
|
223
|
+
To list files in a directory:
|
224
|
+
|
225
|
+
```ruby
|
226
|
+
directory.files
|
227
|
+
```
|
228
|
+
|
229
|
+
**Note**: File contents is not downloaded until `body` attribute is called.
|
230
|
+
|
231
|
+
## Upload Files
|
232
|
+
|
233
|
+
To upload a file into a directory:
|
234
|
+
|
235
|
+
```ruby
|
236
|
+
file = directory.files.create :key => 'space.jpg', :body => File.open "space.jpg"
|
237
|
+
```
|
238
|
+
|
239
|
+
**Note**: For files larger than 5 GB please refer to the [Upload Large Files](#upload_large_files) section.
|
240
|
+
|
241
|
+
|
242
|
+
## Upload Large Files
|
243
|
+
|
244
|
+
OSS requires files larger than 5 GB (the OSS default limit) to be uploaded into segments along with an accompanying manifest file. All of the segments must be uploaded to the same container.
|
245
|
+
|
246
|
+
Segmented files are downloaded like ordinary files. See [Download Files](#download-files) section for more information.
|
247
|
+
|
248
|
+
## Download Files
|
249
|
+
|
250
|
+
The most efficient way to download files from a private or public directory is as follows:
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
File.open('downloaded-file.jpg', 'w') do | f |
|
254
|
+
directory.files.get("my_big_file.jpg") do | data, remaining, content_length |
|
255
|
+
f.syswrite data
|
256
|
+
end
|
257
|
+
end
|
258
|
+
```
|
259
|
+
|
260
|
+
This will download and save the file.
|
261
|
+
|
262
|
+
**Note**: The `body` attribute of file will be empty if a file has been downloaded using this method.
|
263
|
+
|
264
|
+
If a file object has already been loaded into memory, you can save it as follows:
|
265
|
+
|
266
|
+
```ruby
|
267
|
+
File.open('germany.jpg', 'w') {|f| f.write(file_object.body) }
|
268
|
+
```
|
269
|
+
|
270
|
+
**Note**: This method is more memory intensive as the entire object is loaded into memory before saving the file as in the example above.
|
271
|
+
|
272
|
+
|
273
|
+
## File URL
|
274
|
+
|
275
|
+
To get a file's URL:
|
276
|
+
|
277
|
+
```ruby
|
278
|
+
file.public_url
|
279
|
+
```
|
280
|
+
|
281
|
+
## Copy File
|
282
|
+
|
283
|
+
Cloud Files supports copying files. To copy files into a container named "trip" with a name of "europe.jpg" do the following:
|
284
|
+
|
285
|
+
```ruby
|
286
|
+
file.copy("trip", "europe.jpg")
|
287
|
+
```
|
288
|
+
|
289
|
+
To move or rename a file, perform a copy operation and then delete the old file:
|
290
|
+
|
291
|
+
```ruby
|
292
|
+
file.copy("trip", "germany.jpg")
|
293
|
+
file.destroy
|
294
|
+
```
|
295
|
+
|
296
|
+
## Delete File
|
297
|
+
|
298
|
+
To delete a file:
|
299
|
+
|
300
|
+
```ruby
|
301
|
+
file.destroy
|
302
|
+
```
|
303
|
+
## Development
|
304
|
+
|
305
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
306
|
+
|
307
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
308
|
+
|
309
|
+
## License
|
310
|
+
|
311
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
312
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fog/aliyun"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/fog-aliyun.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fog/aliyun/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'fog-aliyun'
|
8
|
+
spec.version = Fog::Aliyun::VERSION
|
9
|
+
spec.authors = ['Qinsi Deng, Jianxun Li, Jane Han']
|
10
|
+
spec.email = ['dengqinsi@sina.com']
|
11
|
+
|
12
|
+
spec.summary = 'Fog provider for Aliyun Web Services.'
|
13
|
+
spec.description = 'As a FOG provider, fog-aliyun support aliyun OSS/ECS. It will support more aliyun services later.'
|
14
|
+
spec.homepage = 'https://github.com/fog/fog-aliyun'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.3'
|
25
|
+
spec.add_development_dependency 'rubocop', '~> 0.40.0'
|
26
|
+
spec.add_development_dependency 'mime-types', '~> 2.6', '>= 2.6.2'
|
27
|
+
spec.add_development_dependency 'pry-nav'
|
28
|
+
|
29
|
+
spec.add_dependency 'fog-core', '~> 1.27'
|
30
|
+
spec.add_dependency 'fog-json', '~> 1.0'
|
31
|
+
spec.add_dependency 'ipaddress', '~> 0.8'
|
32
|
+
spec.add_dependency 'xml-simple', '~> 1.1'
|
33
|
+
end
|