{-# 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.BatchGetStreamKey
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Performs GetStreamKey on multiple ARNs simultaneously.
module Amazonka.IVS.BatchGetStreamKey
  ( -- * Creating a Request
    BatchGetStreamKey (..),
    newBatchGetStreamKey,

    -- * Request Lenses
    batchGetStreamKey_arns,

    -- * Destructuring the Response
    BatchGetStreamKeyResponse (..),
    newBatchGetStreamKeyResponse,

    -- * Response Lenses
    batchGetStreamKeyResponse_errors,
    batchGetStreamKeyResponse_streamKeys,
    batchGetStreamKeyResponse_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:/ 'newBatchGetStreamKey' smart constructor.
data BatchGetStreamKey = BatchGetStreamKey'
  { -- | Array of ARNs, one per channel.
    BatchGetStreamKey -> NonEmpty Text
arns :: Prelude.NonEmpty Prelude.Text
  }
  deriving (BatchGetStreamKey -> BatchGetStreamKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetStreamKey -> BatchGetStreamKey -> Bool
$c/= :: BatchGetStreamKey -> BatchGetStreamKey -> Bool
== :: BatchGetStreamKey -> BatchGetStreamKey -> Bool
$c== :: BatchGetStreamKey -> BatchGetStreamKey -> Bool
Prelude.Eq, ReadPrec [BatchGetStreamKey]
ReadPrec BatchGetStreamKey
Int -> ReadS BatchGetStreamKey
ReadS [BatchGetStreamKey]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetStreamKey]
$creadListPrec :: ReadPrec [BatchGetStreamKey]
readPrec :: ReadPrec BatchGetStreamKey
$creadPrec :: ReadPrec BatchGetStreamKey
readList :: ReadS [BatchGetStreamKey]
$creadList :: ReadS [BatchGetStreamKey]
readsPrec :: Int -> ReadS BatchGetStreamKey
$creadsPrec :: Int -> ReadS BatchGetStreamKey
Prelude.Read, Int -> BatchGetStreamKey -> ShowS
[BatchGetStreamKey] -> ShowS
BatchGetStreamKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetStreamKey] -> ShowS
$cshowList :: [BatchGetStreamKey] -> ShowS
show :: BatchGetStreamKey -> String
$cshow :: BatchGetStreamKey -> String
showsPrec :: Int -> BatchGetStreamKey -> ShowS
$cshowsPrec :: Int -> BatchGetStreamKey -> ShowS
Prelude.Show, forall x. Rep BatchGetStreamKey x -> BatchGetStreamKey
forall x. BatchGetStreamKey -> Rep BatchGetStreamKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetStreamKey x -> BatchGetStreamKey
$cfrom :: forall x. BatchGetStreamKey -> Rep BatchGetStreamKey x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetStreamKey' 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:
--
-- 'arns', 'batchGetStreamKey_arns' - Array of ARNs, one per channel.
newBatchGetStreamKey ::
  -- | 'arns'
  Prelude.NonEmpty Prelude.Text ->
  BatchGetStreamKey
newBatchGetStreamKey :: NonEmpty Text -> BatchGetStreamKey
newBatchGetStreamKey NonEmpty Text
pArns_ =
  BatchGetStreamKey'
    { $sel:arns:BatchGetStreamKey' :: NonEmpty Text
arns =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pArns_
    }

-- | Array of ARNs, one per channel.
batchGetStreamKey_arns :: Lens.Lens' BatchGetStreamKey (Prelude.NonEmpty Prelude.Text)
batchGetStreamKey_arns :: Lens' BatchGetStreamKey (NonEmpty Text)
batchGetStreamKey_arns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetStreamKey' {NonEmpty Text
arns :: NonEmpty Text
$sel:arns:BatchGetStreamKey' :: BatchGetStreamKey -> NonEmpty Text
arns} -> NonEmpty Text
arns) (\s :: BatchGetStreamKey
s@BatchGetStreamKey' {} NonEmpty Text
a -> BatchGetStreamKey
s {$sel:arns:BatchGetStreamKey' :: NonEmpty Text
arns = NonEmpty Text
a} :: BatchGetStreamKey) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchGetStreamKey where
  type
    AWSResponse BatchGetStreamKey =
      BatchGetStreamKeyResponse
  request :: (Service -> Service)
-> BatchGetStreamKey -> Request BatchGetStreamKey
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 BatchGetStreamKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchGetStreamKey)))
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 [BatchError]
-> Maybe [StreamKey] -> Int -> BatchGetStreamKeyResponse
BatchGetStreamKeyResponse'
            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
"errors" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"streamKeys" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 BatchGetStreamKey where
  hashWithSalt :: Int -> BatchGetStreamKey -> Int
hashWithSalt Int
_salt BatchGetStreamKey' {NonEmpty Text
arns :: NonEmpty Text
$sel:arns:BatchGetStreamKey' :: BatchGetStreamKey -> NonEmpty Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
arns

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

instance Data.ToHeaders BatchGetStreamKey where
  toHeaders :: BatchGetStreamKey -> 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 BatchGetStreamKey where
  toJSON :: BatchGetStreamKey -> Value
toJSON BatchGetStreamKey' {NonEmpty Text
arns :: NonEmpty Text
$sel:arns:BatchGetStreamKey' :: BatchGetStreamKey -> NonEmpty Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"arns" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
arns)]
      )

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

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

