{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.ChimeSDKMessaging.ListChannelFlows
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a paginated lists of all the channel flows created under a
-- single Chime. This is a developer API.
module Amazonka.ChimeSDKMessaging.ListChannelFlows
  ( -- * Creating a Request
    ListChannelFlows (..),
    newListChannelFlows,

    -- * Request Lenses
    listChannelFlows_maxResults,
    listChannelFlows_nextToken,
    listChannelFlows_appInstanceArn,

    -- * Destructuring the Response
    ListChannelFlowsResponse (..),
    newListChannelFlowsResponse,

    -- * Response Lenses
    listChannelFlowsResponse_channelFlows,
    listChannelFlowsResponse_nextToken,
    listChannelFlowsResponse_httpStatus,
  )
where

import Amazonka.ChimeSDKMessaging.Types
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

-- | /See:/ 'newListChannelFlows' smart constructor.
data ListChannelFlows = ListChannelFlows'
  { -- | The maximum number of channel flows that you want to return.
    ListChannelFlows -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token passed by previous API calls until all requested channel flows
    -- are returned.
    ListChannelFlows -> Maybe (Sensitive Text)
nextToken :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The ARN of the app instance.
    ListChannelFlows -> Text
appInstanceArn :: Prelude.Text
  }
  deriving (ListChannelFlows -> ListChannelFlows -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListChannelFlows -> ListChannelFlows -> Bool
$c/= :: ListChannelFlows -> ListChannelFlows -> Bool
== :: ListChannelFlows -> ListChannelFlows -> Bool
$c== :: ListChannelFlows -> ListChannelFlows -> Bool
Prelude.Eq, Int -> ListChannelFlows -> ShowS
[ListChannelFlows] -> ShowS
ListChannelFlows -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListChannelFlows] -> ShowS
$cshowList :: [ListChannelFlows] -> ShowS
show :: ListChannelFlows -> String
$cshow :: ListChannelFlows -> String
showsPrec :: Int -> ListChannelFlows -> ShowS
$cshowsPrec :: Int -> ListChannelFlows -> ShowS
Prelude.Show, forall x. Rep ListChannelFlows x -> ListChannelFlows
forall x. ListChannelFlows -> Rep ListChannelFlows x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListChannelFlows x -> ListChannelFlows
$cfrom :: forall x. ListChannelFlows -> Rep ListChannelFlows x
Prelude.Generic)

-- |
-- Create a value of 'ListChannelFlows' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'maxResults', 'listChannelFlows_maxResults' - The maximum number of channel flows that you want to return.
--
-- 'nextToken', 'listChannelFlows_nextToken' - The token passed by previous API calls until all requested channel flows
-- are returned.
--
-- 'appInstanceArn', 'listChannelFlows_appInstanceArn' - The ARN of the app instance.
newListChannelFlows ::
  -- | 'appInstanceArn'
  Prelude.Text ->
  ListChannelFlows
newListChannelFlows :: Text -> ListChannelFlows
newListChannelFlows Text
pAppInstanceArn_ =
  ListChannelFlows'
    { $sel:maxResults:ListChannelFlows' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListChannelFlows' :: Maybe (Sensitive Text)
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:appInstanceArn:ListChannelFlows' :: Text
appInstanceArn = Text
pAppInstanceArn_
    }

-- | The maximum number of channel flows that you want to return.
listChannelFlows_maxResults :: Lens.Lens' ListChannelFlows (Prelude.Maybe Prelude.Natural)
listChannelFlows_maxResults :: Lens' ListChannelFlows (Maybe Natural)
listChannelFlows_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelFlows' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListChannelFlows' :: ListChannelFlows -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListChannelFlows
s@ListChannelFlows' {} Maybe Natural
a -> ListChannelFlows
s {$sel:maxResults:ListChannelFlows' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListChannelFlows)

-- | The token passed by previous API calls until all requested channel flows
-- are returned.
listChannelFlows_nextToken :: Lens.Lens' ListChannelFlows (Prelude.Maybe Prelude.Text)
listChannelFlows_nextToken :: Lens' ListChannelFlows (Maybe Text)
listChannelFlows_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelFlows' {Maybe (Sensitive Text)
nextToken :: Maybe (Sensitive Text)
$sel:nextToken:ListChannelFlows' :: ListChannelFlows -> Maybe (Sensitive Text)
nextToken} -> Maybe (Sensitive Text)
nextToken) (\s :: ListChannelFlows
s@ListChannelFlows' {} Maybe (Sensitive Text)
a -> ListChannelFlows
s {$sel:nextToken:ListChannelFlows' :: Maybe (Sensitive Text)
nextToken = Maybe (Sensitive Text)
a} :: ListChannelFlows) 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 a. Iso' (Sensitive a) a
Data._Sensitive

-- | The ARN of the app instance.
listChannelFlows_appInstanceArn :: Lens.Lens' ListChannelFlows Prelude.Text
listChannelFlows_appInstanceArn :: Lens' ListChannelFlows Text
listChannelFlows_appInstanceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelFlows' {Text
appInstanceArn :: Text
$sel:appInstanceArn:ListChannelFlows' :: ListChannelFlows -> Text
appInstanceArn} -> Text
appInstanceArn) (\s :: ListChannelFlows
s@ListChannelFlows' {} Text
a -> ListChannelFlows
s {$sel:appInstanceArn:ListChannelFlows' :: Text
appInstanceArn = Text
a} :: ListChannelFlows)

instance Core.AWSRequest ListChannelFlows where
  type
    AWSResponse ListChannelFlows =
      ListChannelFlowsResponse
  request :: (Service -> Service)
-> ListChannelFlows -> Request ListChannelFlows
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListChannelFlows
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListChannelFlows)))
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 [ChannelFlowSummary]
-> Maybe (Sensitive Text) -> Int -> ListChannelFlowsResponse
ListChannelFlowsResponse'
            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
"ChannelFlows" 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.<*> (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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListChannelFlows where
  hashWithSalt :: Int -> ListChannelFlows -> Int
hashWithSalt Int
_salt ListChannelFlows' {Maybe Natural
Maybe (Sensitive Text)
Text
appInstanceArn :: Text
nextToken :: Maybe (Sensitive Text)
maxResults :: Maybe Natural
$sel:appInstanceArn:ListChannelFlows' :: ListChannelFlows -> Text
$sel:nextToken:ListChannelFlows' :: ListChannelFlows -> Maybe (Sensitive Text)
$sel:maxResults:ListChannelFlows' :: ListChannelFlows -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
appInstanceArn

instance Prelude.NFData ListChannelFlows where
  rnf :: ListChannelFlows -> ()
rnf ListChannelFlows' {Maybe Natural
Maybe (Sensitive Text)
Text
appInstanceArn :: Text
nextToken :: Maybe (Sensitive Text)
maxResults :: Maybe Natural
$sel:appInstanceArn:ListChannelFlows' :: ListChannelFlows -> Text
$sel:nextToken:ListChannelFlows' :: ListChannelFlows -> Maybe (Sensitive Text)
$sel:maxResults:ListChannelFlows' :: ListChannelFlows -> Maybe Natural
..} =
    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 (Sensitive Text)
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
appInstanceArn

instance Data.ToHeaders ListChannelFlows where
  toHeaders :: ListChannelFlows -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath ListChannelFlows where
  toPath :: ListChannelFlows -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/channel-flows"

instance Data.ToQuery ListChannelFlows where
  toQuery :: ListChannelFlows -> QueryString
toQuery ListChannelFlows' {Maybe Natural
Maybe (Sensitive Text)
Text
appInstanceArn :: Text
nextToken :: Maybe (Sensitive Text)
maxResults :: Maybe Natural
$sel:appInstanceArn:ListChannelFlows' :: ListChannelFlows -> Text
$sel:nextToken:ListChannelFlows' :: ListChannelFlows -> Maybe (Sensitive Text)
$sel:maxResults:ListChannelFlows' :: ListChannelFlows -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"max-results" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"next-token" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe (Sensitive Text)
nextToken,
        ByteString
"app-instance-arn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
appInstanceArn
      ]

