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

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

-- | Define and configure the output AMIs of the pipeline.
--
-- /See:/ 'newAmiDistributionConfiguration' smart constructor.
data AmiDistributionConfiguration = AmiDistributionConfiguration'
  { -- | Launch permissions can be used to configure which Amazon Web Services
    -- accounts can use the AMI to launch instances.
    AmiDistributionConfiguration -> Maybe LaunchPermissionConfiguration
launchPermission :: Prelude.Maybe LaunchPermissionConfiguration,
    -- | The ID of an account to which you want to distribute an image.
    AmiDistributionConfiguration -> Maybe (NonEmpty Text)
targetAccountIds :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The tags to apply to AMIs distributed to this Region.
    AmiDistributionConfiguration -> Maybe (HashMap Text Text)
amiTags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the output AMI.
    AmiDistributionConfiguration -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The KMS key identifier used to encrypt the distributed image.
    AmiDistributionConfiguration -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The description of the distribution configuration. Minimum and maximum
    -- length are in characters.
    AmiDistributionConfiguration -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (AmiDistributionConfiguration
-> AmiDistributionConfiguration -> Bool
(AmiDistributionConfiguration
 -> AmiDistributionConfiguration -> Bool)
-> (AmiDistributionConfiguration
    -> AmiDistributionConfiguration -> Bool)
-> Eq AmiDistributionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AmiDistributionConfiguration
-> AmiDistributionConfiguration -> Bool
$c/= :: AmiDistributionConfiguration
-> AmiDistributionConfiguration -> Bool
== :: AmiDistributionConfiguration
-> AmiDistributionConfiguration -> Bool
$c== :: AmiDistributionConfiguration
-> AmiDistributionConfiguration -> Bool
Prelude.Eq, ReadPrec [AmiDistributionConfiguration]
ReadPrec AmiDistributionConfiguration
Int -> ReadS AmiDistributionConfiguration
ReadS [AmiDistributionConfiguration]
(Int -> ReadS AmiDistributionConfiguration)
-> ReadS [AmiDistributionConfiguration]
-> ReadPrec AmiDistributionConfiguration
-> ReadPrec [AmiDistributionConfiguration]
-> Read AmiDistributionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AmiDistributionConfiguration]
$creadListPrec :: ReadPrec [AmiDistributionConfiguration]
readPrec :: ReadPrec AmiDistributionConfiguration
$creadPrec :: ReadPrec AmiDistributionConfiguration
readList :: ReadS [AmiDistributionConfiguration]
$creadList :: ReadS [AmiDistributionConfiguration]
readsPrec :: Int -> ReadS AmiDistributionConfiguration
$creadsPrec :: Int -> ReadS AmiDistributionConfiguration
Prelude.Read, Int -> AmiDistributionConfiguration -> ShowS
[AmiDistributionConfiguration] -> ShowS
AmiDistributionConfiguration -> String
(Int -> AmiDistributionConfiguration -> ShowS)
-> (AmiDistributionConfiguration -> String)
-> ([AmiDistributionConfiguration] -> ShowS)
-> Show AmiDistributionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AmiDistributionConfiguration] -> ShowS
$cshowList :: [AmiDistributionConfiguration] -> ShowS
show :: AmiDistributionConfiguration -> String
$cshow :: AmiDistributionConfiguration -> String
showsPrec :: Int -> AmiDistributionConfiguration -> ShowS
$cshowsPrec :: Int -> AmiDistributionConfiguration -> ShowS
Prelude.Show, (forall x.
 AmiDistributionConfiguration -> Rep AmiDistributionConfiguration x)
-> (forall x.
    Rep AmiDistributionConfiguration x -> AmiDistributionConfiguration)
-> Generic AmiDistributionConfiguration
forall x.
Rep AmiDistributionConfiguration x -> AmiDistributionConfiguration
forall x.
AmiDistributionConfiguration -> Rep AmiDistributionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AmiDistributionConfiguration x -> AmiDistributionConfiguration
$cfrom :: forall x.
AmiDistributionConfiguration -> Rep AmiDistributionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'AmiDistributionConfiguration' 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:
--
-- 'launchPermission', 'amiDistributionConfiguration_launchPermission' - Launch permissions can be used to configure which Amazon Web Services
-- accounts can use the AMI to launch instances.
--
-- 'targetAccountIds', 'amiDistributionConfiguration_targetAccountIds' - The ID of an account to which you want to distribute an image.
--
-- 'amiTags', 'amiDistributionConfiguration_amiTags' - The tags to apply to AMIs distributed to this Region.
--
-- 'name', 'amiDistributionConfiguration_name' - The name of the output AMI.
--
-- 'kmsKeyId', 'amiDistributionConfiguration_kmsKeyId' - The KMS key identifier used to encrypt the distributed image.
--
-- 'description', 'amiDistributionConfiguration_description' - The description of the distribution configuration. Minimum and maximum
-- length are in characters.
newAmiDistributionConfiguration ::
  AmiDistributionConfiguration
newAmiDistributionConfiguration :: AmiDistributionConfiguration
newAmiDistributionConfiguration =
  AmiDistributionConfiguration' :: Maybe LaunchPermissionConfiguration
-> Maybe (NonEmpty Text)
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AmiDistributionConfiguration
AmiDistributionConfiguration'
    { $sel:launchPermission:AmiDistributionConfiguration' :: Maybe LaunchPermissionConfiguration
launchPermission =
        Maybe LaunchPermissionConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:targetAccountIds:AmiDistributionConfiguration' :: Maybe (NonEmpty Text)
targetAccountIds = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:amiTags:AmiDistributionConfiguration' :: Maybe (HashMap Text Text)
amiTags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:AmiDistributionConfiguration' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:AmiDistributionConfiguration' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:AmiDistributionConfiguration' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Launch permissions can be used to configure which Amazon Web Services
-- accounts can use the AMI to launch instances.
amiDistributionConfiguration_launchPermission :: Lens.Lens' AmiDistributionConfiguration (Prelude.Maybe LaunchPermissionConfiguration)
amiDistributionConfiguration_launchPermission :: (Maybe LaunchPermissionConfiguration
 -> f (Maybe LaunchPermissionConfiguration))
-> AmiDistributionConfiguration -> f AmiDistributionConfiguration
amiDistributionConfiguration_launchPermission = (AmiDistributionConfiguration
 -> Maybe LaunchPermissionConfiguration)
-> (AmiDistributionConfiguration
    -> Maybe LaunchPermissionConfiguration
    -> AmiDistributionConfiguration)
-> Lens
     AmiDistributionConfiguration
     AmiDistributionConfiguration
     (Maybe LaunchPermissionConfiguration)
     (Maybe LaunchPermissionConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AmiDistributionConfiguration' {Maybe LaunchPermissionConfiguration
launchPermission :: Maybe LaunchPermissionConfiguration
$sel:launchPermission:AmiDistributionConfiguration' :: AmiDistributionConfiguration -> Maybe LaunchPermissionConfiguration
launchPermission} -> Maybe LaunchPermissionConfiguration
launchPermission) (\s :: AmiDistributionConfiguration
s@AmiDistributionConfiguration' {} Maybe LaunchPermissionConfiguration
a -> AmiDistributionConfiguration
s {$sel:launchPermission:AmiDistributionConfiguration' :: Maybe LaunchPermissionConfiguration
launchPermission = Maybe LaunchPermissionConfiguration
a} :: AmiDistributionConfiguration)

-- | The ID of an account to which you want to distribute an image.
amiDistributionConfiguration_targetAccountIds :: Lens.Lens' AmiDistributionConfiguration (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
amiDistributionConfiguration_targetAccountIds :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> AmiDistributionConfiguration -> f AmiDistributionConfiguration
amiDistributionConfiguration_targetAccountIds = (AmiDistributionConfiguration -> Maybe (NonEmpty Text))
-> (AmiDistributionConfiguration
    -> Maybe (NonEmpty Text) -> AmiDistributionConfiguration)
-> Lens
     AmiDistributionConfiguration
     AmiDistributionConfiguration
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AmiDistributionConfiguration' {Maybe (NonEmpty Text)
targetAccountIds :: Maybe (NonEmpty Text)
$sel:targetAccountIds:AmiDistributionConfiguration' :: AmiDistributionConfiguration -> Maybe (NonEmpty Text)
targetAccountIds} -> Maybe (NonEmpty Text)
targetAccountIds) (\s :: AmiDistributionConfiguration
s@AmiDistributionConfiguration' {} Maybe (NonEmpty Text)
a -> AmiDistributionConfiguration
s {$sel:targetAccountIds:AmiDistributionConfiguration' :: Maybe (NonEmpty Text)
targetAccountIds = Maybe (NonEmpty Text)
a} :: AmiDistributionConfiguration) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> AmiDistributionConfiguration -> f AmiDistributionConfiguration)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> AmiDistributionConfiguration
-> f AmiDistributionConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty 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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The tags to apply to AMIs distributed to this Region.
amiDistributionConfiguration_amiTags :: Lens.Lens' AmiDistributionConfiguration (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
amiDistributionConfiguration_amiTags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> AmiDistributionConfiguration -> f AmiDistributionConfiguration
amiDistributionConfiguration_amiTags = (AmiDistributionConfiguration -> Maybe (HashMap Text Text))
-> (AmiDistributionConfiguration
    -> Maybe (HashMap Text Text) -> AmiDistributionConfiguration)
-> Lens
     AmiDistributionConfiguration
     AmiDistributionConfiguration
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AmiDistributionConfiguration' {Maybe (HashMap Text Text)
amiTags :: Maybe (HashMap Text Text)
$sel:amiTags:AmiDistributionConfiguration' :: AmiDistributionConfiguration -> Maybe (HashMap Text Text)
amiTags} -> Maybe (HashMap Text Text)
amiTags) (\s :: AmiDistributionConfiguration
s@AmiDistributionConfiguration' {} Maybe (HashMap Text Text)
a -> AmiDistributionConfiguration
s {$sel:amiTags:AmiDistributionConfiguration' :: Maybe (HashMap Text Text)
amiTags = Maybe (HashMap Text Text)
a} :: AmiDistributionConfiguration) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> AmiDistributionConfiguration -> f AmiDistributionConfiguration)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> AmiDistributionConfiguration
-> f AmiDistributionConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the output AMI.
amiDistributionConfiguration_name :: Lens.Lens' AmiDistributionConfiguration (Prelude.Maybe Prelude.Text)
amiDistributionConfiguration_name :: (Maybe Text -> f (Maybe Text))
-> AmiDistributionConfiguration -> f AmiDistributionConfiguration
amiDistributionConfiguration_name = (AmiDistributionConfiguration -> Maybe Text)
-> (AmiDistributionConfiguration
    -> Maybe Text -> AmiDistributionConfiguration)
-> Lens
     AmiDistributionConfiguration
     AmiDistributionConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AmiDistributionConfiguration' {Maybe Text
name :: Maybe Text
$sel:name:AmiDistributionConfiguration' :: AmiDistributionConfiguration -> Maybe Text
name} -> Maybe Text
name) (\s :: AmiDistributionConfiguration
s@AmiDistributionConfiguration' {} Maybe Text
a -> AmiDistributionConfiguration
s {$sel:name:AmiDistributionConfiguration' :: Maybe Text
name = Maybe Text
a} :: AmiDistributionConfiguration)

-- | The KMS key identifier used to encrypt the distributed image.
amiDistributionConfiguration_kmsKeyId :: Lens.Lens' AmiDistributionConfiguration (Prelude.Maybe Prelude.Text)
amiDistributionConfiguration_kmsKeyId :: (Maybe Text -> f (Maybe Text))
-> AmiDistributionConfiguration -> f AmiDistributionConfiguration
amiDistributionConfiguration_kmsKeyId = (AmiDistributionConfiguration -> Maybe Text)
-> (AmiDistributionConfiguration
    -> Maybe Text -> AmiDistributionConfiguration)
-> Lens
     AmiDistributionConfiguration
     AmiDistributionConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AmiDistributionConfiguration' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:AmiDistributionConfiguration' :: AmiDistributionConfiguration -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: AmiDistributionConfiguration
s@AmiDistributionConfiguration' {} Maybe Text
a -> AmiDistributionConfiguration
s {$sel:kmsKeyId:AmiDistributionConfiguration' :: Maybe Text
kmsKeyId = Maybe Text
a} :: AmiDistributionConfiguration)

-- | The description of the distribution configuration. Minimum and maximum
-- length are in characters.
amiDistributionConfiguration_description :: Lens.Lens' AmiDistributionConfiguration (Prelude.Maybe Prelude.Text)
amiDistributionConfiguration_description :: (Maybe Text -> f (Maybe Text))
-> AmiDistributionConfiguration -> f AmiDistributionConfiguration
amiDistributionConfiguration_description = (AmiDistributionConfiguration -> Maybe Text)
-> (AmiDistributionConfiguration
    -> Maybe Text -> AmiDistributionConfiguration)
-> Lens
     AmiDistributionConfiguration
     AmiDistributionConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AmiDistributionConfiguration' {Maybe Text
description :: Maybe Text
$sel:description:AmiDistributionConfiguration' :: AmiDistributionConfiguration -> Maybe Text
description} -> Maybe Text
description) (\s :: AmiDistributionConfiguration
s@AmiDistributionConfiguration' {} Maybe Text
a -> AmiDistributionConfiguration
s {$sel:description:AmiDistributionConfiguration' :: Maybe Text
description = Maybe Text
a} :: AmiDistributionConfiguration)

instance Core.FromJSON AmiDistributionConfiguration where
  parseJSON :: Value -> Parser AmiDistributionConfiguration
parseJSON =
    String
-> (Object -> Parser AmiDistributionConfiguration)
-> Value
-> Parser AmiDistributionConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AmiDistributionConfiguration"
      ( \Object
x ->
          Maybe LaunchPermissionConfiguration
-> Maybe (NonEmpty Text)
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> AmiDistributionConfiguration
AmiDistributionConfiguration'
            (Maybe LaunchPermissionConfiguration
 -> Maybe (NonEmpty Text)
 -> Maybe (HashMap Text Text)
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> AmiDistributionConfiguration)
-> Parser (Maybe LaunchPermissionConfiguration)
-> Parser
     (Maybe (NonEmpty Text)
      -> Maybe (HashMap Text Text)
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> AmiDistributionConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe LaunchPermissionConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"launchPermission")
            Parser
  (Maybe (NonEmpty Text)
   -> Maybe (HashMap Text Text)
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> AmiDistributionConfiguration)
-> Parser (Maybe (NonEmpty Text))
-> Parser
     (Maybe (HashMap Text Text)
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> AmiDistributionConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"targetAccountIds")
            Parser
  (Maybe (HashMap Text Text)
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> AmiDistributionConfiguration)
-> Parser (Maybe (HashMap Text Text))
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> AmiDistributionConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"amiTags" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> AmiDistributionConfiguration)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> AmiDistributionConfiguration)
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
"name")
            Parser (Maybe Text -> Maybe Text -> AmiDistributionConfiguration)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AmiDistributionConfiguration)
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
"kmsKeyId")
            Parser (Maybe Text -> AmiDistributionConfiguration)
-> Parser (Maybe Text) -> Parser AmiDistributionConfiguration
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")
      )

instance
  Prelude.Hashable
    AmiDistributionConfiguration

instance Prelude.NFData AmiDistributionConfiguration

instance Core.ToJSON AmiDistributionConfiguration where
  toJSON :: AmiDistributionConfiguration -> Value
toJSON AmiDistributionConfiguration' {Maybe (NonEmpty Text)
Maybe Text
Maybe (HashMap Text Text)
Maybe LaunchPermissionConfiguration
description :: Maybe Text
kmsKeyId :: Maybe Text
name :: Maybe Text
amiTags :: Maybe (HashMap Text Text)
targetAccountIds :: Maybe (NonEmpty Text)
launchPermission :: Maybe LaunchPermissionConfiguration
$sel:description:AmiDistributionConfiguration' :: AmiDistributionConfiguration -> Maybe Text
$sel:kmsKeyId:AmiDistributionConfiguration' :: AmiDistributionConfiguration -> Maybe Text
$sel:name:AmiDistributionConfiguration' :: AmiDistributionConfiguration -> Maybe Text
$sel:amiTags:AmiDistributionConfiguration' :: AmiDistributionConfiguration -> Maybe (HashMap Text Text)
$sel:targetAccountIds:AmiDistributionConfiguration' :: AmiDistributionConfiguration -> Maybe (NonEmpty Text)
$sel:launchPermission:AmiDistributionConfiguration' :: AmiDistributionConfiguration -> Maybe LaunchPermissionConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"launchPermission" Text -> LaunchPermissionConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (LaunchPermissionConfiguration -> Pair)
-> Maybe LaunchPermissionConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LaunchPermissionConfiguration
launchPermission,
            (Text
"targetAccountIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
targetAccountIds,
            (Text
"amiTags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
amiTags,
            (Text
"name" 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
name,
            (Text
"kmsKeyId" 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
kmsKeyId,
            (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
          ]
      )