awscosts 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -58,6 +58,21 @@ To find the on demand EC2 price and Elastic MapReduce price for the Oregon regio
58
58
  AWSCosts.region('us-west-2').emr.ec2_price('cc2.8xlarge')
59
59
  AWSCosts.region('us-west-2').emr.emr_price('cc2.8xlarge')
60
60
 
61
+ ### S3
62
+
63
+ To find the First 1 TB / month price in the Singapore region which includes the Standard
64
+ Storage, Reduced Redundancy Storage, and the Glacier Storage
65
+
66
+ AWSCosts.region('ap-southeast-1').s3.storage.price('firstTBstorage')
67
+
68
+ Pricing is also available for data transfer
69
+
70
+ region.s3.data_transfer.price
71
+
72
+ And request pricing
73
+
74
+ region.s3.request.price
75
+
61
76
  ## Supported Services
62
77
 
63
78
  The following AWS services are currently support (more to come):
@@ -68,6 +83,7 @@ The following AWS services are currently support (more to come):
68
83
  * Reserved heavy utilisation
69
84
  * Elastic Load Balancer (ELB)
70
85
  * Elastic MapReduce (EMR)
86
+ * S3
71
87
 
72
88
  EC2 platforms:
73
89
 
data/lib/awscosts.rb CHANGED
@@ -2,6 +2,7 @@ require "awscosts/version"
2
2
  require "awscosts/region"
3
3
  require "awscosts/ec2"
4
4
  require "awscosts/emr"
5
+ require "awscosts/s3"
5
6
 
6
7
  module AWSCosts
7
8
 
@@ -27,6 +27,10 @@ class AWSCosts::Region
27
27
  AWSCosts::EMR.fetch(self.price_mapping)
28
28
  end
29
29
 
30
+ def s3
31
+ AWSCosts::S3.new(self)
32
+ end
33
+
30
34
  private
31
35
  def initialize name
32
36
  @name = name
@@ -0,0 +1,27 @@
1
+ require 'awscosts/s3_storage'
2
+ require 'awscosts/s3_requests'
3
+ require 'awscosts/s3_data_transfer'
4
+
5
+ class AWSCosts::S3
6
+
7
+ attr_reader :region
8
+
9
+ def initialize region
10
+ @region = region
11
+ end
12
+
13
+ def storage
14
+ AWSCosts::S3Storage.fetch(self.region.price_mapping)
15
+ end
16
+
17
+ def data_transfer
18
+ AWSCosts::S3DataTransfer.fetch(self.region.price_mapping)
19
+ end
20
+
21
+ def requests
22
+ AWSCosts::S3Requests.fetch(self.region.price_mapping)
23
+ end
24
+ end
25
+
26
+
27
+
@@ -0,0 +1,37 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ class AWSCosts::S3DataTransfer
5
+
6
+ TYPES = %w{dataXferInS3, dataXferOutS3CrossRegion, dataXferOutS3}
7
+
8
+ def initialize data
9
+ @data= data
10
+ end
11
+
12
+ def price type = nil
13
+ type.nil? ? @data : @data[type.to_s]
14
+ end
15
+
16
+ def self.fetch region
17
+ @cache ||= begin
18
+ result = {}
19
+ data= JSON.parse(HTTParty.get("http://aws.amazon.com/s3/pricing/pricing-data-transfer.json").body)
20
+ data['config']['regions'].each do |region|
21
+ types = {}
22
+ region['types'].each do |type|
23
+ types[type['name']] = {}
24
+ type['tiers'].each do |tier|
25
+ types[type['name']][tier['name']] = tier['prices']['USD'].to_f
26
+ end
27
+ end
28
+ result[region['region']] = types
29
+ end
30
+ result
31
+ end
32
+ self.new(@cache[region])
33
+ end
34
+
35
+ end
36
+
37
+
@@ -0,0 +1,34 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ class AWSCosts::S3Requests
5
+
6
+ TIERS = %w{putcopypost, glacierRequests, deleteRequests, getEtc, glacierDataRestore}
7
+
8
+ def initialize data
9
+ @data= data
10
+ end
11
+
12
+ def price tier = nil
13
+ tier.nil? ? @data : @data[tier.to_s]
14
+ end
15
+
16
+ def self.fetch region
17
+ @cache ||= begin
18
+ result = {}
19
+ data= JSON.parse(HTTParty.get("http://aws.amazon.com/s3/pricing/pricing-requests.json").body)
20
+ data['config']['regions'].each do |region|
21
+ tiers = {}
22
+ region['tiers'].each do |tier|
23
+ tiers[tier['name']] = { rate: tier['rate'], price: tier['prices']['USD'].to_f}
24
+ end
25
+ result[region['region']] = tiers
26
+ end
27
+ result
28
+ end
29
+ self.new(@cache[region])
30
+ end
31
+
32
+ end
33
+
34
+
@@ -0,0 +1,38 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ class AWSCosts::S3Storage
5
+
6
+ TIERS = %w{firstTBstorage, next49TBstorage, next49TBstorage, next501TBstorage}
7
+
8
+ def initialize data
9
+ @data= data
10
+ end
11
+
12
+ def price tier = nil
13
+ tier.nil? ? @data : @data[tier.to_s]
14
+ end
15
+
16
+ def self.fetch region
17
+ @cache ||= begin
18
+ result = {}
19
+ data= JSON.parse(HTTParty.get("http://aws.amazon.com/s3/pricing/pricing-storage.json").body)
20
+ data['config']['regions'].each do |region|
21
+ tiers = {}
22
+ region['tiers'].each do |tier|
23
+ storage_type = {}
24
+ tiers[tier['name']] = storage_type
25
+ tier['storageTypes'].each do |type|
26
+ storage_type[type['type']] = type['prices']['USD'].to_f
27
+ end
28
+ end
29
+ result[region['region']] = tiers
30
+ end
31
+ result
32
+ end
33
+ self.new(@cache[region])
34
+ end
35
+
36
+ end
37
+
38
+
@@ -1,3 +1,3 @@
1
1
  module AWSCosts
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awscosts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-05-24 00:00:00.000000000 Z
12
+ date: 2013-05-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -96,6 +96,10 @@ files:
96
96
  - lib/awscosts/ec2_reserved_instances.rb
97
97
  - lib/awscosts/emr.rb
98
98
  - lib/awscosts/region.rb
99
+ - lib/awscosts/s3.rb
100
+ - lib/awscosts/s3_data_transfer.rb
101
+ - lib/awscosts/s3_requests.rb
102
+ - lib/awscosts/s3_storage.rb
99
103
  - lib/awscosts/version.rb
100
104
  - spec/awscosts/ec2_spec.rb
101
105
  - spec/awscosts/region_spec.rb
@@ -115,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
119
  version: '0'
116
120
  segments:
117
121
  - 0
118
- hash: 1325715737968826083
122
+ hash: 1983521738208440787
119
123
  required_rubygems_version: !ruby/object:Gem::Requirement
120
124
  none: false
121
125
  requirements:
@@ -124,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
128
  version: '0'
125
129
  segments:
126
130
  - 0
127
- hash: 1325715737968826083
131
+ hash: 1983521738208440787
128
132
  requirements: []
129
133
  rubyforge_project:
130
134
  rubygems_version: 1.8.23