{-# 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.APIGateway.UpdateDomainName
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Changes information about the DomainName resource.
module Amazonka.APIGateway.UpdateDomainName
  ( -- * Creating a Request
    UpdateDomainName (..),
    newUpdateDomainName,

    -- * Request Lenses
    updateDomainName_patchOperations,
    updateDomainName_domainName,

    -- * Destructuring the Response
    DomainName (..),
    newDomainName,

    -- * Response Lenses
    domainName_certificateArn,
    domainName_certificateName,
    domainName_certificateUploadDate,
    domainName_distributionDomainName,
    domainName_distributionHostedZoneId,
    domainName_domainName,
    domainName_domainNameStatus,
    domainName_domainNameStatusMessage,
    domainName_endpointConfiguration,
    domainName_mutualTlsAuthentication,
    domainName_ownershipVerificationCertificateArn,
    domainName_regionalCertificateArn,
    domainName_regionalCertificateName,
    domainName_regionalDomainName,
    domainName_regionalHostedZoneId,
    domainName_securityPolicy,
    domainName_tags,
  )
where

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

-- | A request to change information about the DomainName resource.
--
-- /See:/ 'newUpdateDomainName' smart constructor.
data UpdateDomainName = UpdateDomainName'
  { -- | For more information about supported patch operations, see
    -- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
    UpdateDomainName -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation],
    -- | The name of the DomainName resource to be changed.
    UpdateDomainName -> Text
domainName :: Prelude.Text
  }
  deriving (UpdateDomainName -> UpdateDomainName -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDomainName -> UpdateDomainName -> Bool
$c/= :: UpdateDomainName -> UpdateDomainName -> Bool
== :: UpdateDomainName -> UpdateDomainName -> Bool
$c== :: UpdateDomainName -> UpdateDomainName -> Bool
Prelude.Eq, ReadPrec [UpdateDomainName]
ReadPrec UpdateDomainName
Int -> ReadS UpdateDomainName
ReadS [UpdateDomainName]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDomainName]
$creadListPrec :: ReadPrec [UpdateDomainName]
readPrec :: ReadPrec UpdateDomainName
$creadPrec :: ReadPrec UpdateDomainName
readList :: ReadS [UpdateDomainName]
$creadList :: ReadS [UpdateDomainName]
readsPrec :: Int -> ReadS UpdateDomainName
$creadsPrec :: Int -> ReadS UpdateDomainName
Prelude.Read, Int -> UpdateDomainName -> ShowS
[UpdateDomainName] -> ShowS
UpdateDomainName -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDomainName] -> ShowS
$cshowList :: [UpdateDomainName] -> ShowS
show :: UpdateDomainName -> String
$cshow :: UpdateDomainName -> String
showsPrec :: Int -> UpdateDomainName -> ShowS
$cshowsPrec :: Int -> UpdateDomainName -> ShowS
Prelude.Show, forall x. Rep UpdateDomainName x -> UpdateDomainName
forall x. UpdateDomainName -> Rep UpdateDomainName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDomainName x -> UpdateDomainName
$cfrom :: forall x. UpdateDomainName -> Rep UpdateDomainName x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDomainName' 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:
--
-- 'patchOperations', 'updateDomainName_patchOperations' - For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
--
-- 'domainName', 'updateDomainName_domainName' - The name of the DomainName resource to be changed.
newUpdateDomainName ::
  -- | 'domainName'
  Prelude.Text ->
  UpdateDomainName
newUpdateDomainName :: Text -> UpdateDomainName
newUpdateDomainName Text
pDomainName_ =
  UpdateDomainName'
    { $sel:patchOperations:UpdateDomainName' :: Maybe [PatchOperation]
patchOperations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:UpdateDomainName' :: Text
domainName = Text
pDomainName_
    }

-- | For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
updateDomainName_patchOperations :: Lens.Lens' UpdateDomainName (Prelude.Maybe [PatchOperation])
updateDomainName_patchOperations :: Lens' UpdateDomainName (Maybe [PatchOperation])
updateDomainName_patchOperations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDomainName' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateDomainName' :: UpdateDomainName -> Maybe [PatchOperation]
patchOperations} -> Maybe [PatchOperation]
patchOperations) (\s :: UpdateDomainName
s@UpdateDomainName' {} Maybe [PatchOperation]
a -> UpdateDomainName
s {$sel:patchOperations:UpdateDomainName' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
a} :: UpdateDomainName) 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 name of the DomainName resource to be changed.
updateDomainName_domainName :: Lens.Lens' UpdateDomainName Prelude.Text
updateDomainName_domainName :: Lens' UpdateDomainName Text
updateDomainName_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDomainName' {Text
domainName :: Text
$sel:domainName:UpdateDomainName' :: UpdateDomainName -> Text
domainName} -> Text
domainName) (\s :: UpdateDomainName
s@UpdateDomainName' {} Text
a -> UpdateDomainName
s {$sel:domainName:UpdateDomainName' :: Text
domainName = Text
a} :: UpdateDomainName)

instance Core.AWSRequest UpdateDomainName where
  type AWSResponse UpdateDomainName = DomainName
  request :: (Service -> Service)
-> UpdateDomainName -> Request UpdateDomainName
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateDomainName
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDomainName)))
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 -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable UpdateDomainName where
  hashWithSalt :: Int -> UpdateDomainName -> Int
hashWithSalt Int
_salt UpdateDomainName' {Maybe [PatchOperation]
Text
domainName :: Text
patchOperations :: Maybe [PatchOperation]
$sel:domainName:UpdateDomainName' :: UpdateDomainName -> Text
$sel:patchOperations:UpdateDomainName' :: UpdateDomainName -> Maybe [PatchOperation]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PatchOperation]
patchOperations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance Prelude.NFData UpdateDomainName where
  rnf :: UpdateDomainName -> ()
rnf UpdateDomainName' {Maybe [PatchOperation]
Text
domainName :: Text
patchOperations :: Maybe [PatchOperation]
$sel:domainName:UpdateDomainName' :: UpdateDomainName -> Text
$sel:patchOperations:UpdateDomainName' :: UpdateDomainName -> Maybe [PatchOperation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [PatchOperation]
patchOperations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domainName

instance Data.ToHeaders UpdateDomainName where
  toHeaders :: UpdateDomainName -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

instance Data.ToJSON UpdateDomainName where
  toJSON :: UpdateDomainName -> Value
toJSON UpdateDomainName' {Maybe [PatchOperation]
Text
domainName :: Text
patchOperations :: Maybe [PatchOperation]
$sel:domainName:UpdateDomainName' :: UpdateDomainName -> Text
$sel:patchOperations:UpdateDomainName' :: UpdateDomainName -> Maybe [PatchOperation]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"patchOperations" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PatchOperation]
patchOperations
          ]
      )

instance Data.ToPath UpdateDomainName where
  toPath :: UpdateDomainName -> ByteString
toPath UpdateDomainName' {Maybe [PatchOperation]
Text
domainName :: Text
patchOperations :: Maybe [PatchOperation]
$sel:domainName:UpdateDomainName' :: UpdateDomainName -> Text
$sel:patchOperations:UpdateDomainName' :: UpdateDomainName -> Maybe [PatchOperation]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/domainnames/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
domainName]

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