Skip to content

Commit 262054d

Browse files
committed
Add ECS support: implement listClusters
1 parent 6b0bc8b commit 262054d

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

src/AWS/ECS/ECS.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use strict"
2+
3+
const ECS = require('aws-sdk/clients/ecs')
4+
5+
exports.newECS = (params) =>
6+
() => new ECS(params)
7+
8+
exports.listClustersImpl = (ecs) =>
9+
() => ecs.listClusters().promise()

src/AWS/ECS/ECS.purs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 }

src/AWS/ECS/Types.purs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module AWS.ECS.Types where
2+
3+
import Prelude (class Show)
4+
import Data.Newtype (class Newtype)
5+
6+
newtype ClusterArn
7+
= ClusterArn String
8+
9+
derive instance ntClusterArn :: Newtype ClusterArn _
10+
11+
derive newtype instance showClusterArn :: Show ClusterArn
12+
13+
type Clusters
14+
= Array ClusterArn
15+
16+
type ListClustersResponse
17+
= { clusterArns :: Clusters }

0 commit comments

Comments
 (0)