This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
forked from ilia-semenov/awspricingfull
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainexample.py
114 lines (89 loc) · 5.15 KB
/
mainexample.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
'''
Simple main routine for `awspricingfull` module.
Call the class corresponding to your needs (EC2Prices(), RDSPrices(), etc.),
and use any method with parameters needed. See the awspricingfull documentation for reference.
In a nutshell: To save CSV use save_csv method for instance of any of the functional classes
(EC2Prices() - EC2, RDSPrices() - RDS, ELCPrices() - ElastiCache, RSPrices() - Redshift, DDBPrices() - DynamoDB).
With save_csv use "reserved" or "ondemand" as first parameter, your path as second (home
dir by default) and file name as third (conventional default). Also, to save prices for all
the products use AllAWSPrices() class and same save_csv method with small difference - you
can set the first parameter to "all" which will return all the pricing (reserved and on-demand
for all the services).
Method print_table is available for EC2Prices(), RDSPrices(), ELCPrices(), RSPrices(), DDBPrices(). It outputs
the pricing in a table format to console. Prettytable library is required. Method takes only one parameter:
"reserved" or "ondemand". Not available for AllAWSPrices().
Method print_json is available for all classes. It returns the pricing in a JSON format
and does not output it to console. Method takes only one parameter: "reserved" or "ondemand"
and additional "all" for AllAWSPrices().
Created: Mar 26, 2015
Updated: Feb 14, 2017
@author: Ilia Semenov
@version: 3.2
'''
import awspricingfull
if __name__ == '__main__':
'''
1. Create 1nstance of the class needed: EC2Prices() - EC2, RDSPrices() - RDS,
ELCPrices() - ElastiCache, RSPrices() - Redshift, DDBPrices - DynamoDB, AllAWSPrices() - full pricing.
2. Run the method needed: return_json, print_table, save_csv.
'''
'''
FULL PRICING
'''
allpricing=awspricingfull.AllAWSPrices2() #Full Pricing class instance
#print (allpricing.return_json("ondemand")) #JSON - On-Demand Pricing: All Services
#print (allpricing.return_json("reserved")) #JSON - Reserved Pricing: All Services
#print (allpricing.return_json("all")) #JSON - Full Pricing: All Services
#allpricing.save_csv("ondemand") #CSV - On-Demand Pricing: All Services
#allpricing.save_csv("reserved") #CSV - Reserved Pricing: All Services
allpricing.save_csv("all") #CSV - Full Pricing: All Services
'''
EC2
'''
ec2pricing=awspricingfull.EC2Prices() #EC2 Pricing class instance
#print (ec2pricing.return_json("ondemand")) #JSON - On-Demand Pricing: EC2
#print (ec2pricing.return_json("reserved")) #JSON - Reserved Pricing: EC2
#ec2pricing.print_table("ondemand") #PrettyTable - On-Demand Pricing: EC2
#ec2pricing.print_table("reserved") #PrettyTable - Reserved Pricing: EC2
#ec2pricing.save_csv("ondemand") #CSV - On-Demand Pricing: EC2
#ec2pricing.save_csv("reserved") #CSV - Reserved Pricing: EC2
'''
RDS
'''
rdspricing=awspricingfull.RDSPrices() #RDS Pricing class instance
#print (rdspricing.return_json("ondemand")) #JSON - On-Demand Pricing: RDS
#print (rdspricing.return_json("reserved")) #JSON - Reserved Pricing: RDS
#rdspricing.print_table("ondemand") #PrettyTable - On-Demand Pricing: RDS
#rdspricing.print_table("reserved") #PrettyTable - Reserved Pricing: RDS
#rdspricing.save_csv("ondemand") #CSV - On-Demand Pricing: RDS
#rdspricing.save_csv("reserved") #CSV - Reserved Pricing: RDS
'''
ELASTICACHE
'''
elcpricing=awspricingfull.ELCPrices() #ElastiCache Pricing class instance
#print (elcpricing.return_json("ondemand")) #JSON - On-Demand Pricing: ElastiCache
#print (elcpricing.return_json("reserved")) #JSON - Reserved Pricing: ElastiCache
#elcpricing.print_table("ondemand") #PrettyTable - On-Demand Pricing: ElastiCache
#elcpricing.print_table("reserved") #PrettyTable - Reserved Pricing: ElastiCache
#elcpricing.save_csv("ondemand") #CSV - On-Demand Pricing: ElastiCache
#elcpricing.save_csv("reserved") #CSV - Reserved Pricing: ElastiCache
'''
REDSHIFT
'''
rspricing=awspricingfull.RSPrices() #Redshift Pricing class instance
#print (rspricing.return_json("ondemand")) #JSON - On-Demand Pricing: Redshift
#print (rspricing.return_json("reserved")) #JSON - Reserved Pricing: Redshift
#rspricing.print_table("ondemand") #PrettyTable - On-Demand Pricing: Redshift
#rspricing.print_table("reserved") #PrettyTable - Reserved Pricing: Redshift
#rspricing.save_csv("ondemand") #CSV - On-Demand Pricing: Redshift
#rspricing.save_csv("reserved") #CSV - Reserved Pricing: Redshift
'''
DYNAMODB
'''
ddbpricing=awspricingfull.DDBPrices() #DynamoDB Pricing class instance
#print (ddbpricing.return_json("ondemand")) #JSON - On-Demand Pricing: DynamoDB
#print (ddbpricing.return_json("reserved")) #JSON - Reserved Pricing: DynamoDB
#ddbpricing.print_table("ondemand") #PrettyTable - On-Demand Pricing: DynamoDB
#ddbpricing.print_table("reserved") #PrettyTable - Reserved Pricing: DynamoDB
#ddbpricing.save_csv("ondemand") #CSV - On-Demand Pricing: DynamoDB
#ddbpricing.save_csv("reserved") #CSV - Reserved Pricing: DynamoDB