{-# 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.RenewDomain
-- 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 renews a domain for the specified number of years. The
-- cost of renewing your domain is billed to your AWS account.
--
-- We recommend that you renew your domain several weeks before the
-- expiration date. Some TLD registries delete domains before the
-- expiration date if you haven\'t renewed far enough in advance. For more
-- information about renewing domain registration, see
-- <https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/domain-renew.html Renewing Registration for a Domain>
-- in the /Amazon Route 53 Developer Guide/.
module Amazonka.Route53Domains.RenewDomain
  ( -- * Creating a Request
    RenewDomain (..),
    newRenewDomain,

    -- * Request Lenses
    renewDomain_durationInYears,
    renewDomain_domainName,
    renewDomain_currentExpiryYear,

    -- * Destructuring the Response
    RenewDomainResponse (..),
    newRenewDomainResponse,

    -- * Response Lenses
    renewDomainResponse_httpStatus,
    renewDomainResponse_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 @RenewDomain@ request includes the number of years that you want to
-- renew for and the current expiration year.
--
-- /See:/ 'newRenewDomain' smart constructor.
data RenewDomain = RenewDomain'
  { -- | The number of years that you want to renew the domain for. The maximum
    -- number of years depends on the top-level domain. For the range of valid
    -- values for your domain, see
    -- <https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/registrar-tld-list.html Domains that You Can Register with Amazon Route 53>
    -- in the /Amazon Route 53 Developer Guide/.
    --
    -- Default: 1
    RenewDomain -> Maybe Natural
durationInYears :: Prelude.Maybe Prelude.Natural,
    -- | The name of the domain that you want to renew.
    RenewDomain -> Text
domainName :: Prelude.Text,
    -- | The year when the registration for the domain is set to expire. This
    -- value must match the current expiration date for the domain.
    RenewDomain -> Int
currentExpiryYear :: Prelude.Int
  }
  deriving (RenewDomain -> RenewDomain -> Bool
(RenewDomain -> RenewDomain -> Bool)
-> (RenewDomain -> RenewDomain -> Bool) -> Eq RenewDomain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RenewDomain -> RenewDomain -> Bool
$c/= :: RenewDomain -> RenewDomain -> Bool
== :: RenewDomain -> RenewDomain -> Bool
$c== :: RenewDomain -> RenewDomain -> Bool
Prelude.Eq, ReadPrec [RenewDomain]
ReadPrec RenewDomain
Int -> ReadS RenewDomain
ReadS [RenewDomain]
(Int -> ReadS RenewDomain)
-> ReadS [RenewDomain]
-> ReadPrec RenewDomain
-> ReadPrec [RenewDomain]
-> Read RenewDomain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RenewDomain]
$creadListPrec :: ReadPrec [RenewDomain]
readPrec :: ReadPrec RenewDomain
$creadPrec :: ReadPrec RenewDomain
readList :: ReadS [RenewDomain]
$creadList :: ReadS [RenewDomain]
readsPrec :: Int -> ReadS RenewDomain
$creadsPrec :: Int -> ReadS RenewDomain
Prelude.Read, Int -> RenewDomain -> ShowS
[RenewDomain] -> ShowS
RenewDomain -> String
(Int -> RenewDomain -> ShowS)
-> (RenewDomain -> String)
-> ([RenewDomain] -> ShowS)
-> Show RenewDomain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RenewDomain] -> ShowS
$cshowList :: [RenewDomain] -> ShowS
show :: RenewDomain -> String
$cshow :: RenewDomain -> String
showsPrec :: Int -> RenewDomain -> ShowS
$cshowsPrec :: Int -> RenewDomain -> ShowS
Prelude.Show, (forall x. RenewDomain -> Rep RenewDomain x)
-> (forall x. Rep RenewDomain x -> RenewDomain)
-> Generic RenewDomain
forall x. Rep RenewDomain x -> RenewDomain
forall x. RenewDomain -> Rep RenewDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RenewDomain x -> RenewDomain
$cfrom :: forall x. RenewDomain -> Rep RenewDomain x
Prelude.Generic)

-- |
-- Create a value of 'RenewDomain' 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:
--
-- 'durationInYears', 'renewDomain_durationInYears' - The number of years that you want to renew the domain for. The maximum
-- number of years depends on the top-level domain. For the range of valid
-- values for your domain, see
-- <https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/registrar-tld-list.html Domains that You Can Register with Amazon Route 53>
-- in the /Amazon Route 53 Developer Guide/.
--
-- Default: 1
--
-- 'domainName', 'renewDomain_domainName' - The name of the domain that you want to renew.
--
-- 'currentExpiryYear', 'renewDomain_currentExpiryYear' - The year when the registration for the domain is set to expire. This
-- value must match the current expiration date for the domain.
newRenewDomain ::
  -- | 'domainName'
  Prelude.Text ->
  -- | 'currentExpiryYear'
  Prelude.Int ->
  RenewDomain
newRenewDomain :: Text -> Int -> RenewDomain
newRenewDomain Text
pDomainName_ Int
pCurrentExpiryYear_ =
  RenewDomain' :: Maybe Natural -> Text -> Int -> RenewDomain
RenewDomain'
    { $sel:durationInYears:RenewDomain' :: Maybe Natural
durationInYears = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:RenewDomain' :: Text
domainName = Text
pDomainName_,
      $sel:currentExpiryYear:RenewDomain' :: Int
currentExpiryYear = Int
pCurrentExpiryYear_
    }

-- | The number of years that you want to renew the domain for. The maximum
-- number of years depends on the top-level domain. For the range of valid
-- values for your domain, see
-- <https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/registrar-tld-list.html Domains that You Can Register with Amazon Route 53>
-- in the /Amazon Route 53 Developer Guide/.
--
-- Default: 1
renewDomain_durationInYears :: Lens.Lens' RenewDomain (Prelude.Maybe Prelude.Natural)
renewDomain_durationInYears :: (Maybe Natural -> f (Maybe Natural))
-> RenewDomain -> f RenewDomain
renewDomain_durationInYears = (RenewDomain -> Maybe Natural)
-> (RenewDomain -> Maybe Natural -> RenewDomain)
-> Lens RenewDomain RenewDomain (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewDomain' {Maybe Natural
durationInYears :: Maybe Natural
$sel:durationInYears:RenewDomain' :: RenewDomain -> Maybe Natural
durationInYears} -> Maybe Natural
durationInYears) (\s :: RenewDomain
s@RenewDomain' {} Maybe Natural
a -> RenewDomain
s {$sel:durationInYears:RenewDomain' :: Maybe Natural
durationInYears = Maybe Natural
a} :: RenewDomain)

-- | The name of the domain that you want to renew.
renewDomain_domainName :: Lens.Lens' RenewDomain Prelude.Text
renewDomain_domainName :: (Text -> f Text) -> RenewDomain -> f RenewDomain
renewDomain_domainName = (RenewDomain -> Text)
-> (RenewDomain -> Text -> RenewDomain)
-> Lens RenewDomain RenewDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewDomain' {Text
domainName :: Text
$sel:domainName:RenewDomain' :: RenewDomain -> Text
domainName} -> Text
domainName) (\s :: RenewDomain
s@RenewDomain' {} Text
a -> RenewDomain
s {$sel:domainName:RenewDomain' :: Text
domainName = Text
a} :: RenewDomain)

-- | The year when the registration for the domain is set to expire. This
-- value must match the current expiration date for the domain.
renewDomain_currentExpiryYear :: Lens.Lens' RenewDomain Prelude.Int
renewDomain_currentExpiryYear :: (Int -> f Int) -> RenewDomain -> f RenewDomain
renewDomain_currentExpiryYear = (RenewDomain -> Int)
-> (RenewDomain -> Int -> RenewDomain)
-> Lens RenewDomain RenewDomain Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewDomain' {Int
currentExpiryYear :: Int
$sel:currentExpiryYear:RenewDomain' :: RenewDomain -> Int
currentExpiryYear} -> Int
currentExpiryYear) (\s :: RenewDomain
s@RenewDomain' {} Int
a -> RenewDomain
s {$sel:currentExpiryYear:RenewDomain' :: Int
currentExpiryYear = Int
a} :: RenewDomain)

instance Core.AWSRequest RenewDomain where
  type AWSResponse RenewDomain = RenewDomainResponse
  request :: RenewDomain -> Request RenewDomain
request = Service -> RenewDomain -> Request RenewDomain
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RenewDomain
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RenewDomain)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse RenewDomain))
-> Logger
-> Service
-> Proxy RenewDomain
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RenewDomain)))
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 -> RenewDomainResponse
RenewDomainResponse'
            (Int -> Text -> RenewDomainResponse)
-> Either String Int -> Either String (Text -> RenewDomainResponse)
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 -> RenewDomainResponse)
-> Either String Text -> Either String RenewDomainResponse
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 RenewDomain

instance Prelude.NFData RenewDomain

instance Core.ToHeaders RenewDomain where
  toHeaders :: RenewDomain -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RenewDomain -> 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.RenewDomain" ::
                          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 RenewDomain where
  toJSON :: RenewDomain -> Value
toJSON RenewDomain' {Int
Maybe Natural
Text
currentExpiryYear :: Int
domainName :: Text
durationInYears :: Maybe Natural
$sel:currentExpiryYear:RenewDomain' :: RenewDomain -> Int
$sel:domainName:RenewDomain' :: RenewDomain -> Text
$sel:durationInYears:RenewDomain' :: RenewDomain -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DurationInYears" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
durationInYears,
            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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CurrentExpiryYear" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
