{-# 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.ContainerDistributionConfiguration
-- 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.ContainerDistributionConfiguration where

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

-- | Container distribution settings for encryption, licensing, and sharing
-- in a specific Region.
--
-- /See:/ 'newContainerDistributionConfiguration' smart constructor.
data ContainerDistributionConfiguration = ContainerDistributionConfiguration'
  { -- | Tags that are attached to the container distribution configuration.
    ContainerDistributionConfiguration -> Maybe [Text]
containerTags :: Prelude.Maybe [Prelude.Text],
    -- | The description of the container distribution configuration.
    ContainerDistributionConfiguration -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The destination repository for the container distribution configuration.
    ContainerDistributionConfiguration -> TargetContainerRepository
targetRepository :: TargetContainerRepository
  }
  deriving (ContainerDistributionConfiguration
-> ContainerDistributionConfiguration -> Bool
(ContainerDistributionConfiguration
 -> ContainerDistributionConfiguration -> Bool)
-> (ContainerDistributionConfiguration
    -> ContainerDistributionConfiguration -> Bool)
-> Eq ContainerDistributionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContainerDistributionConfiguration
-> ContainerDistributionConfiguration -> Bool
$c/= :: ContainerDistributionConfiguration
-> ContainerDistributionConfiguration -> Bool
== :: ContainerDistributionConfiguration
-> ContainerDistributionConfiguration -> Bool
$c== :: ContainerDistributionConfiguration
-> ContainerDistributionConfiguration -> Bool
Prelude.Eq, ReadPrec [ContainerDistributionConfiguration]
ReadPrec ContainerDistributionConfiguration
Int -> ReadS ContainerDistributionConfiguration
ReadS [ContainerDistributionConfiguration]
(Int -> ReadS ContainerDistributionConfiguration)
-> ReadS [ContainerDistributionConfiguration]
-> ReadPrec ContainerDistributionConfiguration
-> ReadPrec [ContainerDistributionConfiguration]
-> Read ContainerDistributionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContainerDistributionConfiguration]
$creadListPrec :: ReadPrec [ContainerDistributionConfiguration]
readPrec :: ReadPrec ContainerDistributionConfiguration
$creadPrec :: ReadPrec ContainerDistributionConfiguration
readList :: ReadS [ContainerDistributionConfiguration]
$creadList :: ReadS [ContainerDistributionConfiguration]
readsPrec :: Int -> ReadS ContainerDistributionConfiguration
$creadsPrec :: Int -> ReadS ContainerDistributionConfiguration
Prelude.Read, Int -> ContainerDistributionConfiguration -> ShowS
[ContainerDistributionConfiguration] -> ShowS
ContainerDistributionConfiguration -> String
(Int -> ContainerDistributionConfiguration -> ShowS)
-> (ContainerDistributionConfiguration -> String)
-> ([ContainerDistributionConfiguration] -> ShowS)
-> Show ContainerDistributionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContainerDistributionConfiguration] -> ShowS
$cshowList :: [ContainerDistributionConfiguration] -> ShowS
show :: ContainerDistributionConfiguration -> String
$cshow :: ContainerDistributionConfiguration -> String
showsPrec :: Int -> ContainerDistributionConfiguration -> ShowS
$cshowsPrec :: Int -> ContainerDistributionConfiguration -> ShowS
Prelude.Show, (forall x.
 ContainerDistributionConfiguration
 -> Rep ContainerDistributionConfiguration x)
-> (forall x.
    Rep ContainerDistributionConfiguration x
    -> ContainerDistributionConfiguration)
-> Generic ContainerDistributionConfiguration
forall x.
Rep ContainerDistributionConfiguration x
-> ContainerDistributionConfiguration
forall x.
ContainerDistributionConfiguration
-> Rep ContainerDistributionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ContainerDistributionConfiguration x
-> ContainerDistributionConfiguration
$cfrom :: forall x.
ContainerDistributionConfiguration
-> Rep ContainerDistributionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ContainerDistributionConfiguration' 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:
--
-- 'containerTags', 'containerDistributionConfiguration_containerTags' - Tags that are attached to the container distribution configuration.
--
-- 'description', 'containerDistributionConfiguration_description' - The description of the container distribution configuration.
--
-- 'targetRepository', 'containerDistributionConfiguration_targetRepository' - The destination repository for the container distribution configuration.
newContainerDistributionConfiguration ::
  -- | 'targetRepository'
  TargetContainerRepository ->
  ContainerDistributionConfiguration
newContainerDistributionConfiguration :: TargetContainerRepository -> ContainerDistributionConfiguration
newContainerDistributionConfiguration
  TargetContainerRepository
pTargetRepository_ =
    ContainerDistributionConfiguration' :: Maybe [Text]
-> Maybe Text
-> TargetContainerRepository
-> ContainerDistributionConfiguration
ContainerDistributionConfiguration'
      { $sel:containerTags:ContainerDistributionConfiguration' :: Maybe [Text]
containerTags =
          Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:description:ContainerDistributionConfiguration' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:targetRepository:ContainerDistributionConfiguration' :: TargetContainerRepository
targetRepository = TargetContainerRepository
pTargetRepository_
      }

-- | Tags that are attached to the container distribution configuration.
containerDistributionConfiguration_containerTags :: Lens.Lens' ContainerDistributionConfiguration (Prelude.Maybe [Prelude.Text])
containerDistributionConfiguration_containerTags :: (Maybe [Text] -> f (Maybe [Text]))
-> ContainerDistributionConfiguration
-> f ContainerDistributionConfiguration
containerDistributionConfiguration_containerTags = (ContainerDistributionConfiguration -> Maybe [Text])
-> (ContainerDistributionConfiguration
    -> Maybe [Text] -> ContainerDistributionConfiguration)
-> Lens
     ContainerDistributionConfiguration
     ContainerDistributionConfiguration
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerDistributionConfiguration' {Maybe [Text]
containerTags :: Maybe [Text]
$sel:containerTags:ContainerDistributionConfiguration' :: ContainerDistributionConfiguration -> Maybe [Text]
containerTags} -> Maybe [Text]
containerTags) (\s :: ContainerDistributionConfiguration
s@ContainerDistributionConfiguration' {} Maybe [Text]
a -> ContainerDistributionConfiguration
s {$sel:containerTags:ContainerDistributionConfiguration' :: Maybe [Text]
containerTags = Maybe [Text]
a} :: ContainerDistributionConfiguration) ((Maybe [Text] -> f (Maybe [Text]))
 -> ContainerDistributionConfiguration
 -> f ContainerDistributionConfiguration)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ContainerDistributionConfiguration
-> f ContainerDistributionConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The description of the container distribution configuration.
containerDistributionConfiguration_description :: Lens.Lens' ContainerDistributionConfiguration (Prelude.Maybe Prelude.Text)
containerDistributionConfiguration_description :: (Maybe Text -> f (Maybe Text))
-> ContainerDistributionConfiguration
-> f ContainerDistributionConfiguration
containerDistributionConfiguration_description = (ContainerDistributionConfiguration -> Maybe Text)
-> (ContainerDistributionConfiguration
    -> Maybe Text -> ContainerDistributionConfiguration)
-> Lens
     ContainerDistributionConfiguration
     ContainerDistributionConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerDistributionConfiguration' {Maybe Text
description :: Maybe Text
$sel:description:ContainerDistributionConfiguration' :: ContainerDistributionConfiguration -> Maybe Text
description} -> Maybe Text
description) (\s :: ContainerDistributionConfiguration
s@ContainerDistributionConfiguration' {} Maybe Text
a -> ContainerDistributionConfiguration
s {$sel:description:ContainerDistributionConfiguration' :: Maybe Text
description = Maybe Text
a} :: ContainerDistributionConfiguration)

-- | The destination repository for the container distribution configuration.
containerDistributionConfiguration_targetRepository :: Lens.Lens' ContainerDistributionConfiguration TargetContainerRepository
containerDistributionConfiguration_targetRepository :: (TargetContainerRepository -> f TargetContainerRepository)
-> ContainerDistributionConfiguration
-> f ContainerDistributionConfiguration
containerDistributionConfiguration_targetRepository = (ContainerDistributionConfiguration -> TargetContainerRepository)
-> (ContainerDistributionConfiguration
    -> TargetContainerRepository -> ContainerDistributionConfiguration)
-> Lens
     ContainerDistributionConfiguration
     ContainerDistributionConfiguration
     TargetContainerRepository
     TargetContainerRepository
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerDistributionConfiguration' {TargetContainerRepository
targetRepository :: TargetContainerRepository
$sel:targetRepository:ContainerDistributionConfiguration' :: ContainerDistributionConfiguration -> TargetContainerRepository
targetRepository} -> TargetContainerRepository
targetRepository) (\s :: ContainerDistributionConfiguration
s@ContainerDistributionConfiguration' {} TargetContainerRepository
a -> ContainerDistributionConfiguration
s {$sel:targetRepository:ContainerDistributionConfiguration' :: TargetContainerRepository
targetRepository = TargetContainerRepository
a} :: ContainerDistributionConfiguration)

instance
  Core.FromJSON
    ContainerDistributionConfiguration
  where
  parseJSON :: Value -> Parser ContainerDistributionConfiguration
parseJSON =
    String
-> (Object -> Parser ContainerDistributionConfiguration)
-> Value
-> Parser ContainerDistributionConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContainerDistributionConfiguration"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text
-> TargetContainerRepository
-> ContainerDistributionConfiguration
ContainerDistributionConfiguration'
            (Maybe [Text]
 -> Maybe Text
 -> TargetContainerRepository
 -> ContainerDistributionConfiguration)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Text
      -> TargetContainerRepository -> ContainerDistributionConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"containerTags" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> TargetContainerRepository -> ContainerDistributionConfiguration)
-> Parser (Maybe Text)
-> Parser
     (TargetContainerRepository -> ContainerDistributionConfiguration)
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
"description")
            Parser
  (TargetContainerRepository -> ContainerDistributionConfiguration)
-> Parser TargetContainerRepository
-> Parser ContainerDistributionConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser TargetContainerRepository
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"targetRepository")
      )

instance
  Prelude.Hashable
    ContainerDistributionConfiguration

instance
  Prelude.NFData
    ContainerDistributionConfiguration

instance
  Core.ToJSON
    ContainerDistributionConfiguration
  where
  toJSON :: ContainerDistributionConfiguration -> Value
toJSON ContainerDistributionConfiguration' {Maybe [Text]
Maybe Text
TargetContainerRepository
targetRepository :: TargetContainerRepository
description :: Maybe Text
containerTags :: Maybe [Text]
$sel:targetRepository:ContainerDistributionConfiguration' :: ContainerDistributionConfiguration -> TargetContainerRepository
$sel:description:ContainerDistributionConfiguration' :: ContainerDistributionConfiguration -> Maybe Text
$sel:containerTags:ContainerDistributionConfiguration' :: ContainerDistributionConfiguration -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"containerTags" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
containerTags,
            (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"targetRepository" Text -> TargetContainerRepository -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TargetContainerRepository
targetRepository)
          ]
      )