{-# 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.ResourceGroupsTagging.Types.ResourceTagMapping
-- 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.ResourceGroupsTagging.Types.ResourceTagMapping where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.ResourceGroupsTagging.Types.ComplianceDetails
import Amazonka.ResourceGroupsTagging.Types.Tag

-- | A list of resource ARNs and the tags (keys and values) that are
-- associated with each.
--
-- /See:/ 'newResourceTagMapping' smart constructor.
data ResourceTagMapping = ResourceTagMapping'
  { -- | Information that shows whether a resource is compliant with the
    -- effective tag policy, including details on any noncompliant tag keys.
    ResourceTagMapping -> Maybe ComplianceDetails
complianceDetails :: Prelude.Maybe ComplianceDetails,
    -- | The ARN of the resource.
    ResourceTagMapping -> Maybe Text
resourceARN :: Prelude.Maybe Prelude.Text,
    -- | The tags that have been applied to one or more AWS resources.
    ResourceTagMapping -> Maybe [Tag]
tags :: Prelude.Maybe [Tag]
  }
  deriving (ResourceTagMapping -> ResourceTagMapping -> Bool
(ResourceTagMapping -> ResourceTagMapping -> Bool)
-> (ResourceTagMapping -> ResourceTagMapping -> Bool)
-> Eq ResourceTagMapping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceTagMapping -> ResourceTagMapping -> Bool
$c/= :: ResourceTagMapping -> ResourceTagMapping -> Bool
== :: ResourceTagMapping -> ResourceTagMapping -> Bool
$c== :: ResourceTagMapping -> ResourceTagMapping -> Bool
Prelude.Eq, ReadPrec [ResourceTagMapping]
ReadPrec ResourceTagMapping
Int -> ReadS ResourceTagMapping
ReadS [ResourceTagMapping]
(Int -> ReadS ResourceTagMapping)
-> ReadS [ResourceTagMapping]
-> ReadPrec ResourceTagMapping
-> ReadPrec [ResourceTagMapping]
-> Read ResourceTagMapping
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceTagMapping]
$creadListPrec :: ReadPrec [ResourceTagMapping]
readPrec :: ReadPrec ResourceTagMapping
$creadPrec :: ReadPrec ResourceTagMapping
readList :: ReadS [ResourceTagMapping]
$creadList :: ReadS [ResourceTagMapping]
readsPrec :: Int -> ReadS ResourceTagMapping
$creadsPrec :: Int -> ReadS ResourceTagMapping
Prelude.Read, Int -> ResourceTagMapping -> ShowS
[ResourceTagMapping] -> ShowS
ResourceTagMapping -> String
(Int -> ResourceTagMapping -> ShowS)
-> (ResourceTagMapping -> String)
-> ([ResourceTagMapping] -> ShowS)
-> Show ResourceTagMapping
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceTagMapping] -> ShowS
$cshowList :: [ResourceTagMapping] -> ShowS
show :: ResourceTagMapping -> String
$cshow :: ResourceTagMapping -> String
showsPrec :: Int -> ResourceTagMapping -> ShowS
$cshowsPrec :: Int -> ResourceTagMapping -> ShowS
Prelude.Show, (forall x. ResourceTagMapping -> Rep ResourceTagMapping x)
-> (forall x. Rep ResourceTagMapping x -> ResourceTagMapping)
-> Generic ResourceTagMapping
forall x. Rep ResourceTagMapping x -> ResourceTagMapping
forall x. ResourceTagMapping -> Rep ResourceTagMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceTagMapping x -> ResourceTagMapping
$cfrom :: forall x. ResourceTagMapping -> Rep ResourceTagMapping x
Prelude.Generic)

-- |
-- Create a value of 'ResourceTagMapping' 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:
--
-- 'complianceDetails', 'resourceTagMapping_complianceDetails' - Information that shows whether a resource is compliant with the
-- effective tag policy, including details on any noncompliant tag keys.
--
-- 'resourceARN', 'resourceTagMapping_resourceARN' - The ARN of the resource.
--
-- 'tags', 'resourceTagMapping_tags' - The tags that have been applied to one or more AWS resources.
newResourceTagMapping ::
  ResourceTagMapping
