{-# 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.AppSync.GetDomainName
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves a custom @DomainName@ object.
module Amazonka.AppSync.GetDomainName
  ( -- * Creating a Request
    GetDomainName (..),
    newGetDomainName,

    -- * Request Lenses
    getDomainName_domainName,

    -- * Destructuring the Response
    GetDomainNameResponse (..),
    newGetDomainNameResponse,

    -- * Response Lenses
    getDomainNameResponse_domainNameConfig,
    getDomainNameResponse_httpStatus,
  )
where

import Amazonka.AppSync.Types
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

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

-- |
-- Create a value of 'GetDomainName' 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', 'getDomainName_domainName' - The domain name.
newGetDomainName ::
  -- | 'domainName'
  Prelude.Text ->
  GetDomainName
newGetDomainName :: Text -> GetDomainName
newGetDomainName Text
pDomainName_ =
  GetDomainName' {$sel:domainName:GetDomainName' :: Text
domainName = Text
pDomainName_}

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

instance Core.AWSRequest GetDomainName where
  type
    AWSResponse GetDomainName =
      GetDomainNameResponse
  request :: (Service -> Service) -> GetDomainName -> Request GetDomainName
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetDomainName
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDomainName)))
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 DomainNameConfig -> Int -> GetDomainNameResponse
GetDomainNameResponse'
            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
"domainNameConfig")
            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 GetDomainName where
  hashWithSalt :: Int -> GetDomainName -> Int
hashWithSalt Int
_salt GetDomainName' {Text
domainName :: Text
$sel:domainName:GetDomainName' :: GetDomainName -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance Prelude.NFData GetDomainName where
  rnf :: GetDomainName -> ()
rnf GetDomainName' {Text
domainName :: Text
$sel:domainName:GetDomainName' :: GetDomainName -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
domainName

instance Data.ToHeaders GetDomainName where
  toHeaders :: GetDomainName -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath GetDomainName where
  toPath :: GetDomainName -> ByteString
toPath GetDomainName' {Text
domainName :: Text
$sel:domainName:GetDomainName' :: GetDomainName -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/domainnames/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
domainName]

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

-- | /See:/ 'newGetDomainNameResponse' smart constructor.
data GetDomainNameResponse = GetDomainNameResponse'
  { -- | The configuration for the @DomainName@.
    GetDomainNameResponse -> Maybe DomainNameConfig
domainNameConfig :: Prelude.Maybe DomainNameConfig,
    -- | The response's http status code.
    GetDomainNameResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDomainNameResponse -> GetDomainNameResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDomainNameResponse -> GetDomainNameResponse -> Bool
$c/= :: GetDomainNameResponse -> GetDomainNameResponse -> Bool
== :: GetDomainNameResponse -> GetDomainNameResponse -> Bool
$c== :: GetDomainNameResponse -> GetDomainNameResponse -> Bool
Prelude.Eq, ReadPrec [GetDomainNameResponse]
ReadPrec GetDomainNameResponse
Int -> ReadS GetDomainNameResponse
ReadS [GetDomainNameResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDomainNameResponse]
$creadListPrec :: ReadPrec [GetDomainNameResponse]
readPrec :: ReadPrec GetDomainNameResponse
$creadPrec :: ReadPrec GetDomainNameResponse
readList :: ReadS [GetDomainNameResponse]
$creadList :: ReadS [GetDomainNameResponse]
readsPrec :: Int -> ReadS GetDomainNameResponse
$creadsPrec :: Int -> ReadS GetDomainNameResponse
Prelude.Read, Int -> GetDomainNameResponse -> ShowS
[GetDomainNameResponse] -> ShowS
GetDomainNameResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDomainNameResponse] -> ShowS
$cshowList :: [GetDomainNameResponse] -> ShowS
show :: GetDomainNameResponse -> String
$cshow :: GetDomainNameResponse -> String
showsPrec :: Int -> GetDomainNameResponse -> ShowS
$cshowsPrec :: Int -> GetDomainNameResponse -> ShowS
Prelude.Show, forall x. Rep GetDomainNameResponse x -> GetDomainNameResponse
forall x. GetDomainNameResponse -> Rep GetDomainNameResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDomainNameResponse x -> GetDomainNameResponse
$cfrom :: forall x. GetDomainNameResponse -> Rep GetDomainNameResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDomainNameResponse' 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:
--
-- 'domainNameConfig', 'getDomainNameResponse_domainNameConfig' - The configuration for the @DomainName@.
--
-- 'httpStatus', 'getDomainNameResponse_httpStatus' - The response's http status code.
newGetDomainNameResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDomainNameResponse
newGetDomainNameResponse :: Int -> GetDomainNameResponse
newGetDomainNameResponse Int
pHttpStatus_ =
  GetDomainNameResponse'
    { $sel:domainNameConfig:GetDomainNameResponse' :: Maybe DomainNameConfig
domainNameConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDomainNameResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The configuration for the @DomainName@.
getDomainNameResponse_domainNameConfig :: Lens.Lens' GetDomainNameResponse (Prelude.Maybe DomainNameConfig)
getDomainNameResponse_domainNameConfig :: Lens' GetDomainNameResponse (Maybe DomainNameConfig)
getDomainNameResponse_domainNameConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDomainNameResponse' {Maybe DomainNameConfig
domainNameConfig :: Maybe DomainNameConfig
$sel:domainNameConfig:GetDomainNameResponse' :: GetDomainNameResponse -> Maybe DomainNameConfig
domainNameConfig} -> Maybe DomainNameConfig
domainNameConfig) (\s :: GetDomainNameResponse
s@GetDomainNameResponse' {} Maybe DomainNameConfig
a -> GetDomainNameResponse
s {$sel:domainNameConfig:GetDomainNameResponse' :: Maybe DomainNameConfig
domainNameConfig = Maybe DomainNameConfig
a} :: GetDomainNameResponse)

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

instance Prelude.NFData GetDomainNameResponse where
  rnf :: GetDomainNameResponse -> ()
rnf GetDomainNameResponse' {Int
Maybe DomainNameConfig
httpStatus :: Int
domainNameConfig :: Maybe DomainNameConfig
$sel:httpStatus:GetDomainNameResponse' :: GetDomainNameResponse -> Int
$sel:domainNameConfig:GetDomainNameResponse' :: GetDomainNameResponse -> Maybe DomainNameConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DomainNameConfig
domainNameConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus