-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: refactoring - create ECS & EC2 folders
- Loading branch information
1 parent
8608f38
commit cec4450
Showing
7 changed files
with
142 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module AWS.Pricing.EC2.Types where | ||
|
||
import AWS.Pricing.Types (Terms) | ||
import Data.Either (Either) | ||
import Data.Maybe (Maybe) | ||
|
||
type GetEC2ProductsResponse | ||
= { formatVersion :: String | ||
, priceList :: Array (Either String EC2PriceList) | ||
, nextToken :: Maybe String | ||
} | ||
|
||
type EC2Attributes r | ||
= { instanceType :: String | ||
, instanceFamily :: String | ||
, operatingSystem :: String | ||
, vcpu :: String | ||
, servicename :: String | ||
| r | ||
} | ||
|
||
type EC2Product r | ||
= { attributes :: (Either String (EC2Attributes ())) | r } | ||
|
||
type EC2PriceList | ||
= { serviceCode :: String | ||
, version :: String | ||
, publicationDate :: String | ||
, product :: EC2Product () | ||
, terms :: Terms | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module AWS.Pricing.EC2.Utils where | ||
|
||
import Prelude | ||
import AWS.Core.Util (handleError) | ||
import AWS.Pricing.EC2.Types (EC2Attributes, EC2PriceList, EC2Product) | ||
import AWS.Pricing.Types (InternalPriceList, InternalProduct) | ||
import AWS.Pricing.Utils (toTerms) | ||
import Data.Argonaut (Json, decodeJson) | ||
import Data.Bifunctor (lmap, bimap) | ||
import Data.Either (Either) | ||
|
||
toEC2PriceList :: InternalPriceList -> EC2PriceList | ||
toEC2PriceList pl = | ||
{ serviceCode: pl.serviceCode | ||
, version: pl.version | ||
, publicationDate: pl.publicationDate | ||
, product: toEC2Product pl.product | ||
, terms: toTerms pl.terms | ||
} | ||
|
||
toEC2Product :: InternalProduct -> EC2Product () | ||
toEC2Product internalProduct = | ||
{ attributes: parseAttributes internalProduct.attributes | ||
} | ||
where | ||
parseAttributes :: Json -> Either String (EC2Attributes ()) | ||
parseAttributes = decodeJson <#> lmap handleError | ||
|
||
parseEC2PriceList :: Json -> Either String EC2PriceList | ||
parseEC2PriceList = decodeJson <#> bimap handleError toEC2PriceList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module AWS.Pricing.ECS.Types where | ||
|
||
import Prelude | ||
import Data.Either (Either) | ||
import Data.Maybe (Maybe) | ||
import AWS.Pricing.Types (Terms) | ||
|
||
type GetECSProductsResponse | ||
= { formatVersion :: String | ||
, priceList :: Array (Either String ECSPriceList) | ||
, nextToken :: Maybe String | ||
} | ||
|
||
type ECSAttributes r | ||
= { servicecode :: String | ||
, usagetype :: String | ||
, servicename :: String | ||
, operation :: String | ||
| r | ||
} | ||
|
||
type ECSProduct r | ||
= { attributes :: (Either String (ECSAttributes ())) | r } | ||
|
||
type ECSPriceList | ||
= { serviceCode :: String | ||
, version :: String | ||
, publicationDate :: String | ||
, product :: ECSProduct () | ||
, terms :: Terms | ||
} | ||
|
||
data ECSUsageType | ||
= EUC1FargateEphemeralStorageGBHours | ||
| EUC1FargateGBHours | ||
| EUC1FargatevCPUHoursperCPU | ||
|
||
instance showECSUsageType :: Show ECSUsageType where | ||
show EUC1FargateEphemeralStorageGBHours = "EUC1-Fargate-EphemeralStorage-GB-Hours" | ||
show EUC1FargateGBHours = "EUC1-Fargate-GB-Hours" | ||
show EUC1FargatevCPUHoursperCPU = "EUC1-Fargate-vCPU-Hours:perCPU" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module AWS.Pricing.ECS.Utils where | ||
|
||
import Prelude | ||
import AWS.Core.Util (handleError) | ||
import AWS.Pricing.ECS.Types | ||
( ECSPriceList | ||
, ECSProduct | ||
, ECSAttributes | ||
) | ||
import AWS.Pricing.Types (InternalPriceList, InternalProduct) | ||
import AWS.Pricing.Utils (toTerms) | ||
import Data.Argonaut (Json, decodeJson) | ||
import Data.Bifunctor (lmap, bimap) | ||
import Data.Either (Either) | ||
|
||
toECSPriceList :: InternalPriceList -> ECSPriceList | ||
toECSPriceList pl = | ||
{ serviceCode: pl.serviceCode | ||
, version: pl.version | ||
, publicationDate: pl.publicationDate | ||
, product: toECSProduct pl.product | ||
, terms: toTerms pl.terms | ||
} | ||
|
||
toECSProduct :: InternalProduct -> ECSProduct () | ||
toECSProduct internalProduct = | ||
{ attributes: parseAttributes internalProduct.attributes | ||
} | ||
where | ||
parseAttributes :: Json -> Either String (ECSAttributes ()) | ||
parseAttributes = decodeJson <#> lmap handleError | ||
|
||
parseECSPriceList :: Json -> Either String ECSPriceList | ||
parseECSPriceList = decodeJson <#> bimap handleError toECSPriceList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters