{-# 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.MediaLive.Types.InputLocation
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaLive.Types.InputLocation where

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

-- | Input Location
--
-- /See:/ 'newInputLocation' smart constructor.
data InputLocation = InputLocation'
  { -- | key used to extract the password from EC2 Parameter store
    InputLocation -> Maybe Text
passwordParam :: Prelude.Maybe Prelude.Text,
    -- | Documentation update needed
    InputLocation -> Maybe Text
username :: Prelude.Maybe Prelude.Text,
    -- | Uniform Resource Identifier - This should be a path to a file accessible
    -- to the Live system (eg. a http:\/\/ URI) depending on the output type.
    -- For example, a RTMP destination should have a uri simliar to:
    -- \"rtmp:\/\/fmsserver\/live\".
    InputLocation -> Text
uri :: Prelude.Text
  }
  deriving (InputLocation -> InputLocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputLocation -> InputLocation -> Bool
$c/= :: InputLocation -> InputLocation -> Bool
== :: InputLocation -> InputLocation -> Bool
$c== :: InputLocation -> InputLocation -> Bool
Prelude.Eq, ReadPrec [InputLocation]
ReadPrec InputLocation
Int -> ReadS InputLocation
ReadS [InputLocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputLocation]
$creadListPrec :: ReadPrec [InputLocation]
readPrec :: ReadPrec InputLocation
$creadPrec :: ReadPrec InputLocation
readList :: ReadS [InputLocation]
$creadList :: ReadS [InputLocation]
readsPrec :: Int -> ReadS InputLocation
$creadsPrec :: Int -> ReadS InputLocation
Prelude.Read, Int -> InputLocation -> ShowS
[InputLocation] -> ShowS
InputLocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputLocation] -> ShowS
$cshowList :: [InputLocation] -> ShowS
show :: InputLocation -> String
$cshow :: InputLocation -> String
showsPrec :: Int -> InputLocation -> ShowS
$cshowsPrec :: Int -> InputLocation -> ShowS
Prelude.Show, forall x. Rep InputLocation x -> InputLocation
forall x. InputLocation -> Rep InputLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputLocation x -> InputLocation
$cfrom :: forall x. InputLocation -> Rep InputLocation x
Prelude.Generic)

-- |
-- Create a value of 'InputLocation' 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:
--
-- 'passwordParam', 'inputLocation_passwordParam' - key used to extract the password from EC2 Parameter store
--
-- 'username', 'inputLocation_username' - Documentation update needed
--
-- 'uri', 'inputLocation_uri' - Uniform Resource Identifier - This should be a path to a file accessible
-- to the Live system (eg. a http:\/\/ URI) depending on the output type.
-- For example, a RTMP destination should have a uri simliar to:
-- \"rtmp:\/\/fmsserver\/live\".
newInputLocation ::
  -- | 'uri'
  Prelude.Text ->
  InputLocation
newInputLocation :: Text -> InputLocation
newInputLocation Text
pUri_ =
  InputLocation'
    { $sel:passwordParam:InputLocation' :: Maybe Text
passwordParam = forall a. Maybe a
Prelude.Nothing,
      $sel:username:InputLocation' :: Maybe Text
username = forall a. Maybe a
Prelude.Nothing,
      $sel:uri:InputLocation' :: Text
uri = Text
pUri_
    }

-- | key used to extract the password from EC2 Parameter store
inputLocation_passwordParam :: Lens.Lens' InputLocation (Prelude.Maybe Prelude.Text)
inputLocation_passwordParam :: Lens' InputLocation (Maybe Text)
inputLocation_passwordParam = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputLocation' {Maybe Text
passwordParam :: Maybe Text
$sel:passwordParam:InputLocation' :: InputLocation -> Maybe Text
passwordParam} -> Maybe Text
passwordParam) (\s :: InputLocation
s@InputLocation' {} Maybe Text
a -> InputLocation
s {$sel:passwordParam:InputLocation' :: Maybe Text
passwordParam = Maybe Text
a} :: InputLocation)

-- | Documentation update needed
inputLocation_username :: Lens.Lens' InputLocation (Prelude.Maybe Prelude.Text)
inputLocation_username :: Lens' InputLocation (Maybe Text)
inputLocation_username = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputLocation' {Maybe Text
username :: Maybe Text
$sel:username:InputLocation' :: InputLocation -> Maybe Text
username} -> Maybe Text
username) (\s :: InputLocation
s@InputLocation' {} Maybe Text
a -> InputLocation
s {$sel:username:InputLocation' :: Maybe Text
username = Maybe Text
a} :: InputLocation)

-- | Uniform Resource Identifier - This should be a path to a file accessible
-- to the Live system (eg. a http:\/\/ URI) depending on the output type.
-- For example, a RTMP destination should have a uri simliar to:
-- \"rtmp:\/\/fmsserver\/live\".
inputLocation_uri :: Lens.Lens' InputLocation Prelude.Text
inputLocation_uri :: Lens' InputLocation Text
inputLocation_uri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputLocation' {Text
uri :: Text
$sel:uri:InputLocation' :: InputLocation -> Text
uri} -> Text
uri) (\s :: InputLocation
s@InputLocation' {} Text
a -> InputLocation
s {$sel:uri:InputLocation' :: Text
uri = Text
a} :: InputLocation)

instance Data.FromJSON InputLocation where
  parseJSON :: Value -> Parser InputLocation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InputLocation"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> InputLocation
InputLocation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"passwordParam")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"username")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"uri")
      )

instance Prelude.Hashable InputLocation where
  hashWithSalt :: Int -> InputLocation -> Int
hashWithSalt Int
_salt InputLocation' {Maybe Text
Text
uri :: Text
username :: Maybe Text
passwordParam :: Maybe Text
$sel:uri:InputLocation' :: InputLocation -> Text
$sel:username:InputLocation' :: InputLocation -> Maybe Text
$sel:passwordParam:InputLocation' :: InputLocation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
passwordParam
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
username
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
uri

instance Prelude.NFData InputLocation where
  rnf :: InputLocation -> ()
rnf InputLocation' {Maybe Text
Text
uri :: Text
username :: Maybe Text
passwordParam :: Maybe Text
$sel:uri:InputLocation' :: InputLocation -> Text
$sel:username:InputLocation' :: InputLocation -> Maybe Text
$sel:passwordParam:InputLocation' :: InputLocation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
passwordParam
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
username
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
uri

instance Data.ToJSON InputLocation where
  toJSON :: InputLocation -> Value
toJSON InputLocation' {Maybe Text
Text
uri :: Text
username :: Maybe Text
passwordParam :: Maybe Text
$sel:uri:InputLocation' :: InputLocation -> Text
$sel:username:InputLocation' :: InputLocation -> Maybe Text
$sel:passwordParam:InputLocation' :: InputLocation -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"passwordParam" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
passwordParam,
            (Key
"username" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
username,
            forall a. a -> Maybe a
Prelude.Just (Key
"uri" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
uri)
          ]
      )