{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.StreamKey
-- 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)
module Amazonka.IVS.Types.StreamKey where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Object specifying a stream key.
--
-- /See:/ 'newStreamKey' smart constructor.
data StreamKey = StreamKey'
  { -- | Stream-key ARN.
    StreamKey -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | Stream-key value.
    StreamKey -> Maybe (Sensitive Text)
value :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | Channel ARN for the stream.
    StreamKey -> Maybe Text
channelArn :: Prelude.Maybe Prelude.Text,
    -- | Array of 1-50 maps, each of the form @string:string (key:value)@.
    StreamKey -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (StreamKey -> StreamKey -> Bool
(StreamKey -> StreamKey -> Bool)
-> (StreamKey -> StreamKey -> Bool) -> Eq StreamKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StreamKey -> StreamKey -> Bool
$c/= :: StreamKey -> StreamKey -> Bool
== :: StreamKey -> StreamKey -> Bool
$c== :: StreamKey -> StreamKey -> Bool
Prelude.Eq, Int -> StreamKey -> ShowS
[StreamKey] -> ShowS
StreamKey -> String
(Int -> StreamKey -> ShowS)
-> (StreamKey -> String)
-> ([StreamKey] -> ShowS)
-> Show StreamKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StreamKey] -> ShowS
$cshowList :: [StreamKey] -> ShowS
show :: StreamKey -> String
$cshow :: StreamKey -> String
showsPrec :: Int -> StreamKey -> ShowS
$cshowsPrec :: Int -> StreamKey -> ShowS
Prelude.Show, (forall x. StreamKey -> Rep StreamKey x)
-> (forall x. Rep StreamKey x -> StreamKey) -> Generic StreamKey
forall x. Rep StreamKey x -> StreamKey
forall x. StreamKey -> Rep StreamKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StreamKey x -> StreamKey
$cfrom :: forall x. StreamKey -> Rep StreamKey x
Prelude.Generic)

-- |
-- Create a value of 'StreamKey' 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', 'streamKey_arn' - Stream-key ARN.
--
-- 'value', 'streamKey_value' - Stream-key value.
--
-- 'channelArn', 'streamKey_channelArn' - Channel ARN for the stream.
--
-- 'tags', 'streamKey_tags' - Array of 1-50 maps, each of the form @string:string (key:value)@.
newStreamKey ::
  StreamKey
newStreamKey :: StreamKey
newStreamKey =
  StreamKey' :: Maybe Text
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe (HashMap Text Text)
-> StreamKey
StreamKey'
    { $sel:arn:StreamKey' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:value:StreamKey' :: Maybe (Sensitive Text)
value = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:channelArn:StreamKey' :: Maybe Text
channelArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:StreamKey' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | Stream-key ARN.
streamKey_arn :: Lens.Lens' StreamKey (Prelude.Maybe Prelude.Text)
streamKey_arn :: (Maybe Text -> f (Maybe Text)) -> StreamKey -> f StreamKey
streamKey_arn = (StreamKey -> Maybe Text)
-> (StreamKey -> Maybe Text -> StreamKey)
-> Lens StreamKey StreamKey (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamKey' {Maybe Text
arn :: Maybe Text
$sel:arn:StreamKey' :: StreamKey -> Maybe Text
arn} -> Maybe Text
arn) (\s :: StreamKey
s@StreamKey' {} Maybe Text
a -> StreamKey
s {$sel:arn:StreamKey' :: Maybe Text
arn = Maybe Text
a} :: StreamKey)

-- | Stream-key value.
streamKey_value :: Lens.Lens' StreamKey (Prelude.Maybe Prelude.Text)
streamKey_value :: (Maybe Text -> f (Maybe Text)) -> StreamKey -> f StreamKey
streamKey_value = (StreamKey -> Maybe (Sensitive Text))
-> (StreamKey -> Maybe (Sensitive Text) -> StreamKey)
-> Lens
     StreamKey
     StreamKey
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamKey' {Maybe (Sensitive Text)
value :: Maybe (Sensitive Text)
$sel:value:StreamKey' :: StreamKey -> Maybe (Sensitive Text)
value} -> Maybe (Sensitive Text)
value) (\s :: StreamKey
s@StreamKey' {} Maybe (Sensitive Text)
a -> StreamKey
s {$sel:value:StreamKey' :: Maybe (Sensitive Text)
value = Maybe (Sensitive Text)
a} :: StreamKey) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> StreamKey -> f StreamKey)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> StreamKey
-> f StreamKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | Channel ARN for the stream.
streamKey_channelArn :: Lens.Lens' StreamKey (Prelude.Maybe Prelude.Text)
streamKey_channelArn :: (Maybe Text -> f (Maybe Text)) -> StreamKey -> f StreamKey
streamKey_channelArn = (StreamKey -> Maybe Text)
-> (StreamKey -> Maybe Text -> StreamKey)
-> Lens StreamKey StreamKey (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamKey' {Maybe Text
channelArn :: Maybe Text
$sel:channelArn:StreamKey' :: StreamKey -> Maybe Text
channelArn} -> Maybe Text
channelArn) (\s :: StreamKey
s@StreamKey' {} Maybe Text
a -> StreamKey
s {$sel:channelArn:StreamKey' :: Maybe Text
channelArn = Maybe Text
a} :: StreamKey)

-- | Array of 1-50 maps, each of the form @string:string (key:value)@.
streamKey_tags :: Lens.Lens' StreamKey (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
streamKey_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> StreamKey -> f StreamKey
streamKey_tags = (StreamKey -> Maybe (HashMap Text Text))
-> (StreamKey -> Maybe (HashMap Text Text) -> StreamKey)
-> Lens
     StreamKey
     StreamKey
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamKey' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:StreamKey' :: StreamKey -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: StreamKey
s@StreamKey' {} Maybe (HashMap Text Text)
a -> StreamKey
s {$sel:tags:StreamKey' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: StreamKey) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> StreamKey -> f StreamKey)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> StreamKey
-> f StreamKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON StreamKey where
  parseJSON :: Value -> Parser StreamKey
parseJSON =
    String -> (Object -> Parser StreamKey) -> Value -> Parser StreamKey
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StreamKey"
      ( \Object
x ->
          Maybe Text
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe (HashMap Text Text)
-> StreamKey
StreamKey'
            (Maybe Text
 -> Maybe (Sensitive Text)
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> StreamKey)
-> Parser (Maybe Text)
-> Parser
     (Maybe (Sensitive Text)
      -> Maybe Text -> Maybe (HashMap Text Text) -> StreamKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"arn")
            Parser
  (Maybe (Sensitive Text)
   -> Maybe Text -> Maybe (HashMap Text Text) -> StreamKey)
-> Parser (Maybe (Sensitive Text))
-> Parser (Maybe Text -> Maybe (HashMap Text Text) -> StreamKey)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"value")
            Parser (Maybe Text -> Maybe (HashMap Text Text) -> StreamKey)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Text) -> StreamKey)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"channelArn")
            Parser (Maybe (HashMap Text Text) -> StreamKey)
-> Parser (Maybe (HashMap Text Text)) -> Parser StreamKey
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tags" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable StreamKey

instance Prelude.NFData StreamKey