{-# 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.ElasticBeanstalk.CheckDNSAvailability
-- 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)
--
-- Checks if the specified CNAME is available.
module Amazonka.ElasticBeanstalk.CheckDNSAvailability
  ( -- * Creating a Request
    CheckDNSAvailability (..),
    newCheckDNSAvailability,

    -- * Request Lenses
    checkDNSAvailability_cNAMEPrefix,

    -- * Destructuring the Response
    CheckDNSAvailabilityResponse (..),
    newCheckDNSAvailabilityResponse,

    -- * Response Lenses
    checkDNSAvailabilityResponse_fullyQualifiedCNAME,
    checkDNSAvailabilityResponse_available,
    checkDNSAvailabilityResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ElasticBeanstalk.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Results message indicating whether a CNAME is available.
--
-- /See:/ 'newCheckDNSAvailability' smart constructor.
data CheckDNSAvailability = CheckDNSAvailability'
  { -- | The prefix used when this CNAME is reserved.
    CheckDNSAvailability -> Text
cNAMEPrefix :: Prelude.Text
  }
  deriving (CheckDNSAvailability -> CheckDNSAvailability -> Bool
(CheckDNSAvailability -> CheckDNSAvailability -> Bool)
-> (CheckDNSAvailability -> CheckDNSAvailability -> Bool)
-> Eq CheckDNSAvailability
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CheckDNSAvailability -> CheckDNSAvailability -> Bool
$c/= :: CheckDNSAvailability -> CheckDNSAvailability -> Bool
== :: CheckDNSAvailability -> CheckDNSAvailability -> Bool
$c== :: CheckDNSAvailability -> CheckDNSAvailability -> Bool
Prelude.Eq, ReadPrec [CheckDNSAvailability]
ReadPrec CheckDNSAvailability
Int -> ReadS CheckDNSAvailability
ReadS [CheckDNSAvailability]
(Int -> ReadS CheckDNSAvailability)
-> ReadS [CheckDNSAvailability]
-> ReadPrec CheckDNSAvailability
-> ReadPrec [CheckDNSAvailability]
-> Read CheckDNSAvailability
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CheckDNSAvailability]
$creadListPrec :: ReadPrec [CheckDNSAvailability]
readPrec :: ReadPrec CheckDNSAvailability
$creadPrec :: ReadPrec CheckDNSAvailability
readList :: ReadS [CheckDNSAvailability]
$creadList :: ReadS [CheckDNSAvailability]
readsPrec :: Int -> ReadS CheckDNSAvailability
$creadsPrec :: Int -> ReadS CheckDNSAvailability
Prelude.Read, Int -> CheckDNSAvailability -> ShowS
[CheckDNSAvailability] -> ShowS
CheckDNSAvailability -> String
(Int -> CheckDNSAvailability -> ShowS)
-> (CheckDNSAvailability -> String)
-> ([CheckDNSAvailability] -> ShowS)
-> Show CheckDNSAvailability
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CheckDNSAvailability] -> ShowS
$cshowList :: [CheckDNSAvailability] -> ShowS
show :: CheckDNSAvailability -> String
$cshow :: CheckDNSAvailability -> String
showsPrec :: Int -> CheckDNSAvailability -> ShowS
$cshowsPrec :: Int -> CheckDNSAvailability -> ShowS
Prelude.Show, (forall x. CheckDNSAvailability -> Rep CheckDNSAvailability x)
-> (forall x. Rep CheckDNSAvailability x -> CheckDNSAvailability)
-> Generic CheckDNSAvailability
forall x. Rep CheckDNSAvailability x -> CheckDNSAvailability
forall x. CheckDNSAvailability -> Rep CheckDNSAvailability x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CheckDNSAvailability x -> CheckDNSAvailability
$cfrom :: forall x. CheckDNSAvailability -> Rep CheckDNSAvailability x
Prelude.Generic)

-- |
-- Create a value of 'CheckDNSAvailability' 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:
--
-- 'cNAMEPrefix', 'checkDNSAvailability_cNAMEPrefix' - The prefix used when this CNAME is reserved.
newCheckDNSAvailability ::
  -- | 'cNAMEPrefix'
  Prelude.Text ->
  CheckDNSAvailability
newCheckDNSAvailability :: Text -> CheckDNSAvailability
newCheckDNSAvailability Text
pCNAMEPrefix_ =
  CheckDNSAvailability' :: Text -> CheckDNSAvailability
CheckDNSAvailability' {$sel:cNAMEPrefix:CheckDNSAvailability' :: Text
cNAMEPrefix = Text
pCNAMEPrefix_}

-- | The prefix used when this CNAME is reserved.
checkDNSAvailability_cNAMEPrefix :: Lens.Lens' CheckDNSAvailability Prelude.Text
checkDNSAvailability_cNAMEPrefix :: (Text -> f Text) -> CheckDNSAvailability -> f CheckDNSAvailability
checkDNSAvailability_cNAMEPrefix = (CheckDNSAvailability -> Text)
-> (CheckDNSAvailability -> Text -> CheckDNSAvailability)
-> Lens CheckDNSAvailability CheckDNSAvailability Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CheckDNSAvailability' {Text
cNAMEPrefix :: Text
$sel:cNAMEPrefix:CheckDNSAvailability' :: CheckDNSAvailability -> Text
cNAMEPrefix} -> Text
cNAMEPrefix) (\s :: CheckDNSAvailability
s@CheckDNSAvailability' {} Text
a -> CheckDNSAvailability
s {$sel:cNAMEPrefix:CheckDNSAvailability' :: Text
cNAMEPrefix = Text
a} :: CheckDNSAvailability)

instance Core.AWSRequest CheckDNSAvailability where
  type
    AWSResponse CheckDNSAvailability =
      CheckDNSAvailabilityResponse
  request :: CheckDNSAvailability -> Request CheckDNSAvailability
request = Service -> CheckDNSAvailability -> Request CheckDNSAvailability
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy CheckDNSAvailability
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CheckDNSAvailability)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse CheckDNSAvailability))
-> Logger
-> Service
-> Proxy CheckDNSAvailability
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CheckDNSAvailability)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"CheckDNSAvailabilityResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Maybe Bool -> Int -> CheckDNSAvailabilityResponse
CheckDNSAvailabilityResponse'
            (Maybe Text -> Maybe Bool -> Int -> CheckDNSAvailabilityResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Bool -> Int -> CheckDNSAvailabilityResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"FullyQualifiedCNAME")
            Either String (Maybe Bool -> Int -> CheckDNSAvailabilityResponse)
-> Either String (Maybe Bool)
-> Either String (Int -> CheckDNSAvailabilityResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Available")
            Either String (Int -> CheckDNSAvailabilityResponse)
-> Either String Int -> Either String CheckDNSAvailabilityResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable CheckDNSAvailability

instance Prelude.NFData CheckDNSAvailability

instance Core.ToHeaders CheckDNSAvailability where
  toHeaders :: CheckDNSAvailability -> ResponseHeaders
toHeaders = ResponseHeaders -> CheckDNSAvailability -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery CheckDNSAvailability where
  toQuery :: CheckDNSAvailability -> QueryString
toQuery CheckDNSAvailability' {Text
cNAMEPrefix :: Text
$sel:cNAMEPrefix:CheckDNSAvailability' :: CheckDNSAvailability -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"CheckDNSAvailability" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"CNAMEPrefix" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
cNAMEPrefix
      ]

-- | Indicates if the specified CNAME is available.
--
-- /See:/ 'newCheckDNSAvailabilityResponse' smart constructor.
data CheckDNSAvailabilityResponse = CheckDNSAvailabilityResponse'
  { -- | The fully qualified CNAME to reserve when CreateEnvironment is called
    -- with the provided prefix.
    CheckDNSAvailabilityResponse -> Maybe Text
fullyQualifiedCNAME :: Prelude.Maybe Prelude.Text,
    -- | Indicates if the specified CNAME is available:
    --
    -- -   @true@ : The CNAME is available.
    --
    -- -   @false@ : The CNAME is not available.
    CheckDNSAvailabilityResponse -> Maybe Bool
available :: Prelude.Maybe Prelude.Bool,
    -- | The response's http status code.
    CheckDNSAvailabilityResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CheckDNSAvailabilityResponse
-> CheckDNSAvailabilityResponse -> Bool
(CheckDNSAvailabilityResponse
 -> CheckDNSAvailabilityResponse -> Bool)
-> (CheckDNSAvailabilityResponse
    -> CheckDNSAvailabilityResponse -> Bool)
-> Eq CheckDNSAvailabilityResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CheckDNSAvailabilityResponse
-> CheckDNSAvailabilityResponse -> Bool
$c/= :: CheckDNSAvailabilityResponse
-> CheckDNSAvailabilityResponse -> Bool
== :: CheckDNSAvailabilityResponse
-> CheckDNSAvailabilityResponse -> Bool
$c== :: CheckDNSAvailabilityResponse
-> CheckDNSAvailabilityResponse -> Bool
Prelude.Eq, ReadPrec [CheckDNSAvailabilityResponse]
ReadPrec CheckDNSAvailabilityResponse
Int -> ReadS CheckDNSAvailabilityResponse
ReadS [CheckDNSAvailabilityResponse]
(Int -> ReadS CheckDNSAvailabilityResponse)
-> ReadS [CheckDNSAvailabilityResponse]
-> ReadPrec CheckDNSAvailabilityResponse
-> ReadPrec [CheckDNSAvailabilityResponse]
-> Read CheckDNSAvailabilityResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CheckDNSAvailabilityResponse]
$creadListPrec :: ReadPrec [CheckDNSAvailabilityResponse]
readPrec :: ReadPrec CheckDNSAvailabilityResponse
$creadPrec :: ReadPrec CheckDNSAvailabilityResponse
readList :: ReadS [CheckDNSAvailabilityResponse]
$creadList :: ReadS [CheckDNSAvailabilityResponse]
readsPrec :: Int -> ReadS CheckDNSAvailabilityResponse
$creadsPrec :: Int -> ReadS CheckDNSAvailabilityResponse
Prelude.Read, Int -> CheckDNSAvailabilityResponse -> ShowS
[CheckDNSAvailabilityResponse] -> ShowS
CheckDNSAvailabilityResponse -> String
(Int -> CheckDNSAvailabilityResponse -> ShowS)
-> (CheckDNSAvailabilityResponse -> String)
-> ([CheckDNSAvailabilityResponse] -> ShowS)
-> Show CheckDNSAvailabilityResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CheckDNSAvailabilityResponse] -> ShowS
$cshowList :: [CheckDNSAvailabilityResponse] -> ShowS
show :: CheckDNSAvailabilityResponse -> String
$cshow :: CheckDNSAvailabilityResponse -> String
showsPrec :: Int -> CheckDNSAvailabilityResponse -> ShowS
$cshowsPrec :: Int -> CheckDNSAvailabilityResponse -> ShowS
Prelude.Show, (forall x.
 CheckDNSAvailabilityResponse -> Rep CheckDNSAvailabilityResponse x)
-> (forall x.
    Rep CheckDNSAvailabilityResponse x -> CheckDNSAvailabilityResponse)
-> Generic CheckDNSAvailabilityResponse
forall x.
Rep CheckDNSAvailabilityResponse x -> CheckDNSAvailabilityResponse
forall x.
CheckDNSAvailabilityResponse -> Rep CheckDNSAvailabilityResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CheckDNSAvailabilityResponse x -> CheckDNSAvailabilityResponse
$cfrom :: forall x.
CheckDNSAvailabilityResponse -> Rep CheckDNSAvailabilityResponse x
Prelude.Generic)

-- |
-- Create a value of 'CheckDNSAvailabilityResponse' 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:
--
-- 'fullyQualifiedCNAME', 'checkDNSAvailabilityResponse_fullyQualifiedCNAME' - The fully qualified CNAME to reserve when CreateEnvironment is called
-- with the provided prefix.
--
-- 'available', 'checkDNSAvailabilityResponse_available' - Indicates if the specified CNAME is available:
--
-- -   @true@ : The CNAME is available.
--
-- -   @false@ : The CNAME is not available.
--
-- 'httpStatus', 'checkDNSAvailabilityResponse_httpStatus' - The response's http status code.
newCheckDNSAvailabilityResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CheckDNSAvailabilityResponse
newCheckDNSAvailabilityResponse :: Int -> CheckDNSAvailabilityResponse
newCheckDNSAvailabilityResponse Int
pHttpStatus_ =
  CheckDNSAvailabilityResponse' :: Maybe Text -> Maybe Bool -> Int -> CheckDNSAvailabilityResponse
CheckDNSAvailabilityResponse'
    { $sel:fullyQualifiedCNAME:CheckDNSAvailabilityResponse' :: Maybe Text
fullyQualifiedCNAME =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:available:CheckDNSAvailabilityResponse' :: Maybe Bool
available = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CheckDNSAvailabilityResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The fully qualified CNAME to reserve when CreateEnvironment is called
-- with the provided prefix.
checkDNSAvailabilityResponse_fullyQualifiedCNAME :: Lens.Lens' CheckDNSAvailabilityResponse (Prelude.Maybe Prelude.Text)
checkDNSAvailabilityResponse_fullyQualifiedCNAME :: (Maybe Text -> f (Maybe Text))
-> CheckDNSAvailabilityResponse -> f CheckDNSAvailabilityResponse
checkDNSAvailabilityResponse_fullyQualifiedCNAME = (CheckDNSAvailabilityResponse -> Maybe Text)
-> (CheckDNSAvailabilityResponse
    -> Maybe Text -> CheckDNSAvailabilityResponse)
-> Lens
     CheckDNSAvailabilityResponse
     CheckDNSAvailabilityResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CheckDNSAvailabilityResponse' {Maybe Text
fullyQualifiedCNAME :: Maybe Text
$sel:fullyQualifiedCNAME:CheckDNSAvailabilityResponse' :: CheckDNSAvailabilityResponse -> Maybe Text
fullyQualifiedCNAME} -> Maybe Text
fullyQualifiedCNAME) (\s :: CheckDNSAvailabilityResponse
s@CheckDNSAvailabilityResponse' {} Maybe Text
a -> CheckDNSAvailabilityResponse
s {$sel:fullyQualifiedCNAME:CheckDNSAvailabilityResponse' :: Maybe Text
fullyQualifiedCNAME = Maybe Text
a} :: CheckDNSAvailabilityResponse)

-- | Indicates if the specified CNAME is available:
--
-- -   @true@ : The CNAME is available.
--
-- -   @false@ : The CNAME is not available.
checkDNSAvailabilityResponse_available :: Lens.Lens' CheckDNSAvailabilityResponse (Prelude.Maybe Prelude.Bool)
checkDNSAvailabilityResponse_available :: (Maybe Bool -> f (Maybe Bool))
-> CheckDNSAvailabilityResponse -> f CheckDNSAvailabilityResponse
checkDNSAvailabilityResponse_available = (CheckDNSAvailabilityResponse -> Maybe Bool)
-> (CheckDNSAvailabilityResponse
    -> Maybe Bool -> CheckDNSAvailabilityResponse)
-> Lens
     CheckDNSAvailabilityResponse
     CheckDNSAvailabilityResponse
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CheckDNSAvailabilityResponse' {Maybe Bool
available :: Maybe Bool
$sel:available:CheckDNSAvailabilityResponse' :: CheckDNSAvailabilityResponse -> Maybe Bool
available} -> Maybe Bool
available) (\s :: CheckDNSAvailabilityResponse
s@CheckDNSAvailabilityResponse' {} Maybe Bool
a -> CheckDNSAvailabilityResponse
s {$sel:available:CheckDNSAvailabilityResponse' :: Maybe Bool
available = Maybe Bool
a} :: CheckDNSAvailabilityResponse)

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

instance Prelude.NFData CheckDNSAvailabilityResponse