{-# 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.GetSipMediaApplication
-- 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 information for a SIP media application, including name,
-- AWS Region, and endpoints.
module Amazonka.Chime.GetSipMediaApplication
  ( -- * Creating a Request
    GetSipMediaApplication (..),
    newGetSipMediaApplication,

    -- * Request Lenses
    getSipMediaApplication_sipMediaApplicationId,

    -- * Destructuring the Response
    GetSipMediaApplicationResponse (..),
    newGetSipMediaApplicationResponse,

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

-- |
-- Create a value of 'GetSipMediaApplication' 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:
--
-- 'sipMediaApplicationId', 'getSipMediaApplication_sipMediaApplicationId' - The SIP media application ID.
newGetSipMediaApplication ::
  -- | 'sipMediaApplicationId'
  Prelude.Text ->
  GetSipMediaApplication
newGetSipMediaApplication :: Text -> GetSipMediaApplication
newGetSipMediaApplication Text
pSipMediaApplicationId_ =
  GetSipMediaApplication' :: Text -> GetSipMediaApplication
GetSipMediaApplication'
    { $sel:sipMediaApplicationId:GetSipMediaApplication' :: Text
sipMediaApplicationId =
        Text
pSipMediaApplicationId_
    }

-- | The SIP media application ID.
getSipMediaApplication_sipMediaApplicationId :: Lens.Lens' GetSipMediaApplication Prelude.Text
getSipMediaApplication_sipMediaApplicationId :: (Text -> f Text)
-> GetSipMediaApplication -> f GetSipMediaApplication
getSipMediaApplication_sipMediaApplicationId = (GetSipMediaApplication -> Text)
-> (GetSipMediaApplication -> Text -> GetSipMediaApplication)
-> Lens GetSipMediaApplication GetSipMediaApplication Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSipMediaApplication' {Text
sipMediaApplicationId :: Text
$sel:sipMediaApplicationId:GetSipMediaApplication' :: GetSipMediaApplication -> Text
sipMediaApplicationId} -> Text
sipMediaApplicationId) (\s :: GetSipMediaApplication
s@GetSipMediaApplication' {} Text
a -> GetSipMediaApplication
s {$sel:sipMediaApplicationId:GetSipMediaApplication' :: Text
sipMediaApplicationId = Text
a} :: GetSipMediaApplication)

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

instance Prelude.NFData GetSipMediaApplication

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

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

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

-- | /See:/ 'newGetSipMediaApplicationResponse' smart constructor.
data GetSipMediaApplicationResponse = GetSipMediaApplicationResponse'
  { -- | The SIP media application details.
    GetSipMediaApplicationResponse -> Maybe SipMediaApplication
sipMediaApplication :: Prelude.Maybe SipMediaApplication,
    -- | The response's http status code.
    GetSipMediaApplicationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetSipMediaApplicationResponse
-> GetSipMediaApplicationResponse -> Bool
(GetSipMediaApplicationResponse
 -> GetSipMediaApplicationResponse -> Bool)
-> (GetSipMediaApplicationResponse
    -> GetSipMediaApplicationResponse -> Bool)
-> Eq GetSipMediaApplicationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSipMediaApplicationResponse
-> GetSipMediaApplicationResponse -> Bool
$c/= :: GetSipMediaApplicationResponse
-> GetSipMediaApplicationResponse -> Bool
== :: GetSipMediaApplicationResponse
-> GetSipMediaApplicationResponse -> Bool
$c== :: GetSipMediaApplicationResponse
-> GetSipMediaApplicationResponse -> Bool
Prelude.Eq, Int -> GetSipMediaApplicationResponse -> ShowS
[GetSipMediaApplicationResponse] -> ShowS
GetSipMediaApplicationResponse -> String
(Int -> GetSipMediaApplicationResponse -> ShowS)
-> (GetSipMediaApplicationResponse -> String)
-> ([GetSipMediaApplicationResponse] -> ShowS)
-> Show GetSipMediaApplicationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSipMediaApplicationResponse] -> ShowS
$cshowList :: [GetSipMediaApplicationResponse] -> ShowS
show :: GetSipMediaApplicationResponse -> String
$cshow :: GetSipMediaApplicationResponse -> String
showsPrec :: Int -> GetSipMediaApplicationResponse -> ShowS
$cshowsPrec :: Int -> GetSipMediaApplicationResponse -> ShowS
Prelude.Show, (forall x.
 GetSipMediaApplicationResponse
 -> Rep GetSipMediaApplicationResponse x)
-> (forall x.
    Rep GetSipMediaApplicationResponse x
    -> GetSipMediaApplicationResponse)
-> Generic GetSipMediaApplicationResponse
forall x.
Rep GetSipMediaApplicationResponse x
-> GetSipMediaApplicationResponse
forall x.
GetSipMediaApplicationResponse
-> Rep GetSipMediaApplicationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetSipMediaApplicationResponse x
-> GetSipMediaApplicationResponse
$cfrom :: forall x.
GetSipMediaApplicationResponse
-> Rep GetSipMediaApplicationResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetSipMediaApplicationResponse' 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:
--
-- 'sipMediaApplication', 'getSipMediaApplicationResponse_sipMediaApplication' - The SIP media application details.
--
-- 'httpStatus', 'getSipMediaApplicationResponse_httpStatus' - The response's http status code.
newGetSipMediaApplicationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSipMediaApplicationResponse
newGetSipMediaApplicationResponse :: Int -> GetSipMediaApplicationResponse
newGetSipMediaApplicationResponse Int
pHttpStatus_ =
  GetSipMediaApplicationResponse' :: Maybe SipMediaApplication -> Int -> GetSipMediaApplicationResponse
GetSipMediaApplicationResponse'
    { $sel:sipMediaApplication:GetSipMediaApplicationResponse' :: Maybe SipMediaApplication
sipMediaApplication =
        Maybe SipMediaApplication
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSipMediaApplicationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The SIP media application details.
getSipMediaApplicationResponse_sipMediaApplication :: Lens.Lens' GetSipMediaApplicationResponse (Prelude.Maybe SipMediaApplication)
getSipMediaApplicationResponse_sipMediaApplication :: (Maybe SipMediaApplication -> f (Maybe SipMediaApplication))
-> GetSipMediaApplicationResponse
-> f GetSipMediaApplicationResponse
getSipMediaApplicationResponse_sipMediaApplication = (GetSipMediaApplicationResponse -> Maybe SipMediaApplication)
-> (GetSipMediaApplicationResponse
    -> Maybe SipMediaApplication -> GetSipMediaApplicationResponse)
-> Lens
     GetSipMediaApplicationResponse
     GetSipMediaApplicationResponse
     (Maybe SipMediaApplication)
     (Maybe SipMediaApplication)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSipMediaApplicationResponse' {Maybe SipMediaApplication
sipMediaApplication :: Maybe SipMediaApplication
$sel:sipMediaApplication:GetSipMediaApplicationResponse' :: GetSipMediaApplicationResponse -> Maybe SipMediaApplication
sipMediaApplication} -> Maybe SipMediaApplication
sipMediaApplication) (\s :: GetSipMediaApplicationResponse
s@GetSipMediaApplicationResponse' {} Maybe SipMediaApplication
a -> GetSipMediaApplicationResponse
s {$sel:sipMediaApplication:GetSipMediaApplicationResponse' :: Maybe SipMediaApplication
sipMediaApplication = Maybe SipMediaApplication
a} :: GetSipMediaApplicationResponse)

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

instance
  Prelude.NFData
    GetSipMediaApplicationResponse