{-# 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.AppRunner.Types.ImageRepository
-- 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.AppRunner.Types.ImageRepository where

import Amazonka.AppRunner.Types.ImageConfiguration
import Amazonka.AppRunner.Types.ImageRepositoryType
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

-- | Describes a source image repository.
--
-- /See:/ 'newImageRepository' smart constructor.
data ImageRepository = ImageRepository'
  { -- | Configuration for running the identified image.
    ImageRepository -> Maybe ImageConfiguration
imageConfiguration :: Prelude.Maybe ImageConfiguration,
    -- | The identifier of an image.
    --
    -- For an image in Amazon Elastic Container Registry (Amazon ECR), this is
    -- an image name. For the image name format, see
    -- <https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-pull-ecr-image.html Pulling an image>
    -- in the /Amazon ECR User Guide/.
    ImageRepository -> Text
imageIdentifier :: Prelude.Text,
    -- | The type of the image repository. This reflects the repository provider
    -- and whether the repository is private or public.
    ImageRepository -> ImageRepositoryType
imageRepositoryType :: ImageRepositoryType
  }
  deriving (ImageRepository -> ImageRepository -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageRepository -> ImageRepository -> Bool
$c/= :: ImageRepository -> ImageRepository -> Bool
== :: ImageRepository -> ImageRepository -> Bool
$c== :: ImageRepository -> ImageRepository -> Bool
Prelude.Eq, Int -> ImageRepository -> ShowS
[ImageRepository] -> ShowS
ImageRepository -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageRepository] -> ShowS
$cshowList :: [ImageRepository] -> ShowS
show :: ImageRepository -> String
$cshow :: ImageRepository -> String
showsPrec :: Int -> ImageRepository -> ShowS
$cshowsPrec :: Int -> ImageRepository -> ShowS
Prelude.Show, forall x. Rep ImageRepository x -> ImageRepository
forall x. ImageRepository -> Rep ImageRepository x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImageRepository x -> ImageRepository
$cfrom :: forall x. ImageRepository -> Rep ImageRepository x
Prelude.Generic)

-- |
-- Create a value of 'ImageRepository' 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:
--
-- 'imageConfiguration', 'imageRepository_imageConfiguration' - Configuration for running the identified image.
--
-- 'imageIdentifier', 'imageRepository_imageIdentifier' - The identifier of an image.
--
-- For an image in Amazon Elastic Container Registry (Amazon ECR), this is
-- an image name. For the image name format, see
-- <https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-pull-ecr-image.html Pulling an image>
-- in the /Amazon ECR User Guide/.
--
-- 'imageRepositoryType', 'imageRepository_imageRepositoryType' - The type of the image repository. This reflects the repository provider
-- and whether the repository is private or public.
newImageRepository ::
  -- | 'imageIdentifier'
  Prelude.Text ->
  -- | 'imageRepositoryType'
  ImageRepositoryType ->
  ImageRepository
newImageRepository :: Text -> ImageRepositoryType -> ImageRepository
newImageRepository
  Text
pImageIdentifier_
  ImageRepositoryType
pImageRepositoryType_ =
    ImageRepository'
      { $sel:imageConfiguration:ImageRepository' :: Maybe ImageConfiguration
imageConfiguration =
          forall a. Maybe a
Prelude.Nothing,
        $sel:imageIdentifier:ImageRepository' :: Text
imageIdentifier = Text
pImageIdentifier_,
        $sel:imageRepositoryType:ImageRepository' :: ImageRepositoryType
imageRepositoryType = ImageRepositoryType
pImageRepositoryType_
      }

-- | Configuration for running the identified image.
imageRepository_imageConfiguration :: Lens.Lens' ImageRepository (Prelude.Maybe ImageConfiguration)
imageRepository_imageConfiguration :: Lens' ImageRepository (Maybe ImageConfiguration)
imageRepository_imageConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageRepository' {Maybe ImageConfiguration
imageConfiguration :: Maybe ImageConfiguration
$sel:imageConfiguration:ImageRepository' :: ImageRepository -> Maybe ImageConfiguration
imageConfiguration} -> Maybe ImageConfiguration
imageConfiguration) (\s :: ImageRepository
s@ImageRepository' {} Maybe ImageConfiguration
a -> ImageRepository
s {$sel:imageConfiguration:ImageRepository' :: Maybe ImageConfiguration
imageConfiguration = Maybe ImageConfiguration
a} :: ImageRepository)

-- | The identifier of an image.
--
-- For an image in Amazon Elastic Container Registry (Amazon ECR), this is
-- an image name. For the image name format, see
-- <https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-pull-ecr-image.html Pulling an image>
-- in the /Amazon ECR User Guide/.
imageRepository_imageIdentifier :: Lens.Lens' ImageRepository Prelude.Text
imageRepository_imageIdentifier :: Lens' ImageRepository Text
imageRepository_imageIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageRepository' {Text
imageIdentifier :: Text
$sel:imageIdentifier:ImageRepository' :: ImageRepository -> Text
imageIdentifier} -> Text
imageIdentifier) (\s :: ImageRepository
s@ImageRepository' {} Text
a -> ImageRepository
s {$sel:imageIdentifier:ImageRepository' :: Text
imageIdentifier = Text
a} :: ImageRepository)

-- | The type of the image repository. This reflects the repository provider
-- and whether the repository is private or public.
imageRepository_imageRepositoryType :: Lens.Lens' ImageRepository ImageRepositoryType
imageRepository_imageRepositoryType :: Lens' ImageRepository ImageRepositoryType
imageRepository_imageRepositoryType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageRepository' {ImageRepositoryType
imageRepositoryType :: ImageRepositoryType
$sel:imageRepositoryType:ImageRepository' :: ImageRepository -> ImageRepositoryType
imageRepositoryType} -> ImageRepositoryType
imageRepositoryType) (\s :: ImageRepository
s@ImageRepository' {} ImageRepositoryType
a -> ImageRepository
s {$sel:imageRepositoryType:ImageRepository' :: ImageRepositoryType
imageRepositoryType = ImageRepositoryType
a} :: ImageRepository)

instance Data.FromJSON ImageRepository where
  parseJSON :: Value -> Parser ImageRepository
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ImageRepository"
      ( \Object
x ->
          Maybe ImageConfiguration
-> Text -> ImageRepositoryType -> ImageRepository
ImageRepository'
            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
"ImageConfiguration")
            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
"ImageIdentifier")
            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
"ImageRepositoryType")
      )

instance Prelude.Hashable ImageRepository where
  hashWithSalt :: Int -> ImageRepository -> Int
hashWithSalt Int
_salt ImageRepository' {Maybe ImageConfiguration
Text
ImageRepositoryType
imageRepositoryType :: ImageRepositoryType
imageIdentifier :: Text
imageConfiguration :: Maybe ImageConfiguration
$sel:imageRepositoryType:ImageRepository' :: ImageRepository -> ImageRepositoryType
$sel:imageIdentifier:ImageRepository' :: ImageRepository -> Text
$sel:imageConfiguration:ImageRepository' :: ImageRepository -> Maybe ImageConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ImageConfiguration
imageConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
imageIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ImageRepositoryType
imageRepositoryType

instance Prelude.NFData ImageRepository where
  rnf :: ImageRepository -> ()
rnf ImageRepository' {Maybe ImageConfiguration
Text
ImageRepositoryType
imageRepositoryType :: ImageRepositoryType
imageIdentifier :: Text
imageConfiguration :: Maybe ImageConfiguration
$sel:imageRepositoryType:ImageRepository' :: ImageRepository -> ImageRepositoryType
$sel:imageIdentifier:ImageRepository' :: ImageRepository -> Text
$sel:imageConfiguration:ImageRepository' :: ImageRepository -> Maybe ImageConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ImageConfiguration
imageConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
imageIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ImageRepositoryType
imageRepositoryType

instance Data.ToJSON ImageRepository where
  toJSON :: ImageRepository -> Value
toJSON ImageRepository' {Maybe ImageConfiguration
Text
ImageRepositoryType
imageRepositoryType :: ImageRepositoryType
imageIdentifier :: Text
imageConfiguration :: Maybe ImageConfiguration
$sel:imageRepositoryType:ImageRepository' :: ImageRepository -> ImageRepositoryType
$sel:imageIdentifier:ImageRepository' :: ImageRepository -> Text
$sel:imageConfiguration:ImageRepository' :: ImageRepository -> Maybe ImageConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ImageConfiguration" 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 ImageConfiguration
imageConfiguration,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ImageIdentifier" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
imageIdentifier),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ImageRepositoryType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ImageRepositoryType
imageRepositoryType)
          ]
      )