{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IVS.Types
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
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]
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
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. 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' {$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 :: Lens' GetChannel Text
getChannel_arn = 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 :: (Service -> Service) -> GetChannel -> Request GetChannel
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetChannel)))
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 Channel -> Int -> GetChannelResponse
GetChannelResponse'
            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
"channel")
            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 GetChannel where
  hashWithSalt :: Int -> GetChannel -> Int
hashWithSalt Int
_salt GetChannel' {Text
arn :: Text
$sel:arn:GetChannel' :: GetChannel -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

instance Prelude.NFData GetChannel where
  rnf :: GetChannel -> ()
rnf GetChannel' {Text
arn :: Text
$sel:arn:GetChannel' :: GetChannel -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
arn

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

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

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

instance Data.ToQuery GetChannel where
  toQuery :: GetChannel -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
    { $sel:channel:GetChannelResponse' :: Maybe Channel
channel = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetChannelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

getChannelResponse_channel :: Lens.Lens' GetChannelResponse (Prelude.Maybe Channel)
getChannelResponse_channel :: Lens' GetChannelResponse (Maybe Channel)
getChannelResponse_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 :: Lens' GetChannelResponse Int
getChannelResponse_httpStatus = 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 where
  rnf :: GetChannelResponse -> ()
rnf GetChannelResponse' {Int
Maybe Channel
httpStatus :: Int
channel :: Maybe Channel
$sel:httpStatus:GetChannelResponse' :: GetChannelResponse -> Int
$sel:channel:GetChannelResponse' :: GetChannelResponse -> Maybe Channel
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Channel
channel
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus