{-# 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.Lightsail.UpdateDomainEntry
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates a domain recordset after it is created.
--
-- The @update domain entry@ operation supports tag-based access control
-- via resource tags applied to the resource identified by @domain name@.
-- For more information, see the
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-controlling-access-using-tags Amazon Lightsail Developer Guide>.
module Amazonka.Lightsail.UpdateDomainEntry
  ( -- * Creating a Request
    UpdateDomainEntry (..),
    newUpdateDomainEntry,

    -- * Request Lenses
    updateDomainEntry_domainName,
    updateDomainEntry_domainEntry,

    -- * Destructuring the Response
    UpdateDomainEntryResponse (..),
    newUpdateDomainEntryResponse,

    -- * Response Lenses
    updateDomainEntryResponse_operations,
    updateDomainEntryResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateDomainEntry' smart constructor.
data UpdateDomainEntry = UpdateDomainEntry'
  { -- | The name of the domain recordset to update.
    UpdateDomainEntry -> Text
domainName :: Prelude.Text,
    -- | An array of key-value pairs containing information about the domain
    -- entry.
    UpdateDomainEntry -> DomainEntry
domainEntry :: DomainEntry
  }
  deriving (UpdateDomainEntry -> UpdateDomainEntry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDomainEntry -> UpdateDomainEntry -> Bool
$c/= :: UpdateDomainEntry -> UpdateDomainEntry -> Bool
== :: UpdateDomainEntry -> UpdateDomainEntry -> Bool
$c== :: UpdateDomainEntry -> UpdateDomainEntry -> Bool
Prelude.Eq, ReadPrec [UpdateDomainEntry]
ReadPrec UpdateDomainEntry
Int -> ReadS UpdateDomainEntry
ReadS [UpdateDomainEntry]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDomainEntry]
$creadListPrec :: ReadPrec [UpdateDomainEntry]
readPrec :: ReadPrec UpdateDomainEntry
$creadPrec :: ReadPrec UpdateDomainEntry
readList :: ReadS [UpdateDomainEntry]
$creadList :: ReadS [UpdateDomainEntry]
readsPrec :: Int -> ReadS UpdateDomainEntry
$creadsPrec :: Int -> ReadS UpdateDomainEntry
Prelude.Read, Int -> UpdateDomainEntry -> ShowS
[UpdateDomainEntry] -> ShowS
UpdateDomainEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDomainEntry] -> ShowS
$cshowList :: [UpdateDomainEntry] -> ShowS
show :: UpdateDomainEntry -> String
$cshow :: UpdateDomainEntry -> String
showsPrec :: Int -> UpdateDomainEntry -> ShowS
$cshowsPrec :: Int -> UpdateDomainEntry -> ShowS
Prelude.Show, forall x. Rep UpdateDomainEntry x -> UpdateDomainEntry
forall x. UpdateDomainEntry -> Rep UpdateDomainEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDomainEntry x -> UpdateDomainEntry
$cfrom :: forall x. UpdateDomainEntry -> Rep UpdateDomainEntry x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDomainEntry' 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:
--
-- 'domainName', 'updateDomainEntry_domainName' - The name of the domain recordset to update.
--
-- 'domainEntry', 'updateDomainEntry_domainEntry' - An array of key-value pairs containing information about the domain
-- entry.
newUpdateDomainEntry ::
  -- | 'domainName'
  Prelude.Text ->
  -- | 'domainEntry'
  DomainEntry ->
  UpdateDomainEntry
newUpdateDomainEntry :: Text -> DomainEntry -> UpdateDomainEntry
newUpdateDomainEntry Text
pDomainName_ DomainEntry
pDomainEntry_ =
  UpdateDomainEntry'
    { $sel:domainName:UpdateDomainEntry' :: Text
domainName = Text
pDomainName_,
      $sel:domainEntry:UpdateDomainEntry' :: DomainEntry
domainEntry = DomainEntry
pDomainEntry_
    }

-- | The name of the domain recordset to update.
updateDomainEntry_domainName :: Lens.Lens' UpdateDomainEntry Prelude.Text
updateDomainEntry_domainName :: Lens' UpdateDomainEntry Text
updateDomainEntry_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDomainEntry' {Text
domainName :: Text
$sel:domainName:UpdateDomainEntry' :: UpdateDomainEntry -> Text
domainName} -> Text
domainName) (\s :: UpdateDomainEntry
s@UpdateDomainEntry' {} Text
a -> UpdateDomainEntry
s {$sel:domainName:UpdateDomainEntry' :: Text
domainName = Text
a} :: UpdateDomainEntry)