-- | /See:/ 'newListChannelFlowsResponse' smart constructor.
data ListChannelFlowsResponse = ListChannelFlowsResponse'
  { -- | The information about each channel flow.
    ListChannelFlowsResponse -> Maybe [ChannelFlowSummary]
channelFlows :: Prelude.Maybe [ChannelFlowSummary],
    -- | The token passed by previous API calls until all requested channels are
    -- returned.
    ListChannelFlowsResponse -> Maybe (Sensitive Text)
nextToken :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The response's http status code.
    ListChannelFlowsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListChannelFlowsResponse -> ListChannelFlowsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListChannelFlowsResponse -> ListChannelFlowsResponse -> Bool
$c/= :: ListChannelFlowsResponse -> ListChannelFlowsResponse -> Bool
== :: ListChannelFlowsResponse -> ListChannelFlowsResponse -> Bool
$c== :: ListChannelFlowsResponse -> ListChannelFlowsResponse -> Bool
Prelude.Eq, Int -> ListChannelFlowsResponse -> ShowS
[ListChannelFlowsResponse] -> ShowS
ListChannelFlowsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListChannelFlowsResponse] -> ShowS
$cshowList :: [ListChannelFlowsResponse] -> ShowS
show :: ListChannelFlowsResponse -> String
$cshow :: ListChannelFlowsResponse -> String
showsPrec :: Int -> ListChannelFlowsResponse -> ShowS
$cshowsPrec :: Int -> ListChannelFlowsResponse -> ShowS
Prelude.Show, forall x.
Rep ListChannelFlowsResponse x -> ListChannelFlowsResponse
forall x.
ListChannelFlowsResponse -> Rep ListChannelFlowsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListChannelFlowsResponse x -> ListChannelFlowsResponse
$cfrom :: forall x.
ListChannelFlowsResponse -> Rep ListChannelFlowsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListChannelFlowsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'channelFlows', 'listChannelFlowsResponse_channelFlows' - The information about each channel flow.
--
-- 'nextToken', 'listChannelFlowsResponse_nextToken' - The token passed by previous API calls until all requested channels are
-- returned.
--
-- 'httpStatus', 'listChannelFlowsResponse_httpStatus' - The response's http status code.
newListChannelFlowsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListChannelFlowsResponse
newListChannelFlowsResponse :: Int -> ListChannelFlowsResponse
newListChannelFlowsResponse Int
pHttpStatus_ =
  ListChannelFlowsResponse'
    { $sel:channelFlows:ListChannelFlowsResponse' :: Maybe [ChannelFlowSummary]
channelFlows =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListChannelFlowsResponse' :: Maybe (Sensitive Text)
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListChannelFlowsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The information about each channel flow.
listChannelFlowsResponse_channelFlows :: Lens.Lens' ListChannelFlowsResponse (Prelude.Maybe [ChannelFlowSummary])
listChannelFlowsResponse_channelFlows :: Lens' ListChannelFlowsResponse (Maybe [ChannelFlowSummary])
listChannelFlowsResponse_channelFlows = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelFlowsResponse' {Maybe [ChannelFlowSummary]
channelFlows :: Maybe [ChannelFlowSummary]
$sel:channelFlows:ListChannelFlowsResponse' :: ListChannelFlowsResponse -> Maybe [ChannelFlowSummary]
channelFlows} -> Maybe [ChannelFlowSummary]
channelFlows) (\s :: ListChannelFlowsResponse
s@ListChannelFlowsResponse' {} Maybe [ChannelFlowSummary]
a -> ListChannelFlowsResponse
s {$sel:channelFlows:ListChannelFlowsResponse' :: Maybe [ChannelFlowSummary]
channelFlows = Maybe [ChannelFlowSummary]
a} :: ListChannelFlowsResponse) 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

-- | The token passed by previous API calls until all requested channels are
-- returned.
listChannelFlowsResponse_nextToken :: Lens.Lens' ListChannelFlowsResponse (Prelude.Maybe Prelude.Text)
listChannelFlowsResponse_nextToken :: Lens' ListChannelFlowsResponse (Maybe Text)
listChannelFlowsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelFlowsResponse' {Maybe (Sensitive Text)
nextToken :: Maybe (Sensitive Text)
$sel:nextToken:ListChannelFlowsResponse' :: ListChannelFlowsResponse -> Maybe (Sensitive Text)
nextToken} -> Maybe (Sensitive Text)
nextToken) (\s :: ListChannelFlowsResponse
s@ListChannelFlowsResponse' {} Maybe (Sensitive Text)
a -> ListChannelFlowsResponse
s {$sel:nextToken:ListChannelFlowsResponse' :: Maybe (Sensitive Text)
nextToken = Maybe (Sensitive Text)
a} :: ListChannelFlowsResponse) 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 a. Iso' (Sensitive a) a
Data._Sensitive

-- | The response's http status code.
listChannelFlowsResponse_httpStatus :: Lens.Lens' ListChannelFlowsResponse Prelude.Int
listChannelFlowsResponse_httpStatus :: Lens' ListChannelFlowsResponse Int
listChannelFlowsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelFlowsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListChannelFlowsResponse' :: ListChannelFlowsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListChannelFlowsResponse
s@ListChannelFlowsResponse' {} Int
a -> ListChannelFlowsResponse
s {$sel:httpStatus:ListChannelFlowsResponse' :: Int
httpStatus = Int
a} :: ListChannelFlowsResponse)

instance Prelude.NFData ListChannelFlowsResponse where
  rnf :: ListChannelFlowsResponse -> ()
rnf ListChannelFlowsResponse' {Int
Maybe [ChannelFlowSummary]
Maybe (Sensitive Text)
httpStatus :: Int
nextToken :: Maybe (Sensitive Text)
channelFlows :: Maybe [ChannelFlowSummary]
$sel:httpStatus:ListChannelFlowsResponse' :: ListChannelFlowsResponse -> Int
$sel:nextToken:ListChannelFlowsResponse' :: ListChannelFlowsResponse -> Maybe (Sensitive Text)
$sel:channelFlows:ListChannelFlowsResponse' :: ListChannelFlowsResponse -> Maybe [ChannelFlowSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ChannelFlowSummary]
channelFlows
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus