{-# 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.IoT1ClickProjects.Types.PlacementDescription
-- 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.IoT1ClickProjects.Types.PlacementDescription where

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

-- | An object describing a project\'s placement.
--
-- /See:/ 'newPlacementDescription' smart constructor.
data PlacementDescription = PlacementDescription'
  { -- | The name of the project containing the placement.
    PlacementDescription -> Text
projectName :: Prelude.Text,
    -- | The name of the placement.
    PlacementDescription -> Text
placementName :: Prelude.Text,
    -- | The user-defined attributes associated with the placement.
    PlacementDescription -> HashMap Text Text
attributes :: Prelude.HashMap Prelude.Text Prelude.Text,
    -- | The date when the placement was initially created, in UNIX epoch time
    -- format.
    PlacementDescription -> POSIX
createdDate :: Core.POSIX,
    -- | The date when the placement was last updated, in UNIX epoch time format.
    -- If the placement was not updated, then @createdDate@ and @updatedDate@
    -- are the same.
    PlacementDescription -> POSIX
updatedDate :: Core.POSIX
  }
  deriving (PlacementDescription -> PlacementDescription -> Bool
(PlacementDescription -> PlacementDescription -> Bool)
-> (PlacementDescription -> PlacementDescription -> Bool)
-> Eq PlacementDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PlacementDescription -> PlacementDescription -> Bool
$c/= :: PlacementDescription -> PlacementDescription -> Bool
== :: PlacementDescription -> PlacementDescription -> Bool
$c== :: PlacementDescription -> PlacementDescription -> Bool
Prelude.Eq, ReadPrec [PlacementDescription]
ReadPrec PlacementDescription
Int -> ReadS PlacementDescription
ReadS [PlacementDescription]
(Int -> ReadS PlacementDescription)
-> ReadS [PlacementDescription]
-> ReadPrec PlacementDescription
-> ReadPrec [PlacementDescription]
-> Read PlacementDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PlacementDescription]
$creadListPrec :: ReadPrec [PlacementDescription]
readPrec :: ReadPrec PlacementDescription
$creadPrec :: ReadPrec PlacementDescription
readList :: ReadS [PlacementDescription]
$creadList :: ReadS [PlacementDescription]
readsPrec :: Int -> ReadS PlacementDescription
$creadsPrec :: Int -> ReadS PlacementDescription
Prelude.Read, Int -> PlacementDescription -> ShowS
[PlacementDescription] -> ShowS
PlacementDescription -> String
(Int -> PlacementDescription -> ShowS)
-> (PlacementDescription -> String)
-> ([PlacementDescription] -> ShowS)
-> Show PlacementDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PlacementDescription] -> ShowS
$cshowList :: [PlacementDescription] -> ShowS
show :: PlacementDescription -> String
$cshow :: PlacementDescription -> String
showsPrec :: Int -> PlacementDescription -> ShowS
$cshowsPrec :: Int -> PlacementDescription -> ShowS
Prelude.Show, (forall x. PlacementDescription -> Rep PlacementDescription x)
-> (forall x. Rep PlacementDescription x -> PlacementDescription)
-> Generic PlacementDescription
forall x. Rep PlacementDescription x -> PlacementDescription
forall x. PlacementDescription -> Rep PlacementDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PlacementDescription x -> PlacementDescription
$cfrom :: forall x. PlacementDescription -> Rep PlacementDescription x
Prelude.Generic)

-- |
-- Create a value of 'PlacementDescription' 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:
--
-- 'projectName', 'placementDescription_projectName' - The name of the project containing the placement.
--
-- 'placementName', 'placementDescription_placementName' - The name of the placement.
--
-- 'attributes', 'placementDescription_attributes' - The user-defined attributes associated with the placement.
--
-- 'createdDate', 'placementDescription_createdDate' - The date when the placement was initially created, in UNIX epoch time
-- format.
--
-- 'updatedDate', 'placementDescription_updatedDate' - The date when the placement was last updated, in UNIX epoch time format.
-- If the placement was not updated, then @createdDate@ and @updatedDate@
-- are the same.
newPlacementDescription ::
  -- | 'projectName'
  Prelude.Text ->
  -- | 'placementName'
  Prelude.Text ->
  -- | 'createdDate'
  Prelude.UTCTime ->
  -- | 'updatedDate'
  Prelude.UTCTime ->
  PlacementDescription
