{-# 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.Route53Domains.UpdateTagsForDomain
-- 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)
--
-- This operation adds or updates tags for a specified domain.
--
-- All tag operations are eventually consistent; subsequent operations
-- might not immediately represent all issued operations.
module Amazonka.Route53Domains.UpdateTagsForDomain
  ( -- * Creating a Request
    UpdateTagsForDomain (..),
    newUpdateTagsForDomain,

    -- * Request Lenses
    updateTagsForDomain_tagsToUpdate,
    updateTagsForDomain_domainName,

    -- * Destructuring the Response
    UpdateTagsForDomainResponse (..),
    newUpdateTagsForDomainResponse,

    -- * Response Lenses
    updateTagsForDomainResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Route53Domains.Types

-- | The UpdateTagsForDomainRequest includes the following elements.
--
-- /See:/ 'newUpdateTagsForDomain' smart constructor.
data UpdateTagsForDomain = UpdateTagsForDomain'
  { -- | A list of the tag keys and values that you want to add or update. If you
    -- specify a key that already exists, the corresponding value will be
    -- replaced.
    UpdateTagsForDomain -> Maybe [Tag]
tagsToUpdate :: Prelude.Maybe [Tag],
    -- | The domain for which you want to add or update tags.
    UpdateTagsForDomain -> Text
domainName :: Prelude.Text
  }
  deriving (UpdateTagsForDomain -> UpdateTagsForDomain -> Bool
(UpdateTagsForDomain -> UpdateTagsForDomain -> Bool)
-> (UpdateTagsForDomain -> UpdateTagsForDomain -> Bool)
-> Eq UpdateTagsForDomain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateTagsForDomain -> UpdateTagsForDomain -> Bool
$c/= :: UpdateTagsForDomain -> UpdateTagsForDomain -> Bool
== :: UpdateTagsForDomain -> UpdateTagsForDomain -> Bool
$c== :: UpdateTagsForDomain -> UpdateTagsForDomain -> Bool
Prelude.Eq, ReadPrec [UpdateTagsForDomain]
ReadPrec UpdateTagsForDomain
Int -> ReadS UpdateTagsForDomain
ReadS [UpdateTagsForDomain]
(Int -> ReadS UpdateTagsForDomain)
-> ReadS [UpdateTagsForDomain]
-> ReadPrec UpdateTagsForDomain
-> ReadPrec [UpdateTagsForDomain]
-> Read UpdateTagsForDomain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateTagsForDomain]
$creadListPrec :: ReadPrec [UpdateTagsForDomain]
readPrec :: ReadPrec UpdateTagsForDomain
$creadPrec :: ReadPrec UpdateTagsForDomain
readList :: ReadS [UpdateTagsForDomain]
$creadList :: ReadS [UpdateTagsForDomain]
readsPrec :: Int -> ReadS UpdateTagsForDomain
$creadsPrec :: Int -> ReadS UpdateTagsForDomain
Prelude.Read, Int -> UpdateTagsForDomain -> ShowS
[UpdateTagsForDomain] -> ShowS
UpdateTagsForDomain -> String
(Int -> UpdateTagsForDomain -> ShowS)
-> (UpdateTagsForDomain -> String)
-> ([UpdateTagsForDomain] -> ShowS)
-> Show UpdateTagsForDomain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateTagsForDomain] -> ShowS
$cshowList :: [UpdateTagsForDomain] -> ShowS
show :: UpdateTagsForDomain -> String
$cshow :: UpdateTagsForDomain -> String
showsPrec :: Int -> UpdateTagsForDomain -> ShowS
$cshowsPrec :: Int -> UpdateTagsForDomain -> ShowS
Prelude.Show, (forall x. UpdateTagsForDomain -> Rep UpdateTagsForDomain x)
-> (forall x. Rep UpdateTagsForDomain x -> UpdateTagsForDomain)
-> Generic UpdateTagsForDomain
forall x. Rep UpdateTagsForDomain x -> UpdateTagsForDomain
forall x. UpdateTagsForDomain -> Rep UpdateTagsForDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateTagsForDomain x -> UpdateTagsForDomain
$cfrom :: forall x. UpdateTagsForDomain -> Rep UpdateTagsForDomain x
Prelude.Generic)

-- |
-- Create a value of 'UpdateTagsForDomain' 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:
--
-- 'tagsToUpdate', 'updateTagsForDomain_tagsToUpdate' - A list of the tag keys and values that you want to add or update. If you
-- specify a key that already exists, the corresponding value will be
-- replaced.
--
-- 'domainName', 'updateTagsForDomain_domainName' - The domain for which you want to add or update tags.
newUpdateTagsForDomain ::
  -- | 'domainName'
  Prelude.Text ->
  UpdateTagsForDomain
newUpdateTagsForDomain :: Text -> UpdateTagsForDomain
newUpdateTagsForDomain Text
pDomainName_ =
  UpdateTagsForDomain' :: Maybe [Tag] -> Text -> UpdateTagsForDomain
UpdateTagsForDomain'
    { $sel:tagsToUpdate:UpdateTagsForDomain' :: Maybe [Tag]
tagsToUpdate =
        Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:UpdateTagsForDomain' :: Text
domainName = Text
pDomainName_
    }

-- | A list of the tag keys and values that you want to add or update. If you
-- specify a key that already exists, the corresponding value will be
-- replaced.
updateTagsForDomain_tagsToUpdate :: Lens.Lens' UpdateTagsForDomain (Prelude.Maybe [Tag])
updateTagsForDomain_tagsToUpdate :: (Maybe [Tag] -> f (Maybe [Tag]))
-> UpdateTagsForDomain -> f UpdateTagsForDomain
updateTagsForDomain_tagsToUpdate = (UpdateTagsForDomain -> Maybe [Tag])
-> (UpdateTagsForDomain -> Maybe [Tag] -> UpdateTagsForDomain)
-> Lens
     UpdateTagsForDomain UpdateTagsForDomain (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTagsForDomain' {Maybe [Tag]
tagsToUpdate :: Maybe [Tag]
$sel:tagsToUpdate:UpdateTagsForDomain' :: UpdateTagsForDomain -> Maybe [Tag]
tagsToUpdate} -> Maybe [Tag]
tagsToUpdate) (\s :: UpdateTagsForDomain
s@UpdateTagsForDomain' {} Maybe [Tag]
a -> UpdateTagsForDomain
s {$sel:tagsToUpdate:UpdateTagsForDomain' :: Maybe [Tag]
tagsToUpdate = Maybe [Tag]
a} :: UpdateTagsForDomain) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> UpdateTagsForDomain -> f UpdateTagsForDomain)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> UpdateTagsForDomain
-> f UpdateTagsForDomain
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 domain for which you want to add or update tags.
updateTagsForDomain_domainName :: Lens.Lens' UpdateTagsForDomain Prelude.Text
updateTagsForDomain_domainName :: (Text -> f Text) -> UpdateTagsForDomain -> f UpdateTagsForDomain
updateTagsForDomain_domainName = (UpdateTagsForDomain -> Text)
-> (UpdateTagsForDomain -> Text -> UpdateTagsForDomain)
-> Lens UpdateTagsForDomain UpdateTagsForDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTagsForDomain' {Text
domainName :: Text
$sel:domainName:UpdateTagsForDomain' :: UpdateTagsForDomain -> Text
domainName} -> Text
domainName) (\s :: UpdateTagsForDomain
s@UpdateTagsForDomain' {} Text
a -> UpdateTagsForDomain
s {$sel:domainName:UpdateTagsForDomain' :: Text
domainName = Text
a} :: UpdateTagsForDomain)

instance Core.AWSRequest UpdateTagsForDomain where
  type
    AWSResponse UpdateTagsForDomain =
      UpdateTagsForDomainResponse
  request :: UpdateTagsForDomain -> Request UpdateTagsForDomain
request = Service -> UpdateTagsForDomain -> Request UpdateTagsForDomain
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateTagsForDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateTagsForDomain)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateTagsForDomain))
-> Logger
-> Service
-> Proxy UpdateTagsForDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateTagsForDomain)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateTagsForDomainResponse
UpdateTagsForDomainResponse'
            (Int -> UpdateTagsForDomainResponse)
-> Either String Int -> Either String UpdateTagsForDomainResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateTagsForDomain

instance Prelude.NFData UpdateTagsForDomain

instance Core.ToHeaders UpdateTagsForDomain where
  toHeaders :: UpdateTagsForDomain -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateTagsForDomain -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Route53Domains_v20140515.UpdateTagsForDomain" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateTagsForDomain where
  toJSON :: UpdateTagsForDomain -> Value
toJSON UpdateTagsForDomain' {Maybe [Tag]
Text
domainName :: Text
tagsToUpdate :: Maybe [Tag]
$sel:domainName:UpdateTagsForDomain' :: UpdateTagsForDomain -> Text
$sel:tagsToUpdate:UpdateTagsForDomain' :: UpdateTagsForDomain -> Maybe [Tag]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TagsToUpdate" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tagsToUpdate,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DomainName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
domainName)
          ]
      )

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

instance Core.ToQuery UpdateTagsForDomain where
  toQuery :: UpdateTagsForDomain -> QueryString
toQuery = QueryString -> UpdateTagsForDomain -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

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

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

instance Prelude.NFData UpdateTagsForDomainResponse