|
| 1 | +module AWS.ECS |
| 2 | + ( ECS |
| 3 | + , makeClient |
| 4 | + , listClusters |
| 5 | + ) where |
| 6 | + |
| 7 | +import Prelude |
| 8 | + |
| 9 | +import AWS.Core.Client (makeClientHelper) |
| 10 | +import AWS.Core.Types (DefaultClientProps) |
| 11 | +import AWS.ECS.Types (ListClustersResponse) |
| 12 | +import Control.Promise (Promise, toAffE) |
| 13 | +import Data.Argonaut (Json) |
| 14 | +import Data.Function.Uncurried (Fn1, runFn1) |
| 15 | +import Data.Newtype (wrap) |
| 16 | +import Effect (Effect) |
| 17 | +import Effect.Aff (Aff) |
| 18 | +import Justifill (justifillVia) |
| 19 | +import Justifill.Fillable (class Fillable) |
| 20 | +import Justifill.Justifiable (class Justifiable) |
| 21 | +import Type.Proxy (Proxy(..)) |
| 22 | + |
| 23 | +foreign import data ECS :: Type |
| 24 | + |
| 25 | +foreign import newECS :: Json -> (Effect ECS) |
| 26 | + |
| 27 | +makeClient :: |
| 28 | + forall r via. |
| 29 | + Justifiable { | r } { | via } => |
| 30 | + Fillable { | via } DefaultClientProps => |
| 31 | + { | r } -> |
| 32 | + Effect ECS |
| 33 | +makeClient r = makeClientHelper newECS props |
| 34 | + where |
| 35 | + viaProxy :: Proxy { | via } |
| 36 | + viaProxy = Proxy |
| 37 | + |
| 38 | + props :: DefaultClientProps |
| 39 | + props = justifillVia viaProxy r |
| 40 | + |
| 41 | +type InternalListClustersResponse |
| 42 | + = { clusterArns :: Array String } |
| 43 | + |
| 44 | +foreign import listClustersImpl :: Fn1 ECS (Effect (Promise InternalListClustersResponse)) |
| 45 | + |
| 46 | +listClusters :: ECS -> Aff ListClustersResponse |
| 47 | +listClusters ecs = |
| 48 | + runFn1 listClustersImpl ecs |
| 49 | + # toAffE |
| 50 | + <#> toResponse |
| 51 | + where |
| 52 | + toResponse :: InternalListClustersResponse -> ListClustersResponse |
| 53 | + toResponse internalRspse = { clusterArns: internalRspse."clusterArns" <#> wrap } |
0 commit comments