{-# 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.ChimeSdkVoice.ListSipRules
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- -- | Undocumented operation.
--
-- This operation returns paginated results.
module Amazonka.ChimeSdkVoice.ListSipRules
  ( -- * Creating a Request
    ListSipRules (..),
    newListSipRules,

    -- * Request Lenses
    listSipRules_maxResults,
    listSipRules_nextToken,
    listSipRules_sipMediaApplicationId,

    -- * Destructuring the Response
    ListSipRulesResponse (..),
    newListSipRulesResponse,

    -- * Response Lenses
    listSipRulesResponse_nextToken,
    listSipRulesResponse_sipRules,
    listSipRulesResponse_httpStatus,
  )
where

import Amazonka.ChimeSdkVoice.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:/ 'newListSipRules' smart constructor.
data ListSipRules = ListSipRules'
  { ListSipRules -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    ListSipRules -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    ListSipRules -> Maybe Text
sipMediaApplicationId :: Prelude.Maybe Prelude.Text
  }
  deriving (ListSipRules -> ListSipRules -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListSipRules -> ListSipRules -> Bool
$c/= :: ListSipRules -> ListSipRules -> Bool
== :: ListSipRules -> ListSipRules -> Bool
$c== :: ListSipRules -> ListSipRules -> Bool
Prelude.Eq, ReadPrec [ListSipRules]
ReadPrec ListSipRules
Int -> ReadS ListSipRules
ReadS [ListSipRules]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListSipRules]
$creadListPrec :: ReadPrec [ListSipRules]
readPrec :: ReadPrec ListSipRules
$creadPrec :: ReadPrec ListSipRules
readList :: ReadS [ListSipRules]
$creadList :: ReadS [ListSipRules]
readsPrec :: Int -> ReadS ListSipRules
$creadsPrec :: Int -> ReadS ListSipRules
Prelude.Read, Int -> ListSipRules -> ShowS
[ListSipRules] -> ShowS
ListSipRules -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListSipRules] -> ShowS
$cshowList :: [ListSipRules] -> ShowS
show :: ListSipRules -> String
$cshow :: ListSipRules -> String
showsPrec :: Int -> ListSipRules -> ShowS
$cshowsPrec :: Int -> ListSipRules -> ShowS
Prelude.Show, forall x. Rep ListSipRules x -> ListSipRules
forall x. ListSipRules -> Rep ListSipRules x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListSipRules x -> ListSipRules
$cfrom :: forall x. ListSipRules -> Rep ListSipRules x
Prelude.Generic)

-- |
-- Create a value of 'ListSipRules' 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', 'listSipRules_maxResults' - Undocumented member.
--
-- 'nextToken', 'listSipRules_nextToken' - Undocumented member.
--
-- 'sipMediaApplicationId', 'listSipRules_sipMediaApplicationId' - Undocumented member.
newListSipRules ::
  ListSipRules
newListSipRules :: ListSipRules
newListSipRules =
  ListSipRules'
    { $sel:maxResults:ListSipRules' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListSipRules' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:sipMediaApplicationId:ListSipRules' :: Maybe Text
sipMediaApplicationId = forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
listSipRules_maxResults :: Lens.Lens' ListSipRules (Prelude.Maybe Prelude.Natural)
listSipRules_maxResults :: Lens' ListSipRules (Maybe Natural)
listSipRules_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSipRules' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListSipRules' :: ListSipRules -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListSipRules
s@ListSipRules' {} Maybe Natural
a -> ListSipRules
s {$sel:maxResults:ListSipRules' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListSipRules)

-- | Undocumented member.
listSipRules_nextToken :: Lens.Lens' ListSipRules (Prelude.Maybe Prelude.Text)
listSipRules_nextToken :: Lens' ListSipRules (Maybe Text)
listSipRules_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSipRules' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListSipRules' :: ListSipRules -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListSipRules
s@ListSipRules' {} Maybe Text
a -> ListSipRules
s {$sel:nextToken:ListSipRules' :: Maybe Text
nextToken = Maybe Text
a} :: ListSipRules)

-- | Undocumented member.
listSipRules_sipMediaApplicationId :: Lens.Lens' ListSipRules (Prelude.Maybe Prelude.Text)
listSipRules_sipMediaApplicationId :: Lens' ListSipRules (Maybe Text)
listSipRules_sipMediaApplicationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSipRules' {Maybe Text
sipMediaApplicationId :: Maybe Text
$sel:sipMediaApplicationId:ListSipRules' :: ListSipRules -> Maybe Text
sipMediaApplicationId} -> Maybe Text
sipMediaApplicationId) (\s :: ListSipRules
s@ListSipRules' {} Maybe Text
a -> ListSipRules
s {$sel:sipMediaApplicationId:ListSipRules' :: Maybe Text
sipMediaApplicationId = Maybe Text
a} :: ListSipRules)

