{-# 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.Chime.ListSipRules
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the SIP rules under the administrator\'s AWS account.
module Amazonka.Chime.ListSipRules
  ( -- * Creating a Request
    ListSipRules (..),
    newListSipRules,

    -- * Request Lenses
    listSipRules_nextToken,
    listSipRules_maxResults,
    listSipRules_sipMediaApplicationId,

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

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

import Amazonka.Chime.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | The token to use to retrieve the next page of results.
    ListSipRules -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return in a single call. Defaults to
    -- 100.
    ListSipRules -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The SIP media application ID.
    ListSipRules -> Maybe Text
sipMediaApplicationId :: Prelude.Maybe Prelude.Text
  }
  deriving (ListSipRules -> ListSipRules -> Bool
(ListSipRules -> ListSipRules -> Bool)
-> (ListSipRules -> ListSipRules -> Bool) -> Eq ListSipRules
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]
(Int -> ReadS ListSipRules)
-> ReadS [ListSipRules]
-> ReadPrec ListSipRules
-> ReadPrec [ListSipRules]
-> Read 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
(Int -> ListSipRules -> ShowS)
-> (ListSipRules -> String)
-> ([ListSipRules] -> ShowS)
-> Show ListSipRules
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. ListSipRules -> Rep ListSipRules x)
-> (forall x. Rep ListSipRules x -> ListSipRules)
-> Generic ListSipRules
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:
--
-- 'nextToken', 'listSipRules_nextToken' - The token to use to retrieve the next page of results.
--
-- 'maxResults', 'listSipRules_maxResults' - The maximum number of results to return in a single call. Defaults to
-- 100.
--
-- 'sipMediaApplicationId', 'listSipRules_sipMediaApplicationId' - The SIP media application ID.
newListSipRules ::
  ListSipRules
newListSipRules :: ListSipRules
newListSipRules =
  ListSipRules' :: Maybe Text -> Maybe Natural -> Maybe Text -> ListSipRules
ListSipRules'
    { $sel:nextToken:ListSipRules' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListSipRules' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:sipMediaApplicationId:ListSipRules' :: Maybe Text
sipMediaApplicationId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The token to use to retrieve the next page of results.
listSipRules_nextToken :: Lens.Lens' ListSipRules (Prelude.Maybe Prelude.Text)
listSipRules_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListSipRules -> f ListSipRules
listSipRules_nextToken = (ListSipRules -> Maybe Text)
-> (ListSipRules -> Maybe Text -> ListSipRules)
-> Lens ListSipRules ListSipRules (Maybe Text) (Maybe Text)
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)

-- | The maximum number of results to return in a single call. Defaults to
-- 100.
listSipRules_maxResults :: Lens.Lens' ListSipRules (Prelude.Maybe Prelude.Natural)
listSipRules_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListSipRules -> f ListSipRules
listSipRules_maxResults = (ListSipRules -> Maybe Natural)
-> (ListSipRules -> Maybe Natural -> ListSipRules)
-> Lens ListSipRules ListSipRules (Maybe Natural) (Maybe Natural)
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)

-- | The SIP media application ID.
listSipRules_sipMediaApplicationId :: Lens.Lens' ListSipRules (Prelude.Maybe Prelude.Text)
listSipRules_sipMediaApplicationId :: (Maybe Text -> f (Maybe Text)) -> ListSipRules -> f ListSipRules
listSipRules_sipMediaApplicationId = (ListSipRules -> Maybe Text)
-> (ListSipRules -> Maybe Text -> ListSipRules)
-> Lens ListSipRules ListSipRules (Maybe Text) (Maybe Text)
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.AWSRequest ListSipRules where
  type AWSResponse ListSipRules = ListSipRulesResponse
  request :: ListSipRules -> Request ListSipRules
request = Service -> ListSipRules -> Request ListSipRules
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListSipRules
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListSipRules)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListSipRules))
-> Logger
-> Service
-> Proxy ListSipRules
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListSipRules)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Maybe Text -> Maybe [SipRule] -> Int -> ListSipRulesResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [SipRule] -> Int -> ListSipRulesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Maybe [SipRule] -> Int -> ListSipRulesResponse)
-> Either String (Maybe [SipRule])
-> Either String (Int -> ListSipRulesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [SipRule]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"SipRules" Either String (Maybe (Maybe [SipRule]))
-> Maybe [SipRule] -> Either String (Maybe [SipRule])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [SipRule]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListSipRulesResponse)
-> Either String Int -> Either String ListSipRulesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListSipRules

instance Prelude.NFData ListSipRules

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

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

instance Core.ToQuery ListSipRules where
  toQuery :: ListSipRules -> QueryString
