{-# 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.GetSipRule
-- 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)
--
-- Retrieves the details of a SIP rule, such as the rule ID, name,
-- triggers, and target endpoints.
module Amazonka.Chime.GetSipRule
  ( -- * Creating a Request
    GetSipRule (..),
    newGetSipRule,

    -- * Request Lenses
    getSipRule_sipRuleId,

    -- * Destructuring the Response
    GetSipRuleResponse (..),
    newGetSipRuleResponse,

    -- * Response Lenses
    getSipRuleResponse_sipRule,
    getSipRuleResponse_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:/ 'newGetSipRule' smart constructor.
data GetSipRule = GetSipRule'
  { -- | The SIP rule ID.
    GetSipRule -> Text
sipRuleId :: Prelude.Text
  }
  deriving (GetSipRule -> GetSipRule -> Bool
(GetSipRule -> GetSipRule -> Bool)
-> (GetSipRule -> GetSipRule -> Bool) -> Eq GetSipRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSipRule -> GetSipRule -> Bool
$c/= :: GetSipRule -> GetSipRule -> Bool
== :: GetSipRule -> GetSipRule -> Bool
$c== :: GetSipRule -> GetSipRule -> Bool
Prelude.Eq, ReadPrec [GetSipRule]
ReadPrec GetSipRule
Int -> ReadS GetSipRule
ReadS [GetSipRule]
(Int -> ReadS GetSipRule)
-> ReadS [GetSipRule]
-> ReadPrec GetSipRule
-> ReadPrec [GetSipRule]
-> Read GetSipRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSipRule]
$creadListPrec :: ReadPrec [GetSipRule]
readPrec :: ReadPrec GetSipRule
$creadPrec :: ReadPrec GetSipRule
readList :: ReadS [GetSipRule]
$creadList :: ReadS [GetSipRule]
readsPrec :: Int -> ReadS GetSipRule
$creadsPrec :: Int -> ReadS GetSipRule
Prelude.Read, Int -> GetSipRule -> ShowS
[GetSipRule] -> ShowS
GetSipRule -> String
(Int -> GetSipRule -> ShowS)
-> (GetSipRule -> String)
-> ([GetSipRule] -> ShowS)
-> Show GetSipRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSipRule] -> ShowS
$cshowList :: [GetSipRule] -> ShowS
show :: GetSipRule -> String
$cshow :: GetSipRule -> String
showsPrec :: Int -> GetSipRule -> ShowS
$cshowsPrec :: Int -> GetSipRule -> ShowS
Prelude.Show, (forall x. GetSipRule -> Rep GetSipRule x)
-> (forall x. Rep GetSipRule x -> GetSipRule) -> Generic GetSipRule
forall x. Rep GetSipRule x -> GetSipRule
forall x. GetSipRule -> Rep GetSipRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSipRule x -> GetSipRule
$cfrom :: forall x. GetSipRule -> Rep GetSipRule x
Prelude.Generic)

-- |
-- Create a value of 'GetSipRule' 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:
--
-- 'sipRuleId', 'getSipRule_sipRuleId' - The SIP rule ID.
newGetSipRule ::
  -- | 'sipRuleId'
  Prelude.Text ->
  GetSipRule
newGetSipRule :: Text -> GetSipRule
newGetSipRule Text
pSipRuleId_ =
  GetSipRule' :: Text -> GetSipRule
GetSipRule' {$sel:sipRuleId:GetSipRule' :: Text
sipRuleId = Text
pSipRuleId_}

-- | The SIP rule ID.
getSipRule_sipRuleId :: Lens.Lens' GetSipRule Prelude.Text
getSipRule_sipRuleId :: (Text -> f Text) -> GetSipRule -> f GetSipRule
getSipRule_sipRuleId = (GetSipRule -> Text)
-> (GetSipRule -> Text -> GetSipRule)
-> Lens GetSipRule GetSipRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSipRule' {Text
sipRuleId :: Text
$sel:sipRuleId:GetSipRule' :: GetSipRule -> Text
sipRuleId} -> Text
sipRuleId) (\s :: GetSipRule
s@GetSipRule' {} Text
a -> GetSipRule
s {$sel:sipRuleId:GetSipRule' :: Text
sipRuleId = Text
a} :: GetSipRule)

instance Core.AWSRequest GetSipRule where
  type AWSResponse GetSipRule = GetSipRuleResponse
  request :: GetSipRule -> Request GetSipRule
request = Service -> GetSipRule -> Request GetSipRule
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetSipRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSipRule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetSipRule))
-> Logger
-> Service
-> Proxy GetSipRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetSipRule)))
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 SipRule -> Int -> GetSipRuleResponse
GetSipRuleResponse'
            (Maybe SipRule -> Int -> GetSipRuleResponse)
-> Either String (Maybe SipRule)
-> Either String (Int -> GetSipRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe SipRule)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"SipRule")
            Either String (Int -> GetSipRuleResponse)
-> Either String Int -> Either String GetSipRuleResponse
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 GetSipRule

instance Prelude.NFData GetSipRule

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

instance Core.ToPath GetSipRule where
  toPath :: GetSipRule -> ByteString
toPath GetSipRule' {Text
sipRuleId :: Text
$sel:sipRuleId:GetSipRule' :: GetSipRule -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/sip-rules/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
sipRuleId]

instance Core.ToQuery GetSipRule where
  toQuery :: GetSipRule -> QueryString
toQuery = QueryString -> GetSipRule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'GetSipRuleResponse' 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:
--
-- 'sipRule', 'getSipRuleResponse_sipRule' - The SIP rule details.
--
-- 'httpStatus', 'getSipRuleResponse_httpStatus' - The response's http status code.
newGetSipRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSipRuleResponse
newGetSipRuleResponse :: Int -> GetSipRuleResponse
newGetSipRuleResponse Int
pHttpStatus_ =
  GetSipRuleResponse' :: Maybe SipRule -> Int -> GetSipRuleResponse
GetSipRuleResponse'
    { $sel:sipRule:GetSipRuleResponse' :: Maybe SipRule
sipRule = Maybe SipRule
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSipRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The SIP rule details.
getSipRuleResponse_sipRule :: Lens.Lens' GetSipRuleResponse (Prelude.Maybe SipRule)
getSipRuleResponse_sipRule :: (Maybe SipRule -> f (Maybe SipRule))
-> GetSipRuleResponse -> f GetSipRuleResponse
getSipRuleResponse_sipRule = (GetSipRuleResponse -> Maybe SipRule)
-> (GetSipRuleResponse -> Maybe SipRule -> GetSipRuleResponse)
-> Lens
     GetSipRuleResponse
     GetSipRuleResponse
     (Maybe SipRule)
     (Maybe SipRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSipRuleResponse' {Maybe SipRule
sipRule :: Maybe SipRule
$sel:sipRule:GetSipRuleResponse' :: GetSipRuleResponse -> Maybe SipRule
sipRule} -> Maybe SipRule
sipRule) (\s :: GetSipRuleResponse
s@GetSipRuleResponse' {} Maybe SipRule
a -> GetSipRuleResponse
s {$sel:sipRule:GetSipRuleResponse' :: Maybe SipRule
sipRule = Maybe SipRule
a} :: GetSipRuleResponse)

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

instance Prelude.NFData GetSipRuleResponse