{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ResourceGroupsTagging.Types.ResourceTagMapping where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 Amazon Web Services
    -- resources.
    ResourceTagMapping -> Maybe [Tag]
tags :: Prelude.Maybe [Tag]
  }
  deriving (ResourceTagMapping -> ResourceTagMapping -> Bool
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]
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
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. 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 Amazon Web Services
-- resources.
newResourceTagMapping ::
  ResourceTagMapping
newResourceTagMapping :: ResourceTagMapping
newResourceTagMapping =
  ResourceTagMapping'
    { $sel:complianceDetails:ResourceTagMapping' :: Maybe ComplianceDetails
complianceDetails =
        forall a. Maybe a
Prelude.Nothing,
      $sel:resourceARN:ResourceTagMapping' :: Maybe Text
resourceARN = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:ResourceTagMapping' :: Maybe [Tag]
tags = 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 :: Lens' ResourceTagMapping (Maybe ComplianceDetails)
resourceTagMapping_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 :: Lens' ResourceTagMapping (Maybe Text)
resourceTagMapping_resourceARN = 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 Amazon Web Services
-- resources.
resourceTagMapping_tags :: Lens.Lens' ResourceTagMapping (Prelude.Maybe [Tag])
resourceTagMapping_tags :: Lens' ResourceTagMapping (Maybe [Tag])
resourceTagMapping_tags = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable ResourceTagMapping where
  hashWithSalt :: Int -> ResourceTagMapping -> Int
hashWithSalt Int
_salt ResourceTagMapping' {Maybe [Tag]
Maybe Text
Maybe ComplianceDetails
tags :: Maybe [Tag]
resourceARN :: Maybe Text
complianceDetails :: Maybe ComplianceDetails
$sel:tags:ResourceTagMapping' :: ResourceTagMapping -> Maybe [Tag]
$sel:resourceARN:ResourceTagMapping' :: ResourceTagMapping -> Maybe Text
$sel:complianceDetails:ResourceTagMapping' :: ResourceTagMapping -> Maybe ComplianceDetails
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ComplianceDetails
complianceDetails
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags

instance Prelude.NFData ResourceTagMapping where
  rnf :: ResourceTagMapping -> ()
rnf ResourceTagMapping' {Maybe [Tag]
Maybe Text
Maybe ComplianceDetails
tags :: Maybe [Tag]
resourceARN :: Maybe Text
complianceDetails :: Maybe ComplianceDetails
$sel:tags:ResourceTagMapping' :: ResourceTagMapping -> Maybe [Tag]
$sel:resourceARN:ResourceTagMapping' :: ResourceTagMapping -> Maybe Text
$sel:complianceDetails:ResourceTagMapping' :: ResourceTagMapping -> Maybe ComplianceDetails
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ComplianceDetails
complianceDetails
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags