{-# 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.IVS.GetChannel
-- 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)
--
-- Gets the channel configuration for the specified channel ARN. See also
-- BatchGetChannel.
module Amazonka.IVS.GetChannel
  ( -- * Creating a Request
    GetChannel (..),
    newGetChannel,

    -- * Request Lenses
    getChannel_arn,

    -- * Destructuring the Response
    GetChannelResponse (..),
    newGetChannelResponse,

    -- * Response Lenses
    getChannelResponse_channel,
    getChannelResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IVS.Types
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:/ 'newGetChannel' smart constructor.
data GetChannel = GetChannel'
  { -- | ARN of the channel for which the configuration is to be retrieved.
    GetChannel -> Text
arn :: Prelude.Text
  }
  deriving (GetChannel -> GetChannel -> Bool
(GetChannel -> GetChannel -> Bool)
-> (GetChannel -> GetChannel -> Bool) -> Eq GetChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetChannel -> GetChannel -> Bool
$c/= :: GetChannel -> GetChannel -> Bool
== :: GetChannel -> GetChannel -> Bool
$c== :: GetChannel -> GetChannel -> Bool
Prelude.Eq, ReadPrec [GetChannel]
ReadPrec GetChannel
Int -> ReadS GetChannel
ReadS [GetChannel]
(Int -> ReadS GetChannel)
-> ReadS [GetChannel]
-> ReadPrec GetChannel
-> ReadPrec [GetChannel]
-> Read GetChannel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetChannel]
$creadListPrec :: ReadPrec [GetChannel]
readPrec :: ReadPrec GetChannel
$creadPrec :: ReadPrec GetChannel
readList :: ReadS [GetChannel]
$creadList :: ReadS [GetChannel]
readsPrec :: Int -> ReadS GetChannel
$creadsPrec :: Int -> ReadS GetChannel
Prelude.Read, Int -> GetChannel -> ShowS
[GetChannel] -> ShowS
GetChannel -> String
(Int -> GetChannel -> ShowS)
-> (GetChannel -> String)
-> ([GetChannel] -> ShowS)
-> Show GetChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetChannel] -> ShowS
$cshowList :: [GetChannel] -> ShowS
show :: GetChannel -> String
$cshow :: GetChannel -> String
showsPrec :: Int -> GetChannel -> ShowS
$cshowsPrec :: Int -> GetChannel -> ShowS
Prelude.Show, (forall x. GetChannel -> Rep GetChannel x)
-> (forall x. Rep GetChannel x -> GetChannel) -> Generic GetChannel
forall x. Rep GetChannel x -> GetChannel
forall x. GetChannel -> Rep GetChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetChannel x -> GetChannel
$cfrom :: forall x. GetChannel -> Rep GetChannel x
Prelude.Generic)

-- |
-- Create a value of 'GetChannel' 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:
--
-- 'arn', 'getChannel_arn' - ARN of the channel for which the configuration is to be retrieved.
newGetChannel ::
  -- | 'arn'
  Prelude.Text ->
  GetChannel
newGetChannel :: Text -> GetChannel
newGetChannel Text
pArn_ = GetChannel' :: Text -> GetChannel
GetChannel' {$sel:arn:GetChannel' :: Text
arn = Text
pArn_}

-- | ARN of the channel for which the configuration is to be retrieved.
getChannel_arn :: Lens.Lens' GetChannel Prelude.Text
getChannel_arn :: (Text -> f Text) -> GetChannel -> f GetChannel
getChannel_arn = (GetChannel -> Text)
-> (GetChannel -> Text -> GetChannel)
-> Lens GetChannel GetChannel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetChannel' {Text
arn :: Text
$sel:arn:GetChannel' :: GetChannel -> Text
arn} -> Text
arn) (\s :: GetChannel
s@GetChannel' {} Text
a -> GetChannel
s {$sel:arn:GetChannel' :: Text
arn = Text
a} :: GetChannel)

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

instance Prelude.NFData GetChannel

instance Core.ToHeaders GetChannel where
  toHeaders :: GetChannel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetChannel -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON GetChannel where
  toJSON :: GetChannel -> Value
toJSON GetChannel' {Text
arn :: Text
$sel:arn:GetChannel' :: GetChannel -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn)]
      )

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

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

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

-- |
-- Create a value of 'GetChannelResponse' 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:
--
-- 'channel', 'getChannelResponse_channel' -
--
-- 'httpStatus', 'getChannelResponse_httpStatus' - The response's http status code.
newGetChannelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetChannelResponse
newGetChannelResponse :: Int -> GetChannelResponse
newGetChannelResponse Int
pHttpStatus_ =
  GetChannelResponse' :: Maybe Channel -> Int -> GetChannelResponse
GetChannelResponse'
    { $sel:channel:GetChannelResponse' :: Maybe Channel
channel = Maybe Channel
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetChannelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- |
getChannelResponse_channel :: Lens.Lens' GetChannelResponse (Prelude.Maybe Channel)
getChannelResponse_channel :: (Maybe Channel -> f (Maybe Channel))
-> GetChannelResponse -> f GetChannelResponse
getChannelResponse_channel = (GetChannelResponse -> Maybe Channel)
-> (GetChannelResponse -> Maybe Channel -> GetChannelResponse)
-> Lens
     GetChannelResponse
     GetChannelResponse
     (Maybe Channel)
     (Maybe Channel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetChannelResponse' {Maybe Channel
channel :: Maybe Channel
$sel:channel:GetChannelResponse' :: GetChannelResponse -> Maybe Channel
channel} -> Maybe Channel
channel) (\s :: GetChannelResponse
s@GetChannelResponse' {} Maybe Channel
a -> GetChannelResponse
s {$sel:channel:GetChannelResponse' :: Maybe Channel
channel = Maybe Channel
a} :: GetChannelResponse)

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

instance Prelude.NFData GetChannelResponse