{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.SSM.DescribeSessions
(
DescribeSessions (..),
newDescribeSessions,
describeSessions_filters,
describeSessions_maxResults,
describeSessions_nextToken,
describeSessions_state,
DescribeSessionsResponse (..),
newDescribeSessionsResponse,
describeSessionsResponse_nextToken,
describeSessionsResponse_sessions,
describeSessionsResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SSM.Types
data DescribeSessions = DescribeSessions'
{
DescribeSessions -> Maybe (NonEmpty SessionFilter)
filters :: Prelude.Maybe (Prelude.NonEmpty SessionFilter),
DescribeSessions -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
DescribeSessions -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
DescribeSessions -> SessionState
state :: SessionState
}
deriving (DescribeSessions -> DescribeSessions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSessions -> DescribeSessions -> Bool
$c/= :: DescribeSessions -> DescribeSessions -> Bool
== :: DescribeSessions -> DescribeSessions -> Bool
$c== :: DescribeSessions -> DescribeSessions -> Bool
Prelude.Eq, ReadPrec [DescribeSessions]
ReadPrec DescribeSessions
Int -> ReadS DescribeSessions
ReadS [DescribeSessions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeSessions]
$creadListPrec :: ReadPrec [DescribeSessions]
readPrec :: ReadPrec DescribeSessions
$creadPrec :: ReadPrec DescribeSessions
readList :: ReadS [DescribeSessions]
$creadList :: ReadS [DescribeSessions]
readsPrec :: Int -> ReadS DescribeSessions
$creadsPrec :: Int -> ReadS DescribeSessions
Prelude.Read, Int -> DescribeSessions -> ShowS
[DescribeSessions] -> ShowS
DescribeSessions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSessions] -> ShowS
$cshowList :: [DescribeSessions] -> ShowS
show :: DescribeSessions -> String
$cshow :: DescribeSessions -> String
showsPrec :: Int -> DescribeSessions -> ShowS
$cshowsPrec :: Int -> DescribeSessions -> ShowS
Prelude.Show, forall x. Rep DescribeSessions x -> DescribeSessions
forall x. DescribeSessions -> Rep DescribeSessions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeSessions x -> DescribeSessions
$cfrom :: forall x. DescribeSessions -> Rep DescribeSessions x
Prelude.Generic)
newDescribeSessions ::
SessionState ->
DescribeSessions
newDescribeSessions :: SessionState -> DescribeSessions
newDescribeSessions SessionState
pState_ =
DescribeSessions'
{ $sel:filters:DescribeSessions' :: Maybe (NonEmpty SessionFilter)
filters = forall a. Maybe a
Prelude.Nothing,
$sel:maxResults:DescribeSessions' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:DescribeSessions' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
$sel:state:DescribeSessions' :: SessionState
state = SessionState
pState_
}
describeSessions_filters :: Lens.Lens' DescribeSessions (Prelude.Maybe (Prelude.NonEmpty SessionFilter))
describeSessions_filters :: Lens' DescribeSessions (Maybe (NonEmpty SessionFilter))
describeSessions_filters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSessions' {Maybe (NonEmpty SessionFilter)
filters :: Maybe (NonEmpty SessionFilter)
$sel:filters:DescribeSessions' :: DescribeSessions -> Maybe (NonEmpty SessionFilter)
filters} -> Maybe (NonEmpty SessionFilter)
filters) (\s :: DescribeSessions
s@DescribeSessions' {} Maybe (NonEmpty SessionFilter)
a -> DescribeSessions
s {$sel:filters:DescribeSessions' :: Maybe (NonEmpty SessionFilter)
filters = Maybe (NonEmpty SessionFilter)
a} :: DescribeSessions) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
describeSessions_maxResults :: Lens.Lens' DescribeSessions (Prelude.Maybe Prelude.Natural)
describeSessions_maxResults :: Lens' DescribeSessions (Maybe Natural)
describeSessions_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSessions' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DescribeSessions' :: DescribeSessions -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DescribeSessions
s@DescribeSessions' {} Maybe Natural
a -> DescribeSessions
s {$sel:maxResults:DescribeSessions' :: Maybe Natural
maxResults = Maybe Natural
a} :: DescribeSessions)
describeSessions_nextToken :: Lens.Lens' DescribeSessions (Prelude.Maybe Prelude.Text)
describeSessions_nextToken :: Lens' DescribeSessions (Maybe Text)
describeSessions_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSessions' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeSessions' :: DescribeSessions -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeSessions
s@DescribeSessions' {} Maybe Text
a -> DescribeSessions
s {$sel:nextToken:DescribeSessions' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeSessions)
describeSessions_state :: Lens.Lens' DescribeSessions SessionState
describeSessions_state :: Lens' DescribeSessions SessionState
describeSessions_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSessions' {SessionState
state :: SessionState
$sel:state:DescribeSessions' :: DescribeSessions -> SessionState
state} -> SessionState
state) (\s :: DescribeSessions
s@DescribeSessions' {} SessionState
a -> DescribeSessions
s {$sel:state:DescribeSessions' :: SessionState
state = SessionState
a} :: DescribeSessions)
instance Core.AWSPager DescribeSessions where
page :: DescribeSessions
-> AWSResponse DescribeSessions -> Maybe DescribeSessions
page DescribeSessions
rq AWSResponse DescribeSessions
rs
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse DescribeSessions
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeSessionsResponse (Maybe Text)
describeSessionsResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse DescribeSessions
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeSessionsResponse (Maybe [Session])
describeSessionsResponse_sessions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
forall a. a -> Maybe a
Prelude.Just
forall a b. (a -> b) -> a -> b
Prelude.$ DescribeSessions
rq
forall a b. a -> (a -> b) -> b
Prelude.& Lens' DescribeSessions (Maybe Text)
describeSessions_nextToken
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeSessions
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeSessionsResponse (Maybe Text)
describeSessionsResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest DescribeSessions where
type
AWSResponse DescribeSessions =
DescribeSessionsResponse
request :: (Service -> Service)
-> DescribeSessions -> Request DescribeSessions
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeSessions
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeSessions)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text -> Maybe [Session] -> Int -> DescribeSessionsResponse
DescribeSessionsResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextToken")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Sessions" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable DescribeSessions where
hashWithSalt :: Int -> DescribeSessions -> Int
hashWithSalt Int
_salt DescribeSessions' {Maybe Natural
Maybe (NonEmpty SessionFilter)
Maybe Text
SessionState
state :: SessionState
nextToken :: Maybe Text
maxResults :: Maybe Natural
filters :: Maybe (NonEmpty SessionFilter)
$sel:state:DescribeSessions' :: DescribeSessions -> SessionState
$sel:nextToken:DescribeSessions' :: DescribeSessions -> Maybe Text
$sel:maxResults:DescribeSessions' :: DescribeSessions -> Maybe Natural
$sel:filters:DescribeSessions' :: DescribeSessions -> Maybe (NonEmpty SessionFilter)
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty SessionFilter)
filters
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SessionState
state
instance Prelude.NFData DescribeSessions where
rnf :: DescribeSessions -> ()
rnf DescribeSessions' {Maybe Natural
Maybe (NonEmpty SessionFilter)
Maybe Text
SessionState
state :: SessionState
nextToken :: Maybe Text
maxResults :: Maybe Natural
filters :: Maybe (NonEmpty SessionFilter)
$sel:state:DescribeSessions' :: DescribeSessions -> SessionState
$sel:nextToken:DescribeSessions' :: DescribeSessions -> Maybe Text
$sel:maxResults:DescribeSessions' :: DescribeSessions -> Maybe Natural
$sel:filters:DescribeSessions' :: DescribeSessions -> Maybe (NonEmpty SessionFilter)
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty SessionFilter)
filters
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SessionState
state
instance Data.ToHeaders DescribeSessions where
toHeaders :: DescribeSessions -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"AmazonSSM.DescribeSessions" :: Prelude.ByteString),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON DescribeSessions where
toJSON :: DescribeSessions -> Value
toJSON DescribeSessions' {Maybe Natural
Maybe (NonEmpty SessionFilter)
Maybe Text
SessionState
state :: SessionState
nextToken :: Maybe Text
maxResults :: Maybe Natural
filters :: Maybe (NonEmpty SessionFilter)
$sel:state:DescribeSessions' :: DescribeSessions -> SessionState
$sel:nextToken:DescribeSessions' :: DescribeSessions -> Maybe Text
$sel:maxResults:DescribeSessions' :: DescribeSessions -> Maybe Natural
$sel:filters:DescribeSessions' :: DescribeSessions -> Maybe (NonEmpty SessionFilter)
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Filters" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty SessionFilter)
filters,
(Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
(Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
forall a. a -> Maybe a
Prelude.Just (Key
"State" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SessionState
state)
]
)
instance Data.ToPath DescribeSessions where
toPath :: DescribeSessions -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery DescribeSessions where
toQuery :: DescribeSessions -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data DescribeSessionsResponse = DescribeSessionsResponse'
{
DescribeSessionsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
DescribeSessionsResponse -> Maybe [Session]
sessions :: Prelude.Maybe [Session],
DescribeSessionsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DescribeSessionsResponse -> DescribeSessionsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSessionsResponse -> DescribeSessionsResponse -> Bool
$c/= :: DescribeSessionsResponse -> DescribeSessionsResponse -> Bool
== :: DescribeSessionsResponse -> DescribeSessionsResponse -> Bool
$c== :: DescribeSessionsResponse -> DescribeSessionsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeSessionsResponse]
ReadPrec DescribeSessionsResponse
Int -> ReadS DescribeSessionsResponse
ReadS [DescribeSessionsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeSessionsResponse]
$creadListPrec :: ReadPrec [DescribeSessionsResponse]
readPrec :: ReadPrec DescribeSessionsResponse
$creadPrec :: ReadPrec DescribeSessionsResponse
readList :: ReadS [DescribeSessionsResponse]
$creadList :: ReadS [DescribeSessionsResponse]
readsPrec :: Int -> ReadS DescribeSessionsResponse
$creadsPrec :: Int -> ReadS DescribeSessionsResponse
Prelude.Read, Int -> DescribeSessionsResponse -> ShowS
[DescribeSessionsResponse] -> ShowS
DescribeSessionsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSessionsResponse] -> ShowS
$cshowList :: [DescribeSessionsResponse] -> ShowS
show :: DescribeSessionsResponse -> String
$cshow :: DescribeSessionsResponse -> String
showsPrec :: Int -> DescribeSessionsResponse -> ShowS
$cshowsPrec :: Int -> DescribeSessionsResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeSessionsResponse x -> DescribeSessionsResponse
forall x.
DescribeSessionsResponse -> Rep DescribeSessionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeSessionsResponse x -> DescribeSessionsResponse
$cfrom :: forall x.
DescribeSessionsResponse -> Rep DescribeSessionsResponse x
Prelude.Generic)
newDescribeSessionsResponse ::
Prelude.Int ->
DescribeSessionsResponse
newDescribeSessionsResponse :: Int -> DescribeSessionsResponse
newDescribeSessionsResponse Int
pHttpStatus_ =
DescribeSessionsResponse'
{ $sel:nextToken:DescribeSessionsResponse' :: Maybe Text
nextToken =
forall a. Maybe a
Prelude.Nothing,
$sel:sessions:DescribeSessionsResponse' :: Maybe [Session]
sessions = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DescribeSessionsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
describeSessionsResponse_nextToken :: Lens.Lens' DescribeSessionsResponse (Prelude.Maybe Prelude.Text)
describeSessionsResponse_nextToken :: Lens' DescribeSessionsResponse (Maybe Text)
describeSessionsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSessionsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeSessionsResponse' :: DescribeSessionsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeSessionsResponse
s@DescribeSessionsResponse' {} Maybe Text
a -> DescribeSessionsResponse
s {$sel:nextToken:DescribeSessionsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeSessionsResponse)
describeSessionsResponse_sessions :: Lens.Lens' DescribeSessionsResponse (Prelude.Maybe [Session])
describeSessionsResponse_sessions :: Lens' DescribeSessionsResponse (Maybe [Session])
describeSessionsResponse_sessions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSessionsResponse' {Maybe [Session]
sessions :: Maybe [Session]
$sel:sessions:DescribeSessionsResponse' :: DescribeSessionsResponse -> Maybe [Session]
sessions} -> Maybe [Session]
sessions) (\s :: DescribeSessionsResponse
s@DescribeSessionsResponse' {} Maybe [Session]
a -> DescribeSessionsResponse
s {$sel:sessions:DescribeSessionsResponse' :: Maybe [Session]
sessions = Maybe [Session]
a} :: DescribeSessionsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
describeSessionsResponse_httpStatus :: Lens.Lens' DescribeSessionsResponse Prelude.Int
describeSessionsResponse_httpStatus :: Lens' DescribeSessionsResponse Int
describeSessionsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSessionsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeSessionsResponse' :: DescribeSessionsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeSessionsResponse
s@DescribeSessionsResponse' {} Int
a -> DescribeSessionsResponse
s {$sel:httpStatus:DescribeSessionsResponse' :: Int
httpStatus = Int
a} :: DescribeSessionsResponse)
instance Prelude.NFData DescribeSessionsResponse where
rnf :: DescribeSessionsResponse -> ()
rnf DescribeSessionsResponse' {Int
Maybe [Session]
Maybe Text
httpStatus :: Int
sessions :: Maybe [Session]
nextToken :: Maybe Text
$sel:httpStatus:DescribeSessionsResponse' :: DescribeSessionsResponse -> Int
$sel:sessions:DescribeSessionsResponse' :: DescribeSessionsResponse -> Maybe [Session]
$sel:nextToken:DescribeSessionsResponse' :: DescribeSessionsResponse -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Session]
sessions
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus