{-# 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.Lightsail.GetDomain
-- 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)
--
-- Returns information about a specific domain recordset.
module Amazonka.Lightsail.GetDomain
  ( -- * Creating a Request
    GetDomain (..),
    newGetDomain,

    -- * Request Lenses
    getDomain_domainName,

    -- * Destructuring the Response
    GetDomainResponse (..),
    newGetDomainResponse,

    -- * Response Lenses
    getDomainResponse_domain,
    getDomainResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetDomain' smart constructor.
data GetDomain = GetDomain'
  { -- | The domain name for which your want to return information about.
    GetDomain -> Text
domainName :: Prelude.Text
  }
  deriving (GetDomain -> GetDomain -> Bool
(GetDomain -> GetDomain -> Bool)
-> (GetDomain -> GetDomain -> Bool) -> Eq GetDomain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDomain -> GetDomain -> Bool
$c/= :: GetDomain -> GetDomain -> Bool
== :: GetDomain -> GetDomain -> Bool
$c== :: GetDomain -> GetDomain -> Bool
Prelude.Eq, ReadPrec [GetDomain]
ReadPrec GetDomain
Int -> ReadS GetDomain
ReadS [GetDomain]
(Int -> ReadS GetDomain)
-> ReadS [GetDomain]
-> ReadPrec GetDomain
-> ReadPrec [GetDomain]
-> Read GetDomain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDomain]
$creadListPrec :: ReadPrec [GetDomain]
readPrec :: ReadPrec GetDomain
$creadPrec :: ReadPrec GetDomain
readList :: ReadS [GetDomain]
$creadList :: ReadS [GetDomain]
readsPrec :: Int -> ReadS GetDomain
$creadsPrec :: Int -> ReadS GetDomain
Prelude.Read, Int -> GetDomain -> ShowS
[GetDomain] -> ShowS
GetDomain -> String
(Int -> GetDomain -> ShowS)
-> (GetDomain -> String)
-> ([GetDomain] -> ShowS)
-> Show GetDomain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDomain] -> ShowS
$cshowList :: [GetDomain] -> ShowS
show :: GetDomain -> String
$cshow :: GetDomain -> String
showsPrec :: Int -> GetDomain -> ShowS
$cshowsPrec :: Int -> GetDomain -> ShowS
Prelude.Show, (forall x. GetDomain -> Rep GetDomain x)
-> (forall x. Rep GetDomain x -> GetDomain) -> Generic GetDomain
forall x. Rep GetDomain x -> GetDomain
forall x. GetDomain -> Rep GetDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDomain x -> GetDomain
$cfrom :: forall x. GetDomain -> Rep GetDomain x
Prelude.Generic)

-- |
-- Create a value of 'GetDomain' 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', 'getDomain_domainName' - The domain name for which your want to return information about.
newGetDomain ::
  -- | 'domainName'
  Prelude.Text ->
  GetDomain
newGetDomain :: Text -> GetDomain
newGetDomain Text
pDomainName_ =
  GetDomain' :: Text -> GetDomain
GetDomain' {$sel:domainName:GetDomain' :: Text
domainName = Text
pDomainName_}

-- | The domain name for which your want to return information about.
getDomain_domainName :: Lens.Lens' GetDomain Prelude.Text
getDomain_domainName :: (Text -> f Text) -> GetDomain -> f GetDomain
getDomain_domainName = (GetDomain -> Text)
-> (GetDomain -> Text -> GetDomain)
-> Lens GetDomain GetDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDomain' {Text
domainName :: Text
$sel:domainName:GetDomain' :: GetDomain -> Text
domainName} -> Text
domainName) (\s :: GetDomain
s@GetDomain' {} Text
a -> GetDomain
s {$sel:domainName:GetDomain' :: Text
domainName = Text
a} :: GetDomain)

instance Core.AWSRequest GetDomain where
  type AWSResponse GetDomain = GetDomainResponse
  request :: GetDomain -> Request GetDomain
request = Service -> GetDomain -> Request GetDomain
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDomain
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDomain)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDomain))
-> Logger
-> Service
-> Proxy GetDomain
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDomain)))
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 ->
          Maybe Domain -> Int -> GetDomainResponse
GetDomainResponse'
            (Maybe Domain -> Int -> GetDomainResponse)
-> Either String (Maybe Domain)
-> Either String (Int -> GetDomainResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Domain)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"domain")
            Either String (Int -> GetDomainResponse)
-> Either String Int -> Either String GetDomainResponse
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 GetDomain

instance Prelude.NFData GetDomain

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

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

-- | /See:/ 'newGetDomainResponse' smart constructor.
data GetDomainResponse = GetDomainResponse'
  { -- | An array of key-value pairs containing information about your get domain
    -- request.
    GetDomainResponse -> Maybe Domain
domain :: Prelude.Maybe Domain,
    -- | The response's http status code.
    GetDomainResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDomainResponse -> GetDomainResponse -> Bool
(GetDomainResponse -> GetDomainResponse -> Bool)
-> (GetDomainResponse -> GetDomainResponse -> Bool)
-> Eq GetDomainResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDomainResponse -> GetDomainResponse -> Bool
$c/= :: GetDomainResponse -> GetDomainResponse -> Bool
== :: GetDomainResponse -> GetDomainResponse -> Bool
$c== :: GetDomainResponse -> GetDomainResponse -> Bool
Prelude.Eq, ReadPrec [GetDomainResponse]
ReadPrec GetDomainResponse
Int -> ReadS GetDomainResponse
ReadS [GetDomainResponse]
(Int -> ReadS GetDomainResponse)
-> ReadS [GetDomainResponse]
-> ReadPrec GetDomainResponse
-> ReadPrec [GetDomainResponse]
-> Read GetDomainResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDomainResponse]
$creadListPrec :: ReadPrec [GetDomainResponse]
readPrec :: ReadPrec GetDomainResponse
$creadPrec :: ReadPrec GetDomainResponse
readList :: ReadS [GetDomainResponse]
$creadList :: ReadS [GetDomainResponse]
readsPrec :: Int -> ReadS GetDomainResponse
$creadsPrec :: Int -> ReadS GetDomainResponse
Prelude.Read, Int -> GetDomainResponse -> ShowS
[GetDomainResponse] -> ShowS
GetDomainResponse -> String
(Int -> GetDomainResponse -> ShowS)
-> (GetDomainResponse -> String)
-> ([GetDomainResponse] -> ShowS)
-> Show GetDomainResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDomainResponse] -> ShowS
$cshowList :: [GetDomainResponse] -> ShowS
show :: GetDomainResponse -> String
$cshow :: GetDomainResponse -> String
showsPrec :: Int -> GetDomainResponse -> ShowS
$cshowsPrec :: Int -> GetDomainResponse -> ShowS
Prelude.Show, (forall x. GetDomainResponse -> Rep GetDomainResponse x)
-> (forall x. Rep GetDomainResponse x -> GetDomainResponse)
-> Generic GetDomainResponse
forall x. Rep GetDomainResponse x -> GetDomainResponse
forall x. GetDomainResponse -> Rep GetDomainResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDomainResponse x -> GetDomainResponse
$cfrom :: forall x. GetDomainResponse -> Rep GetDomainResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDomainResponse' 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:
--
-- 'domain', 'getDomainResponse_domain' - An array of key-value pairs containing information about your get domain
-- request.
--
-- 'httpStatus', 'getDomainResponse_httpStatus' - The response's http status code.
newGetDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDomainResponse
newGetDomainResponse :: Int -> GetDomainResponse
newGetDomainResponse Int
pHttpStatus_ =
  GetDomainResponse' :: Maybe Domain -> Int -> GetDomainResponse
GetDomainResponse'
    { $sel:domain:GetDomainResponse' :: Maybe Domain
domain = Maybe Domain
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDomainResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of key-value pairs containing information about your get domain
-- request.
getDomainResponse_domain :: Lens.Lens' GetDomainResponse (Prelude.Maybe Domain)
getDomainResponse_domain :: (Maybe Domain -> f (Maybe Domain))
-> GetDomainResponse -> f GetDomainResponse
getDomainResponse_domain = (GetDomainResponse -> Maybe Domain)
-> (GetDomainResponse -> Maybe Domain -> GetDomainResponse)
-> Lens
     GetDomainResponse GetDomainResponse (Maybe Domain) (Maybe Domain)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDomainResponse' {Maybe Domain
domain :: Maybe Domain
$sel:domain:GetDomainResponse' :: GetDomainResponse -> Maybe Domain
domain} -> Maybe Domain
domain) (\s :: GetDomainResponse
s@GetDomainResponse' {} Maybe Domain
a -> GetDomainResponse
s {$sel:domain:GetDomainResponse' :: Maybe Domain
domain = Maybe Domain
a} :: GetDomainResponse)

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

instance Prelude.NFData GetDomainResponse