currentExpiryYear)
          ]
      )

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

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

-- | /See:/ 'newRenewDomainResponse' smart constructor.
data RenewDomainResponse = RenewDomainResponse'
  { -- | The response's http status code.
    RenewDomainResponse -> Int
httpStatus :: Prelude.Int,
    -- | 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>.
    RenewDomainResponse -> Text
operationId :: Prelude.Text
  }
  deriving (RenewDomainResponse -> RenewDomainResponse -> Bool
(RenewDomainResponse -> RenewDomainResponse -> Bool)
-> (RenewDomainResponse -> RenewDomainResponse -> Bool)
-> Eq RenewDomainResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RenewDomainResponse -> RenewDomainResponse -> Bool
$c/= :: RenewDomainResponse -> RenewDomainResponse -> Bool
== :: RenewDomainResponse -> RenewDomainResponse -> Bool
$c== :: RenewDomainResponse -> RenewDomainResponse -> Bool
Prelude.Eq, ReadPrec [RenewDomainResponse]
ReadPrec RenewDomainResponse
Int -> ReadS RenewDomainResponse
ReadS [RenewDomainResponse]
(Int -> ReadS RenewDomainResponse)
-> ReadS [RenewDomainResponse]
-> ReadPrec RenewDomainResponse
-> ReadPrec [RenewDomainResponse]
-> Read RenewDomainResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RenewDomainResponse]
$creadListPrec :: ReadPrec [RenewDomainResponse]
readPrec :: ReadPrec RenewDomainResponse
$creadPrec :: ReadPrec RenewDomainResponse
readList :: ReadS [RenewDomainResponse]
$creadList :: ReadS [RenewDomainResponse]
readsPrec :: Int -> ReadS RenewDomainResponse
$creadsPrec :: Int -> ReadS RenewDomainResponse
Prelude.Read, Int -> RenewDomainResponse -> ShowS
[RenewDomainResponse] -> ShowS
RenewDomainResponse -> String
(Int -> RenewDomainResponse -> ShowS)
-> (RenewDomainResponse -> String)
-> ([RenewDomainResponse] -> ShowS)
-> Show RenewDomainResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RenewDomainResponse] -> ShowS
$cshowList :: [RenewDomainResponse] -> ShowS
show :: RenewDomainResponse -> String
$cshow :: RenewDomainResponse -> String
showsPrec :: Int -> RenewDomainResponse -> ShowS
$cshowsPrec :: Int -> RenewDomainResponse -> ShowS
Prelude.Show, (forall x. RenewDomainResponse -> Rep RenewDomainResponse x)
-> (forall x. Rep RenewDomainResponse x -> RenewDomainResponse)
-> Generic RenewDomainResponse
forall x. Rep RenewDomainResponse x -> RenewDomainResponse
forall x. RenewDomainResponse -> Rep RenewDomainResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RenewDomainResponse x -> RenewDomainResponse
$cfrom :: forall x. RenewDomainResponse -> Rep RenewDomainResponse x
Prelude.Generic)

-- |
-- Create a value of 'RenewDomainResponse' 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', 'renewDomainResponse_httpStatus' - The response's http status code.
--
-- 'operationId', 'renewDomainResponse_operationId' - 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>.
newRenewDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'operationId'
  Prelude.Text ->
  RenewDomainResponse
newRenewDomainResponse :: Int -> Text -> RenewDomainResponse
newRenewDomainResponse Int
pHttpStatus_ Text
pOperationId_ =
  RenewDomainResponse' :: Int -> Text -> RenewDomainResponse
RenewDomainResponse'
    { $sel:httpStatus:RenewDomainResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:operationId:RenewDomainResponse' :: Text
operationId = Text
pOperationId_
    }

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

-- | 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>.
renewDomainResponse_operationId :: Lens.Lens' RenewDomainResponse Prelude.Text
renewDomainResponse_operationId :: (Text -> f Text) -> RenewDomainResponse -> f RenewDomainResponse
renewDomainResponse_operationId = (RenewDomainResponse -> Text)
-> (RenewDomainResponse -> Text -> RenewDomainResponse)
-> Lens RenewDomainResponse RenewDomainResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewDomainResponse' {Text
operationId :: Text
$sel:operationId:RenewDomainResponse' :: RenewDomainResponse -> Text
operationId} -> Text
operationId) (\s :: RenewDomainResponse
s@RenewDomainResponse' {} Text
a -> RenewDomainResponse
s {$sel:operationId:RenewDomainResponse' :: Text
operationId = Text
a} :: RenewDomainResponse)

instance Prelude.NFData RenewDomainResponse