toQuery ListSipRules' {Maybe Natural
Maybe Text
sipMediaApplicationId :: Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:sipMediaApplicationId:ListSipRules' :: ListSipRules -> Maybe Text
$sel:maxResults:ListSipRules' :: ListSipRules -> Maybe Natural
$sel:nextToken:ListSipRules' :: ListSipRules -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"next-token" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"max-results" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults,
        ByteString
"sip-media-application"
          ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
sipMediaApplicationId
      ]

-- | /See:/ 'newListSipRulesResponse' smart constructor.
data ListSipRulesResponse = ListSipRulesResponse'
  { -- | The token to use to retrieve the next page of results.
    ListSipRulesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | List of SIP rules and rule details.
    ListSipRulesResponse -> Maybe [SipRule]
sipRules :: Prelude.Maybe [SipRule],
    -- | The response's http status code.
    ListSipRulesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListSipRulesResponse -> ListSipRulesResponse -> Bool
(ListSipRulesResponse -> ListSipRulesResponse -> Bool)
-> (ListSipRulesResponse -> ListSipRulesResponse -> Bool)
-> Eq ListSipRulesResponse
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]
(Int -> ReadS ListSipRulesResponse)
-> ReadS [ListSipRulesResponse]
-> ReadPrec ListSipRulesResponse
-> ReadPrec [ListSipRulesResponse]
-> Read 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
(Int -> ListSipRulesResponse -> ShowS)
-> (ListSipRulesResponse -> String)
-> ([ListSipRulesResponse] -> ShowS)
-> Show ListSipRulesResponse
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. ListSipRulesResponse -> Rep ListSipRulesResponse x)
-> (forall x. Rep ListSipRulesResponse x -> ListSipRulesResponse)
-> Generic ListSipRulesResponse
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' - The token to use to retrieve the next page of results.
--
-- 'sipRules', 'listSipRulesResponse_sipRules' - List of SIP rules and rule details.
--
-- 'httpStatus', 'listSipRulesResponse_httpStatus' - The response's http status code.
newListSipRulesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListSipRulesResponse
newListSipRulesResponse :: Int -> ListSipRulesResponse
newListSipRulesResponse Int
pHttpStatus_ =
  ListSipRulesResponse' :: Maybe Text -> Maybe [SipRule] -> Int -> ListSipRulesResponse
ListSipRulesResponse'
    { $sel:nextToken:ListSipRulesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sipRules:ListSipRulesResponse' :: Maybe [SipRule]
sipRules = Maybe [SipRule]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListSipRulesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token to use to retrieve the next page of results.
listSipRulesResponse_nextToken :: Lens.Lens' ListSipRulesResponse (Prelude.Maybe Prelude.Text)
listSipRulesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListSipRulesResponse -> f ListSipRulesResponse
listSipRulesResponse_nextToken = (ListSipRulesResponse -> Maybe Text)
-> (ListSipRulesResponse -> Maybe Text -> ListSipRulesResponse)
-> Lens
     ListSipRulesResponse ListSipRulesResponse (Maybe Text) (Maybe Text)
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)

-- | List of SIP rules and rule details.
listSipRulesResponse_sipRules :: Lens.Lens' ListSipRulesResponse (Prelude.Maybe [SipRule])
listSipRulesResponse_sipRules :: (Maybe [SipRule] -> f (Maybe [SipRule]))
-> ListSipRulesResponse -> f ListSipRulesResponse
listSipRulesResponse_sipRules = (ListSipRulesResponse -> Maybe [SipRule])
-> (ListSipRulesResponse
    -> Maybe [SipRule] -> ListSipRulesResponse)
-> Lens
     ListSipRulesResponse
     ListSipRulesResponse
     (Maybe [SipRule])
     (Maybe [SipRule])
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) ((Maybe [SipRule] -> f (Maybe [SipRule]))
 -> ListSipRulesResponse -> f ListSipRulesResponse)
-> ((Maybe [SipRule] -> f (Maybe [SipRule]))
    -> Maybe [SipRule] -> f (Maybe [SipRule]))
-> (Maybe [SipRule] -> f (Maybe [SipRule]))
-> ListSipRulesResponse
-> f ListSipRulesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [SipRule] [SipRule] [SipRule] [SipRule]
-> Iso
     (Maybe [SipRule])
     (Maybe [SipRule])
     (Maybe [SipRule])
     (Maybe [SipRule])
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 AnIso [SipRule] [SipRule] [SipRule] [SipRule]
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 :: (Int -> f Int) -> ListSipRulesResponse -> f ListSipRulesResponse
listSipRulesResponse_httpStatus = (ListSipRulesResponse -> Int)
-> (ListSipRulesResponse -> Int -> ListSipRulesResponse)
-> Lens ListSipRulesResponse ListSipRulesResponse Int Int
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