{-# 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.AppSync.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)
--
-- Updates a custom @DomainName@ object.
module Amazonka.AppSync.UpdateDomainName
  ( -- * Creating a Request
    UpdateDomainName (..),
    newUpdateDomainName,

    -- * Request Lenses
    updateDomainName_description,
    updateDomainName_domainName,

    -- * Destructuring the Response
    UpdateDomainNameResponse (..),
    newUpdateDomainNameResponse,

    -- * Response Lenses
    updateDomainNameResponse_domainNameConfig,
    updateDomainNameResponse_httpStatus,
  )
where

import Amazonka.AppSync.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

-- | /See:/ 'newUpdateDomainName' smart constructor.
data UpdateDomainName = UpdateDomainName'
  { -- | A description of the @DomainName@.
    UpdateDomainName -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The domain name.
    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:
--
-- 'description', 'updateDomainName_description' - A description of the @DomainName@.
--
-- 'domainName', 'updateDomainName_domainName' - The domain name.
newUpdateDomainName ::
  -- | 'domainName'
  Prelude.Text ->
  UpdateDomainName
newUpdateDomainName :: Text -> UpdateDomainName
newUpdateDomainName Text
pDomainName_ =
  UpdateDomainName'
    { $sel:description:UpdateDomainName' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:UpdateDomainName' :: Text
domainName = Text
pDomainName_
    }

-- | A description of the @DomainName@.
updateDomainName_description :: Lens.Lens' UpdateDomainName (Prelude.Maybe Prelude.Text)
updateDomainName_description :: Lens' UpdateDomainName (Maybe Text)
updateDomainName_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDomainName' {Maybe Text
description :: Maybe Text
$sel:description:UpdateDomainName' :: UpdateDomainName -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateDomainName
s@UpdateDomainName' {} Maybe Text
a -> UpdateDomainName
s {$sel:description:UpdateDomainName' :: Maybe Text
description = Maybe Text
a} :: UpdateDomainName)

-- | The domain name.
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 =
      UpdateDomainNameResponse
  request :: (Service -> Service)
-> UpdateDomainName -> Request UpdateDomainName
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 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 ->
          Maybe DomainNameConfig -> Int -> UpdateDomainNameResponse
UpdateDomainNameResponse'
            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
"domainNameConfig")
            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 UpdateDomainName where
  hashWithSalt :: Int -> UpdateDomainName -> Int
hashWithSalt Int
_salt UpdateDomainName' {Maybe Text
Text
domainName :: Text
description :: Maybe Text
$sel:domainName:UpdateDomainName' :: UpdateDomainName -> Text
$sel:description:UpdateDomainName' :: UpdateDomainName -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance Prelude.NFData UpdateDomainName where
  rnf :: UpdateDomainName -> ()
rnf UpdateDomainName' {Maybe Text
Text
domainName :: Text
description :: Maybe Text
$sel:domainName:UpdateDomainName' :: UpdateDomainName -> Text
$sel:description:UpdateDomainName' :: UpdateDomainName -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      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
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateDomainName where
  toJSON :: UpdateDomainName -> Value
toJSON UpdateDomainName' {Maybe Text
Text
domainName :: Text
description :: Maybe Text
$sel:domainName:UpdateDomainName' :: UpdateDomainName -> Text
$sel:description:UpdateDomainName' :: UpdateDomainName -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"description" 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 Text
description]
      )

instance Data.ToPath UpdateDomainName where
  toPath :: UpdateDomainName -> ByteString
toPath UpdateDomainName' {Maybe Text
Text
domainName :: Text
description :: Maybe Text
$sel:domainName:UpdateDomainName' :: UpdateDomainName -> Text
$sel:description:UpdateDomainName' :: UpdateDomainName -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/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

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

-- |
-- Create a value of 'UpdateDomainNameResponse' 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:
--
-- 'domainNameConfig', 'updateDomainNameResponse_domainNameConfig' - The configuration for the @DomainName@.
--
-- 'httpStatus', 'updateDomainNameResponse_httpStatus' - The response's http status code.
newUpdateDomainNameResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateDomainNameResponse
newUpdateDomainNameResponse :: Int -> UpdateDomainNameResponse
newUpdateDomainNameResponse Int
pHttpStatus_ =
  UpdateDomainNameResponse'
    { $sel:domainNameConfig:UpdateDomainNameResponse' :: Maybe DomainNameConfig
domainNameConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateDomainNameResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The configuration for the @DomainName@.
updateDomainNameResponse_domainNameConfig :: Lens.Lens' UpdateDomainNameResponse (Prelude.Maybe DomainNameConfig)
updateDomainNameResponse_domainNameConfig :: Lens' UpdateDomainNameResponse (Maybe DomainNameConfig)
updateDomainNameResponse_domainNameConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDomainNameResponse' {Maybe DomainNameConfig
domainNameConfig :: Maybe DomainNameConfig
$sel:domainNameConfig:UpdateDomainNameResponse' :: UpdateDomainNameResponse -> Maybe DomainNameConfig
domainNameConfig} -> Maybe DomainNameConfig
domainNameConfig) (\s :: UpdateDomainNameResponse
s@UpdateDomainNameResponse' {} Maybe DomainNameConfig
a -> UpdateDomainNameResponse
s {$sel:domainNameConfig:UpdateDomainNameResponse' :: Maybe DomainNameConfig
domainNameConfig = Maybe DomainNameConfig
a} :: UpdateDomainNameResponse)

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

instance Prelude.NFData UpdateDomainNameResponse where
  rnf :: UpdateDomainNameResponse -> ()
rnf UpdateDomainNameResponse' {Int
Maybe DomainNameConfig
httpStatus :: Int
domainNameConfig :: Maybe DomainNameConfig
$sel:httpStatus:UpdateDomainNameResponse' :: UpdateDomainNameResponse -> Int
$sel:domainNameConfig:UpdateDomainNameResponse' :: UpdateDomainNameResponse -> Maybe DomainNameConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DomainNameConfig
domainNameConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus