{-# 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.EnableDomainTransferLock
-- 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 sets the transfer lock on the domain (specifically the
-- @clientTransferProhibited@ status) to prevent domain transfers.
-- Successful submission returns an operation ID that you can use to track
-- the progress and completion of the action. If the request is not
-- completed successfully, the domain registrant will be notified by email.
module Amazonka.Route53Domains.EnableDomainTransferLock
  ( -- * Creating a Request
    EnableDomainTransferLock (..),
    newEnableDomainTransferLock,

    -- * Request Lenses
    enableDomainTransferLock_domainName,

    -- * Destructuring the Response
    EnableDomainTransferLockResponse (..),
    newEnableDomainTransferLockResponse,

    -- * Response Lenses
    enableDomainTransferLockResponse_httpStatus,
    enableDomainTransferLockResponse_operationId,
  )
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

-- | A request to set the transfer lock for the specified domain.
--
-- /See:/ 'newEnableDomainTransferLock' smart constructor.
data EnableDomainTransferLock = EnableDomainTransferLock'
  { -- | The name of the domain that you want to set the transfer lock for.
    EnableDomainTransferLock -> Text
domainName :: Prelude.Text
  }
  deriving (EnableDomainTransferLock -> EnableDomainTransferLock -> Bool
(EnableDomainTransferLock -> EnableDomainTransferLock -> Bool)
-> (EnableDomainTransferLock -> EnableDomainTransferLock -> Bool)
-> Eq EnableDomainTransferLock
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableDomainTransferLock -> EnableDomainTransferLock -> Bool
$c/= :: EnableDomainTransferLock -> EnableDomainTransferLock -> Bool
== :: EnableDomainTransferLock -> EnableDomainTransferLock -> Bool
$c== :: EnableDomainTransferLock -> EnableDomainTransferLock -> Bool
Prelude.Eq, ReadPrec [EnableDomainTransferLock]
ReadPrec EnableDomainTransferLock
Int -> ReadS EnableDomainTransferLock
ReadS [EnableDomainTransferLock]
(Int -> ReadS EnableDomainTransferLock)
-> ReadS [EnableDomainTransferLock]
-> ReadPrec EnableDomainTransferLock
-> ReadPrec [EnableDomainTransferLock]
-> Read EnableDomainTransferLock
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableDomainTransferLock]
$creadListPrec :: ReadPrec [EnableDomainTransferLock]
readPrec :: ReadPrec EnableDomainTransferLock
$creadPrec :: ReadPrec EnableDomainTransferLock
readList :: ReadS [EnableDomainTransferLock]
$creadList :: ReadS [EnableDomainTransferLock]
readsPrec :: Int -> ReadS EnableDomainTransferLock
$creadsPrec :: Int -> ReadS EnableDomainTransferLock
Prelude.Read, Int -> EnableDomainTransferLock -> ShowS
[EnableDomainTransferLock] -> ShowS
EnableDomainTransferLock -> String
(Int -> EnableDomainTransferLock -> ShowS)
-> (EnableDomainTransferLock -> String)
-> ([EnableDomainTransferLock] -> ShowS)
-> Show EnableDomainTransferLock
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableDomainTransferLock] -> ShowS
$cshowList :: [EnableDomainTransferLock] -> ShowS
show :: EnableDomainTransferLock -> String
$cshow :: EnableDomainTransferLock -> String
showsPrec :: Int -> EnableDomainTransferLock -> ShowS
$cshowsPrec :: Int -> EnableDomainTransferLock -> ShowS
Prelude.Show, (forall x.
 EnableDomainTransferLock -> Rep EnableDomainTransferLock x)
-> (forall x.
    Rep EnableDomainTransferLock x -> EnableDomainTransferLock)
-> Generic EnableDomainTransferLock
forall x.
Rep EnableDomainTransferLock x -> EnableDomainTransferLock
forall x.
EnableDomainTransferLock -> Rep EnableDomainTransferLock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EnableDomainTransferLock x -> EnableDomainTransferLock
$cfrom :: forall x.
EnableDomainTransferLock -> Rep EnableDomainTransferLock x
Prelude.Generic)

-- |
-- Create a value of 'EnableDomainTransferLock' 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', 'enableDomainTransferLock_domainName' - The name of the domain that you want to set the transfer lock for.
newEnableDomainTransferLock ::
  -- | 'domainName'
  Prelude.Text ->
  EnableDomainTransferLock
newEnableDomainTransferLock :: Text -> EnableDomainTransferLock
newEnableDomainTransferLock Text
pDomainName_ =
  EnableDomainTransferLock' :: Text -> EnableDomainTransferLock
EnableDomainTransferLock'
    { $sel:domainName:EnableDomainTransferLock' :: Text
domainName =
        Text
pDomainName_
    }

-- | The name of the domain that you want to set the transfer lock for.
enableDomainTransferLock_domainName :: Lens.Lens' EnableDomainTransferLock Prelude.Text
enableDomainTransferLock_domainName :: (Text -> f Text)
-> EnableDomainTransferLock -> f EnableDomainTransferLock
enableDomainTransferLock_domainName = (EnableDomainTransferLock -> Text)
-> (EnableDomainTransferLock -> Text -> EnableDomainTransferLock)
-> Lens EnableDomainTransferLock EnableDomainTransferLock Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableDomainTransferLock' {Text
domainName :: Text
$sel:domainName:EnableDomainTransferLock' :: EnableDomainTransferLock -> Text
domainName} -> Text
domainName) (\s :: EnableDomainTransferLock
s@EnableDomainTransferLock' {} Text
a -> EnableDomainTransferLock
s {$sel:domainName:EnableDomainTransferLock' :: Text
domainName = Text
a} :: EnableDomainTransferLock)

instance Core.AWSRequest EnableDomainTransferLock where
  type
    AWSResponse EnableDomainTransferLock =
      EnableDomainTransferLockResponse
  request :: EnableDomainTransferLock -> Request EnableDomainTransferLock
request = Service
-> EnableDomainTransferLock -> Request EnableDomainTransferLock
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy EnableDomainTransferLock
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse EnableDomainTransferLock)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse EnableDomainTransferLock))
-> Logger
-> Service
-> Proxy EnableDomainTransferLock
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse EnableDomainTransferLock)))
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 ->
          Int -> Text -> EnableDomainTransferLockResponse
EnableDomainTransferLockResponse'
            (Int -> Text -> EnableDomainTransferLockResponse)
-> Either String Int
-> Either String (Text -> EnableDomainTransferLockResponse)
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))
            Either String (Text -> EnableDomainTransferLockResponse)
-> Either String Text
-> Either String EnableDomainTransferLockResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"OperationId")
      )

instance Prelude.Hashable EnableDomainTransferLock

instance Prelude.NFData EnableDomainTransferLock

instance Core.ToHeaders EnableDomainTransferLock where
  toHeaders :: EnableDomainTransferLock -> ResponseHeaders
toHeaders =
    ResponseHeaders -> EnableDomainTransferLock -> 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.EnableDomainTransferLock" ::
                          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 EnableDomainTransferLock where
  toJSON :: EnableDomainTransferLock -> Value
toJSON EnableDomainTransferLock' {Text
domainName :: Text
$sel:domainName:EnableDomainTransferLock' :: EnableDomainTransferLock -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [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 EnableDomainTransferLock where
  toPath :: EnableDomainTransferLock -> ByteString
toPath = ByteString -> EnableDomainTransferLock -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | The EnableDomainTransferLock response includes the following elements.
--
-- /See:/ 'newEnableDomainTransferLockResponse' smart constructor.
data EnableDomainTransferLockResponse = EnableDomainTransferLockResponse'
  { -- | The response's http status code.
    EnableDomainTransferLockResponse -> Int
httpStatus :: Prelude.Int,
    -- | Identifier for tracking the progress of the request. To use this ID to
    -- query the operation status, use GetOperationDetail.
    EnableDomainTransferLockResponse -> Text
operationId :: Prelude.Text
  }
  deriving (EnableDomainTransferLockResponse
-> EnableDomainTransferLockResponse -> Bool
(EnableDomainTransferLockResponse
 -> EnableDomainTransferLockResponse -> Bool)
-> (EnableDomainTransferLockResponse
    -> EnableDomainTransferLockResponse -> Bool)
-> Eq EnableDomainTransferLockResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableDomainTransferLockResponse
-> EnableDomainTransferLockResponse -> Bool
$c/= :: EnableDomainTransferLockResponse
-> EnableDomainTransferLockResponse -> Bool
== :: EnableDomainTransferLockResponse
-> EnableDomainTransferLockResponse -> Bool
$c== :: EnableDomainTransferLockResponse
-> EnableDomainTransferLockResponse -> Bool
Prelude.Eq, ReadPrec [EnableDomainTransferLockResponse]
ReadPrec EnableDomainTransferLockResponse
Int -> ReadS EnableDomainTransferLockResponse
ReadS [EnableDomainTransferLockResponse]
(Int -> ReadS EnableDomainTransferLockResponse)
-> ReadS [EnableDomainTransferLockResponse]
-> ReadPrec EnableDomainTransferLockResponse
-> ReadPrec [EnableDomainTransferLockResponse]
-> Read EnableDomainTransferLockResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableDomainTransferLockResponse]
$creadListPrec :: ReadPrec [EnableDomainTransferLockResponse]
readPrec :: ReadPrec EnableDomainTransferLockResponse
$creadPrec :: ReadPrec EnableDomainTransferLockResponse
readList :: ReadS [EnableDomainTransferLockResponse]
$creadList :: ReadS [EnableDomainTransferLockResponse]
readsPrec :: Int -> ReadS EnableDomainTransferLockResponse
$creadsPrec :: Int -> ReadS EnableDomainTransferLockResponse
Prelude.Read, Int -> EnableDomainTransferLockResponse -> ShowS
[EnableDomainTransferLockResponse] -> ShowS
EnableDomainTransferLockResponse -> String
(Int -> EnableDomainTransferLockResponse -> ShowS)
-> (EnableDomainTransferLockResponse -> String)
-> ([EnableDomainTransferLockResponse] -> ShowS)
-> Show EnableDomainTransferLockResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableDomainTransferLockResponse] -> ShowS
$cshowList :: [EnableDomainTransferLockResponse] -> ShowS
show :: EnableDomainTransferLockResponse -> String
$cshow :: EnableDomainTransferLockResponse -> String
showsPrec :: Int -> EnableDomainTransferLockResponse -> ShowS
$cshowsPrec :: Int -> EnableDomainTransferLockResponse -> ShowS
Prelude.Show, (forall x.
 EnableDomainTransferLockResponse
 -> Rep EnableDomainTransferLockResponse x)
-> (forall x.
    Rep EnableDomainTransferLockResponse x
    -> EnableDomainTransferLockResponse)
-> Generic EnableDomainTransferLockResponse
forall x.
Rep EnableDomainTransferLockResponse x
-> EnableDomainTransferLockResponse
forall x.
EnableDomainTransferLockResponse
-> Rep EnableDomainTransferLockResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EnableDomainTransferLockResponse x
-> EnableDomainTransferLockResponse
$cfrom :: forall x.
EnableDomainTransferLockResponse
-> Rep EnableDomainTransferLockResponse x
Prelude.Generic)

-- |
-- Create a value of 'EnableDomainTransferLockResponse' 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', 'enableDomainTransferLockResponse_httpStatus' - The response's http status code.
--
-- 'operationId', 'enableDomainTransferLockResponse_operationId' - Identifier for tracking the progress of the request. To use this ID to
-- query the operation status, use GetOperationDetail.
newEnableDomainTransferLockResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'operationId'
  Prelude.Text ->
  EnableDomainTransferLockResponse
newEnableDomainTransferLockResponse :: Int -> Text -> EnableDomainTransferLockResponse
newEnableDomainTransferLockResponse
  Int
pHttpStatus_
  Text
pOperationId_ =
    EnableDomainTransferLockResponse' :: Int -> Text -> EnableDomainTransferLockResponse
EnableDomainTransferLockResponse'
      { $sel:httpStatus:EnableDomainTransferLockResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:operationId:EnableDomainTransferLockResponse' :: Text
operationId = Text
pOperationId_
      }

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

-- | Identifier for tracking the progress of the request. To use this ID to
-- query the operation status, use GetOperationDetail.
enableDomainTransferLockResponse_operationId :: Lens.Lens' EnableDomainTransferLockResponse Prelude.Text
enableDomainTransferLockResponse_operationId :: (Text -> f Text)
-> EnableDomainTransferLockResponse
-> f EnableDomainTransferLockResponse
enableDomainTransferLockResponse_operationId = (EnableDomainTransferLockResponse -> Text)
-> (EnableDomainTransferLockResponse
    -> Text -> EnableDomainTransferLockResponse)
-> Lens
     EnableDomainTransferLockResponse
     EnableDomainTransferLockResponse
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableDomainTransferLockResponse' {Text
operationId :: Text
$sel:operationId:EnableDomainTransferLockResponse' :: EnableDomainTransferLockResponse -> Text
operationId} -> Text
operationId) (\s :: EnableDomainTransferLockResponse
s@EnableDomainTransferLockResponse' {} Text
a -> EnableDomainTransferLockResponse
s {$sel:operationId:EnableDomainTransferLockResponse' :: Text
operationId = Text
a} :: EnableDomainTransferLockResponse)

instance
  Prelude.NFData
    EnableDomainTransferLockResponse