{-# 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.AssociateDelegationSignerToDomain
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a delegation signer (DS) record in the registry zone for this
-- domain name.
--
-- Note that creating DS record at the registry impacts DNSSEC validation
-- of your DNS records. This action may render your domain name unavailable
-- on the internet if the steps are completed in the wrong order, or with
-- incorrect timing. For more information about DNSSEC signing, see
-- <https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-configuring-dnssec.html Configuring DNSSEC signing>
-- in the /Route 53 developer guide/.
module Amazonka.Route53Domains.AssociateDelegationSignerToDomain
  ( -- * Creating a Request
    AssociateDelegationSignerToDomain (..),
    newAssociateDelegationSignerToDomain,

    -- * Request Lenses
    associateDelegationSignerToDomain_domainName,
    associateDelegationSignerToDomain_signingAttributes,

    -- * Destructuring the Response
    AssociateDelegationSignerToDomainResponse (..),
    newAssociateDelegationSignerToDomainResponse,

    -- * Response Lenses
    associateDelegationSignerToDomainResponse_operationId,
    associateDelegationSignerToDomainResponse_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

-- | /See:/ 'newAssociateDelegationSignerToDomain' smart constructor.
data AssociateDelegationSignerToDomain = AssociateDelegationSignerToDomain'
  { -- | The name of the domain.
    AssociateDelegationSignerToDomain -> Text
domainName :: Prelude.Text,
    -- | The information about a key, including the algorithm, public key-value,
    -- and flags.
    AssociateDelegationSignerToDomain -> DnssecSigningAttributes
signingAttributes :: DnssecSigningAttributes
  }
  deriving (AssociateDelegationSignerToDomain
-> AssociateDelegationSignerToDomain -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateDelegationSignerToDomain
-> AssociateDelegationSignerToDomain -> Bool
$c/= :: AssociateDelegationSignerToDomain
-> AssociateDelegationSignerToDomain -> Bool
== :: AssociateDelegationSignerToDomain
-> AssociateDelegationSignerToDomain -> Bool
$c== :: AssociateDelegationSignerToDomain
-> AssociateDelegationSignerToDomain -> Bool
Prelude.Eq, ReadPrec [AssociateDelegationSignerToDomain]
ReadPrec AssociateDelegationSignerToDomain
Int -> ReadS AssociateDelegationSignerToDomain
ReadS [AssociateDelegationSignerToDomain]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateDelegationSignerToDomain]
$creadListPrec :: ReadPrec [AssociateDelegationSignerToDomain]
readPrec :: ReadPrec AssociateDelegationSignerToDomain
$creadPrec :: ReadPrec AssociateDelegationSignerToDomain
readList :: ReadS [AssociateDelegationSignerToDomain]
$creadList :: ReadS [AssociateDelegationSignerToDomain]
readsPrec :: Int -> ReadS AssociateDelegationSignerToDomain
$creadsPrec :: Int -> ReadS AssociateDelegationSignerToDomain
Prelude.Read, Int -> AssociateDelegationSignerToDomain -> ShowS
[AssociateDelegationSignerToDomain] -> ShowS
AssociateDelegationSignerToDomain -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateDelegationSignerToDomain] -> ShowS
$cshowList :: [AssociateDelegationSignerToDomain] -> ShowS
show :: AssociateDelegationSignerToDomain -> String
$cshow :: AssociateDelegationSignerToDomain -> String
showsPrec :: Int -> AssociateDelegationSignerToDomain -> ShowS
$cshowsPrec :: Int -> AssociateDelegationSignerToDomain -> ShowS
Prelude.Show, forall x.
Rep AssociateDelegationSignerToDomain x
-> AssociateDelegationSignerToDomain
forall x.
AssociateDelegationSignerToDomain
-> Rep AssociateDelegationSignerToDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateDelegationSignerToDomain x
-> AssociateDelegationSignerToDomain
$cfrom :: forall x.
AssociateDelegationSignerToDomain
-> Rep AssociateDelegationSignerToDomain x
Prelude.Generic)

-- |
-- Create a value of 'AssociateDelegationSignerToDomain' 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', 'associateDelegationSignerToDomain_domainName' - The name of the domain.
--
-- 'signingAttributes', 'associateDelegationSignerToDomain_signingAttributes' - The information about a key, including the algorithm, public key-value,
-- and flags.
newAssociateDelegationSignerToDomain ::
  -- | 'domainName'
  Prelude.Text ->
  -- | 'signingAttributes'
  DnssecSigningAttributes ->
  AssociateDelegationSignerToDomain
newAssociateDelegationSignerToDomain :: Text
-> DnssecSigningAttributes -> AssociateDelegationSignerToDomain
newAssociateDelegationSignerToDomain
  Text
pDomainName_
  DnssecSigningAttributes
pSigningAttributes_ =
    AssociateDelegationSignerToDomain'
      { $sel:domainName:AssociateDelegationSignerToDomain' :: Text
domainName =
          Text
pDomainName_,
        $sel:signingAttributes:AssociateDelegationSignerToDomain' :: DnssecSigningAttributes
signingAttributes = DnssecSigningAttributes
pSigningAttributes_
      }

-- | The name of the domain.
associateDelegationSignerToDomain_domainName :: Lens.Lens' AssociateDelegationSignerToDomain Prelude.Text
associateDelegationSignerToDomain_domainName :: Lens' AssociateDelegationSignerToDomain Text
associateDelegationSignerToDomain_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateDelegationSignerToDomain' {Text
domainName :: Text
$sel:domainName:AssociateDelegationSignerToDomain' :: AssociateDelegationSignerToDomain -> Text
domainName} -> Text
domainName) (\s :: AssociateDelegationSignerToDomain
s@AssociateDelegationSignerToDomain' {} Text
a -> AssociateDelegationSignerToDomain
s {$sel:domainName:AssociateDelegationSignerToDomain' :: Text
domainName = Text
a} :: AssociateDelegationSignerToDomain)

-- | The information about a key, including the algorithm, public key-value,
-- and flags.
associateDelegationSignerToDomain_signingAttributes :: Lens.Lens' AssociateDelegationSignerToDomain DnssecSigningAttributes
associateDelegationSignerToDomain_signingAttributes :: Lens' AssociateDelegationSignerToDomain DnssecSigningAttributes
associateDelegationSignerToDomain_signingAttributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateDelegationSignerToDomain' {DnssecSigningAttributes
signingAttributes :: DnssecSigningAttributes
$sel:signingAttributes:AssociateDelegationSignerToDomain' :: AssociateDelegationSignerToDomain -> DnssecSigningAttributes
signingAttributes} -> DnssecSigningAttributes
signingAttributes) (\s :: AssociateDelegationSignerToDomain
s@AssociateDelegationSignerToDomain' {} DnssecSigningAttributes
a -> AssociateDelegationSignerToDomain
s {$sel:signingAttributes:AssociateDelegationSignerToDomain' :: DnssecSigningAttributes
signingAttributes = DnssecSigningAttributes
a} :: AssociateDelegationSignerToDomain)

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

instance
  Prelude.NFData
    AssociateDelegationSignerToDomain
  where
  rnf :: AssociateDelegationSignerToDomain -> ()
rnf AssociateDelegationSignerToDomain' {Text
DnssecSigningAttributes
signingAttributes :: DnssecSigningAttributes
domainName :: Text
$sel:signingAttributes:AssociateDelegationSignerToDomain' :: AssociateDelegationSignerToDomain -> DnssecSigningAttributes
$sel:domainName:AssociateDelegationSignerToDomain' :: AssociateDelegationSignerToDomain -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
domainName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DnssecSigningAttributes
signingAttributes

instance
  Data.ToHeaders
    AssociateDelegationSignerToDomain
  where
  toHeaders :: AssociateDelegationSignerToDomain -> 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.AssociateDelegationSignerToDomain" ::
                          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
    AssociateDelegationSignerToDomain
  where
  toJSON :: AssociateDelegationSignerToDomain -> Value
toJSON AssociateDelegationSignerToDomain' {Text
DnssecSigningAttributes
signingAttributes :: DnssecSigningAttributes
domainName :: Text
$sel:signingAttributes:AssociateDelegationSignerToDomain' :: AssociateDelegationSignerToDomain -> DnssecSigningAttributes
$sel:domainName:AssociateDelegationSignerToDomain' :: AssociateDelegationSignerToDomain -> 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),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"SigningAttributes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DnssecSigningAttributes
signingAttributes)
          ]
      )

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

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

-- | /See:/ 'newAssociateDelegationSignerToDomainResponse' smart constructor.
data AssociateDelegationSignerToDomainResponse = AssociateDelegationSignerToDomainResponse'
  { -- | The identifier for tracking the progress of the request. To query the
    -- operation status, use
    -- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_GetOperationDetail.html GetOperationDetail>.
    AssociateDelegationSignerToDomainResponse -> Maybe Text
operationId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    AssociateDelegationSignerToDomainResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AssociateDelegationSignerToDomainResponse
-> AssociateDelegationSignerToDomainResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateDelegationSignerToDomainResponse
-> AssociateDelegationSignerToDomainResponse -> Bool
$c/= :: AssociateDelegationSignerToDomainResponse
-> AssociateDelegationSignerToDomainResponse -> Bool
== :: AssociateDelegationSignerToDomainResponse
-> AssociateDelegationSignerToDomainResponse -> Bool
$c== :: AssociateDelegationSignerToDomainResponse
-> AssociateDelegationSignerToDomainResponse -> Bool
Prelude.Eq, ReadPrec [AssociateDelegationSignerToDomainResponse]
ReadPrec AssociateDelegationSignerToDomainResponse
Int -> ReadS AssociateDelegationSignerToDomainResponse
ReadS [AssociateDelegationSignerToDomainResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateDelegationSignerToDomainResponse]
$creadListPrec :: ReadPrec [AssociateDelegationSignerToDomainResponse]
readPrec :: ReadPrec AssociateDelegationSignerToDomainResponse
$creadPrec :: ReadPrec AssociateDelegationSignerToDomainResponse
readList :: ReadS [AssociateDelegationSignerToDomainResponse]
$creadList :: ReadS [AssociateDelegationSignerToDomainResponse]
readsPrec :: Int -> ReadS AssociateDelegationSignerToDomainResponse
$creadsPrec :: Int -> ReadS AssociateDelegationSignerToDomainResponse
Prelude.Read, Int -> AssociateDelegationSignerToDomainResponse -> ShowS
[AssociateDelegationSignerToDomainResponse] -> ShowS
AssociateDelegationSignerToDomainResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateDelegationSignerToDomainResponse] -> ShowS
$cshowList :: [AssociateDelegationSignerToDomainResponse] -> ShowS
show :: AssociateDelegationSignerToDomainResponse -> String
$cshow :: AssociateDelegationSignerToDomainResponse -> String
showsPrec :: Int -> AssociateDelegationSignerToDomainResponse -> ShowS
$cshowsPrec :: Int -> AssociateDelegationSignerToDomainResponse -> ShowS
Prelude.Show, forall x.
Rep AssociateDelegationSignerToDomainResponse x
-> AssociateDelegationSignerToDomainResponse
forall x.
AssociateDelegationSignerToDomainResponse
-> Rep AssociateDelegationSignerToDomainResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateDelegationSignerToDomainResponse x
-> AssociateDelegationSignerToDomainResponse
$cfrom :: forall x.
AssociateDelegationSignerToDomainResponse
-> Rep AssociateDelegationSignerToDomainResponse x
Prelude.Generic)

-- |
-- Create a value of 'AssociateDelegationSignerToDomainResponse' 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', 'associateDelegationSignerToDomainResponse_operationId' - The identifier for tracking the progress of the request. To query the
-- operation status, use
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_GetOperationDetail.html GetOperationDetail>.
--
-- 'httpStatus', 'associateDelegationSignerToDomainResponse_httpStatus' - The response's http status code.
newAssociateDelegationSignerToDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AssociateDelegationSignerToDomainResponse
newAssociateDelegationSignerToDomainResponse :: Int -> AssociateDelegationSignerToDomainResponse
newAssociateDelegationSignerToDomainResponse
  Int
pHttpStatus_ =
    AssociateDelegationSignerToDomainResponse'
      { $sel:operationId:AssociateDelegationSignerToDomainResponse' :: Maybe Text
operationId =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:AssociateDelegationSignerToDomainResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The identifier for tracking the progress of the request. To query the
-- operation status, use
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_GetOperationDetail.html GetOperationDetail>.
associateDelegationSignerToDomainResponse_operationId :: Lens.Lens' AssociateDelegationSignerToDomainResponse (Prelude.Maybe Prelude.Text)
associateDelegationSignerToDomainResponse_operationId :: Lens' AssociateDelegationSignerToDomainResponse (Maybe Text)
associateDelegationSignerToDomainResponse_operationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateDelegationSignerToDomainResponse' {Maybe Text
operationId :: Maybe Text
$sel:operationId:AssociateDelegationSignerToDomainResponse' :: AssociateDelegationSignerToDomainResponse -> Maybe Text
operationId} -> Maybe Text
operationId) (\s :: AssociateDelegationSignerToDomainResponse
s@AssociateDelegationSignerToDomainResponse' {} Maybe Text
a -> AssociateDelegationSignerToDomainResponse
s {$sel:operationId:AssociateDelegationSignerToDomainResponse' :: Maybe Text
operationId = Maybe Text
a} :: AssociateDelegationSignerToDomainResponse)

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

instance
  Prelude.NFData
    AssociateDelegationSignerToDomainResponse
  where
  rnf :: AssociateDelegationSignerToDomainResponse -> ()
rnf AssociateDelegationSignerToDomainResponse' {Int
Maybe Text
httpStatus :: Int
operationId :: Maybe Text
$sel:httpStatus:AssociateDelegationSignerToDomainResponse' :: AssociateDelegationSignerToDomainResponse -> Int
$sel:operationId:AssociateDelegationSignerToDomainResponse' :: AssociateDelegationSignerToDomainResponse -> 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