newPlacementDescription :: Text -> Text -> UTCTime -> UTCTime -> PlacementDescription
newPlacementDescription
  Text
pProjectName_
  Text
pPlacementName_
  UTCTime
pCreatedDate_
  UTCTime
pUpdatedDate_ =
    PlacementDescription' :: Text
-> Text
-> HashMap Text Text
-> POSIX
-> POSIX
-> PlacementDescription
PlacementDescription'
      { $sel:projectName:PlacementDescription' :: Text
projectName = Text
pProjectName_,
        $sel:placementName:PlacementDescription' :: Text
placementName = Text
pPlacementName_,
        $sel:attributes:PlacementDescription' :: HashMap Text Text
attributes = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty,
        $sel:createdDate:PlacementDescription' :: POSIX
createdDate = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreatedDate_,
        $sel:updatedDate:PlacementDescription' :: POSIX
updatedDate = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pUpdatedDate_
      }

-- | The name of the project containing the placement.
placementDescription_projectName :: Lens.Lens' PlacementDescription Prelude.Text
placementDescription_projectName :: (Text -> f Text) -> PlacementDescription -> f PlacementDescription
placementDescription_projectName = (PlacementDescription -> Text)
-> (PlacementDescription -> Text -> PlacementDescription)
-> Lens PlacementDescription PlacementDescription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlacementDescription' {Text
projectName :: Text
$sel:projectName:PlacementDescription' :: PlacementDescription -> Text
projectName} -> Text
projectName) (\s :: PlacementDescription
s@PlacementDescription' {} Text
a -> PlacementDescription
s {$sel:projectName:PlacementDescription' :: Text
projectName = Text
a} :: PlacementDescription)

-- | The name of the placement.
placementDescription_placementName :: Lens.Lens' PlacementDescription Prelude.Text
placementDescription_placementName :: (Text -> f Text) -> PlacementDescription -> f PlacementDescription
placementDescription_placementName = (PlacementDescription -> Text)
-> (PlacementDescription -> Text -> PlacementDescription)
-> Lens PlacementDescription PlacementDescription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlacementDescription' {Text
placementName :: Text
$sel:placementName:PlacementDescription' :: PlacementDescription -> Text
placementName} -> Text
placementName) (\s :: PlacementDescription
s@PlacementDescription' {} Text
a -> PlacementDescription
s {$sel:placementName:PlacementDescription' :: Text
placementName = Text
a} :: PlacementDescription)

-- | The user-defined attributes associated with the placement.
placementDescription_attributes :: Lens.Lens' PlacementDescription (Prelude.HashMap Prelude.Text Prelude.Text)
placementDescription_attributes :: (HashMap Text Text -> f (HashMap Text Text))
-> PlacementDescription -> f PlacementDescription
placementDescription_attributes = (PlacementDescription -> HashMap Text Text)
-> (PlacementDescription
    -> HashMap Text Text -> PlacementDescription)
