{-# 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.CloudTrail.Types.ResourceTag
-- 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.CloudTrail.Types.ResourceTag where

import Amazonka.CloudTrail.Types.Tag
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

-- | A resource tag.
--
-- /See:/ 'newResourceTag' smart constructor.
data ResourceTag = ResourceTag'
  { -- | Specifies the ARN of the resource.
    ResourceTag -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
    -- | A list of tags.
    ResourceTag -> Maybe [Tag]
tagsList :: Prelude.Maybe [Tag]
  }
  deriving (ResourceTag -> ResourceTag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceTag -> ResourceTag -> Bool
$c/= :: ResourceTag -> ResourceTag -> Bool
== :: ResourceTag -> ResourceTag -> Bool
$c== :: ResourceTag -> ResourceTag -> Bool
Prelude.Eq, ReadPrec [ResourceTag]
ReadPrec ResourceTag
Int -> ReadS ResourceTag
ReadS [ResourceTag]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceTag]
$creadListPrec :: ReadPrec [ResourceTag]
readPrec :: ReadPrec ResourceTag
$creadPrec :: ReadPrec ResourceTag
readList :: ReadS [ResourceTag]
$creadList :: ReadS [ResourceTag]
readsPrec :: Int -> ReadS ResourceTag
$creadsPrec :: Int -> ReadS ResourceTag
Prelude.Read, Int -> ResourceTag -> ShowS
[ResourceTag] -> ShowS
ResourceTag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceTag] -> ShowS
$cshowList :: [ResourceTag] -> ShowS
show :: ResourceTag -> String
$cshow :: ResourceTag -> String
showsPrec :: Int -> ResourceTag -> ShowS
$cshowsPrec :: Int -> ResourceTag -> ShowS
Prelude.Show, forall x. Rep ResourceTag x -> ResourceTag
forall x. ResourceTag -> Rep ResourceTag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceTag x -> ResourceTag
$cfrom :: forall x. ResourceTag -> Rep ResourceTag x
Prelude.Generic)

-- |
-- Create a value of 'ResourceTag' 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:
--
-- 'resourceId', 'resourceTag_resourceId' - Specifies the ARN of the resource.
--
-- 'tagsList', 'resourceTag_tagsList' - A list of tags.
newResourceTag ::
  ResourceTag
newResourceTag :: ResourceTag
newResourceTag =
  ResourceTag'
    { $sel:resourceId:ResourceTag' :: Maybe Text
resourceId = forall a. Maybe a
Prelude.Nothing,
      $sel:tagsList:ResourceTag' :: Maybe [Tag]
tagsList = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the ARN of the resource.
resourceTag_resourceId :: Lens.Lens' ResourceTag (Prelude.Maybe Prelude.Text)
resourceTag_resourceId :: Lens' ResourceTag (Maybe Text)
resourceTag_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceTag' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:ResourceTag' :: ResourceTag -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: ResourceTag
s@ResourceTag' {} Maybe Text
a -> ResourceTag
s {$sel:resourceId:ResourceTag' :: Maybe Text
resourceId = Maybe Text
a} :: ResourceTag)

-- | A list of tags.
resourceTag_tagsList :: Lens.Lens' ResourceTag (Prelude.Maybe [Tag])
resourceTag_tagsList :: Lens' ResourceTag (Maybe [Tag])
resourceTag_tagsList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceTag' {Maybe [Tag]
tagsList :: Maybe [Tag]
$sel:tagsList:ResourceTag' :: ResourceTag -> Maybe [Tag]
tagsList} -> Maybe [Tag]
tagsList) (\s :: ResourceTag
s@ResourceTag' {} Maybe [Tag]
a -> ResourceTag
s {$sel:tagsList:ResourceTag' :: Maybe [Tag]
tagsList = Maybe [Tag]
a} :: ResourceTag) 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 ResourceTag where
  parseJSON :: Value -> Parser ResourceTag
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceTag"
      ( \Object
x ->
          Maybe Text -> Maybe [Tag] -> ResourceTag
ResourceTag'
            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
"ResourceId")
            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
"TagsList" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ResourceTag where
  hashWithSalt :: Int -> ResourceTag -> Int
hashWithSalt Int
_salt ResourceTag' {Maybe [Tag]
Maybe Text
tagsList :: Maybe [Tag]
resourceId :: Maybe Text
$sel:tagsList:ResourceTag' :: ResourceTag -> Maybe [Tag]
$sel:resourceId:ResourceTag' :: ResourceTag -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tagsList

instance Prelude.NFData ResourceTag where
  rnf :: ResourceTag -> ()
rnf ResourceTag' {Maybe [Tag]
Maybe Text
tagsList :: Maybe [Tag]
resourceId :: Maybe Text
$sel:tagsList:ResourceTag' :: ResourceTag -> Maybe [Tag]
$sel:resourceId:ResourceTag' :: ResourceTag -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tagsList