instance Core.AWSPager ListSipRules where
  page :: ListSipRules -> AWSResponse ListSipRules -> Maybe ListSipRules
page ListSipRules
rq AWSResponse ListSipRules
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListSipRules
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListSipRulesResponse (Maybe Text)
listSipRulesResponse_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 ListSipRules
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListSipRulesResponse (Maybe [SipRule])
listSipRulesResponse_sipRules
            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.$ ListSipRules
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListSipRules (Maybe Text)
listSipRules_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListSipRules
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListSipRulesResponse (Maybe Text)
listSipRulesResponse_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 ListSipRules where
  type AWSResponse ListSipRules = ListSipRulesResponse
  request :: (Service -> Service) -> ListSipRules -> Request ListSipRules
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 ListSipRules
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListSipRules)))
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 [SipRule] -> Int -> ListSipRulesResponse
ListSipRulesResponse'
            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
"SipRules" 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 ListSipRules where
  hashWithSalt :: Int -> ListSipRules -> Int
hashWithSalt Int
_salt ListSipRules' {Maybe Natural
Maybe Text
sipMediaApplicationId :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:sipMediaApplicationId:ListSipRules' :: ListSipRules -> Maybe Text
$sel:nextToken:ListSipRules' :: ListSipRules -> Maybe Text
$sel:maxResults:ListSipRules' :: ListSipRules -> 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 Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sipMediaApplicationId

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

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

instance Data.ToPath ListSipRules where
  toPath :: ListSipRules -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/sip-rules"

instance Data.ToQuery ListSipRules where
  toQuery :: ListSipRules -> QueryString
toQuery ListSipRules' {Maybe Natural
Maybe Text
sipMediaApplicationId :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:sipMediaApplicationId:ListSipRules' :: ListSipRules -> Maybe Text
$sel:nextToken:ListSipRules' :: ListSipRules -> Maybe Text
$sel:maxResults:ListSipRules' :: ListSipRules -> 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 Text
nextToken,
        ByteString
"sip-media-application"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
sipMediaApplicationId
      ]

-- | /See:/ 'newListSipRulesResponse' smart constructor.
data ListSipRulesResponse = ListSipRulesResponse'
  { ListSipRulesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    ListSipRulesResponse -> Maybe [SipRule]
sipRules :: Prelude.Maybe [SipRule],
    -- | The response's http status code.
    ListSipRulesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListSipRulesResponse -> ListSipRulesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListSipRulesResponse -> ListSipRulesResponse -> Bool
$c/= :: ListSipRulesResponse -> ListSipRulesResponse -> Bool
== :: ListSipRulesResponse -> ListSipRulesResponse -> Bool
$c== :: ListSipRulesResponse -> ListSipRulesResponse -> Bool
Prelude.Eq, ReadPrec [ListSipRulesResponse]
ReadPrec ListSipRulesResponse
Int -> ReadS ListSipRulesResponse
ReadS [ListSipRulesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListSipRulesResponse]
$creadListPrec :: ReadPrec [ListSipRulesResponse]
readPrec :: ReadPrec ListSipRulesResponse
$creadPrec :: ReadPrec ListSipRulesResponse
readList :: ReadS [ListSipRulesResponse]
$creadList :: ReadS [ListSipRulesResponse]
readsPrec :: Int -> ReadS ListSipRulesResponse
$creadsPrec :: Int -> ReadS ListSipRulesResponse
Prelude.Read, Int -> ListSipRulesResponse -> ShowS
[ListSipRulesResponse] -> ShowS
ListSipRulesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListSipRulesResponse] -> ShowS
$cshowList :: [ListSipRulesResponse] -> ShowS
show :: ListSipRulesResponse -> String
$cshow :: ListSipRulesResponse -> String
showsPrec :: Int -> ListSipRulesResponse -> ShowS
$cshowsPrec :: Int -> ListSipRulesResponse -> ShowS
Prelude.Show, forall x. Rep ListSipRulesResponse x -> ListSipRulesResponse
forall x. ListSipRulesResponse -> Rep ListSipRulesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListSipRulesResponse x -> ListSipRulesResponse
$cfrom :: forall x. ListSipRulesResponse -> Rep ListSipRulesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListSipRulesResponse' 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:
--
-- 'nextToken', 'listSipRulesResponse_nextToken' - Undocumented member.
--
-- 'sipRules', 'listSipRulesResponse_sipRules' - Undocumented member.
--
-- 'httpStatus', 'listSipRulesResponse_httpStatus' - The response's http status code.
newListSipRulesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListSipRulesResponse
newListSipRulesResponse :: Int -> ListSipRulesResponse
newListSipRulesResponse Int
pHttpStatus_ =
  ListSipRulesResponse'
    { $sel:nextToken:ListSipRulesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:sipRules:ListSipRulesResponse' :: Maybe [SipRule]
sipRules = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListSipRulesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
listSipRulesResponse_nextToken :: Lens.Lens' ListSipRulesResponse (Prelude.Maybe Prelude.Text)
listSipRulesResponse_nextToken :: Lens' ListSipRulesResponse (Maybe Text)
listSipRulesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSipRulesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListSipRulesResponse' :: ListSipRulesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListSipRulesResponse
s@ListSipRulesResponse' {} Maybe Text
a -> ListSipRulesResponse
s {$sel:nextToken:ListSipRulesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListSipRulesResponse)

-- | Undocumented member.
listSipRulesResponse_sipRules :: Lens.Lens' ListSipRulesResponse (Prelude.Maybe [SipRule])
listSipRulesResponse_sipRules :: Lens' ListSipRulesResponse (Maybe [SipRule])
listSipRulesResponse_sipRules = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSipRulesResponse' {Maybe [SipRule]
sipRules :: Maybe [SipRule]
$sel:sipRules:ListSipRulesResponse' :: ListSipRulesResponse -> Maybe [SipRule]
sipRules} -> Maybe [SipRule]
sipRules) (\s :: ListSipRulesResponse
s@ListSipRulesResponse' {} Maybe [SipRule]
a -> ListSipRulesResponse
s {$sel:sipRules:ListSipRulesResponse' :: Maybe [SipRule]
sipRules = Maybe [SipRule]
a} :: ListSipRulesResponse) 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 response's http status code.
listSipRulesResponse_httpStatus :: Lens.Lens' ListSipRulesResponse Prelude.Int
listSipRulesResponse_httpStatus :: Lens' ListSipRulesResponse Int
listSipRulesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSipRulesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListSipRulesResponse' :: ListSipRulesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListSipRulesResponse
s@ListSipRulesResponse' {} Int
a -> ListSipRulesResponse
s {$sel:httpStatus:ListSipRulesResponse' :: Int
httpStatus = Int
a} :: ListSipRulesResponse)

instance Prelude.NFData ListSipRulesResponse where
  rnf :: ListSipRulesResponse -> ()
rnf ListSipRulesResponse' {Int
Maybe [SipRule]
Maybe Text
httpStatus :: Int
sipRules :: Maybe [SipRule]
nextToken :: Maybe Text
$sel:httpStatus:ListSipRulesResponse' :: ListSipRulesResponse -> Int
$sel:sipRules:ListSipRulesResponse' :: ListSipRulesResponse -> Maybe [SipRule]
$sel:nextToken:ListSipRulesResponse' :: ListSipRulesResponse -> 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 [SipRule]
sipRules
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus