{-# 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.ElasticBeanstalk.UpdateTagsForResource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Update the list of tags applied to an AWS Elastic Beanstalk resource.
-- Two lists can be passed: @TagsToAdd@ for tags to add or update, and
-- @TagsToRemove@.
--
-- Elastic Beanstalk supports tagging of all of its resources. For details
-- about resource tagging, see
-- <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/applications-tagging-resources.html Tagging Application Resources>.
--
-- If you create a custom IAM user policy to control permission to this
-- operation, specify one of the following two virtual actions (or both)
-- instead of the API operation name:
--
-- [elasticbeanstalk:AddTags]
--     Controls permission to call @UpdateTagsForResource@ and pass a list
--     of tags to add in the @TagsToAdd@ parameter.
--
-- [elasticbeanstalk:RemoveTags]
--     Controls permission to call @UpdateTagsForResource@ and pass a list
--     of tag keys to remove in the @TagsToRemove@ parameter.
--
-- For details about creating a custom user policy, see
-- <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.iam.managed-policies.html#AWSHowTo.iam.policies Creating a Custom User Policy>.
module Amazonka.ElasticBeanstalk.UpdateTagsForResource
  ( -- * Creating a Request
    UpdateTagsForResource (..),
    newUpdateTagsForResource,

    -- * Request Lenses
    updateTagsForResource_tagsToAdd,
    updateTagsForResource_tagsToRemove,
    updateTagsForResource_resourceArn,

    -- * Destructuring the Response
    UpdateTagsForResourceResponse (..),
    newUpdateTagsForResourceResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElasticBeanstalk.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateTagsForResource' smart constructor.
data UpdateTagsForResource = UpdateTagsForResource'
  { -- | A list of tags to add or update. If a key of an existing tag is added,
    -- the tag\'s value is updated.
    --
    -- Specify at least one of these parameters: @TagsToAdd@, @TagsToRemove@.
    UpdateTagsForResource -> Maybe [Tag]
tagsToAdd :: Prelude.Maybe [Tag],
    -- | A list of tag keys to remove. If a tag key doesn\'t exist, it is
    -- silently ignored.
    --
    -- Specify at least one of these parameters: @TagsToAdd@, @TagsToRemove@.
    UpdateTagsForResource -> Maybe [Text]
tagsToRemove :: Prelude.Maybe [Prelude.Text],
    -- | The Amazon Resource Name (ARN) of the resouce to be updated.
    --
    -- Must be the ARN of an Elastic Beanstalk resource.
    UpdateTagsForResource -> Text
resourceArn :: Prelude.Text
  }
  deriving (UpdateTagsForResource -> UpdateTagsForResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateTagsForResource -> UpdateTagsForResource -> Bool
$c/= :: UpdateTagsForResource -> UpdateTagsForResource -> Bool
== :: UpdateTagsForResource -> UpdateTagsForResource -> Bool
$c== :: UpdateTagsForResource -> UpdateTagsForResource -> Bool
Prelude.Eq, ReadPrec [UpdateTagsForResource]
ReadPrec UpdateTagsForResource
Int -> ReadS UpdateTagsForResource
ReadS [UpdateTagsForResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateTagsForResource]
$creadListPrec :: ReadPrec [UpdateTagsForResource]
readPrec :: ReadPrec UpdateTagsForResource
$creadPrec :: ReadPrec UpdateTagsForResource
readList :: ReadS [UpdateTagsForResource]
$creadList :: ReadS [UpdateTagsForResource]
readsPrec :: Int -> ReadS UpdateTagsForResource
$creadsPrec :: Int -> ReadS UpdateTagsForResource
Prelude.Read, Int -> UpdateTagsForResource -> ShowS
[UpdateTagsForResource] -> ShowS
UpdateTagsForResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateTagsForResource] -> ShowS
$cshowList :: [UpdateTagsForResource] -> ShowS
show :: UpdateTagsForResource -> String
$cshow :: UpdateTagsForResource -> String
showsPrec :: Int -> UpdateTagsForResource -> ShowS
$cshowsPrec :: Int -> UpdateTagsForResource -> ShowS
Prelude.Show, forall x. Rep UpdateTagsForResource x -> UpdateTagsForResource
forall x. UpdateTagsForResource -> Rep UpdateTagsForResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateTagsForResource x -> UpdateTagsForResource
$cfrom :: forall x. UpdateTagsForResource -> Rep UpdateTagsForResource x
Prelude.Generic)

-- |
-- Create a value of 'UpdateTagsForResource' 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:
--
-- 'tagsToAdd', 'updateTagsForResource_tagsToAdd' - A list of tags to add or update. If a key of an existing tag is added,
-- the tag\'s value is updated.
--
-- Specify at least one of these parameters: @TagsToAdd@, @TagsToRemove@.
--
-- 'tagsToRemove', 'updateTagsForResource_tagsToRemove' - A list of tag keys to remove. If a tag key doesn\'t exist, it is
-- silently ignored.
--
-- Specify at least one of these parameters: @TagsToAdd@, @TagsToRemove@.
--
-- 'resourceArn', 'updateTagsForResource_resourceArn' - The Amazon Resource Name (ARN) of the resouce to be updated.
--
-- Must be the ARN of an Elastic Beanstalk resource.
newUpdateTagsForResource ::
  -- | 'resourceArn'
  Prelude.Text ->
  UpdateTagsForResource
newUpdateTagsForResource :: Text -> UpdateTagsForResource
newUpdateTagsForResource Text
pResourceArn_ =
  UpdateTagsForResource'
    { $sel:tagsToAdd:UpdateTagsForResource' :: Maybe [Tag]
tagsToAdd = forall a. Maybe a
Prelude.Nothing,
      $sel:tagsToRemove:UpdateTagsForResource' :: Maybe [Text]
tagsToRemove = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:UpdateTagsForResource' :: Text
resourceArn = Text
pResourceArn_
    }

-- | A list of tags to add or update. If a key of an existing tag is added,
-- the tag\'s value is updated.
--
-- Specify at least one of these parameters: @TagsToAdd@, @TagsToRemove@.
updateTagsForResource_tagsToAdd :: Lens.Lens' UpdateTagsForResource (Prelude.Maybe [Tag])
updateTagsForResource_tagsToAdd :: Lens' UpdateTagsForResource (Maybe [Tag])
updateTagsForResource_tagsToAdd = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTagsForResource' {Maybe [Tag]
tagsToAdd :: Maybe [Tag]
$sel:tagsToAdd:UpdateTagsForResource' :: UpdateTagsForResource -> Maybe [Tag]
tagsToAdd} -> Maybe [Tag]
tagsToAdd) (\s :: UpdateTagsForResource
s@UpdateTagsForResource' {} Maybe [Tag]
a -> UpdateTagsForResource
s {$sel:tagsToAdd:UpdateTagsForResource' :: Maybe [Tag]
tagsToAdd = Maybe [Tag]
a} :: UpdateTagsForResource) 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

-- | A list of tag keys to remove. If a tag key doesn\'t exist, it is
-- silently ignored.
--
-- Specify at least one of these parameters: @TagsToAdd@, @TagsToRemove@.
updateTagsForResource_tagsToRemove :: Lens.Lens' UpdateTagsForResource (Prelude.Maybe [Prelude.Text])
updateTagsForResource_tagsToRemove :: Lens' UpdateTagsForResource (Maybe [Text])
updateTagsForResource_tagsToRemove = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTagsForResource' {Maybe [Text]
tagsToRemove :: Maybe [Text]
$sel:tagsToRemove:UpdateTagsForResource' :: UpdateTagsForResource -> Maybe [Text]
tagsToRemove} -> Maybe [Text]
tagsToRemove) (\s :: UpdateTagsForResource
s@UpdateTagsForResource' {} Maybe [Text]
a -> UpdateTagsForResource
s {$sel:tagsToRemove:UpdateTagsForResource' :: Maybe [Text]
tagsToRemove = Maybe [Text]
a} :: UpdateTagsForResource) 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

-- | The Amazon Resource Name (ARN) of the resouce to be updated.
--
-- Must be the ARN of an Elastic Beanstalk resource.
updateTagsForResource_resourceArn :: Lens.Lens' UpdateTagsForResource Prelude.Text
updateTagsForResource_resourceArn :: Lens' UpdateTagsForResource Text
updateTagsForResource_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTagsForResource' {Text
resourceArn :: Text
$sel:resourceArn:UpdateTagsForResource' :: UpdateTagsForResource -> Text
resourceArn} -> Text
resourceArn) (\s :: UpdateTagsForResource
s@UpdateTagsForResource' {} Text
a -> UpdateTagsForResource
s {$sel:resourceArn:UpdateTagsForResource' :: Text
resourceArn = Text
a} :: UpdateTagsForResource)

instance Core.AWSRequest UpdateTagsForResource where
  type
    AWSResponse UpdateTagsForResource =
      UpdateTagsForResourceResponse
  request :: (Service -> Service)
-> UpdateTagsForResource -> Request UpdateTagsForResource
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 UpdateTagsForResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateTagsForResource)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull UpdateTagsForResourceResponse
UpdateTagsForResourceResponse'

instance Prelude.Hashable UpdateTagsForResource where
  hashWithSalt :: Int -> UpdateTagsForResource -> Int
hashWithSalt Int
_salt UpdateTagsForResource' {Maybe [Text]
Maybe [Tag]
Text
resourceArn :: Text
tagsToRemove :: Maybe [Text]
tagsToAdd :: Maybe [Tag]
$sel:resourceArn:UpdateTagsForResource' :: UpdateTagsForResource -> Text
$sel:tagsToRemove:UpdateTagsForResource' :: UpdateTagsForResource -> Maybe [Text]
$sel:tagsToAdd:UpdateTagsForResource' :: UpdateTagsForResource -> Maybe [Tag]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tagsToAdd
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
tagsToRemove
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn

instance Prelude.NFData UpdateTagsForResource where
  rnf :: UpdateTagsForResource -> ()
rnf UpdateTagsForResource' {Maybe [Text]
Maybe [Tag]
Text
resourceArn :: Text
tagsToRemove :: Maybe [Text]
tagsToAdd :: Maybe [Tag]
$sel:resourceArn:UpdateTagsForResource' :: UpdateTagsForResource -> Text
$sel:tagsToRemove:UpdateTagsForResource' :: UpdateTagsForResource -> Maybe [Text]
$sel:tagsToAdd:UpdateTagsForResource' :: UpdateTagsForResource -> Maybe [Tag]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tagsToAdd
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
tagsToRemove
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceArn

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

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

instance Data.ToQuery UpdateTagsForResource where
  toQuery :: UpdateTagsForResource -> QueryString
toQuery UpdateTagsForResource' {Maybe [Text]
Maybe [Tag]
Text
resourceArn :: Text
tagsToRemove :: Maybe [Text]
tagsToAdd :: Maybe [Tag]
$sel:resourceArn:UpdateTagsForResource' :: UpdateTagsForResource -> Text
$sel:tagsToRemove:UpdateTagsForResource' :: UpdateTagsForResource -> Maybe [Text]
$sel:tagsToAdd:UpdateTagsForResource' :: UpdateTagsForResource -> Maybe [Tag]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"UpdateTagsForResource" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"TagsToAdd"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tagsToAdd),
        ByteString
"TagsToRemove"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
tagsToRemove),
        ByteString
"ResourceArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
resourceArn
      ]

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

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

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