{-# 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.ECR.Types.Image
-- 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.ECR.Types.Image where

import qualified Amazonka.Core as Core
import Amazonka.ECR.Types.ImageIdentifier
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object representing an Amazon ECR image.
--
-- /See:/ 'newImage' smart constructor.
data Image = Image'
  { -- | The Amazon Web Services account ID associated with the registry
    -- containing the image.
    Image -> Maybe Text
registryId :: Prelude.Maybe Prelude.Text,
    -- | The manifest media type of the image.
    Image -> Maybe Text
imageManifestMediaType :: Prelude.Maybe Prelude.Text,
    -- | An object containing the image tag and image digest associated with an
    -- image.
    Image -> Maybe ImageIdentifier
imageId :: Prelude.Maybe ImageIdentifier,
    -- | The name of the repository associated with the image.
    Image -> Maybe Text
repositoryName :: Prelude.Maybe Prelude.Text,
    -- | The image manifest associated with the image.
    Image -> Maybe Text
imageManifest :: Prelude.Maybe Prelude.Text
  }
  deriving (Image -> Image -> Bool
(Image -> Image -> Bool) -> (Image -> Image -> Bool) -> Eq Image
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Image -> Image -> Bool
$c/= :: Image -> Image -> Bool
== :: Image -> Image -> Bool
$c== :: Image -> Image -> Bool
Prelude.Eq, ReadPrec [Image]
ReadPrec Image
Int -> ReadS Image
ReadS [Image]
(Int -> ReadS Image)
-> ReadS [Image]
-> ReadPrec Image
-> ReadPrec [Image]
-> Read Image
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Image]
$creadListPrec :: ReadPrec [Image]
readPrec :: ReadPrec Image
$creadPrec :: ReadPrec Image
readList :: ReadS [Image]
$creadList :: ReadS [Image]
readsPrec :: Int -> ReadS Image
$creadsPrec :: Int -> ReadS Image
Prelude.Read, Int -> Image -> ShowS
[Image] -> ShowS
Image -> String
(Int -> Image -> ShowS)
-> (Image -> String) -> ([Image] -> ShowS) -> Show Image
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Image] -> ShowS
$cshowList :: [Image] -> ShowS
show :: Image -> String
$cshow :: Image -> String
showsPrec :: Int -> Image -> ShowS
$cshowsPrec :: Int -> Image -> ShowS
Prelude.Show, (forall x. Image -> Rep Image x)
-> (forall x. Rep Image x -> Image) -> Generic Image
forall x. Rep Image x -> Image
forall x. Image -> Rep Image x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Image x -> Image
$cfrom :: forall x. Image -> Rep Image x
Prelude.Generic)

-- |
-- Create a value of 'Image' 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:
--
-- 'registryId', 'image_registryId' - The Amazon Web Services account ID associated with the registry
-- containing the image.
--
-- 'imageManifestMediaType', 'image_imageManifestMediaType' - The manifest media type of the image.
--
-- 'imageId', 'image_imageId' - An object containing the image tag and image digest associated with an
-- image.
--
-- 'repositoryName', 'image_repositoryName' - The name of the repository associated with the image.
--
-- 'imageManifest', 'image_imageManifest' - The image manifest associated with the image.
newImage ::
  Image
newImage :: Image
newImage =
  Image' :: Maybe Text
-> Maybe Text
-> Maybe ImageIdentifier
-> Maybe Text
-> Maybe Text
-> Image
Image'
    { $sel:registryId:Image' :: Maybe Text
registryId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:imageManifestMediaType:Image' :: Maybe Text
imageManifestMediaType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:imageId:Image' :: Maybe ImageIdentifier
imageId = Maybe ImageIdentifier
forall a. Maybe a
Prelude.Nothing,
      $sel:repositoryName:Image' :: Maybe Text
repositoryName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:imageManifest:Image' :: Maybe Text
imageManifest = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Web Services account ID associated with the registry
-- containing the image.
image_registryId :: Lens.Lens' Image (Prelude.Maybe Prelude.Text)
image_registryId :: (Maybe Text -> f (Maybe Text)) -> Image -> f Image
image_registryId = (Image -> Maybe Text)
-> (Image -> Maybe Text -> Image)
-> Lens Image Image (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Image' {Maybe Text
registryId :: Maybe Text
$sel:registryId:Image' :: Image -> Maybe Text
registryId} -> Maybe Text
registryId) (\s :: Image
s@Image' {} Maybe Text
a -> Image
s {$sel:registryId:Image' :: Maybe Text
registryId = Maybe Text
a} :: Image)

-- | The manifest media type of the image.
image_imageManifestMediaType :: Lens.Lens' Image (Prelude.Maybe Prelude.Text)
image_imageManifestMediaType :: (Maybe Text -> f (Maybe Text)) -> Image -> f Image
image_imageManifestMediaType = (Image -> Maybe Text)
-> (Image -> Maybe Text -> Image)
-> Lens Image Image (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Image' {Maybe Text
imageManifestMediaType :: Maybe Text
$sel:imageManifestMediaType:Image' :: Image -> Maybe Text
imageManifestMediaType} -> Maybe Text
imageManifestMediaType) (\s :: Image
s@Image' {} Maybe Text
a -> Image
s {$sel:imageManifestMediaType:Image' :: Maybe Text
imageManifestMediaType = Maybe Text
a} :: Image)

-- | An object containing the image tag and image digest associated with an
-- image.
image_imageId :: Lens.Lens' Image (Prelude.Maybe ImageIdentifier)
image_imageId :: (Maybe ImageIdentifier -> f (Maybe ImageIdentifier))
-> Image -> f Image
image_imageId = (Image -> Maybe ImageIdentifier)
-> (Image -> Maybe ImageIdentifier -> Image)
-> Lens Image Image (Maybe ImageIdentifier) (Maybe ImageIdentifier)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Image' {Maybe ImageIdentifier
imageId :: Maybe ImageIdentifier
$sel:imageId:Image' :: Image -> Maybe ImageIdentifier
imageId} -> Maybe ImageIdentifier
imageId) (\s :: Image
s@Image' {} Maybe ImageIdentifier
a -> Image
s {$sel:imageId:Image' :: Maybe ImageIdentifier
imageId = Maybe ImageIdentifier
a} :: Image)

-- | The name of the repository associated with the image.
image_repositoryName :: Lens.Lens' Image (Prelude.Maybe Prelude.Text)
image_repositoryName :: (Maybe Text -> f (Maybe Text)) -> Image -> f Image
image_repositoryName = (Image -> Maybe Text)
-> (Image -> Maybe Text -> Image)
-> Lens Image Image (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Image' {Maybe Text
repositoryName :: Maybe Text
$sel:repositoryName:Image' :: Image -> Maybe Text
repositoryName} -> Maybe Text
repositoryName) (\s :: Image
s@Image' {} Maybe Text
a -> Image
s {$sel:repositoryName:Image' :: Maybe Text
repositoryName = Maybe Text
a} :: Image)

-- | The image manifest associated with the image.
image_imageManifest :: Lens.Lens' Image (Prelude.Maybe Prelude.Text)
image_imageManifest :: (Maybe Text -> f (Maybe Text)) -> Image -> f Image
image_imageManifest = (Image -> Maybe Text)
-> (Image -> Maybe Text -> Image)
-> Lens Image Image (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Image' {Maybe Text
imageManifest :: Maybe Text
$sel:imageManifest:Image' :: Image -> Maybe Text
imageManifest} -> Maybe Text
imageManifest) (\s :: Image
s@Image' {} Maybe Text
a -> Image
s {$sel:imageManifest:Image' :: Maybe Text
imageManifest = Maybe Text
a} :: Image)

instance Core.FromJSON Image where
  parseJSON :: Value -> Parser Image
parseJSON =
    String -> (Object -> Parser Image) -> Value -> Parser Image
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Image"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe ImageIdentifier
-> Maybe Text
-> Maybe Text
-> Image
Image'
            (Maybe Text
 -> Maybe Text
 -> Maybe ImageIdentifier
 -> Maybe Text
 -> Maybe Text
 -> Image)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe ImageIdentifier -> Maybe Text -> Maybe Text -> Image)
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
"registryId")
            Parser
  (Maybe Text
   -> Maybe ImageIdentifier -> Maybe Text -> Maybe Text -> Image)
-> Parser (Maybe Text)
-> Parser
     (Maybe ImageIdentifier -> Maybe Text -> Maybe Text -> Image)
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
"imageManifestMediaType")
            Parser (Maybe ImageIdentifier -> Maybe Text -> Maybe Text -> Image)
-> Parser (Maybe ImageIdentifier)
-> Parser (Maybe Text -> Maybe Text -> Image)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ImageIdentifier)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"imageId")
            Parser (Maybe Text -> Maybe Text -> Image)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Image)
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
"repositoryName")
            Parser (Maybe Text -> Image) -> Parser (Maybe Text) -> Parser Image
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
"imageManifest")
      )

instance Prelude.Hashable Image

instance Prelude.NFData Image