{-# 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.EC2.Types.TagDescription
-- 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.EC2.Types.TagDescription where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.ResourceType
import qualified Amazonka.Prelude as Prelude

-- | Describes a tag.
--
-- /See:/ 'newTagDescription' smart constructor.
data TagDescription = TagDescription'
  { -- | The ID of the resource.
    TagDescription -> Text
resourceId :: Prelude.Text,
    -- | The resource type.
    TagDescription -> ResourceType
resourceType :: ResourceType,
    -- | The tag key.
    TagDescription -> Text
key :: Prelude.Text,
    -- | The tag value.
    TagDescription -> Text
value :: Prelude.Text
  }
  deriving (TagDescription -> TagDescription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagDescription -> TagDescription -> Bool
$c/= :: TagDescription -> TagDescription -> Bool
== :: TagDescription -> TagDescription -> Bool
$c== :: TagDescription -> TagDescription -> Bool
Prelude.Eq, ReadPrec [TagDescription]
ReadPrec TagDescription
Int -> ReadS TagDescription
ReadS [TagDescription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagDescription]
$creadListPrec :: ReadPrec [TagDescription]
readPrec :: ReadPrec TagDescription
$creadPrec :: ReadPrec TagDescription
readList :: ReadS [TagDescription]
$creadList :: ReadS [TagDescription]
readsPrec :: Int -> ReadS TagDescription
$creadsPrec :: Int -> ReadS TagDescription
Prelude.Read, Int -> TagDescription -> ShowS
[TagDescription] -> ShowS
TagDescription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagDescription] -> ShowS
$cshowList :: [TagDescription] -> ShowS
show :: TagDescription -> String
$cshow :: TagDescription -> String
showsPrec :: Int -> TagDescription -> ShowS
$cshowsPrec :: Int -> TagDescription -> ShowS
Prelude.Show, forall x. Rep TagDescription x -> TagDescription
forall x. TagDescription -> Rep TagDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagDescription x -> TagDescription
$cfrom :: forall x. TagDescription -> Rep TagDescription x
Prelude.Generic)

-- |
-- Create a value of 'TagDescription' 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', 'tagDescription_resourceId' - The ID of the resource.
--
-- 'resourceType', 'tagDescription_resourceType' - The resource type.
--
-- 'key', 'tagDescription_key' - The tag key.
--
-- 'value', 'tagDescription_value' - The tag value.
newTagDescription ::
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'resourceType'
  ResourceType ->
  -- | 'key'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  TagDescription
newTagDescription :: Text -> ResourceType -> Text -> Text -> TagDescription
newTagDescription
  Text
pResourceId_
  ResourceType
pResourceType_
  Text
pKey_
  Text
pValue_ =
    TagDescription'
      { $sel:resourceId:TagDescription' :: Text
resourceId = Text
pResourceId_,
        $sel:resourceType:TagDescription' :: ResourceType
resourceType = ResourceType
pResourceType_,
        $sel:key:TagDescription' :: Text
key = Text
pKey_,
        $sel:value:TagDescription' :: Text
value = Text
pValue_
      }

-- | The ID of the resource.
tagDescription_resourceId :: Lens.Lens' TagDescription Prelude.Text
tagDescription_resourceId :: Lens' TagDescription Text
tagDescription_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagDescription' {Text
resourceId :: Text
$sel:resourceId:TagDescription' :: TagDescription -> Text
resourceId} -> Text
resourceId) (\s :: TagDescription
s@TagDescription' {} Text
a -> TagDescription
s {$sel:resourceId:TagDescription' :: Text
resourceId = Text
a} :: TagDescription)

-- | The resource type.
tagDescription_resourceType :: Lens.Lens' TagDescription ResourceType
tagDescription_resourceType :: Lens' TagDescription ResourceType
tagDescription_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagDescription' {ResourceType
resourceType :: ResourceType
$sel:resourceType:TagDescription' :: TagDescription -> ResourceType
resourceType} -> ResourceType
resourceType) (\s :: TagDescription
s@TagDescription' {} ResourceType
a -> TagDescription
s {$sel:resourceType:TagDescription' :: ResourceType
resourceType = ResourceType
a} :: TagDescription)

-- | The tag key.
tagDescription_key :: Lens.Lens' TagDescription Prelude.Text
tagDescription_key :: Lens' TagDescription Text
tagDescription_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagDescription' {Text
key :: Text
$sel:key:TagDescription' :: TagDescription -> Text
key} -> Text
key) (\s :: TagDescription
s@TagDescription' {} Text
a -> TagDescription
s {$sel:key:TagDescription' :: Text
key = Text
a} :: TagDescription)

-- | The tag value.
tagDescription_value :: Lens.Lens' TagDescription Prelude.Text
tagDescription_value :: Lens' TagDescription Text
tagDescription_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagDescription' {Text
value :: Text
$sel:value:TagDescription' :: TagDescription -> Text
value} -> Text
value) (\s :: TagDescription
s@TagDescription' {} Text
a -> TagDescription
s {$sel:value:TagDescription' :: Text
value = Text
a} :: TagDescription)

instance Data.FromXML TagDescription where
  parseXML :: [Node] -> Either String TagDescription
parseXML [Node]
x =
    Text -> ResourceType -> Text -> Text -> TagDescription
TagDescription'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"resourceId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"resourceType")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"key")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"value")

instance Prelude.Hashable TagDescription where
  hashWithSalt :: Int -> TagDescription -> Int
hashWithSalt Int
_salt TagDescription' {Text
ResourceType
value :: Text
key :: Text
resourceType :: ResourceType
resourceId :: Text
$sel:value:TagDescription' :: TagDescription -> Text
$sel:key:TagDescription' :: TagDescription -> Text
$sel:resourceType:TagDescription' :: TagDescription -> ResourceType
$sel:resourceId:TagDescription' :: TagDescription -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResourceType
resourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData TagDescription where
  rnf :: TagDescription -> ()
rnf TagDescription' {Text
ResourceType
value :: Text
key :: Text
resourceType :: ResourceType
resourceId :: Text
$sel:value:TagDescription' :: TagDescription -> Text
$sel:key:TagDescription' :: TagDescription -> Text
$sel:resourceType:TagDescription' :: TagDescription -> ResourceType
$sel:resourceId:TagDescription' :: TagDescription -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ResourceType
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value