-- | An array of key-value pairs containing information about the domain
-- entry.
updateDomainEntry_domainEntry :: Lens.Lens' UpdateDomainEntry DomainEntry
updateDomainEntry_domainEntry :: Lens' UpdateDomainEntry DomainEntry
updateDomainEntry_domainEntry = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDomainEntry' {DomainEntry
domainEntry :: DomainEntry
$sel:domainEntry:UpdateDomainEntry' :: UpdateDomainEntry -> DomainEntry
domainEntry} -> DomainEntry
domainEntry) (\s :: UpdateDomainEntry
s@UpdateDomainEntry' {} DomainEntry
a -> UpdateDomainEntry
s {$sel:domainEntry:UpdateDomainEntry' :: DomainEntry
domainEntry = DomainEntry
a} :: UpdateDomainEntry)

instance Core.AWSRequest UpdateDomainEntry where
  type
    AWSResponse UpdateDomainEntry =
      UpdateDomainEntryResponse
  request :: (Service -> Service)
-> UpdateDomainEntry -> Request UpdateDomainEntry
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateDomainEntry
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateDomainEntry)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> UpdateDomainEntryResponse
UpdateDomainEntryResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"operations" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => 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 UpdateDomainEntry where
  hashWithSalt :: Int -> UpdateDomainEntry -> Int
hashWithSalt Int
_salt UpdateDomainEntry' {Text
DomainEntry
domainEntry :: DomainEntry
domainName :: Text
$sel:domainEntry:UpdateDomainEntry' :: UpdateDomainEntry -> DomainEntry
$sel:domainName:UpdateDomainEntry' :: UpdateDomainEntry -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DomainEntry
domainEntry

instance Prelude.NFData UpdateDomainEntry where
  rnf :: UpdateDomainEntry -> ()
rnf UpdateDomainEntry' {Text
DomainEntry
domainEntry :: DomainEntry
domainName :: Text
$sel:domainEntry:UpdateDomainEntry' :: UpdateDomainEntry -> DomainEntry
$sel:domainName:UpdateDomainEntry' :: UpdateDomainEntry -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
domainName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DomainEntry
domainEntry

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

instance Data.ToJSON UpdateDomainEntry where
  toJSON :: UpdateDomainEntry -> Value
toJSON UpdateDomainEntry' {Text
DomainEntry
domainEntry :: DomainEntry
domainName :: Text
$sel:domainEntry:UpdateDomainEntry' :: UpdateDomainEntry -> DomainEntry
$sel:domainName:UpdateDomainEntry' :: UpdateDomainEntry -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"domainName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
domainName),
            forall a. a -> Maybe a
Prelude.Just (Key
"domainEntry" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DomainEntry
domainEntry)
          ]
      )

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

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

-- | /See:/ 'newUpdateDomainEntryResponse' smart constructor.
data UpdateDomainEntryResponse = UpdateDomainEntryResponse'
  { -- | An array of objects that describe the result of the action, such as the
    -- status of the request, the timestamp of the request, and the resources
    -- affected by the request.
    UpdateDomainEntryResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
    -- | The response's http status code.
    UpdateDomainEntryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateDomainEntryResponse -> UpdateDomainEntryResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDomainEntryResponse -> UpdateDomainEntryResponse -> Bool
$c/= :: UpdateDomainEntryResponse -> UpdateDomainEntryResponse -> Bool
== :: UpdateDomainEntryResponse -> UpdateDomainEntryResponse -> Bool
$c== :: UpdateDomainEntryResponse -> UpdateDomainEntryResponse -> Bool
Prelude.Eq, ReadPrec [UpdateDomainEntryResponse]
ReadPrec UpdateDomainEntryResponse
Int -> ReadS UpdateDomainEntryResponse
ReadS [UpdateDomainEntryResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDomainEntryResponse]
$creadListPrec :: ReadPrec [UpdateDomainEntryResponse]
readPrec :: ReadPrec UpdateDomainEntryResponse
$creadPrec :: ReadPrec UpdateDomainEntryResponse
readList :: ReadS [UpdateDomainEntryResponse]
$creadList :: ReadS [UpdateDomainEntryResponse]
readsPrec :: Int -> ReadS UpdateDomainEntryResponse
$creadsPrec :: Int -> ReadS UpdateDomainEntryResponse
Prelude.Read, Int -> UpdateDomainEntryResponse -> ShowS
[UpdateDomainEntryResponse] -> ShowS
UpdateDomainEntryResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDomainEntryResponse] -> ShowS
$cshowList :: [UpdateDomainEntryResponse] -> ShowS
show :: UpdateDomainEntryResponse -> String
$cshow :: UpdateDomainEntryResponse -> String
showsPrec :: Int -> UpdateDomainEntryResponse -> ShowS
$cshowsPrec :: Int -> UpdateDomainEntryResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateDomainEntryResponse x -> UpdateDomainEntryResponse
forall x.
UpdateDomainEntryResponse -> Rep UpdateDomainEntryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateDomainEntryResponse x -> UpdateDomainEntryResponse
$cfrom :: forall x.
UpdateDomainEntryResponse -> Rep UpdateDomainEntryResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDomainEntryResponse' 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:
--
-- 'operations', 'updateDomainEntryResponse_operations' - An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
--
-- 'httpStatus', 'updateDomainEntryResponse_httpStatus' - The response's http status code.
newUpdateDomainEntryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateDomainEntryResponse
newUpdateDomainEntryResponse :: Int -> UpdateDomainEntryResponse
newUpdateDomainEntryResponse Int
pHttpStatus_ =
  UpdateDomainEntryResponse'
    { $sel:operations:UpdateDomainEntryResponse' :: Maybe [Operation]
operations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateDomainEntryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
updateDomainEntryResponse_operations :: Lens.Lens' UpdateDomainEntryResponse (Prelude.Maybe [Operation])
updateDomainEntryResponse_operations :: Lens' UpdateDomainEntryResponse (Maybe [Operation])
updateDomainEntryResponse_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDomainEntryResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:UpdateDomainEntryResponse' :: UpdateDomainEntryResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: UpdateDomainEntryResponse
s@UpdateDomainEntryResponse' {} Maybe [Operation]
a -> UpdateDomainEntryResponse
s {$sel:operations:UpdateDomainEntryResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: UpdateDomainEntryResponse) 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 response's http status code.
updateDomainEntryResponse_httpStatus :: Lens.Lens' UpdateDomainEntryResponse Prelude.Int
updateDomainEntryResponse_httpStatus :: Lens' UpdateDomainEntryResponse Int
updateDomainEntryResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDomainEntryResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateDomainEntryResponse' :: UpdateDomainEntryResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateDomainEntryResponse
s@UpdateDomainEntryResponse' {} Int
a -> UpdateDomainEntryResponse
s {$sel:httpStatus:UpdateDomainEntryResponse' :: Int
httpStatus = Int
a} :: UpdateDomainEntryResponse)

instance Prelude.NFData UpdateDomainEntryResponse where
  rnf :: UpdateDomainEntryResponse -> ()
rnf UpdateDomainEntryResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:UpdateDomainEntryResponse' :: UpdateDomainEntryResponse -> Int
$sel:operations:UpdateDomainEntryResponse' :: UpdateDomainEntryResponse -> Maybe [Operation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Operation]
operations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus