{-# 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-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)
--
-- 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_regionalHostedZoneId,
    domainName_certificateName,
    domainName_ownershipVerificationCertificateArn,
    domainName_regionalCertificateArn,
    domainName_certificateArn,
    domainName_distributionHostedZoneId,
    domainName_securityPolicy,
    domainName_domainName,
    domainName_mutualTlsAuthentication,
    domainName_regionalCertificateName,
    domainName_regionalDomainName,
    domainName_certificateUploadDate,
    domainName_distributionDomainName,
    domainName_domainNameStatusMessage,
    domainName_endpointConfiguration,
    domainName_domainNameStatus,
    domainName_tags,
  )
where

import Amazonka.APIGateway.Types
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

-- | A request to change information about the DomainName resource.
--
-- /See:/ 'newUpdateDomainName' smart constructor.
data UpdateDomainName = UpdateDomainName'
  { -- | A list of update operations to be applied to the specified resource and
    -- in the order specified in this list.
    UpdateDomainName -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation],
    -- | [Required] The name of the DomainName resource to be changed.
    UpdateDomainName -> Text
domainName :: Prelude.Text
  }
  deriving (UpdateDomainName -> UpdateDomainName -> Bool
(UpdateDomainName -> UpdateDomainName -> Bool)
-> (UpdateDomainName -> UpdateDomainName -> Bool)
-> Eq UpdateDomainName
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]
(Int -> ReadS UpdateDomainName)
-> ReadS [UpdateDomainName]
-> ReadPrec UpdateDomainName
-> ReadPrec [UpdateDomainName]
-> Read 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
(Int -> UpdateDomainName -> ShowS)
-> (UpdateDomainName -> String)
-> ([UpdateDomainName] -> ShowS)
-> Show UpdateDomainName
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. UpdateDomainName -> Rep UpdateDomainName x)
-> (forall x. Rep UpdateDomainName x -> UpdateDomainName)
-> Generic UpdateDomainName
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' - A list of update operations to be applied to the specified resource and
-- in the order specified in this list.
--
-- 'domainName', 'updateDomainName_domainName' - [Required] The name of the DomainName resource to be changed.
newUpdateDomainName ::
  -- | 'domainName'
  Prelude.Text ->
  UpdateDomainName
newUpdateDomainName :: Text -> UpdateDomainName
newUpdateDomainName Text
pDomainName_ =
  UpdateDomainName' :: Maybe [PatchOperation] -> Text -> UpdateDomainName
UpdateDomainName'
    { $sel:patchOperations:UpdateDomainName' :: Maybe [PatchOperation]
patchOperations =
        Maybe [PatchOperation]
forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:UpdateDomainName' :: Text
domainName = Text
pDomainName_
    }

-- | A list of update operations to be applied to the specified resource and
-- in the order specified in this list.
updateDomainName_patchOperations :: Lens.Lens' UpdateDomainName (Prelude.Maybe [PatchOperation])
updateDomainName_patchOperations :: (Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateDomainName -> f UpdateDomainName
updateDomainName_patchOperations = (UpdateDomainName -> Maybe [PatchOperation])
-> (UpdateDomainName -> Maybe [PatchOperation] -> UpdateDomainName)
-> Lens
     UpdateDomainName
     UpdateDomainName
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
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) ((Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
 -> UpdateDomainName -> f UpdateDomainName)
-> ((Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
    -> Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> (Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateDomainName
-> f UpdateDomainName
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PatchOperation] [PatchOperation] [PatchOperation] [PatchOperation]
-> Iso
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
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
  [PatchOperation] [PatchOperation] [PatchOperation] [PatchOperation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | [Required] The name of the DomainName resource to be changed.
updateDomainName_domainName :: Lens.Lens' UpdateDomainName Prelude.Text
updateDomainName_domainName :: (Text -> f Text) -> UpdateDomainName -> f UpdateDomainName
updateDomainName_domainName = (UpdateDomainName -> Text)
-> (UpdateDomainName -> Text -> UpdateDomainName)
-> Lens UpdateDomainName UpdateDomainName Text Text
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 :: UpdateDomainName -> Request UpdateDomainName
request = Service -> UpdateDomainName -> Request UpdateDomainName
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateDomainName
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDomainName)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateDomainName))
-> Logger
-> Service
-> Proxy UpdateDomainName
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDomainName)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String DomainName
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable UpdateDomainName

instance Prelude.NFData UpdateDomainName

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"patchOperations" Text -> [PatchOperation] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([PatchOperation] -> Pair) -> Maybe [PatchOperation] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PatchOperation]
patchOperations
          ]
      )

instance Core.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]
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/domainnames/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
domainName]

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