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

-- | 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 :: Data.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 :: Data.POSIX
  }
  deriving (PlacementDescription -> PlacementDescription -> Bool
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]
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
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. 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'
      { $sel:projectName:PlacementDescription' :: Text
projectName = Text
pProjectName_,
        $sel:placementName:PlacementDescription' :: Text
placementName = Text
pPlacementName_,
        $sel:attributes:PlacementDescription' :: HashMap Text Text
attributes = forall a. Monoid a => a
Prelude.mempty,
        $sel:createdDate:PlacementDescription' :: POSIX
createdDate = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreatedDate_,
        $sel:updatedDate:PlacementDescription' :: POSIX
updatedDate = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time 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 :: Lens' PlacementDescription Text
placementDescription_projectName = 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 :: Lens' PlacementDescription Text
placementDescription_placementName = 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 :: Lens' PlacementDescription (HashMap Text Text)
placementDescription_attributes = 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) 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

-- | The date when the placement was initially created, in UNIX epoch time
-- format.
placementDescription_createdDate :: Lens.Lens' PlacementDescription Prelude.UTCTime
placementDescription_createdDate :: Lens' PlacementDescription UTCTime
placementDescription_createdDate = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._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 :: Lens' PlacementDescription UTCTime
placementDescription_updatedDate = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON PlacementDescription where
  parseJSON :: Value -> Parser PlacementDescription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PlacementDescription"
      ( \Object
x ->
          Text
-> Text
-> HashMap Text Text
-> POSIX
-> POSIX
-> PlacementDescription
PlacementDescription'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"projectName")
            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
"placementName")
            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
"attributes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= 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 -> Parser a
Data..: Key
"createdDate")
            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
"updatedDate")
      )

instance Prelude.Hashable PlacementDescription where
  hashWithSalt :: Int -> PlacementDescription -> Int
hashWithSalt Int
_salt PlacementDescription' {Text
HashMap Text Text
POSIX
updatedDate :: POSIX
createdDate :: POSIX
attributes :: HashMap Text Text
placementName :: Text
projectName :: Text
$sel:updatedDate:PlacementDescription' :: PlacementDescription -> POSIX
$sel:createdDate:PlacementDescription' :: PlacementDescription -> POSIX
$sel:attributes:PlacementDescription' :: PlacementDescription -> HashMap Text Text
$sel:placementName:PlacementDescription' :: PlacementDescription -> Text
$sel:projectName:PlacementDescription' :: PlacementDescription -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
projectName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
placementName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text Text
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
createdDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
updatedDate

instance Prelude.NFData PlacementDescription where
  rnf :: PlacementDescription -> ()
rnf PlacementDescription' {Text
HashMap Text Text
POSIX
updatedDate :: POSIX
createdDate :: POSIX
attributes :: HashMap Text Text
placementName :: Text
projectName :: Text
$sel:updatedDate:PlacementDescription' :: PlacementDescription -> POSIX
$sel:createdDate:PlacementDescription' :: PlacementDescription -> POSIX
$sel:attributes:PlacementDescription' :: PlacementDescription -> HashMap Text Text
$sel:placementName:PlacementDescription' :: PlacementDescription -> Text
$sel:projectName:PlacementDescription' :: PlacementDescription -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
projectName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
placementName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text Text
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
createdDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
updatedDate