{-# 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.ImageBuilder.Types.TargetContainerRepository
-- 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.ImageBuilder.Types.TargetContainerRepository where

import qualified Amazonka.Core as Core
import Amazonka.ImageBuilder.Types.ContainerRepositoryService
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The container repository where the output container image is stored.
--
-- /See:/ 'newTargetContainerRepository' smart constructor.
data TargetContainerRepository = TargetContainerRepository'
  { -- | Specifies the service in which this image was registered.
    TargetContainerRepository -> ContainerRepositoryService
service :: ContainerRepositoryService,
    -- | The name of the container repository where the output container image is
    -- stored. This name is prefixed by the repository location.
    TargetContainerRepository -> Text
repositoryName :: Prelude.Text
  }
  deriving (TargetContainerRepository -> TargetContainerRepository -> Bool
(TargetContainerRepository -> TargetContainerRepository -> Bool)
-> (TargetContainerRepository -> TargetContainerRepository -> Bool)
-> Eq TargetContainerRepository
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetContainerRepository -> TargetContainerRepository -> Bool
$c/= :: TargetContainerRepository -> TargetContainerRepository -> Bool
== :: TargetContainerRepository -> TargetContainerRepository -> Bool
$c== :: TargetContainerRepository -> TargetContainerRepository -> Bool
Prelude.Eq, ReadPrec [TargetContainerRepository]
ReadPrec TargetContainerRepository
Int -> ReadS TargetContainerRepository
ReadS [TargetContainerRepository]
(Int -> ReadS TargetContainerRepository)
-> ReadS [TargetContainerRepository]
-> ReadPrec TargetContainerRepository
-> ReadPrec [TargetContainerRepository]
-> Read TargetContainerRepository
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetContainerRepository]
$creadListPrec :: ReadPrec [TargetContainerRepository]
readPrec :: ReadPrec TargetContainerRepository
$creadPrec :: ReadPrec TargetContainerRepository
readList :: ReadS [TargetContainerRepository]
$creadList :: ReadS [TargetContainerRepository]
readsPrec :: Int -> ReadS TargetContainerRepository
$creadsPrec :: Int -> ReadS TargetContainerRepository
Prelude.Read, Int -> TargetContainerRepository -> ShowS
[TargetContainerRepository] -> ShowS
TargetContainerRepository -> String
(Int -> TargetContainerRepository -> ShowS)
-> (TargetContainerRepository -> String)
-> ([TargetContainerRepository] -> ShowS)
-> Show TargetContainerRepository
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetContainerRepository] -> ShowS
$cshowList :: [TargetContainerRepository] -> ShowS
show :: TargetContainerRepository -> String
$cshow :: TargetContainerRepository -> String
showsPrec :: Int -> TargetContainerRepository -> ShowS
$cshowsPrec :: Int -> TargetContainerRepository -> ShowS
Prelude.Show, (forall x.
 TargetContainerRepository -> Rep TargetContainerRepository x)
-> (forall x.
    Rep TargetContainerRepository x -> TargetContainerRepository)
-> Generic TargetContainerRepository
forall x.
Rep TargetContainerRepository x -> TargetContainerRepository
forall x.
TargetContainerRepository -> Rep TargetContainerRepository x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TargetContainerRepository x -> TargetContainerRepository
$cfrom :: forall x.
TargetContainerRepository -> Rep TargetContainerRepository x
Prelude.Generic)

-- |
-- Create a value of 'TargetContainerRepository' 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:
--
-- 'service', 'targetContainerRepository_service' - Specifies the service in which this image was registered.
--
-- 'repositoryName', 'targetContainerRepository_repositoryName' - The name of the container repository where the output container image is
-- stored. This name is prefixed by the repository location.
newTargetContainerRepository ::
  -- | 'service'
  ContainerRepositoryService ->
  -- | 'repositoryName'
  Prelude.Text ->
  TargetContainerRepository
newTargetContainerRepository :: ContainerRepositoryService -> Text -> TargetContainerRepository
newTargetContainerRepository
  ContainerRepositoryService
pService_
  Text
pRepositoryName_ =
    TargetContainerRepository' :: ContainerRepositoryService -> Text -> TargetContainerRepository
TargetContainerRepository'
      { $sel:service:TargetContainerRepository' :: ContainerRepositoryService
service = ContainerRepositoryService
pService_,
        $sel:repositoryName:TargetContainerRepository' :: Text
repositoryName = Text
pRepositoryName_
      }

-- | Specifies the service in which this image was registered.
targetContainerRepository_service :: Lens.Lens' TargetContainerRepository ContainerRepositoryService
targetContainerRepository_service :: (ContainerRepositoryService -> f ContainerRepositoryService)
-> TargetContainerRepository -> f TargetContainerRepository
targetContainerRepository_service = (TargetContainerRepository -> ContainerRepositoryService)
-> (TargetContainerRepository
    -> ContainerRepositoryService -> TargetContainerRepository)
-> Lens
     TargetContainerRepository
     TargetContainerRepository
     ContainerRepositoryService
     ContainerRepositoryService
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetContainerRepository' {ContainerRepositoryService
service :: ContainerRepositoryService
$sel:service:TargetContainerRepository' :: TargetContainerRepository -> ContainerRepositoryService
service} -> ContainerRepositoryService
service) (\s :: TargetContainerRepository
s@TargetContainerRepository' {} ContainerRepositoryService
a -> TargetContainerRepository
s {$sel:service:TargetContainerRepository' :: ContainerRepositoryService
service = ContainerRepositoryService
a} :: TargetContainerRepository)

-- | The name of the container repository where the output container image is
-- stored. This name is prefixed by the repository location.
targetContainerRepository_repositoryName :: Lens.Lens' TargetContainerRepository Prelude.Text
targetContainerRepository_repositoryName :: (Text -> f Text)
-> TargetContainerRepository -> f TargetContainerRepository
targetContainerRepository_repositoryName = (TargetContainerRepository -> Text)
-> (TargetContainerRepository -> Text -> TargetContainerRepository)
-> Lens
     TargetContainerRepository TargetContainerRepository Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetContainerRepository' {Text
repositoryName :: Text
$sel:repositoryName:TargetContainerRepository' :: TargetContainerRepository -> Text
repositoryName} -> Text
repositoryName) (\s :: TargetContainerRepository
s@TargetContainerRepository' {} Text
a -> TargetContainerRepository
s {$sel:repositoryName:TargetContainerRepository' :: Text
repositoryName = Text
a} :: TargetContainerRepository)

instance Core.FromJSON TargetContainerRepository where
  parseJSON :: Value -> Parser TargetContainerRepository
parseJSON =
    String
-> (Object -> Parser TargetContainerRepository)
-> Value
-> Parser TargetContainerRepository
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TargetContainerRepository"
      ( \Object
x ->
          ContainerRepositoryService -> Text -> TargetContainerRepository
TargetContainerRepository'
            (ContainerRepositoryService -> Text -> TargetContainerRepository)
-> Parser ContainerRepositoryService
-> Parser (Text -> TargetContainerRepository)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ContainerRepositoryService
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"service")
            Parser (Text -> TargetContainerRepository)
-> Parser Text -> Parser TargetContainerRepository
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
"repositoryName")
      )

instance Prelude.Hashable TargetContainerRepository

instance Prelude.NFData TargetContainerRepository

instance Core.ToJSON TargetContainerRepository where
  toJSON :: TargetContainerRepository -> Value
toJSON TargetContainerRepository' {Text
ContainerRepositoryService
repositoryName :: Text
service :: ContainerRepositoryService
$sel:repositoryName:TargetContainerRepository' :: TargetContainerRepository -> Text
$sel:service:TargetContainerRepository' :: TargetContainerRepository -> ContainerRepositoryService
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"service" Text -> ContainerRepositoryService -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ContainerRepositoryService
service),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"repositoryName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
repositoryName)
          ]
      )