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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a tag for an Auto Scaling group.
--
-- /See:/ 'newTagDescription' smart constructor.
data TagDescription = TagDescription'
  { -- | The name of the group.
    TagDescription -> Text
resourceId :: Prelude.Text,
    -- | The type of resource. The only supported value is @auto-scaling-group@.
    TagDescription -> Text
resourceType :: Prelude.Text,
    -- | The tag key.
    TagDescription -> Text
key :: Prelude.Text,
    -- | Determines whether the tag is added to new instances as they are
    -- launched in the group.
    TagDescription -> Bool
propagateAtLaunch :: Prelude.Bool,
    -- | The tag value.
    TagDescription -> Text
value :: Prelude.Text
  }
  deriving (TagDescription -> TagDescription -> Bool
(TagDescription -> TagDescription -> Bool)
-> (TagDescription -> TagDescription -> Bool) -> Eq TagDescription
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]
(Int -> ReadS TagDescription)
-> ReadS [TagDescription]
-> ReadPrec TagDescription
-> ReadPrec [TagDescription]
-> Read 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
(Int -> TagDescription -> ShowS)
-> (TagDescription -> String)
-> ([TagDescription] -> ShowS)
-> Show TagDescription
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. TagDescription -> Rep TagDescription x)
-> (forall x. Rep TagDescription x -> TagDescription)
-> Generic TagDescription
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 name of the group.
--
-- 'resourceType', 'tagDescription_resourceType' - The type of resource. The only supported value is @auto-scaling-group@.
--
-- 'key', 'tagDescription_key' - The tag key.
--
-- 'propagateAtLaunch', 'tagDescription_propagateAtLaunch' - Determines whether the tag is added to new instances as they are
-- launched in the group.
--
-- 'value', 'tagDescription_value' - The tag value.
newTagDescription ::
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'resourceType'
  Prelude.Text ->
  -- | 'key'
  Prelude.Text ->
  -- | 'propagateAtLaunch'
  Prelude.Bool ->
  -- | 'value'
  Prelude.Text ->
  TagDescription
newTagDescription :: Text -> Text -> Text -> Bool -> Text -> TagDescription
newTagDescription
  Text
pResourceId_
  Text
pResourceType_
  Text
pKey_
  Bool
pPropagateAtLaunch_
  Text
pValue_ =
    TagDescription' :: Text -> Text -> Text -> Bool -> Text -> TagDescription
TagDescription'
      { $sel:resourceId:TagDescription' :: Text
resourceId = Text
pResourceId_,
        $sel:resourceType:TagDescription' :: Text
resourceType = Text
pResourceType_,
        $sel:key:TagDescription' :: Text
key = Text
pKey_,
        $sel:propagateAtLaunch:TagDescription' :: Bool
propagateAtLaunch = Bool
pPropagateAtLaunch_,
        $sel:value:TagDescription' :: Text
value = Text
pValue_
      }

-- | The name of the group.
tagDescription_resourceId :: Lens.Lens' TagDescription Prelude.Text
tagDescription_resourceId :: (Text -> f Text) -> TagDescription -> f TagDescription
tagDescription_resourceId = (TagDescription -> Text)
-> (TagDescription -> Text -> TagDescription)
-> Lens TagDescription TagDescription Text Text
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 type of resource. The only supported value is @auto-scaling-group@.
tagDescription_resourceType :: Lens.Lens' TagDescription Prelude.Text
tagDescription_resourceType :: (Text -> f Text) -> TagDescription -> f TagDescription
tagDescription_resourceType = (TagDescription -> Text)
-> (TagDescription -> Text -> TagDescription)
-> Lens TagDescription TagDescription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagDescription' {Text
resourceType :: Text
$sel:resourceType:TagDescription' :: TagDescription -> Text
resourceType} -> Text
resourceType) (\s :: TagDescription
s@TagDescription' {} Text
a -> TagDescription
s {$sel:resourceType:TagDescription' :: Text
resourceType = Text
a} :: TagDescription)

-- | The tag key.
tagDescription_key :: Lens.Lens' TagDescription Prelude.Text
tagDescription_key :: (Text -> f Text) -> TagDescription -> f TagDescription
tagDescription_key = (TagDescription -> Text)
-> (TagDescription -> Text -> TagDescription)
-> Lens TagDescription TagDescription Text Text
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)

-- | Determines whether the tag is added to new instances as they are
-- launched in the group.
tagDescription_propagateAtLaunch :: Lens.Lens' TagDescription Prelude.Bool
tagDescription_propagateAtLaunch :: (Bool -> f Bool) -> TagDescription -> f TagDescription
tagDescription_propagateAtLaunch = (TagDescription -> Bool)
-> (TagDescription -> Bool -> TagDescription)
-> Lens TagDescription TagDescription Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagDescription' {Bool
propagateAtLaunch :: Bool
$sel:propagateAtLaunch:TagDescription' :: TagDescription -> Bool
propagateAtLaunch} -> Bool
propagateAtLaunch) (\s :: TagDescription
s@TagDescription' {} Bool
a -> TagDescription
s {$sel:propagateAtLaunch:TagDescription' :: Bool
propagateAtLaunch = Bool
a} :: TagDescription)

-- | The tag value.
tagDescription_value :: Lens.Lens' TagDescription Prelude.Text
tagDescription_value :: (Text -> f Text) -> TagDescription -> f TagDescription
tagDescription_value = (TagDescription -> Text)
-> (TagDescription -> Text -> TagDescription)
-> Lens TagDescription TagDescription Text Text
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 Core.FromXML TagDescription where
  parseXML :: [Node] -> Either String TagDescription
parseXML [Node]
x =
    Text -> Text -> Text -> Bool -> Text -> TagDescription
TagDescription'
      (Text -> Text -> Text -> Bool -> Text -> TagDescription)
-> Either String Text
-> Either String (Text -> Text -> Bool -> Text -> TagDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ResourceId")
      Either String (Text -> Text -> Bool -> Text -> TagDescription)
-> Either String Text
-> Either String (Text -> Bool -> Text -> TagDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ResourceType")
      Either String (Text -> Bool -> Text -> TagDescription)
-> Either String Text
-> Either String (Bool -> Text -> TagDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Key")
      Either String (Bool -> Text -> TagDescription)
-> Either String Bool -> Either String (Text -> TagDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Bool
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"PropagateAtLaunch")
      Either String (Text -> TagDescription)
-> Either String Text -> Either String TagDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Value")

instance Prelude.Hashable TagDescription

instance Prelude.NFData TagDescription