{-# 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.RetrieveDomainAuthCode
-- 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 returns the AuthCode for the domain. To transfer a domain
-- to another registrar, you provide this value to the new registrar.
module Amazonka.Route53Domains.RetrieveDomainAuthCode
  ( -- * Creating a Request
    RetrieveDomainAuthCode (..),
    newRetrieveDomainAuthCode,

    -- * Request Lenses
    retrieveDomainAuthCode_domainName,

    -- * Destructuring the Response
    RetrieveDomainAuthCodeResponse (..),
    newRetrieveDomainAuthCodeResponse,

    -- * Response Lenses
    retrieveDomainAuthCodeResponse_httpStatus,
    retrieveDomainAuthCodeResponse_authCode,
  )
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 for the authorization code for the specified domain. To
-- transfer a domain to another registrar, you provide this value to the
-- new registrar.
--
-- /See:/ 'newRetrieveDomainAuthCode' smart constructor.
data RetrieveDomainAuthCode = RetrieveDomainAuthCode'
  { -- | The name of the domain that you want to get an authorization code for.
    RetrieveDomainAuthCode -> Text
domainName :: Prelude.Text
  }
  deriving (RetrieveDomainAuthCode -> RetrieveDomainAuthCode -> Bool
(RetrieveDomainAuthCode -> RetrieveDomainAuthCode -> Bool)
-> (RetrieveDomainAuthCode -> RetrieveDomainAuthCode -> Bool)
-> Eq RetrieveDomainAuthCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetrieveDomainAuthCode -> RetrieveDomainAuthCode -> Bool
$c/= :: RetrieveDomainAuthCode -> RetrieveDomainAuthCode -> Bool
== :: RetrieveDomainAuthCode -> RetrieveDomainAuthCode -> Bool
$c== :: RetrieveDomainAuthCode -> RetrieveDomainAuthCode -> Bool
Prelude.Eq, ReadPrec [RetrieveDomainAuthCode]
ReadPrec RetrieveDomainAuthCode
Int -> ReadS RetrieveDomainAuthCode
ReadS [RetrieveDomainAuthCode]
(Int -> ReadS RetrieveDomainAuthCode)
-> ReadS [RetrieveDomainAuthCode]
-> ReadPrec RetrieveDomainAuthCode
-> ReadPrec [RetrieveDomainAuthCode]
-> Read RetrieveDomainAuthCode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RetrieveDomainAuthCode]
$creadListPrec :: ReadPrec [RetrieveDomainAuthCode]
readPrec :: ReadPrec RetrieveDomainAuthCode
$creadPrec :: ReadPrec RetrieveDomainAuthCode
readList :: ReadS [RetrieveDomainAuthCode]
$creadList :: ReadS [RetrieveDomainAuthCode]
readsPrec :: Int -> ReadS RetrieveDomainAuthCode
$creadsPrec :: Int -> ReadS RetrieveDomainAuthCode
Prelude.Read, Int -> RetrieveDomainAuthCode -> ShowS
[RetrieveDomainAuthCode] -> ShowS
RetrieveDomainAuthCode -> String
(Int -> RetrieveDomainAuthCode -> ShowS)
-> (RetrieveDomainAuthCode -> String)
-> ([RetrieveDomainAuthCode] -> ShowS)
-> Show RetrieveDomainAuthCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetrieveDomainAuthCode] -> ShowS
$cshowList :: [RetrieveDomainAuthCode] -> ShowS
show :: RetrieveDomainAuthCode -> String
$cshow :: RetrieveDomainAuthCode -> String
showsPrec :: Int -> RetrieveDomainAuthCode -> ShowS
$cshowsPrec :: Int -> RetrieveDomainAuthCode -> ShowS
Prelude.Show, (forall x. RetrieveDomainAuthCode -> Rep RetrieveDomainAuthCode x)
-> (forall x.
    Rep RetrieveDomainAuthCode x -> RetrieveDomainAuthCode)
-> Generic RetrieveDomainAuthCode
forall x. Rep RetrieveDomainAuthCode x -> RetrieveDomainAuthCode
forall x. RetrieveDomainAuthCode -> Rep RetrieveDomainAuthCode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RetrieveDomainAuthCode x -> RetrieveDomainAuthCode
$cfrom :: forall x. RetrieveDomainAuthCode -> Rep RetrieveDomainAuthCode x
Prelude.Generic)

-- |
-- Create a value of 'RetrieveDomainAuthCode' 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', 'retrieveDomainAuthCode_domainName' - The name of the domain that you want to get an authorization code for.
newRetrieveDomainAuthCode ::
  -- | 'domainName'
  Prelude.Text ->
  RetrieveDomainAuthCode
newRetrieveDomainAuthCode :: Text -> RetrieveDomainAuthCode
newRetrieveDomainAuthCode Text
pDomainName_ =
  RetrieveDomainAuthCode' :: Text -> RetrieveDomainAuthCode
RetrieveDomainAuthCode' {$sel:domainName:RetrieveDomainAuthCode' :: Text
domainName = Text
pDomainName_}

-- | The name of the domain that you want to get an authorization code for.
retrieveDomainAuthCode_domainName :: Lens.Lens' RetrieveDomainAuthCode Prelude.Text
retrieveDomainAuthCode_domainName :: (Text -> f Text)
-> RetrieveDomainAuthCode -> f RetrieveDomainAuthCode
retrieveDomainAuthCode_domainName = (RetrieveDomainAuthCode -> Text)
-> (RetrieveDomainAuthCode -> Text -> RetrieveDomainAuthCode)
-> Lens RetrieveDomainAuthCode RetrieveDomainAuthCode Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetrieveDomainAuthCode' {Text
domainName :: Text
$sel:domainName:RetrieveDomainAuthCode' :: RetrieveDomainAuthCode -> Text
domainName} -> Text
domainName) (\s :: RetrieveDomainAuthCode
s@RetrieveDomainAuthCode' {} Text
a -> RetrieveDomainAuthCode
s {$sel:domainName:RetrieveDomainAuthCode' :: Text
domainName = Text
a} :: RetrieveDomainAuthCode)

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

instance Prelude.Hashable RetrieveDomainAuthCode

instance Prelude.NFData RetrieveDomainAuthCode

instance Core.ToHeaders RetrieveDomainAuthCode where
  toHeaders :: RetrieveDomainAuthCode -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RetrieveDomainAuthCode -> 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.RetrieveDomainAuthCode" ::
                          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 RetrieveDomainAuthCode where
  toJSON :: RetrieveDomainAuthCode -> Value
toJSON RetrieveDomainAuthCode' {Text
domainName :: Text
$sel:domainName:RetrieveDomainAuthCode' :: RetrieveDomainAuthCode -> 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 RetrieveDomainAuthCode where
  toPath :: RetrieveDomainAuthCode -> ByteString
toPath = ByteString -> RetrieveDomainAuthCode -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | The RetrieveDomainAuthCode response includes the following element.
--
-- /See:/ 'newRetrieveDomainAuthCodeResponse' smart constructor.
data RetrieveDomainAuthCodeResponse = RetrieveDomainAuthCodeResponse'
  { -- | The response's http status code.
    RetrieveDomainAuthCodeResponse -> Int
httpStatus :: Prelude.Int,
    -- | The authorization code for the domain.
    RetrieveDomainAuthCodeResponse -> Sensitive Text
authCode :: Core.Sensitive Prelude.Text
  }
  deriving (RetrieveDomainAuthCodeResponse
-> RetrieveDomainAuthCodeResponse -> Bool
(RetrieveDomainAuthCodeResponse
 -> RetrieveDomainAuthCodeResponse -> Bool)
-> (RetrieveDomainAuthCodeResponse
    -> RetrieveDomainAuthCodeResponse -> Bool)
-> Eq RetrieveDomainAuthCodeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetrieveDomainAuthCodeResponse
-> RetrieveDomainAuthCodeResponse -> Bool
$c/= :: RetrieveDomainAuthCodeResponse
-> RetrieveDomainAuthCodeResponse -> Bool
== :: RetrieveDomainAuthCodeResponse
-> RetrieveDomainAuthCodeResponse -> Bool
$c== :: RetrieveDomainAuthCodeResponse
-> RetrieveDomainAuthCodeResponse -> Bool
Prelude.Eq, Int -> RetrieveDomainAuthCodeResponse -> ShowS
[RetrieveDomainAuthCodeResponse] -> ShowS
RetrieveDomainAuthCodeResponse -> String
(Int -> RetrieveDomainAuthCodeResponse -> ShowS)
-> (RetrieveDomainAuthCodeResponse -> String)
-> ([RetrieveDomainAuthCodeResponse] -> ShowS)
-> Show RetrieveDomainAuthCodeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetrieveDomainAuthCodeResponse] -> ShowS
$cshowList :: [RetrieveDomainAuthCodeResponse] -> ShowS
show :: RetrieveDomainAuthCodeResponse -> String
$cshow :: RetrieveDomainAuthCodeResponse -> String
showsPrec :: Int -> RetrieveDomainAuthCodeResponse -> ShowS
$cshowsPrec :: Int -> RetrieveDomainAuthCodeResponse -> ShowS
Prelude.Show, (forall x.
 RetrieveDomainAuthCodeResponse
 -> Rep RetrieveDomainAuthCodeResponse x)
-> (forall x.
    Rep RetrieveDomainAuthCodeResponse x
    -> RetrieveDomainAuthCodeResponse)
-> Generic RetrieveDomainAuthCodeResponse
forall x.
Rep RetrieveDomainAuthCodeResponse x
-> RetrieveDomainAuthCodeResponse
forall x.
RetrieveDomainAuthCodeResponse
-> Rep RetrieveDomainAuthCodeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RetrieveDomainAuthCodeResponse x
-> RetrieveDomainAuthCodeResponse
$cfrom :: forall x.
RetrieveDomainAuthCodeResponse
-> Rep RetrieveDomainAuthCodeResponse x
Prelude.Generic)

-- |
-- Create a value of 'RetrieveDomainAuthCodeResponse' 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', 'retrieveDomainAuthCodeResponse_httpStatus' - The response's http status code.
--
-- 'authCode', 'retrieveDomainAuthCodeResponse_authCode' - The authorization code for the domain.
newRetrieveDomainAuthCodeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'authCode'
  Prelude.Text ->
  RetrieveDomainAuthCodeResponse
newRetrieveDomainAuthCodeResponse :: Int -> Text -> RetrieveDomainAuthCodeResponse
newRetrieveDomainAuthCodeResponse
  Int
pHttpStatus_
  Text
pAuthCode_ =
    RetrieveDomainAuthCodeResponse' :: Int -> Sensitive Text -> RetrieveDomainAuthCodeResponse
RetrieveDomainAuthCodeResponse'
      { $sel:httpStatus:RetrieveDomainAuthCodeResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:authCode:RetrieveDomainAuthCodeResponse' :: Sensitive Text
authCode =
          Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pAuthCode_
      }

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

-- | The authorization code for the domain.
retrieveDomainAuthCodeResponse_authCode :: Lens.Lens' RetrieveDomainAuthCodeResponse Prelude.Text
retrieveDomainAuthCodeResponse_authCode :: (Text -> f Text)
-> RetrieveDomainAuthCodeResponse
-> f RetrieveDomainAuthCodeResponse
retrieveDomainAuthCodeResponse_authCode = (RetrieveDomainAuthCodeResponse -> Sensitive Text)
-> (RetrieveDomainAuthCodeResponse
    -> Sensitive Text -> RetrieveDomainAuthCodeResponse)
-> Lens
     RetrieveDomainAuthCodeResponse
     RetrieveDomainAuthCodeResponse
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetrieveDomainAuthCodeResponse' {Sensitive Text
authCode :: Sensitive Text
$sel:authCode:RetrieveDomainAuthCodeResponse' :: RetrieveDomainAuthCodeResponse -> Sensitive Text
authCode} -> Sensitive Text
authCode) (\s :: RetrieveDomainAuthCodeResponse
s@RetrieveDomainAuthCodeResponse' {} Sensitive Text
a -> RetrieveDomainAuthCodeResponse
s {$sel:authCode:RetrieveDomainAuthCodeResponse' :: Sensitive Text
authCode = Sensitive Text
a} :: RetrieveDomainAuthCodeResponse) ((Sensitive Text -> f (Sensitive Text))
 -> RetrieveDomainAuthCodeResponse
 -> f RetrieveDomainAuthCodeResponse)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> RetrieveDomainAuthCodeResponse
-> f RetrieveDomainAuthCodeResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance
  Prelude.NFData
    RetrieveDomainAuthCodeResponse