lambda_wrap 0.25.0 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c5e074725712f275d266a7e4a903eed3f9fc680
4
- data.tar.gz: c0591eb2e37e873d7e270830728c6e0eb8ec60d3
3
+ metadata.gz: fb6c46e052f6c1185e9810f52f51992a1973c2aa
4
+ data.tar.gz: c4e14dda2fddb4fff94d757e877c6ce6ce0944ad
5
5
  SHA512:
6
- metadata.gz: 90d7756da7775e043f6c8ad6fac06db8f0f7091798b83dbde2701f6e232a1084eae9a1521776cea56af2a7a5a24a5c24a7516969063e968128ec9d6cbaec6666
7
- data.tar.gz: d204fd54dea9cb4eda93c3e39dc23288b0cc74259775a656f641bf59337ad68d3a58b98853a4b3284b3d4f52e5fcb4f703257d0c07bbed762d52382ba143c781
6
+ metadata.gz: c5e2cc04e1c7960382274252074adc6f2e0639d9f32076d13bd523c6a4808a96f691ffd0524e739fe8b3da77e4da4e04a7c8ef68cfe529bf908002a60f4c7e7c
7
+ data.tar.gz: 342207c240ef3003382d97b6bbc1728e5894fd984f31efb87b452519c5c9121d8ee5f48a1a531997424b009bb6aaf6435dace12280078c96f2477c08609feff0
@@ -25,6 +25,47 @@ module LambdaWrap
25
25
  )
26
26
  end
27
27
 
28
+ ##
29
+ # Updates the provisioned throughput read and write capacity of the requested table.
30
+ # If the table does not exist an error message is displayed. If current read/write capacity
31
+ # is equals to requested read/write capacity or the requested read/write capacity is 0 or less than 0
32
+ # no table updation is performed.
33
+ #
34
+ # *Arguments*
35
+ # [table_name] The table name of the dynamoDB to be updated.
36
+ # [read_capacity] The read capacity the table should be updated with.
37
+ # [write_capacity] The write capacity the table should be updated with.
38
+ def update_table_capacity(table_name, read_capacity, write_capacity)
39
+ # Check if table exists.
40
+ begin
41
+ table_details = @client.describe_table(table_name: table_name).table
42
+ rescue Aws::DynamoDB::Errors::ResourceNotFoundException
43
+ raise "Update cannot be performed. Table #{table_name} does not exists."
44
+ end
45
+
46
+ if (read_capacity <= 0 || write_capacity <= 0)
47
+ puts "Table: #{table_name} not updated. Read/Write capacity should be greater than or equal to 1."
48
+ elsif (read_capacity == table_details.provisioned_throughput.read_capacity_units ||
49
+ write_capacity == table_details.provisioned_throughput.write_capacity_units)
50
+ puts "Table: #{table_name} not updated. Current and requested reads/writes are same.
51
+ Current ReadCapacityUnits provisioned for the table: #{table_details.provisioned_throughput.read_capacity_units}.
52
+ Requested ReadCapacityUnits: #{read_capacity}.
53
+ Current WriteCapacityUnits provisioned for the table: #{table_details.provisioned_throughput.write_capacity_units}.
54
+ Requested WriteCapacityUnits: #{write_capacity}. "
55
+ else
56
+ response = @client.update_table(
57
+ table_name: table_name,
58
+ provisioned_throughput: { read_capacity_units: read_capacity, write_capacity_units: write_capacity })
59
+
60
+ raise "Read and writes capacities was not updated for table: #{table_name}." unless (response.table_description.provisioned_throughput.read_capacity_units!= read_capacity ||
61
+ response.table_description.provisioned_throughput.write_capacity_units!= write_capacity)
62
+
63
+ puts "Updated new read/write capacity for table #{table_name}.
64
+ Read capacity updated to: #{read_capacity}.
65
+ Write capacity updated to: #{write_capacity}."
66
+ end
67
+ end
68
+
28
69
  ##
29
70
  # Publishes the database and awaits until it is fully available. If the table already exists,
30
71
  # it only adjusts the read and write
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lambda_wrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Thurner
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-12-19 00:00:00.000000000 Z
13
+ date: 2017-02-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws-sdk