-> Lens
     PlacementDescription
     PlacementDescription
     (HashMap Text Text)
     (HashMap Text Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlacementDescription' {HashMap Text Text
attributes :: HashMap Text Text
$sel:attributes:PlacementDescription' :: PlacementDescription -> HashMap Text Text
attributes} -> HashMap Text Text
attributes) (\s :: PlacementDescription
s@PlacementDescription' {} HashMap Text Text
a -> PlacementDescription
s {$sel:attributes:PlacementDescription' :: HashMap Text Text
attributes = HashMap Text Text
a} :: PlacementDescription) ((HashMap Text Text -> f (HashMap Text Text))
 -> PlacementDescription -> f PlacementDescription)
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> PlacementDescription
-> f PlacementDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The date when the placement was initially created, in UNIX epoch time
-- format.
placementDescription_createdDate :: Lens.Lens' PlacementDescription Prelude.UTCTime
placementDescription_createdDate :: (UTCTime -> f UTCTime)
-> PlacementDescription -> f PlacementDescription
placementDescription_createdDate = (PlacementDescription -> POSIX)
-> (PlacementDescription -> POSIX -> PlacementDescription)
-> Lens PlacementDescription PlacementDescription POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlacementDescription' {POSIX
createdDate :: POSIX
$sel:createdDate:PlacementDescription' :: PlacementDescription -> POSIX
createdDate} -> POSIX
createdDate) (\s :: PlacementDescription
s@PlacementDescription' {} POSIX
a -> PlacementDescription
s {$sel:createdDate:PlacementDescription' :: POSIX
createdDate = POSIX
a} :: PlacementDescription) ((POSIX -> f POSIX)
 -> PlacementDescription -> f PlacementDescription)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> PlacementDescription
-> f PlacementDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The date when the placement was last updated, in UNIX epoch time format.
-- If the placement was not updated, then @createdDate@ and @updatedDate@
-- are the same.
placementDescription_updatedDate :: Lens.Lens' PlacementDescription Prelude.UTCTime
placementDescription_updatedDate :: (UTCTime -> f UTCTime)
-> PlacementDescription -> f PlacementDescription
placementDescription_updatedDate = (PlacementDescription -> POSIX)
-> (PlacementDescription -> POSIX -> PlacementDescription)
-> Lens PlacementDescription PlacementDescription POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlacementDescription' {POSIX
updatedDate :: POSIX
$sel:updatedDate:PlacementDescription' :: PlacementDescription -> POSIX
updatedDate} -> POSIX
updatedDate) (\s :: PlacementDescription
s@PlacementDescription' {} POSIX
a -> PlacementDescription
s {$sel:updatedDate:PlacementDescription' :: POSIX
updatedDate = POSIX
a} :: PlacementDescription) ((POSIX -> f POSIX)
 -> PlacementDescription -> f PlacementDescription)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> PlacementDescription
-> f PlacementDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON PlacementDescription where
  parseJSON :: Value -> Parser PlacementDescription
parseJSON =
    String
-> (Object -> Parser PlacementDescription)
-> Value
-> Parser PlacementDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PlacementDescription"
      ( \Object
x ->
          Text
-> Text
-> HashMap Text Text
-> POSIX
-> POSIX
-> PlacementDescription
PlacementDescription'
            (Text
 -> Text
 -> HashMap Text Text
 -> POSIX
 -> POSIX
 -> PlacementDescription)
-> Parser Text
-> Parser
     (Text
      -> HashMap Text Text -> POSIX -> POSIX -> PlacementDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"projectName")
            Parser
  (Text
   -> HashMap Text Text -> POSIX -> POSIX -> PlacementDescription)
-> Parser Text
-> Parser
     (HashMap Text Text -> POSIX -> POSIX -> PlacementDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"placementName")
            Parser
  (HashMap Text Text -> POSIX -> POSIX -> PlacementDescription)
-> Parser (HashMap Text Text)
-> Parser (POSIX -> POSIX -> PlacementDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (HashMap Text Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attributes" Parser (Maybe (HashMap Text Text))
-> HashMap Text Text -> Parser (HashMap Text Text)
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= HashMap Text Text
forall a. Monoid a => a
Prelude.mempty)
            Parser (POSIX -> POSIX -> PlacementDescription)
-> Parser POSIX -> Parser (POSIX -> PlacementDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"createdDate")
            Parser (POSIX -> PlacementDescription)
-> Parser POSIX -> Parser PlacementDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"updatedDate")
      )

instance Prelude.Hashable PlacementDescription

instance Prelude.NFData PlacementDescription