{-# 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.Lightsail.Types.ContainerImage
-- 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.Lightsail.Types.ContainerImage where

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

-- | Describes a container image that is registered to an Amazon Lightsail
-- container service.
--
-- /See:/ 'newContainerImage' smart constructor.
data ContainerImage = ContainerImage'
  { -- | The name of the container image.
    ContainerImage -> Maybe Text
image :: Prelude.Maybe Prelude.Text,
    -- | The timestamp when the container image was created.
    ContainerImage -> Maybe POSIX
createdAt :: Prelude.Maybe Core.POSIX,
    -- | The digest of the container image.
    ContainerImage -> Maybe Text
digest :: Prelude.Maybe Prelude.Text
  }
  deriving (ContainerImage -> ContainerImage -> Bool
(ContainerImage -> ContainerImage -> Bool)
-> (ContainerImage -> ContainerImage -> Bool) -> Eq ContainerImage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContainerImage -> ContainerImage -> Bool
$c/= :: ContainerImage -> ContainerImage -> Bool
== :: ContainerImage -> ContainerImage -> Bool
$c== :: ContainerImage -> ContainerImage -> Bool
Prelude.Eq, ReadPrec [ContainerImage]
ReadPrec ContainerImage
Int -> ReadS ContainerImage
ReadS [ContainerImage]
(Int -> ReadS ContainerImage)
-> ReadS [ContainerImage]
-> ReadPrec ContainerImage
-> ReadPrec [ContainerImage]
-> Read ContainerImage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContainerImage]
$creadListPrec :: ReadPrec [ContainerImage]
readPrec :: ReadPrec ContainerImage
$creadPrec :: ReadPrec ContainerImage
readList :: ReadS [ContainerImage]
$creadList :: ReadS [ContainerImage]
readsPrec :: Int -> ReadS ContainerImage
$creadsPrec :: Int -> ReadS ContainerImage
Prelude.Read, Int -> ContainerImage -> ShowS
[ContainerImage] -> ShowS
ContainerImage -> String
(Int -> ContainerImage -> ShowS)
-> (ContainerImage -> String)
-> ([ContainerImage] -> ShowS)
-> Show ContainerImage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContainerImage] -> ShowS
$cshowList :: [ContainerImage] -> ShowS
show :: ContainerImage -> String
$cshow :: ContainerImage -> String
showsPrec :: Int -> ContainerImage -> ShowS
$cshowsPrec :: Int -> ContainerImage -> ShowS
Prelude.Show, (forall x. ContainerImage -> Rep ContainerImage x)
-> (forall x. Rep ContainerImage x -> ContainerImage)
-> Generic ContainerImage
forall x. Rep ContainerImage x -> ContainerImage
forall x. ContainerImage -> Rep ContainerImage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContainerImage x -> ContainerImage
$cfrom :: forall x. ContainerImage -> Rep ContainerImage x
Prelude.Generic)

-- |
-- Create a value of 'ContainerImage' 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:
--
-- 'image', 'containerImage_image' - The name of the container image.
--
-- 'createdAt', 'containerImage_createdAt' - The timestamp when the container image was created.
--
-- 'digest', 'containerImage_digest' - The digest of the container image.
newContainerImage ::
  ContainerImage
newContainerImage :: ContainerImage
newContainerImage =
  ContainerImage' :: Maybe Text -> Maybe POSIX -> Maybe Text -> ContainerImage
ContainerImage'
    { $sel:image:ContainerImage' :: Maybe Text
image = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:ContainerImage' :: Maybe POSIX
createdAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:digest:ContainerImage' :: Maybe Text
digest = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the container image.
containerImage_image :: Lens.Lens' ContainerImage (Prelude.Maybe Prelude.Text)
containerImage_image :: (Maybe Text -> f (Maybe Text))
-> ContainerImage -> f ContainerImage
containerImage_image = (ContainerImage -> Maybe Text)
-> (ContainerImage -> Maybe Text -> ContainerImage)
-> Lens ContainerImage ContainerImage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerImage' {Maybe Text
image :: Maybe Text
$sel:image:ContainerImage' :: ContainerImage -> Maybe Text
image} -> Maybe Text
image) (\s :: ContainerImage
s@ContainerImage' {} Maybe Text
a -> ContainerImage
s {$sel:image:ContainerImage' :: Maybe Text
image = Maybe Text
a} :: ContainerImage)

-- | The timestamp when the container image was created.
containerImage_createdAt :: Lens.Lens' ContainerImage (Prelude.Maybe Prelude.UTCTime)
containerImage_createdAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ContainerImage -> f ContainerImage
containerImage_createdAt = (ContainerImage -> Maybe POSIX)
-> (ContainerImage -> Maybe POSIX -> ContainerImage)
-> Lens ContainerImage ContainerImage (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerImage' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:ContainerImage' :: ContainerImage -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: ContainerImage
s@ContainerImage' {} Maybe POSIX
a -> ContainerImage
s {$sel:createdAt:ContainerImage' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: ContainerImage) ((Maybe POSIX -> f (Maybe POSIX))
 -> ContainerImage -> f ContainerImage)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ContainerImage
-> f ContainerImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The digest of the container image.
containerImage_digest :: Lens.Lens' ContainerImage (Prelude.Maybe Prelude.Text)
containerImage_digest :: (Maybe Text -> f (Maybe Text))
-> ContainerImage -> f ContainerImage
containerImage_digest = (ContainerImage -> Maybe Text)
-> (ContainerImage -> Maybe Text -> ContainerImage)
-> Lens ContainerImage ContainerImage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerImage' {Maybe Text
digest :: Maybe Text
$sel:digest:ContainerImage' :: ContainerImage -> Maybe Text
digest} -> Maybe Text
digest) (\s :: ContainerImage
s@ContainerImage' {} Maybe Text
a -> ContainerImage
s {$sel:digest:ContainerImage' :: Maybe Text
digest = Maybe Text
a} :: ContainerImage)

instance Core.FromJSON ContainerImage where
  parseJSON :: Value -> Parser ContainerImage
parseJSON =
    String
-> (Object -> Parser ContainerImage)
-> Value
-> Parser ContainerImage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContainerImage"
      ( \Object
x ->
          Maybe Text -> Maybe POSIX -> Maybe Text -> ContainerImage
ContainerImage'
            (Maybe Text -> Maybe POSIX -> Maybe Text -> ContainerImage)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> ContainerImage)
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
"image")
            Parser (Maybe POSIX -> Maybe Text -> ContainerImage)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> ContainerImage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"createdAt")
            Parser (Maybe Text -> ContainerImage)
-> Parser (Maybe Text) -> Parser ContainerImage
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
"digest")
      )

instance Prelude.Hashable ContainerImage

instance Prelude.NFData ContainerImage