{-# 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.CancelDomainTransferToAnotherAwsAccount
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Cancels the transfer of a domain from the current Amazon Web Services
-- account to another Amazon Web Services account. You initiate a transfer
-- betweenAmazon Web Services accounts using
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_TransferDomainToAnotherAwsAccount.html TransferDomainToAnotherAwsAccount>.
--
-- You must cancel the transfer before the other Amazon Web Services
-- account accepts the transfer using
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_AcceptDomainTransferFromAnotherAwsAccount.html AcceptDomainTransferFromAnotherAwsAccount>.
--
-- Use either
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_ListOperations.html ListOperations>
-- or
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_GetOperationDetail.html GetOperationDetail>
-- to determine whether the operation succeeded.
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_GetOperationDetail.html GetOperationDetail>
-- provides additional information, for example,
-- @Domain Transfer from Aws Account 111122223333 has been cancelled@.
module Amazonka.Route53Domains.CancelDomainTransferToAnotherAwsAccount
  ( -- * Creating a Request
    CancelDomainTransferToAnotherAwsAccount (..),
    newCancelDomainTransferToAnotherAwsAccount,

    -- * Request Lenses
    cancelDomainTransferToAnotherAwsAccount_domainName,

    -- * Destructuring the Response
    CancelDomainTransferToAnotherAwsAccountResponse (..),
    newCancelDomainTransferToAnotherAwsAccountResponse,

    -- * Response Lenses
    cancelDomainTransferToAnotherAwsAccountResponse_operationId,
    cancelDomainTransferToAnotherAwsAccountResponse_httpStatus,
  )
where

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

-- | The CancelDomainTransferToAnotherAwsAccount request includes the
-- following element.
--
-- /See:/ 'newCancelDomainTransferToAnotherAwsAccount' smart constructor.
data CancelDomainTransferToAnotherAwsAccount = CancelDomainTransferToAnotherAwsAccount'
  { -- | The name of the domain for which you want to cancel the transfer to
    -- another Amazon Web Services account.
    CancelDomainTransferToAnotherAwsAccount -> Text
domainName :: Prelude.Text
  }
  deriving (CancelDomainTransferToAnotherAwsAccount
-> CancelDomainTransferToAnotherAwsAccount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelDomainTransferToAnotherAwsAccount
-> CancelDomainTransferToAnotherAwsAccount -> Bool
$c/= :: CancelDomainTransferToAnotherAwsAccount
-> CancelDomainTransferToAnotherAwsAccount -> Bool
== :: CancelDomainTransferToAnotherAwsAccount
-> CancelDomainTransferToAnotherAwsAccount -> Bool
$c== :: CancelDomainTransferToAnotherAwsAccount
-> CancelDomainTransferToAnotherAwsAccount -> Bool
Prelude.Eq, ReadPrec [CancelDomainTransferToAnotherAwsAccount]
ReadPrec CancelDomainTransferToAnotherAwsAccount
Int -> ReadS CancelDomainTransferToAnotherAwsAccount
ReadS [CancelDomainTransferToAnotherAwsAccount]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelDomainTransferToAnotherAwsAccount]
$creadListPrec :: ReadPrec [CancelDomainTransferToAnotherAwsAccount]
readPrec :: ReadPrec CancelDomainTransferToAnotherAwsAccount
$creadPrec :: ReadPrec CancelDomainTransferToAnotherAwsAccount
readList :: ReadS [CancelDomainTransferToAnotherAwsAccount]
$creadList :: ReadS [CancelDomainTransferToAnotherAwsAccount]
readsPrec :: Int -> ReadS CancelDomainTransferToAnotherAwsAccount
$creadsPrec :: Int -> ReadS CancelDomainTransferToAnotherAwsAccount
Prelude.Read, Int -> CancelDomainTransferToAnotherAwsAccount -> ShowS
[CancelDomainTransferToAnotherAwsAccount] -> ShowS
CancelDomainTransferToAnotherAwsAccount -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelDomainTransferToAnotherAwsAccount] -> ShowS
$cshowList :: [CancelDomainTransferToAnotherAwsAccount] -> ShowS
show :: CancelDomainTransferToAnotherAwsAccount -> String
$cshow :: CancelDomainTransferToAnotherAwsAccount -> String
showsPrec :: Int -> CancelDomainTransferToAnotherAwsAccount -> ShowS
$cshowsPrec :: Int -> CancelDomainTransferToAnotherAwsAccount -> ShowS
Prelude.Show, forall x.
Rep CancelDomainTransferToAnotherAwsAccount x
-> CancelDomainTransferToAnotherAwsAccount
forall x.
CancelDomainTransferToAnotherAwsAccount
-> Rep CancelDomainTransferToAnotherAwsAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelDomainTransferToAnotherAwsAccount x
-> CancelDomainTransferToAnotherAwsAccount
$cfrom :: forall x.
CancelDomainTransferToAnotherAwsAccount
-> Rep CancelDomainTransferToAnotherAwsAccount x
Prelude.Generic)

-- |
-- Create a value of 'CancelDomainTransferToAnotherAwsAccount' 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', 'cancelDomainTransferToAnotherAwsAccount_domainName' - The name of the domain for which you want to cancel the transfer to
-- another Amazon Web Services account.
newCancelDomainTransferToAnotherAwsAccount ::
  -- | 'domainName'
  Prelude.Text ->
  CancelDomainTransferToAnotherAwsAccount
newCancelDomainTransferToAnotherAwsAccount :: Text -> CancelDomainTransferToAnotherAwsAccount
newCancelDomainTransferToAnotherAwsAccount
  Text
pDomainName_ =
    CancelDomainTransferToAnotherAwsAccount'
      { $sel:domainName:CancelDomainTransferToAnotherAwsAccount' :: Text
domainName =
          Text
pDomainName_
      }

-- | The name of the domain for which you want to cancel the transfer to
-- another Amazon Web Services account.
cancelDomainTransferToAnotherAwsAccount_domainName :: Lens.Lens' CancelDomainTransferToAnotherAwsAccount Prelude.Text
cancelDomainTransferToAnotherAwsAccount_domainName :: Lens' CancelDomainTransferToAnotherAwsAccount Text
cancelDomainTransferToAnotherAwsAccount_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelDomainTransferToAnotherAwsAccount' {Text
domainName :: Text
$sel:domainName:CancelDomainTransferToAnotherAwsAccount' :: CancelDomainTransferToAnotherAwsAccount -> Text
domainName} -> Text
domainName) (\s :: CancelDomainTransferToAnotherAwsAccount
s@CancelDomainTransferToAnotherAwsAccount' {} Text
a -> CancelDomainTransferToAnotherAwsAccount
s {$sel:domainName:CancelDomainTransferToAnotherAwsAccount' :: Text
domainName = Text
a} :: CancelDomainTransferToAnotherAwsAccount)

instance
  Core.AWSRequest
    CancelDomainTransferToAnotherAwsAccount
  where
  type
    AWSResponse
      CancelDomainTransferToAnotherAwsAccount =
      CancelDomainTransferToAnotherAwsAccountResponse
  request :: (Service -> Service)
-> CancelDomainTransferToAnotherAwsAccount
-> Request CancelDomainTransferToAnotherAwsAccount
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 CancelDomainTransferToAnotherAwsAccount
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse CancelDomainTransferToAnotherAwsAccount)))
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 Text
-> Int -> CancelDomainTransferToAnotherAwsAccountResponse
CancelDomainTransferToAnotherAwsAccountResponse'
            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
"OperationId")
            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
    CancelDomainTransferToAnotherAwsAccount
  where
  hashWithSalt :: Int -> CancelDomainTransferToAnotherAwsAccount -> Int
hashWithSalt
    Int
_salt
    CancelDomainTransferToAnotherAwsAccount' {Text
domainName :: Text
$sel:domainName:CancelDomainTransferToAnotherAwsAccount' :: CancelDomainTransferToAnotherAwsAccount -> Text
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance
  Prelude.NFData
    CancelDomainTransferToAnotherAwsAccount
  where
  rnf :: CancelDomainTransferToAnotherAwsAccount -> ()
rnf CancelDomainTransferToAnotherAwsAccount' {Text
domainName :: Text
$sel:domainName:CancelDomainTransferToAnotherAwsAccount' :: CancelDomainTransferToAnotherAwsAccount -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
domainName

instance
  Data.ToHeaders
    CancelDomainTransferToAnotherAwsAccount
  where
  toHeaders :: CancelDomainTransferToAnotherAwsAccount -> 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
"Route53Domains_v20140515.CancelDomainTransferToAnotherAwsAccount" ::
                          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
    CancelDomainTransferToAnotherAwsAccount
  where
  toJSON :: CancelDomainTransferToAnotherAwsAccount -> Value
toJSON CancelDomainTransferToAnotherAwsAccount' {Text
domainName :: Text
$sel:domainName:CancelDomainTransferToAnotherAwsAccount' :: CancelDomainTransferToAnotherAwsAccount -> 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)]
      )

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

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

-- | The @CancelDomainTransferToAnotherAwsAccount@ response includes the
-- following element.
--
-- /See:/ 'newCancelDomainTransferToAnotherAwsAccountResponse' smart constructor.
data CancelDomainTransferToAnotherAwsAccountResponse = CancelDomainTransferToAnotherAwsAccountResponse'
  { -- | The identifier that @TransferDomainToAnotherAwsAccount@ returned to
    -- track the progress of the request. Because the transfer request was
    -- canceled, the value is no longer valid, and you can\'t use
    -- @GetOperationDetail@ to query the operation status.
    CancelDomainTransferToAnotherAwsAccountResponse -> Maybe Text
operationId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CancelDomainTransferToAnotherAwsAccountResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CancelDomainTransferToAnotherAwsAccountResponse
-> CancelDomainTransferToAnotherAwsAccountResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelDomainTransferToAnotherAwsAccountResponse
-> CancelDomainTransferToAnotherAwsAccountResponse -> Bool
$c/= :: CancelDomainTransferToAnotherAwsAccountResponse
-> CancelDomainTransferToAnotherAwsAccountResponse -> Bool
== :: CancelDomainTransferToAnotherAwsAccountResponse
-> CancelDomainTransferToAnotherAwsAccountResponse -> Bool
$c== :: CancelDomainTransferToAnotherAwsAccountResponse
-> CancelDomainTransferToAnotherAwsAccountResponse -> Bool
Prelude.Eq, ReadPrec [CancelDomainTransferToAnotherAwsAccountResponse]
ReadPrec CancelDomainTransferToAnotherAwsAccountResponse
Int -> ReadS CancelDomainTransferToAnotherAwsAccountResponse
ReadS [CancelDomainTransferToAnotherAwsAccountResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelDomainTransferToAnotherAwsAccountResponse]
$creadListPrec :: ReadPrec [CancelDomainTransferToAnotherAwsAccountResponse]
readPrec :: ReadPrec CancelDomainTransferToAnotherAwsAccountResponse
$creadPrec :: ReadPrec CancelDomainTransferToAnotherAwsAccountResponse
readList :: ReadS [CancelDomainTransferToAnotherAwsAccountResponse]
$creadList :: ReadS [CancelDomainTransferToAnotherAwsAccountResponse]
readsPrec :: Int -> ReadS CancelDomainTransferToAnotherAwsAccountResponse
$creadsPrec :: Int -> ReadS CancelDomainTransferToAnotherAwsAccountResponse
Prelude.Read, Int -> CancelDomainTransferToAnotherAwsAccountResponse -> ShowS
[CancelDomainTransferToAnotherAwsAccountResponse] -> ShowS
CancelDomainTransferToAnotherAwsAccountResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelDomainTransferToAnotherAwsAccountResponse] -> ShowS
$cshowList :: [CancelDomainTransferToAnotherAwsAccountResponse] -> ShowS
show :: CancelDomainTransferToAnotherAwsAccountResponse -> String
$cshow :: CancelDomainTransferToAnotherAwsAccountResponse -> String
showsPrec :: Int -> CancelDomainTransferToAnotherAwsAccountResponse -> ShowS
$cshowsPrec :: Int -> CancelDomainTransferToAnotherAwsAccountResponse -> ShowS
Prelude.Show, forall x.
Rep CancelDomainTransferToAnotherAwsAccountResponse x
-> CancelDomainTransferToAnotherAwsAccountResponse
forall x.
CancelDomainTransferToAnotherAwsAccountResponse
-> Rep CancelDomainTransferToAnotherAwsAccountResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelDomainTransferToAnotherAwsAccountResponse x
-> CancelDomainTransferToAnotherAwsAccountResponse
$cfrom :: forall x.
CancelDomainTransferToAnotherAwsAccountResponse
-> Rep CancelDomainTransferToAnotherAwsAccountResponse x
Prelude.Generic)

-- |
-- Create a value of 'CancelDomainTransferToAnotherAwsAccountResponse' 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:
--
-- 'operationId', 'cancelDomainTransferToAnotherAwsAccountResponse_operationId' - The identifier that @TransferDomainToAnotherAwsAccount@ returned to
-- track the progress of the request. Because the transfer request was
-- canceled, the value is no longer valid, and you can\'t use
-- @GetOperationDetail@ to query the operation status.
--
-- 'httpStatus', 'cancelDomainTransferToAnotherAwsAccountResponse_httpStatus' - The response's http status code.
newCancelDomainTransferToAnotherAwsAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CancelDomainTransferToAnotherAwsAccountResponse
newCancelDomainTransferToAnotherAwsAccountResponse :: Int -> CancelDomainTransferToAnotherAwsAccountResponse
newCancelDomainTransferToAnotherAwsAccountResponse
  Int
pHttpStatus_ =
    CancelDomainTransferToAnotherAwsAccountResponse'
      { $sel:operationId:CancelDomainTransferToAnotherAwsAccountResponse' :: Maybe Text
operationId =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:CancelDomainTransferToAnotherAwsAccountResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The identifier that @TransferDomainToAnotherAwsAccount@ returned to
-- track the progress of the request. Because the transfer request was
-- canceled, the value is no longer valid, and you can\'t use
-- @GetOperationDetail@ to query the operation status.
cancelDomainTransferToAnotherAwsAccountResponse_operationId :: Lens.Lens' CancelDomainTransferToAnotherAwsAccountResponse (Prelude.Maybe Prelude.Text)
cancelDomainTransferToAnotherAwsAccountResponse_operationId :: Lens' CancelDomainTransferToAnotherAwsAccountResponse (Maybe Text)
cancelDomainTransferToAnotherAwsAccountResponse_operationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelDomainTransferToAnotherAwsAccountResponse' {Maybe Text
operationId :: Maybe Text
$sel:operationId:CancelDomainTransferToAnotherAwsAccountResponse' :: CancelDomainTransferToAnotherAwsAccountResponse -> Maybe Text
operationId} -> Maybe Text
operationId) (\s :: CancelDomainTransferToAnotherAwsAccountResponse
s@CancelDomainTransferToAnotherAwsAccountResponse' {} Maybe Text
a -> CancelDomainTransferToAnotherAwsAccountResponse
s {$sel:operationId:CancelDomainTransferToAnotherAwsAccountResponse' :: Maybe Text
operationId = Maybe Text
a} :: CancelDomainTransferToAnotherAwsAccountResponse)

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

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