{-# 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.ELB.AddTags
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Adds the specified tags to the specified load balancer. Each load
-- balancer can have a maximum of 10 tags.
--
-- Each tag consists of a key and an optional value. If a tag with the same
-- key is already associated with the load balancer, @AddTags@ updates its
-- value.
--
-- For more information, see
-- <https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/add-remove-tags.html Tag Your Classic Load Balancer>
-- in the /Classic Load Balancers Guide/.
module Amazonka.ELB.AddTags
  ( -- * Creating a Request
    AddTags (..),
    newAddTags,

    -- * Request Lenses
    addTags_loadBalancerNames,
    addTags_tags,

    -- * Destructuring the Response
    AddTagsResponse (..),
    newAddTagsResponse,

    -- * Response Lenses
    addTagsResponse_httpStatus,
  )
where

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

-- | Contains the parameters for AddTags.
--
-- /See:/ 'newAddTags' smart constructor.
data AddTags = AddTags'
  { -- | The name of the load balancer. You can specify one load balancer only.
    AddTags -> [Text]
loadBalancerNames :: [Prelude.Text],
    -- | The tags.
    AddTags -> NonEmpty Tag
tags :: Prelude.NonEmpty Tag
  }
  deriving (AddTags -> AddTags -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddTags -> AddTags -> Bool
$c/= :: AddTags -> AddTags -> Bool
== :: AddTags -> AddTags -> Bool
$c== :: AddTags -> AddTags -> Bool
Prelude.Eq, ReadPrec [AddTags]
ReadPrec AddTags
Int -> ReadS AddTags
ReadS [AddTags]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddTags]
$creadListPrec :: ReadPrec [AddTags]
readPrec :: ReadPrec AddTags
$creadPrec :: ReadPrec AddTags
readList :: ReadS [AddTags]
$creadList :: ReadS [AddTags]
readsPrec :: Int -> ReadS AddTags
$creadsPrec :: Int -> ReadS AddTags
Prelude.Read, Int -> AddTags -> ShowS
[AddTags] -> ShowS
AddTags -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddTags] -> ShowS
$cshowList :: [AddTags] -> ShowS
show :: AddTags -> String
$cshow :: AddTags -> String
showsPrec :: Int -> AddTags -> ShowS
$cshowsPrec :: Int -> AddTags -> ShowS
Prelude.Show, forall x. Rep AddTags x -> AddTags
forall x. AddTags -> Rep AddTags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddTags x -> AddTags
$cfrom :: forall x. AddTags -> Rep AddTags x
Prelude.Generic)

-- |
-- Create a value of 'AddTags' 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:
--
-- 'loadBalancerNames', 'addTags_loadBalancerNames' - The name of the load balancer. You can specify one load balancer only.
--
-- 'tags', 'addTags_tags' - The tags.
newAddTags ::
  -- | 'tags'
  Prelude.NonEmpty Tag ->
  AddTags
newAddTags :: NonEmpty Tag -> AddTags
newAddTags NonEmpty Tag
pTags_ =
  AddTags'
    { $sel:loadBalancerNames:AddTags' :: [Text]
loadBalancerNames = forall a. Monoid a => a
Prelude.mempty,
      $sel:tags:AddTags' :: NonEmpty Tag
tags = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Tag
pTags_
    }

-- | The name of the load balancer. You can specify one load balancer only.
addTags_loadBalancerNames :: Lens.Lens' AddTags [Prelude.Text]
addTags_loadBalancerNames :: Lens' AddTags [Text]
addTags_loadBalancerNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddTags' {[Text]
loadBalancerNames :: [Text]
$sel:loadBalancerNames:AddTags' :: AddTags -> [Text]
loadBalancerNames} -> [Text]
loadBalancerNames) (\s :: AddTags
s@AddTags' {} [Text]
a -> AddTags
s {$sel:loadBalancerNames:AddTags' :: [Text]
loadBalancerNames = [Text]
a} :: AddTags) 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

-- | The tags.
addTags_tags :: Lens.Lens' AddTags (Prelude.NonEmpty Tag)
addTags_tags :: Lens' AddTags (NonEmpty Tag)
addTags_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddTags' {NonEmpty Tag
tags :: NonEmpty Tag
$sel:tags:AddTags' :: AddTags -> NonEmpty Tag
tags} -> NonEmpty Tag
tags) (\s :: AddTags
s@AddTags' {} NonEmpty Tag
a -> AddTags
s {$sel:tags:AddTags' :: NonEmpty Tag
tags = NonEmpty Tag
a} :: AddTags) 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 AddTags where
  type AWSResponse AddTags = AddTagsResponse
  request :: (Service -> Service) -> AddTags -> Request AddTags
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 AddTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AddTags)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"AddTagsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> AddTagsResponse
AddTagsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

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

instance Prelude.NFData AddTags where
  rnf :: AddTags -> ()
rnf AddTags' {[Text]
NonEmpty Tag
tags :: NonEmpty Tag
loadBalancerNames :: [Text]
$sel:tags:AddTags' :: AddTags -> NonEmpty Tag
$sel:loadBalancerNames:AddTags' :: AddTags -> [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf [Text]
loadBalancerNames
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Tag
tags

instance Data.ToHeaders AddTags where
  toHeaders :: AddTags -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

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

-- | Contains the output of AddTags.
--
-- /See:/ 'newAddTagsResponse' smart constructor.
data AddTagsResponse = AddTagsResponse'
  { -- | The response's http status code.
    AddTagsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AddTagsResponse -> AddTagsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddTagsResponse -> AddTagsResponse -> Bool
$c/= :: AddTagsResponse -> AddTagsResponse -> Bool
== :: AddTagsResponse -> AddTagsResponse -> Bool
$c== :: AddTagsResponse -> AddTagsResponse -> Bool
Prelude.Eq, ReadPrec [AddTagsResponse]
ReadPrec AddTagsResponse
Int -> ReadS AddTagsResponse
ReadS [AddTagsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddTagsResponse]
$creadListPrec :: ReadPrec [AddTagsResponse]
readPrec :: ReadPrec AddTagsResponse
$creadPrec :: ReadPrec AddTagsResponse
readList :: ReadS [AddTagsResponse]
$creadList :: ReadS [AddTagsResponse]
readsPrec :: Int -> ReadS AddTagsResponse
$creadsPrec :: Int -> ReadS AddTagsResponse
Prelude.Read, Int -> AddTagsResponse -> ShowS
[AddTagsResponse] -> ShowS
AddTagsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddTagsResponse] -> ShowS
$cshowList :: [AddTagsResponse] -> ShowS
show :: AddTagsResponse -> String
$cshow :: AddTagsResponse -> String
showsPrec :: Int -> AddTagsResponse -> ShowS
$cshowsPrec :: Int -> AddTagsResponse -> ShowS
Prelude.Show, forall x. Rep AddTagsResponse x -> AddTagsResponse
forall x. AddTagsResponse -> Rep AddTagsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddTagsResponse x -> AddTagsResponse
$cfrom :: forall x. AddTagsResponse -> Rep AddTagsResponse x
Prelude.Generic)

-- |
-- Create a value of 'AddTagsResponse' 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:
--
-- 'httpStatus', 'addTagsResponse_httpStatus' - The response's http status code.
newAddTagsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AddTagsResponse
newAddTagsResponse :: Int -> AddTagsResponse
newAddTagsResponse Int
pHttpStatus_ =
  AddTagsResponse' {$sel:httpStatus:AddTagsResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
addTagsResponse_httpStatus :: Lens.Lens' AddTagsResponse Prelude.Int
addTagsResponse_httpStatus :: Lens' AddTagsResponse Int
addTagsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddTagsResponse' {Int
httpStatus :: Int
$sel:httpStatus:AddTagsResponse' :: AddTagsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AddTagsResponse
s@AddTagsResponse' {} Int
a -> AddTagsResponse
s {$sel:httpStatus:AddTagsResponse' :: Int
httpStatus = Int
a} :: AddTagsResponse)

instance Prelude.NFData AddTagsResponse where
  rnf :: AddTagsResponse -> ()
rnf AddTagsResponse' {Int
httpStatus :: Int
$sel:httpStatus:AddTagsResponse' :: AddTagsResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus