awscli 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,6 +3,8 @@ awscli
3
3
 
4
4
  Amazon Web Service(s) Command Line Interface
5
5
 
6
+ [![Gem Version](https://badge.fury.io/rb/awscli.png)](http://badge.fury.io/rb/awscli) [![Dependency Status](https://gemnasium.com/ashrithr/awscli.png)](https://gemnasium.com/ashrithr/awscli) [![Code Climate](https://codeclimate.com/github/ashrithr/awscli.png)](https://codeclimate.com/github/ashrithr/awscli)
7
+
6
8
  Provides the following interface:
7
9
 
8
10
  - Elastic Cloud Compute (EC2)
@@ -0,0 +1,33 @@
1
+ #Sample awscli dynamo usage examples:
2
+
3
+ # => Create tables
4
+ awscli dynamo table create -n ProductCatalog -k Id -t N -r 5 -w 5
5
+ awscli dynamo table create -n Forum -k Name -t S -r 5 -w 5
6
+ awscli dynamo table create -n Thread -k ForumName -t S --rk-name Subject --rk-type S -r 5 -w 5
7
+ awscli dynamo table create -n Reply -k Id -t S --rk-name ReplyDateTime --rk-type S -r 5 -w 5
8
+
9
+ #Individual Puts
10
+ awscli dynamo item put -t ProductCatalog -i Id:N:101 Title:S:'Book 101 Title' ISBN:S:'111-1111111111' Authors:SS:'Author1,Author2' Price:N:2 Dimensions:S:'8.5 x 11.0 x 0.5' PageCount:N:500 InPublication:N:1 ProductCategory:S:Book
11
+ awscli dynamo item put -t ProductCatalog -i Id:N:102 Title:S:'Book 102 Title' ISBN:S:'222-2222222222' Authors:SS:'Author2' Price:N:20 Dimensions:S:'8.5 x 11.0 x 0.8' PageCount:N:600 InPublication:N:1 ProductCategory:S:Book
12
+ awscli dynamo item put -t ProductCatalog -i Id:N:103 Title:S:'Book 103 Title' ISBN:S:'333-3333333333' Authors:SS:'Author1,Author2' Price:N:2000 Dimensions:S:'8.5 x 11.0 x 1.5' PageCount:N:600 InPublication:N:0 ProductCategory:S:Book
13
+ awscli dynamo item put -t ProductCatalog -i Id:N:201 Title:S:'18-Bike-201' Description:S:'201 Description' BicycleType:S:Road Brand:S:'Mountain A' Price:N:100 Gender:S:M Color:SS:'Green,Red' ProductCategory:S:Bicycle
14
+ awscli dynamo item put -t ProductCatalog -i Id:N:202 Title:S:'21-Bike-202' Description:S:'202 Description' BicycleType:S:Road Brand:S:'Brand-Company A' Price:N:200 Gender:S:M Color:SS:'Green,Black' ProductCategory:S:Bicycle
15
+ awscli dynamo item put -t ProductCatalog -i Id:N:203 Title:S:'19-Bike-203' Description:S:'203 Description' BicycleType:S:Road Brand:S:'Brand-Company B' Price:N:300 Gender:S:W Color:SS:'Red,Green,Black' ProductCategory:S:Bicycle
16
+ awscli dynamo item put -t ProductCatalog -i Id:N:204 Title:S:'18-Bike-204' Description:S:'204 Description' BicycleType:S:Mountain Brand:S:'Brand-Company B' Price:N:400 Gender:S:W Color:SS:'Red' ProductCategory:S:Bicycle
17
+ awscli dynamo item put -t ProductCatalog -i Id:N:205 Title:S:'20-Bike-205' Description:S:'205 Description' BicycleType:S:Hybrid Brand:S:'Brand-Company C' Price:N:500 Gender:S:B Color:SS:'Red,Black' ProductCategory:S:Bicycle
18
+
19
+ #Batch Writes
20
+ awscli dynamo item batch_write --put-requests Forum,Name:S:'Amazon DynamoDB',Category:S:'AWS',Threads:N:2,Messages:N:4,Views:N:1000 Forum,Name:S:'Amazon S3',Category:S:'AWS',Threads:N:0 Thread,ForumName:S:'Amazon DynamoDB',Subject:S:'DynamoDB Thread 1',Message:S:'DynamoDB thread 1 message',LastPostedBy:S:'User A',LastPostedDateTime:S:'2013-04-02 13:49:13 -0700',Views:N:0,Reply:N:0,Answered:N:0,Tags:SS:'index;primarykey;table' Thread,ForumName:S:'Amazon DynamoDB',Subject:S:'DynamoDB Thread 2',Message:S:'DynamoDB thread 2 message',LastPostedBy:S:'User A',LastPostedDateTime:S:'2013-03-19 13:56:48 -0700',Views:N:0,Reply:N:0,Answered:N:0,Tags:SS:'index;primarykey;rangekey' Thread,ForumName:S:'Amazon S3',Subject:S:'S3 Thread 1',Message:S:'S3 thread 1 message',LastPostedBy:S:'User A',LastPostedDateTime:S:'2013-03-19 13:56:48 -0700',Views:N:0,Reply:N:0,Answered:N:0,Tags:SS:'largeobjects;multipart upload'
21
+ awscli dynamo item batch_write --put-requests Reply,Id:S:'Amazon DynamoDB#DynamoDB Thread 1',ReplyDateTime:S:'2013-04-02 13:49:13 -0700',Message:S:'DynamoDB Thread 1 Reply 1 text',PostedBy:S:'User A' Reply,Id:S:'Amazon DynamoDB#DynamoDB Thread 1',ReplyDateTime:S:'2013-04-09 15:00:54 -0700',Message:S:'DynamoDB Thread 1 Reply 2 text',PostedBy:S:'User B' Reply,Id:S:'Amazon DynamoDB#DynamoDB Thread 2',ReplyDateTime:S:'2013-04-09 12:30:12 -0700',Message:S:'DynamoDB Thread 2 Reply 1 text',PostedBy:S:'User A' Reply,Id:S:'Amazon DynamoDB#DynamoDB Thread 2',ReplyDateTime:S:'2013-04-12 04:12:30 -0700',Message:S:'DynamoDB Thread 2 Reply 2 text',PostedBy:S:'User A'
22
+
23
+ #Sample Queries
24
+ #Get an item from the ProductCatalog table whose Id is 101 and get attributes Id,ISBN,Title,Authors
25
+ awscli dynamo item get -t ProductCatalog -k N:101 -g Id ISBN Title Authors
26
+ #Query the Reply table to find replies posted in the last 15 days
27
+ awscli dynamo item query -t Reply -v S,"Amazon DynamoDB#DynamoDB Thread 1" -f LT,S,"2013-04-09 12:30:12 -0700"
28
+
29
+ #Delete tables
30
+ awscli dynamo table delete -n ProductCatalog
31
+ awscli dynamo table delete -n Forum
32
+ awscli dynamo table delete -n Thread
33
+ awscli dynamo table delete -n Reply
@@ -38,6 +38,10 @@ module AwsCli
38
38
 
39
39
  `awscli dynamo item put -t test_table -i Id:N:1 UserName:S:test_user`
40
40
 
41
+ Put a Multi-Valued(NS|SS|BS) attribute into a table:
42
+
43
+ `awscli dynamo item put -t ProductCatalog -i Id:N:101 Authors:SS:'Author1;Author2'`
44
+
41
45
  #{conditional_item}
42
46
 
43
47
  `awscli dynamo item put -t test -i Id:N:1 UserName:S:test_user -a UserName:S:test -e true -r ALL_OLD`
@@ -121,6 +125,13 @@ module AwsCli
121
125
  end
122
126
 
123
127
  desc 'query [OPTIONS]', 'returns one or more items and their attributes by primary key (only available for hash-and-range primary key tables)'
128
+ long_desc <<-DESC
129
+ Usage Example:
130
+
131
+ Query the 'Reply' table to get last 15 days replies from thread 1:
132
+
133
+ `awscli dynamo item query -t Reply -v S,"Amazon DynamoDB#DynamoDB Thread 1" -f LT,S,"2013-04-09 12:30:12 -0700"`
134
+ DESC
124
135
  method_option :table_name, :aliases => '-t', :desc => 'name of the table containing the requested items'
125
136
  method_option :attrs_to_get, :aliases => '-g', :type => :array, :desc => 'array of attribute names, if attribute names are not specified then all attributes will be returned'
126
137
  method_option :limit, :aliases => '-l', :type => :numeric, :desc => 'limit of total items to return'
@@ -222,7 +233,7 @@ module AwsCli
222
233
 
223
234
  The following batch_write operation will put an item into User, Item tables and deletes item from User, Thread tables
224
235
 
225
- `bundle exec bin/awscli dynamo item batch_write --put-requests User,Id:S:003,UserName:S:user123,Password:S:secret123 Item,Id:S:'Amazon Dynamo DB#Thread 5',ReplyDateTime:S:'2012-04-03T11:04:47.034Z' --delete-requests User,S=003 Thread,S='Amazon DynamoDB#Thread 4':S='oops - accidental row'`
236
+ `bundle exec bin/awscli dynamo item batch_write --put-requests User,Id:S:003,UserName:S:user123,Password:S:secret123 Item,Id:S:'Amazon Dynamo DB#Thread 5',ReplyDateTime:S:'2012-04-03T11:04:47.034Z',Comments:SS:'Test;Another' --delete-requests User,S=003 Thread,S='Amazon DynamoDB#Thread 4':S='oops - accidental row'`
226
237
  DESC
227
238
  method_option :put_requests, :aliases => '-p', :type => :array, :desc => 'Format=> table_name,col_name1:col_type1:col_value1,col_name2:col_type2:col_value2 ..'
228
239
  method_option :delete_requests, :aliases => '-d', :type => :array, :desc => 'Format=> table_name,hash_key_type*=hash_key_value*:range_key_type=range_key_value ..'
@@ -20,6 +20,18 @@ module AwsCli
20
20
  end
21
21
 
22
22
  desc 'create', 'create a new table'
23
+ long_desc <<-DESC
24
+ Usage Examples:
25
+
26
+ Create table named 'ProductCatalog' with primary hash key 'Id' of type 'Number' and provisioned Throughput read
27
+ capacity & write capacity of 5:
28
+
29
+ `awscli dynamo table create -n ProductCatalog -k Id -t N -r 5 -w 5`
30
+
31
+ Create table named 'Thread' with primary hash key 'ForumName' of type String and primary range key 'Subject' of type String:
32
+
33
+ `awscli dynamo table create -n Thread -k ForumName -t S --rk-name Subject --rk-type S -r 5 -w 5`
34
+ DESC
23
35
  method_option :name, :aliases => '-n', :required => true, :desc => 'name of the table to create, name should be unique among your account'
24
36
  method_option :pk_name, :aliases => '-k', :required => true, :desc => 'primary key hash attribute name for the table'
25
37
  method_option :pk_type, :aliases => '-t', :required => true, :desc => 'type of the hash attribute, valid values in [N, NS, S, SS]. N-Number, NS-NumberSet, S-String, SS-StringSet'
@@ -174,8 +174,17 @@ module Awscli
174
174
  opts = {}
175
175
  options[:item].each do |item|
176
176
  abort "invalid item format: #{item}" unless item =~ /(.*):(N|S|NS|SS|B|BS):(.*)/
177
- attr_name, attr_type, attr_value = item.split(':')
178
- items[attr_name] = { attr_type => attr_value }
177
+ attr_name, attr_type, attr_value = item.split(':', 3)
178
+ case attr_type
179
+ when 'N', 'S', 'B'
180
+ items[attr_name] = { attr_type => attr_value }
181
+ when 'NS', 'SS', 'BS'
182
+ attr_value_arry = attr_value.split(';')
183
+ abort 'Invalid attribute value format, attributes should be comma separated values' if attr_value_arry.empty?
184
+ items[attr_name] = { attr_type => attr_value_arry }
185
+ else
186
+ abort 'Invalid attribute type'
187
+ end
179
188
  end
180
189
  if options[:expected_attr] #-a
181
190
  expected_attr_name, expected_attr_type, expected_attr_value = options[:expected_attr].split(':')
@@ -272,14 +281,23 @@ module Awscli
272
281
  #request_items['RequestItems'] = {}
273
282
  options[:put_requests] and options[:put_requests].each do |request|
274
283
  #table_name,col_name1:col_type1:col_value1,col_name2:col_type2:col_value2 ..
275
- table_name, *cols = request.split(',')
284
+ table_name, *cols = request.split(/,(?=(?:[^']|'[^']*')*$)/)
276
285
  request_items[table_name] ||= []
277
286
  put_request = {}
278
287
  put_request['PutRequest'] = {}
279
288
  put_request['PutRequest']['Item'] = {}
280
289
  cols.each do |col|
281
- col_name, col_type, col_value = col.split(':')
282
- put_request['PutRequest']['Item'][col_name] = { col_type => col_value }
290
+ col_name, col_type, col_value = col.split(':', 3)
291
+ case col_type
292
+ when 'N', 'S', 'B'
293
+ put_request['PutRequest']['Item'][col_name] = { col_type => col_value }
294
+ when 'NS', 'SS', 'BS'
295
+ col_value_arry = col_value.split(';')
296
+ abort 'Invalid attribute value format, attributes should be comma separated values' if col_value_arry.empty?
297
+ put_request['PutRequest']['Item'][col_name] = { col_type => col_value_arry }
298
+ else
299
+ abort "Invalid attribute type: #{col_type}"
300
+ end
283
301
  end
284
302
  request_items[table_name] << put_request
285
303
  end
@@ -1,3 +1,3 @@
1
1
  module Awscli
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awscli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-15 00:00:00.000000000 Z
12
+ date: 2013-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -160,6 +160,7 @@ files:
160
160
  - lib/awscli/cli/s3/directories.rb
161
161
  - lib/awscli/cli/s3/files.rb
162
162
  - lib/awscli/cli/s3.rb
163
+ - lib/awscli/cli/UsageExamples/dynamo
163
164
  - lib/awscli/cli/UsageExamples/emr
164
165
  - lib/awscli/cli.rb
165
166
  - lib/awscli/connection.rb
@@ -202,3 +203,4 @@ specification_version: 3
202
203
  summary: Command Line Interface for Amazon Web Services built in Ruby, using Fog and
203
204
  Thor
204
205
  test_files: []
206
+ has_rdoc: