{-# 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.CodeDeploy.Types.EC2TagSet
-- 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.CodeDeploy.Types.EC2TagSet where

import Amazonka.CodeDeploy.Types.EC2TagFilter
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about groups of EC2 instance tags.
--
-- /See:/ 'newEC2TagSet' smart constructor.
data EC2TagSet = EC2TagSet'
  { -- | A list that contains other lists of EC2 instance tag groups. For an
    -- instance to be included in the deployment group, it must be identified
    -- by all of the tag groups in the list.
    EC2TagSet -> Maybe [[EC2TagFilter]]
ec2TagSetList :: Prelude.Maybe [[EC2TagFilter]]
  }
  deriving (EC2TagSet -> EC2TagSet -> Bool
(EC2TagSet -> EC2TagSet -> Bool)
-> (EC2TagSet -> EC2TagSet -> Bool) -> Eq EC2TagSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EC2TagSet -> EC2TagSet -> Bool
$c/= :: EC2TagSet -> EC2TagSet -> Bool
== :: EC2TagSet -> EC2TagSet -> Bool
$c== :: EC2TagSet -> EC2TagSet -> Bool
Prelude.Eq, ReadPrec [EC2TagSet]
ReadPrec EC2TagSet
Int -> ReadS EC2TagSet
ReadS [EC2TagSet]
(Int -> ReadS EC2TagSet)
-> ReadS [EC2TagSet]
-> ReadPrec EC2TagSet
-> ReadPrec [EC2TagSet]
-> Read EC2TagSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EC2TagSet]
$creadListPrec :: ReadPrec [EC2TagSet]
readPrec :: ReadPrec EC2TagSet
$creadPrec :: ReadPrec EC2TagSet
readList :: ReadS [EC2TagSet]
$creadList :: ReadS [EC2TagSet]
readsPrec :: Int -> ReadS EC2TagSet
$creadsPrec :: Int -> ReadS EC2TagSet
Prelude.Read, Int -> EC2TagSet -> ShowS
[EC2TagSet] -> ShowS
EC2TagSet -> String
(Int -> EC2TagSet -> ShowS)
-> (EC2TagSet -> String)
-> ([EC2TagSet] -> ShowS)
-> Show EC2TagSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EC2TagSet] -> ShowS
$cshowList :: [EC2TagSet] -> ShowS
show :: EC2TagSet -> String
$cshow :: EC2TagSet -> String
showsPrec :: Int -> EC2TagSet -> ShowS
$cshowsPrec :: Int -> EC2TagSet -> ShowS
Prelude.Show, (forall x. EC2TagSet -> Rep EC2TagSet x)
-> (forall x. Rep EC2TagSet x -> EC2TagSet) -> Generic EC2TagSet
forall x. Rep EC2TagSet x -> EC2TagSet
forall x. EC2TagSet -> Rep EC2TagSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EC2TagSet x -> EC2TagSet
$cfrom :: forall x. EC2TagSet -> Rep EC2TagSet x
Prelude.Generic)

-- |
-- Create a value of 'EC2TagSet' 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:
--
-- 'ec2TagSetList', 'eC2TagSet_ec2TagSetList' - A list that contains other lists of EC2 instance tag groups. For an
-- instance to be included in the deployment group, it must be identified
-- by all of the tag groups in the list.
newEC2TagSet ::
  EC2TagSet
newEC2TagSet :: EC2TagSet
newEC2TagSet =
  EC2TagSet' :: Maybe [[EC2TagFilter]] -> EC2TagSet
EC2TagSet' {$sel:ec2TagSetList:EC2TagSet' :: Maybe [[EC2TagFilter]]
ec2TagSetList = Maybe [[EC2TagFilter]]
forall a. Maybe a
Prelude.Nothing}

-- | A list that contains other lists of EC2 instance tag groups. For an
-- instance to be included in the deployment group, it must be identified
-- by all of the tag groups in the list.
eC2TagSet_ec2TagSetList :: Lens.Lens' EC2TagSet (Prelude.Maybe [[EC2TagFilter]])
eC2TagSet_ec2TagSetList :: (Maybe [[EC2TagFilter]] -> f (Maybe [[EC2TagFilter]]))
-> EC2TagSet -> f EC2TagSet
eC2TagSet_ec2TagSetList = (EC2TagSet -> Maybe [[EC2TagFilter]])
-> (EC2TagSet -> Maybe [[EC2TagFilter]] -> EC2TagSet)
-> Lens
     EC2TagSet
     EC2TagSet
     (Maybe [[EC2TagFilter]])
     (Maybe [[EC2TagFilter]])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EC2TagSet' {Maybe [[EC2TagFilter]]
ec2TagSetList :: Maybe [[EC2TagFilter]]
$sel:ec2TagSetList:EC2TagSet' :: EC2TagSet -> Maybe [[EC2TagFilter]]
ec2TagSetList} -> Maybe [[EC2TagFilter]]
ec2TagSetList) (\s :: EC2TagSet
s@EC2TagSet' {} Maybe [[EC2TagFilter]]
a -> EC2TagSet
s {$sel:ec2TagSetList:EC2TagSet' :: Maybe [[EC2TagFilter]]
ec2TagSetList = Maybe [[EC2TagFilter]]
a} :: EC2TagSet) ((Maybe [[EC2TagFilter]] -> f (Maybe [[EC2TagFilter]]))
 -> EC2TagSet -> f EC2TagSet)
-> ((Maybe [[EC2TagFilter]] -> f (Maybe [[EC2TagFilter]]))
    -> Maybe [[EC2TagFilter]] -> f (Maybe [[EC2TagFilter]]))
-> (Maybe [[EC2TagFilter]] -> f (Maybe [[EC2TagFilter]]))
-> EC2TagSet
-> f EC2TagSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [[EC2TagFilter]] [[EC2TagFilter]] [[EC2TagFilter]] [[EC2TagFilter]]
-> Iso
     (Maybe [[EC2TagFilter]])
     (Maybe [[EC2TagFilter]])
     (Maybe [[EC2TagFilter]])
     (Maybe [[EC2TagFilter]])
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
  [[EC2TagFilter]] [[EC2TagFilter]] [[EC2TagFilter]] [[EC2TagFilter]]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON EC2TagSet where
  parseJSON :: Value -> Parser EC2TagSet
parseJSON =
    String -> (Object -> Parser EC2TagSet) -> Value -> Parser EC2TagSet
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EC2TagSet"
      ( \Object
x ->
          Maybe [[EC2TagFilter]] -> EC2TagSet
EC2TagSet'
            (Maybe [[EC2TagFilter]] -> EC2TagSet)
-> Parser (Maybe [[EC2TagFilter]]) -> Parser EC2TagSet
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [[EC2TagFilter]]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ec2TagSetList" Parser (Maybe (Maybe [[EC2TagFilter]]))
-> Maybe [[EC2TagFilter]] -> Parser (Maybe [[EC2TagFilter]])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [[EC2TagFilter]]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable EC2TagSet

instance Prelude.NFData EC2TagSet

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