{-# 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-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)
--
-- 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_tagsToRemove,
    updateTagsForResource_tagsToAdd,
    updateTagsForResource_resourceArn,

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

import qualified Amazonka.Core as Core
import Amazonka.ElasticBeanstalk.Types
import qualified Amazonka.Lens as Lens
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 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],
    -- | 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],
    -- | 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
(UpdateTagsForResource -> UpdateTagsForResource -> Bool)
-> (UpdateTagsForResource -> UpdateTagsForResource -> Bool)
-> Eq UpdateTagsForResource
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]
(Int -> ReadS UpdateTagsForResource)
-> ReadS [UpdateTagsForResource]
-> ReadPrec UpdateTagsForResource
-> ReadPrec [UpdateTagsForResource]
-> Read 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
(Int -> UpdateTagsForResource -> ShowS)
-> (UpdateTagsForResource -> String)
-> ([UpdateTagsForResource] -> ShowS)
-> Show UpdateTagsForResource
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. UpdateTagsForResource -> Rep UpdateTagsForResource x)
-> (forall x. Rep UpdateTagsForResource x -> UpdateTagsForResource)
-> Generic UpdateTagsForResource
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:
--
-- '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@.
--
-- '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@.
--
-- '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' :: Maybe [Text] -> Maybe [Tag] -> Text -> UpdateTagsForResource
UpdateTagsForResource'
    { $sel:tagsToRemove:UpdateTagsForResource' :: Maybe [Text]
tagsToRemove =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:tagsToAdd:UpdateTagsForResource' :: Maybe [Tag]
tagsToAdd = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:UpdateTagsForResource' :: Text
resourceArn = Text
pResourceArn_
    }

-- | 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 :: (Maybe [Text] -> f (Maybe [Text]))
-> UpdateTagsForResource -> f UpdateTagsForResource
updateTagsForResource_tagsToRemove = (UpdateTagsForResource -> Maybe [Text])
-> (UpdateTagsForResource -> Maybe [Text] -> UpdateTagsForResource)
-> Lens
     UpdateTagsForResource
     UpdateTagsForResource
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> UpdateTagsForResource -> f UpdateTagsForResource)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> UpdateTagsForResource
-> f UpdateTagsForResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe [Tag] -> f (Maybe [Tag]))
-> UpdateTagsForResource -> f UpdateTagsForResource
updateTagsForResource_tagsToAdd = (UpdateTagsForResource -> Maybe [Tag])
-> (UpdateTagsForResource -> Maybe [Tag] -> UpdateTagsForResource)
-> Lens
     UpdateTagsForResource
     UpdateTagsForResource
     (Maybe [Tag])
     (Maybe [Tag])
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) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> UpdateTagsForResource -> f UpdateTagsForResource)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> UpdateTagsForResource
-> f UpdateTagsForResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 AnIso [Tag] [Tag] [Tag] [Tag]
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 :: (Text -> f Text)
-> UpdateTagsForResource -> f UpdateTagsForResource
updateTagsForResource_resourceArn = (UpdateTagsForResource -> Text)
-> (UpdateTagsForResource -> Text -> UpdateTagsForResource)
-> Lens UpdateTagsForResource UpdateTagsForResource Text Text
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 :: UpdateTagsForResource -> Request UpdateTagsForResource
request = Service -> UpdateTagsForResource -> Request UpdateTagsForResource
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateTagsForResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateTagsForResource)))
response =
    AWSResponse UpdateTagsForResource
-> Logger
-> Service
-> Proxy UpdateTagsForResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateTagsForResource)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateTagsForResource
UpdateTagsForResourceResponse
UpdateTagsForResourceResponse'

instance Prelude.Hashable UpdateTagsForResource

instance Prelude.NFData UpdateTagsForResource

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

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

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

-- | /See:/ 'newUpdateTagsForResourceResponse' smart constructor.
data UpdateTagsForResourceResponse = UpdateTagsForResourceResponse'
  {
  }
  deriving (UpdateTagsForResourceResponse
-> UpdateTagsForResourceResponse -> Bool
(UpdateTagsForResourceResponse
 -> UpdateTagsForResourceResponse -> Bool)
-> (UpdateTagsForResourceResponse
    -> UpdateTagsForResourceResponse -> Bool)
-> Eq UpdateTagsForResourceResponse
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]
(Int -> ReadS UpdateTagsForResourceResponse)
-> ReadS [UpdateTagsForResourceResponse]
-> ReadPrec UpdateTagsForResourceResponse
-> ReadPrec [UpdateTagsForResourceResponse]
-> Read 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
(Int -> UpdateTagsForResourceResponse -> ShowS)
-> (UpdateTagsForResourceResponse -> String)
-> ([UpdateTagsForResourceResponse] -> ShowS)
-> Show UpdateTagsForResourceResponse
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.
 UpdateTagsForResourceResponse
 -> Rep UpdateTagsForResourceResponse x)
-> (forall x.
    Rep UpdateTagsForResourceResponse x
    -> UpdateTagsForResourceResponse)
-> Generic UpdateTagsForResourceResponse
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