-- | /See:/ 'newBatchGetStreamKeyResponse' smart constructor.
data BatchGetStreamKeyResponse = BatchGetStreamKeyResponse'
  { BatchGetStreamKeyResponse -> Maybe [BatchError]
errors :: Prelude.Maybe [BatchError],
    BatchGetStreamKeyResponse -> Maybe [StreamKey]
streamKeys :: Prelude.Maybe [StreamKey],
    -- | The response's http status code.
    BatchGetStreamKeyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchGetStreamKeyResponse -> BatchGetStreamKeyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetStreamKeyResponse -> BatchGetStreamKeyResponse -> Bool
$c/= :: BatchGetStreamKeyResponse -> BatchGetStreamKeyResponse -> Bool
== :: BatchGetStreamKeyResponse -> BatchGetStreamKeyResponse -> Bool
$c== :: BatchGetStreamKeyResponse -> BatchGetStreamKeyResponse -> Bool
Prelude.Eq, Int -> BatchGetStreamKeyResponse -> ShowS
[BatchGetStreamKeyResponse] -> ShowS
BatchGetStreamKeyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetStreamKeyResponse] -> ShowS
$cshowList :: [BatchGetStreamKeyResponse] -> ShowS
show :: BatchGetStreamKeyResponse -> String
$cshow :: BatchGetStreamKeyResponse -> String
showsPrec :: Int -> BatchGetStreamKeyResponse -> ShowS
$cshowsPrec :: Int -> BatchGetStreamKeyResponse -> ShowS
Prelude.Show, forall x.
Rep BatchGetStreamKeyResponse x -> BatchGetStreamKeyResponse
forall x.
BatchGetStreamKeyResponse -> Rep BatchGetStreamKeyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchGetStreamKeyResponse x -> BatchGetStreamKeyResponse
$cfrom :: forall x.
BatchGetStreamKeyResponse -> Rep BatchGetStreamKeyResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetStreamKeyResponse' 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:
--
-- 'errors', 'batchGetStreamKeyResponse_errors' -
--
-- 'streamKeys', 'batchGetStreamKeyResponse_streamKeys' -
--
-- 'httpStatus', 'batchGetStreamKeyResponse_httpStatus' - The response's http status code.
newBatchGetStreamKeyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchGetStreamKeyResponse
newBatchGetStreamKeyResponse :: Int -> BatchGetStreamKeyResponse
newBatchGetStreamKeyResponse Int
pHttpStatus_ =
  BatchGetStreamKeyResponse'
    { $sel:errors:BatchGetStreamKeyResponse' :: Maybe [BatchError]
errors =
        forall a. Maybe a
Prelude.Nothing,
      $sel:streamKeys:BatchGetStreamKeyResponse' :: Maybe [StreamKey]
streamKeys = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchGetStreamKeyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

batchGetStreamKeyResponse_errors :: Lens.Lens' BatchGetStreamKeyResponse (Prelude.Maybe [BatchError])
batchGetStreamKeyResponse_errors :: Lens' BatchGetStreamKeyResponse (Maybe [BatchError])
batchGetStreamKeyResponse_errors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetStreamKeyResponse' {Maybe [BatchError]
errors :: Maybe [BatchError]
$sel:errors:BatchGetStreamKeyResponse' :: BatchGetStreamKeyResponse -> Maybe [BatchError]
errors} -> Maybe [BatchError]
errors) (\s :: BatchGetStreamKeyResponse
s@BatchGetStreamKeyResponse' {} Maybe [BatchError]
a -> BatchGetStreamKeyResponse
s {$sel:errors:BatchGetStreamKeyResponse' :: Maybe [BatchError]
errors = Maybe [BatchError]
a} :: BatchGetStreamKeyResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

batchGetStreamKeyResponse_streamKeys :: Lens.Lens' BatchGetStreamKeyResponse (Prelude.Maybe [StreamKey])
batchGetStreamKeyResponse_streamKeys :: Lens' BatchGetStreamKeyResponse (Maybe [StreamKey])
batchGetStreamKeyResponse_streamKeys = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetStreamKeyResponse' {Maybe [StreamKey]
streamKeys :: Maybe [StreamKey]
$sel:streamKeys:BatchGetStreamKeyResponse' :: BatchGetStreamKeyResponse -> Maybe [StreamKey]
streamKeys} -> Maybe [StreamKey]
streamKeys) (\s :: BatchGetStreamKeyResponse
s@BatchGetStreamKeyResponse' {} Maybe [StreamKey]
a -> BatchGetStreamKeyResponse
s {$sel:streamKeys:BatchGetStreamKeyResponse' :: Maybe [StreamKey]
streamKeys = Maybe [StreamKey]
a} :: BatchGetStreamKeyResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData BatchGetStreamKeyResponse where
  rnf :: BatchGetStreamKeyResponse -> ()
rnf BatchGetStreamKeyResponse' {Int
Maybe [BatchError]
Maybe [StreamKey]
httpStatus :: Int
streamKeys :: Maybe [StreamKey]
errors :: Maybe [BatchError]
$sel:httpStatus:BatchGetStreamKeyResponse' :: BatchGetStreamKeyResponse -> Int
$sel:streamKeys:BatchGetStreamKeyResponse' :: BatchGetStreamKeyResponse -> Maybe [StreamKey]
$sel:errors:BatchGetStreamKeyResponse' :: BatchGetStreamKeyResponse -> Maybe [BatchError]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [BatchError]
errors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [StreamKey]
streamKeys
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus