{-# 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.WAFV2.Types.TagInfoForResource
-- 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.WAFV2.Types.TagInfoForResource 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.WAFV2.Types.Tag

-- | The collection of tagging definitions for an Amazon Web Services
-- resource. Tags are key:value pairs that you can use to categorize and
-- manage your resources, for purposes like billing or other management.
-- Typically, the tag key represents a category, such as \"environment\",
-- and the tag value represents a specific value within that category, such
-- as \"test,\" \"development,\" or \"production\". Or you might set the
-- tag key to \"customer\" and the value to the customer name or ID. You
-- can specify one or more tags to add to each Amazon Web Services
-- resource, up to 50 tags for a resource.
--
-- You can tag the Amazon Web Services resources that you manage through
-- WAF: web ACLs, rule groups, IP sets, and regex pattern sets. You can\'t
-- manage or view tags through the WAF console.
--
-- /See:/ 'newTagInfoForResource' smart constructor.
data TagInfoForResource = TagInfoForResource'
  { -- | The Amazon Resource Name (ARN) of the resource.
    TagInfoForResource -> Maybe Text
resourceARN :: Prelude.Maybe Prelude.Text,
    -- | The array of Tag objects defined for the resource.
    TagInfoForResource -> Maybe (NonEmpty Tag)
tagList :: Prelude.Maybe (Prelude.NonEmpty Tag)
  }
  deriving (TagInfoForResource -> TagInfoForResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagInfoForResource -> TagInfoForResource -> Bool
$c/= :: TagInfoForResource -> TagInfoForResource -> Bool
== :: TagInfoForResource -> TagInfoForResource -> Bool
$c== :: TagInfoForResource -> TagInfoForResource -> Bool
Prelude.Eq, ReadPrec [TagInfoForResource]
ReadPrec TagInfoForResource
Int -> ReadS TagInfoForResource
ReadS [TagInfoForResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagInfoForResource]
$creadListPrec :: ReadPrec [TagInfoForResource]
readPrec :: ReadPrec TagInfoForResource
$creadPrec :: ReadPrec TagInfoForResource
readList :: ReadS [TagInfoForResource]
$creadList :: ReadS [TagInfoForResource]
readsPrec :: Int -> ReadS TagInfoForResource
$creadsPrec :: Int -> ReadS TagInfoForResource
Prelude.Read, Int -> TagInfoForResource -> ShowS
[TagInfoForResource] -> ShowS
TagInfoForResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagInfoForResource] -> ShowS
$cshowList :: [TagInfoForResource] -> ShowS
show :: TagInfoForResource -> String
$cshow :: TagInfoForResource -> String
showsPrec :: Int -> TagInfoForResource -> ShowS
$cshowsPrec :: Int -> TagInfoForResource -> ShowS
Prelude.Show, forall x. Rep TagInfoForResource x -> TagInfoForResource
forall x. TagInfoForResource -> Rep TagInfoForResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagInfoForResource x -> TagInfoForResource
$cfrom :: forall x. TagInfoForResource -> Rep TagInfoForResource x
Prelude.Generic)

-- |
-- Create a value of 'TagInfoForResource' 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:
--
-- 'resourceARN', 'tagInfoForResource_resourceARN' - The Amazon Resource Name (ARN) of the resource.
--
-- 'tagList', 'tagInfoForResource_tagList' - The array of Tag objects defined for the resource.
newTagInfoForResource ::
  TagInfoForResource
newTagInfoForResource :: TagInfoForResource
newTagInfoForResource =
  TagInfoForResource'
    { $sel:resourceARN:TagInfoForResource' :: Maybe Text
resourceARN = forall a. Maybe a
Prelude.Nothing,
      $sel:tagList:TagInfoForResource' :: Maybe (NonEmpty Tag)
tagList = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the resource.
tagInfoForResource_resourceARN :: Lens.Lens' TagInfoForResource (Prelude.Maybe Prelude.Text)
tagInfoForResource_resourceARN :: Lens' TagInfoForResource (Maybe Text)
tagInfoForResource_resourceARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagInfoForResource' {Maybe Text
resourceARN :: Maybe Text
$sel:resourceARN:TagInfoForResource' :: TagInfoForResource -> Maybe Text
resourceARN} -> Maybe Text
resourceARN) (\s :: TagInfoForResource
s@TagInfoForResource' {} Maybe Text
a -> TagInfoForResource
s {$sel:resourceARN:TagInfoForResource' :: Maybe Text
resourceARN = Maybe Text
a} :: TagInfoForResource)

-- | The array of Tag objects defined for the resource.
tagInfoForResource_tagList :: Lens.Lens' TagInfoForResource (Prelude.Maybe (Prelude.NonEmpty Tag))
tagInfoForResource_tagList :: Lens' TagInfoForResource (Maybe (NonEmpty Tag))
tagInfoForResource_tagList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagInfoForResource' {Maybe (NonEmpty Tag)
tagList :: Maybe (NonEmpty Tag)
$sel:tagList:TagInfoForResource' :: TagInfoForResource -> Maybe (NonEmpty Tag)
tagList} -> Maybe (NonEmpty Tag)
tagList) (\s :: TagInfoForResource
s@TagInfoForResource' {} Maybe (NonEmpty Tag)
a -> TagInfoForResource
s {$sel:tagList:TagInfoForResource' :: Maybe (NonEmpty Tag)
tagList = Maybe (NonEmpty Tag)
a} :: TagInfoForResource) 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 TagInfoForResource where
  parseJSON :: Value -> Parser TagInfoForResource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TagInfoForResource"
      ( \Object
x ->
          Maybe Text -> Maybe (NonEmpty Tag) -> TagInfoForResource
TagInfoForResource'
            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
"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
"TagList")
      )

instance Prelude.Hashable TagInfoForResource where
  hashWithSalt :: Int -> TagInfoForResource -> Int
hashWithSalt Int
_salt TagInfoForResource' {Maybe (NonEmpty Tag)
Maybe Text
tagList :: Maybe (NonEmpty Tag)
resourceARN :: Maybe Text
$sel:tagList:TagInfoForResource' :: TagInfoForResource -> Maybe (NonEmpty Tag)
$sel:resourceARN:TagInfoForResource' :: TagInfoForResource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Tag)
tagList

instance Prelude.NFData TagInfoForResource where
  rnf :: TagInfoForResource -> ()
rnf TagInfoForResource' {Maybe (NonEmpty Tag)
Maybe Text
tagList :: Maybe (NonEmpty Tag)
resourceARN :: Maybe Text
$sel:tagList:TagInfoForResource' :: TagInfoForResource -> Maybe (NonEmpty Tag)
$sel:resourceARN:TagInfoForResource' :: TagInfoForResource -> Maybe Text
..} =
    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 (NonEmpty Tag)
tagList