{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateOrUpdateTags
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates or updates tags for the specified Auto Scaling group.
--
-- When you specify a tag with a key that already exists, the operation
-- overwrites the previous tag definition, and you do not get an error
-- message.
--
-- For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-tagging.html Tag Auto Scaling groups and instances>
-- in the /Amazon EC2 Auto Scaling User Guide/.
module Amazonka.AutoScaling.CreateOrUpdateTags
  ( -- * Creating a Request
    CreateOrUpdateTags (..),
    newCreateOrUpdateTags,

    -- * Request Lenses
    createOrUpdateTags_tags,

    -- * Destructuring the Response
    CreateOrUpdateTagsResponse (..),
    newCreateOrUpdateTagsResponse,
  )
where

import Amazonka.AutoScaling.Types
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateOrUpdateTags' smart constructor.
data CreateOrUpdateTags = CreateOrUpdateTags'
  { -- | One or more tags.
    CreateOrUpdateTags -> [Tag]
tags :: [Tag]
  }
  deriving (CreateOrUpdateTags -> CreateOrUpdateTags -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateOrUpdateTags -> CreateOrUpdateTags -> Bool
$c/= :: CreateOrUpdateTags -> CreateOrUpdateTags -> Bool
== :: CreateOrUpdateTags -> CreateOrUpdateTags -> Bool
$c== :: CreateOrUpdateTags -> CreateOrUpdateTags -> Bool
Prelude.Eq, ReadPrec [CreateOrUpdateTags]
ReadPrec CreateOrUpdateTags
Int -> ReadS CreateOrUpdateTags
ReadS [CreateOrUpdateTags]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateOrUpdateTags]
$creadListPrec :: ReadPrec [CreateOrUpdateTags]
readPrec :: ReadPrec CreateOrUpdateTags
$creadPrec :: ReadPrec CreateOrUpdateTags
readList :: ReadS [CreateOrUpdateTags]
$creadList :: ReadS [CreateOrUpdateTags]
readsPrec :: Int -> ReadS CreateOrUpdateTags
$creadsPrec :: Int -> ReadS CreateOrUpdateTags
Prelude.Read, Int -> CreateOrUpdateTags -> ShowS
[CreateOrUpdateTags] -> ShowS
CreateOrUpdateTags -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateOrUpdateTags] -> ShowS
$cshowList :: [CreateOrUpdateTags] -> ShowS
show :: CreateOrUpdateTags -> String
$cshow :: CreateOrUpdateTags -> String
showsPrec :: Int -> CreateOrUpdateTags -> ShowS
$cshowsPrec :: Int -> CreateOrUpdateTags -> ShowS
Prelude.Show, forall x. Rep CreateOrUpdateTags x -> CreateOrUpdateTags
forall x. CreateOrUpdateTags -> Rep CreateOrUpdateTags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateOrUpdateTags x -> CreateOrUpdateTags
$cfrom :: forall x. CreateOrUpdateTags -> Rep CreateOrUpdateTags x
Prelude.Generic)

-- |
-- Create a value of 'CreateOrUpdateTags' 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:
--
-- 'tags', 'createOrUpdateTags_tags' - One or more tags.
newCreateOrUpdateTags ::
  CreateOrUpdateTags
newCreateOrUpdateTags :: CreateOrUpdateTags
newCreateOrUpdateTags =
  CreateOrUpdateTags' {$sel:tags:CreateOrUpdateTags' :: [Tag]
tags = forall a. Monoid a => a
Prelude.mempty}

-- | One or more tags.
createOrUpdateTags_tags :: Lens.Lens' CreateOrUpdateTags [Tag]
createOrUpdateTags_tags :: Lens' CreateOrUpdateTags [Tag]
createOrUpdateTags_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOrUpdateTags' {[Tag]
tags :: [Tag]
$sel:tags:CreateOrUpdateTags' :: CreateOrUpdateTags -> [Tag]
tags} -> [Tag]
tags) (\s :: CreateOrUpdateTags
s@CreateOrUpdateTags' {} [Tag]
a -> CreateOrUpdateTags
s {$sel:tags:CreateOrUpdateTags' :: [Tag]
tags = [Tag]
a} :: CreateOrUpdateTags) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateOrUpdateTags where
  type
    AWSResponse CreateOrUpdateTags =
      CreateOrUpdateTagsResponse
  request :: (Service -> Service)
-> CreateOrUpdateTags -> Request CreateOrUpdateTags
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateOrUpdateTags
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateOrUpdateTags)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull CreateOrUpdateTagsResponse
CreateOrUpdateTagsResponse'

instance Prelude.Hashable CreateOrUpdateTags where
  hashWithSalt :: Int -> CreateOrUpdateTags -> Int
hashWithSalt Int
_salt CreateOrUpdateTags' {[Tag]
tags :: [Tag]
$sel:tags:CreateOrUpdateTags' :: CreateOrUpdateTags -> [Tag]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Tag]
tags

instance Prelude.NFData CreateOrUpdateTags where
  rnf :: CreateOrUpdateTags -> ()
rnf CreateOrUpdateTags' {[Tag]
tags :: [Tag]
$sel:tags:CreateOrUpdateTags' :: CreateOrUpdateTags -> [Tag]
..} = forall a. NFData a => a -> ()
Prelude.rnf [Tag]
tags

instance Data.ToHeaders CreateOrUpdateTags where
  toHeaders :: CreateOrUpdateTags -> [Header]
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath CreateOrUpdateTags where
  toPath :: CreateOrUpdateTags -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery CreateOrUpdateTags where
  toQuery :: CreateOrUpdateTags -> QueryString
toQuery CreateOrUpdateTags' {[Tag]
tags :: [Tag]
$sel:tags:CreateOrUpdateTags' :: CreateOrUpdateTags -> [Tag]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"CreateOrUpdateTags" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"Tags" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" [Tag]
tags
      ]

-- | /See:/ 'newCreateOrUpdateTagsResponse' smart constructor.
data CreateOrUpdateTagsResponse = CreateOrUpdateTagsResponse'
  {
  }
  deriving (CreateOrUpdateTagsResponse -> CreateOrUpdateTagsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateOrUpdateTagsResponse -> CreateOrUpdateTagsResponse -> Bool
$c/= :: CreateOrUpdateTagsResponse -> CreateOrUpdateTagsResponse -> Bool
== :: CreateOrUpdateTagsResponse -> CreateOrUpdateTagsResponse -> Bool
$c== :: CreateOrUpdateTagsResponse -> CreateOrUpdateTagsResponse -> Bool
Prelude.Eq, ReadPrec [CreateOrUpdateTagsResponse]
ReadPrec CreateOrUpdateTagsResponse
Int -> ReadS CreateOrUpdateTagsResponse
ReadS [CreateOrUpdateTagsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateOrUpdateTagsResponse]
$creadListPrec :: ReadPrec [CreateOrUpdateTagsResponse]
readPrec :: ReadPrec CreateOrUpdateTagsResponse
$creadPrec :: ReadPrec CreateOrUpdateTagsResponse
readList :: ReadS [CreateOrUpdateTagsResponse]
$creadList :: ReadS [CreateOrUpdateTagsResponse]
readsPrec :: Int -> ReadS CreateOrUpdateTagsResponse
$creadsPrec :: Int -> ReadS CreateOrUpdateTagsResponse
Prelude.Read, Int -> CreateOrUpdateTagsResponse -> ShowS
[CreateOrUpdateTagsResponse] -> ShowS
CreateOrUpdateTagsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateOrUpdateTagsResponse] -> ShowS
$cshowList :: [CreateOrUpdateTagsResponse] -> ShowS
show :: CreateOrUpdateTagsResponse -> String
$cshow :: CreateOrUpdateTagsResponse -> String
showsPrec :: Int -> CreateOrUpdateTagsResponse -> ShowS
$cshowsPrec :: Int -> CreateOrUpdateTagsResponse -> ShowS
Prelude.Show, forall x.
Rep CreateOrUpdateTagsResponse x -> CreateOrUpdateTagsResponse
forall x.
CreateOrUpdateTagsResponse -> Rep CreateOrUpdateTagsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateOrUpdateTagsResponse x -> CreateOrUpdateTagsResponse
$cfrom :: forall x.
CreateOrUpdateTagsResponse -> Rep CreateOrUpdateTagsResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateOrUpdateTagsResponse' 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.
newCreateOrUpdateTagsResponse ::
  CreateOrUpdateTagsResponse
newCreateOrUpdateTagsResponse :: CreateOrUpdateTagsResponse
newCreateOrUpdateTagsResponse =
  CreateOrUpdateTagsResponse
CreateOrUpdateTagsResponse'

instance Prelude.NFData CreateOrUpdateTagsResponse where
  rnf :: CreateOrUpdateTagsResponse -> ()
rnf CreateOrUpdateTagsResponse
_ = ()