newResourceTagMapping :: ResourceTagMapping
newResourceTagMapping =
  ResourceTagMapping' :: Maybe ComplianceDetails
-> Maybe Text -> Maybe [Tag] -> ResourceTagMapping
ResourceTagMapping'
    { $sel:complianceDetails:ResourceTagMapping' :: Maybe ComplianceDetails
complianceDetails =
        Maybe ComplianceDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceARN:ResourceTagMapping' :: Maybe Text
resourceARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:ResourceTagMapping' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing
    }

-- | Information that shows whether a resource is compliant with the
-- effective tag policy, including details on any noncompliant tag keys.
resourceTagMapping_complianceDetails :: Lens.Lens' ResourceTagMapping (Prelude.Maybe ComplianceDetails)
resourceTagMapping_complianceDetails :: (Maybe ComplianceDetails -> f (Maybe ComplianceDetails))
-> ResourceTagMapping -> f ResourceTagMapping
resourceTagMapping_complianceDetails = (ResourceTagMapping -> Maybe ComplianceDetails)
-> (ResourceTagMapping
    -> Maybe ComplianceDetails -> ResourceTagMapping)
-> Lens
     ResourceTagMapping
     ResourceTagMapping
     (Maybe ComplianceDetails)
     (Maybe ComplianceDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceTagMapping' {Maybe ComplianceDetails
complianceDetails :: Maybe ComplianceDetails
$sel:complianceDetails:ResourceTagMapping' :: ResourceTagMapping -> Maybe ComplianceDetails
complianceDetails} -> Maybe ComplianceDetails
complianceDetails) (\s :: ResourceTagMapping
s@ResourceTagMapping' {} Maybe ComplianceDetails
a -> ResourceTagMapping
s {$sel:complianceDetails:ResourceTagMapping' :: Maybe ComplianceDetails
complianceDetails = Maybe ComplianceDetails
a} :: ResourceTagMapping)

-- | The ARN of the resource.
resourceTagMapping_resourceARN :: Lens.Lens' ResourceTagMapping (Prelude.Maybe Prelude.Text)
resourceTagMapping_resourceARN :: (Maybe Text -> f (Maybe Text))
-> ResourceTagMapping -> f ResourceTagMapping
resourceTagMapping_resourceARN = (ResourceTagMapping -> Maybe Text)
-> (ResourceTagMapping -> Maybe Text -> ResourceTagMapping)
-> Lens
     ResourceTagMapping ResourceTagMapping (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceTagMapping' {Maybe Text
resourceARN :: Maybe Text
$sel:resourceARN:ResourceTagMapping' :: ResourceTagMapping -> Maybe Text
resourceARN} -> Maybe Text
resourceARN) (\s :: ResourceTagMapping
s@ResourceTagMapping' {} Maybe Text
a -> ResourceTagMapping
s {$sel:resourceARN:ResourceTagMapping' :: Maybe Text
resourceARN = Maybe Text
a} :: ResourceTagMapping)

-- | The tags that have been applied to one or more AWS resources.
resourceTagMapping_tags :: Lens.Lens' ResourceTagMapping (Prelude.Maybe [Tag])
resourceTagMapping_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> ResourceTagMapping -> f ResourceTagMapping
resourceTagMapping_tags = (ResourceTagMapping -> Maybe [Tag])
-> (ResourceTagMapping -> Maybe [Tag] -> ResourceTagMapping)
-> Lens
     ResourceTagMapping ResourceTagMapping (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceTagMapping' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:ResourceTagMapping' :: ResourceTagMapping -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: ResourceTagMapping
s@ResourceTagMapping' {} Maybe [Tag]
a -> ResourceTagMapping
s {$sel:tags:ResourceTagMapping' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: ResourceTagMapping) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> ResourceTagMapping -> f ResourceTagMapping)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> ResourceTagMapping
-> f ResourceTagMapping
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable ResourceTagMapping

instance Prelude.NFData ResourceTagMapping