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

-- | Describes a tag for an Auto Scaling group.
--
-- /See:/ 'newTag' smart constructor.
data Tag = Tag'
  { -- | The tag key.
    Tag -> Text
key :: Prelude.Text,
    -- | The name of the Auto Scaling group.
    Tag -> Text
resourceId :: Prelude.Text,
    -- | The type of resource. The only supported value is @auto-scaling-group@.
    Tag -> Text
resourceType :: Prelude.Text,
    -- | Determines whether the tag is added to new instances as they are
    -- launched in the group.
    Tag -> Bool
propagateAtLaunch :: Prelude.Bool,
    -- | The tag value.
    Tag -> Text
value :: Prelude.Text
  }
  deriving (Tag -> Tag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Tag -> Tag -> Bool
$c/= :: Tag -> Tag -> Bool
== :: Tag -> Tag -> Bool
$c== :: Tag -> Tag -> Bool
Prelude.Eq, ReadPrec [Tag]
ReadPrec Tag
Int -> ReadS Tag
ReadS [Tag]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Tag]
$creadListPrec :: ReadPrec [Tag]
readPrec :: ReadPrec Tag
$creadPrec :: ReadPrec Tag
readList :: ReadS [Tag]
$creadList :: ReadS [Tag]
readsPrec :: Int -> ReadS Tag
$creadsPrec :: Int -> ReadS Tag
Prelude.Read, Int -> Tag -> ShowS
[Tag] -> ShowS
Tag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Tag] -> ShowS
$cshowList :: [Tag] -> ShowS
show :: Tag -> String
$cshow :: Tag -> String
showsPrec :: Int -> Tag -> ShowS
$cshowsPrec :: Int -> Tag -> ShowS
Prelude.Show, forall x. Rep Tag x -> Tag
forall x. Tag -> Rep Tag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Tag x -> Tag
$cfrom :: forall x. Tag -> Rep Tag x
Prelude.Generic)

-- |
-- Create a value of 'Tag' 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:
--
-- 'key', 'tag_key' - The tag key.
--
-- 'resourceId', 'tag_resourceId' - The name of the Auto Scaling group.
--
-- 'resourceType', 'tag_resourceType' - The type of resource. The only supported value is @auto-scaling-group@.
--
-- 'propagateAtLaunch', 'tag_propagateAtLaunch' - Determines whether the tag is added to new instances as they are
-- launched in the group.
--
-- 'value', 'tag_value' - The tag value.
newTag ::
  -- | 'key'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'resourceType'
  Prelude.Text ->
  -- | 'propagateAtLaunch'
  Prelude.Bool ->
  -- | 'value'
  Prelude.Text ->
  Tag
newTag :: Text -> Text -> Text -> Bool -> Text -> Tag
newTag
  Text
pKey_
  Text
pResourceId_
  Text
pResourceType_
  Bool
pPropagateAtLaunch_
  Text
pValue_ =
    Tag'
      { $sel:key:Tag' :: Text
key = Text
pKey_,
        $sel:resourceId:Tag' :: Text
resourceId = Text
pResourceId_,
        $sel:resourceType:Tag' :: Text
resourceType = Text
pResourceType_,
        $sel:propagateAtLaunch:Tag' :: Bool
propagateAtLaunch = Bool
pPropagateAtLaunch_,
        $sel:value:Tag' :: Text
value = Text
pValue_
      }

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

-- | The name of the Auto Scaling group.
tag_resourceId :: Lens.Lens' Tag Prelude.Text
tag_resourceId :: Lens' Tag Text
tag_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tag' {Text
resourceId :: Text
$sel:resourceId:Tag' :: Tag -> Text
resourceId} -> Text
resourceId) (\s :: Tag
s@Tag' {} Text
a -> Tag
s {$sel:resourceId:Tag' :: Text
resourceId = Text
a} :: Tag)

-- | The type of resource. The only supported value is @auto-scaling-group@.
tag_resourceType :: Lens.Lens' Tag Prelude.Text
tag_resourceType :: Lens' Tag Text
tag_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tag' {Text
resourceType :: Text
$sel:resourceType:Tag' :: Tag -> Text
resourceType} -> Text
resourceType) (\s :: Tag
s@Tag' {} Text
a -> Tag
s {$sel:resourceType:Tag' :: Text
resourceType = Text
a} :: Tag)

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

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

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

instance Prelude.NFData Tag where
  rnf :: Tag -> ()
rnf Tag' {Bool
Text
value :: Text
propagateAtLaunch :: Bool
resourceType :: Text
resourceId :: Text
key :: Text
$sel:value:Tag' :: Tag -> Text
$sel:propagateAtLaunch:Tag' :: Tag -> Bool
$sel:resourceType:Tag' :: Tag -> Text
$sel:resourceId:Tag' :: Tag -> Text
$sel:key:Tag' :: Tag -> Text
..} =
    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
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
propagateAtLaunch
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.ToQuery Tag where
  toQuery :: Tag -> QueryString
toQuery Tag' {Bool
Text
value :: Text
propagateAtLaunch :: Bool
resourceType :: Text
resourceId :: Text
key :: Text
$sel:value:Tag' :: Tag -> Text
$sel:propagateAtLaunch:Tag' :: Tag -> Bool
$sel:resourceType:Tag' :: Tag -> Text
$sel:resourceId:Tag' :: Tag -> Text
$sel:key:Tag' :: Tag -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Key" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
key,
        ByteString
"ResourceId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
resourceId,
        ByteString
"ResourceType" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
resourceType,
        ByteString
"PropagateAtLaunch" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Bool
propagateAtLaunch,
        ByteString
"Value" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
value
      ]