{-# 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.Amplify.GetDomainAssociation
-- 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 the domain information for an Amplify app.
module Amazonka.Amplify.GetDomainAssociation
  ( -- * Creating a Request
    GetDomainAssociation (..),
    newGetDomainAssociation,

    -- * Request Lenses
    getDomainAssociation_appId,
    getDomainAssociation_domainName,

    -- * Destructuring the Response
    GetDomainAssociationResponse (..),
    newGetDomainAssociationResponse,

    -- * Response Lenses
    getDomainAssociationResponse_httpStatus,
    getDomainAssociationResponse_domainAssociation,
  )
where

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

-- | The request structure for the get domain association request.
--
-- /See:/ 'newGetDomainAssociation' smart constructor.
data GetDomainAssociation = GetDomainAssociation'
  { -- | The unique id for an Amplify app.
    GetDomainAssociation -> Text
appId :: Prelude.Text,
    -- | The name of the domain.
    GetDomainAssociation -> Text
domainName :: Prelude.Text
  }
  deriving (GetDomainAssociation -> GetDomainAssociation -> Bool
(GetDomainAssociation -> GetDomainAssociation -> Bool)
-> (GetDomainAssociation -> GetDomainAssociation -> Bool)
-> Eq GetDomainAssociation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDomainAssociation -> GetDomainAssociation -> Bool
$c/= :: GetDomainAssociation -> GetDomainAssociation -> Bool
== :: GetDomainAssociation -> GetDomainAssociation -> Bool
$c== :: GetDomainAssociation -> GetDomainAssociation -> Bool
Prelude.Eq, ReadPrec [GetDomainAssociation]
ReadPrec GetDomainAssociation
Int -> ReadS GetDomainAssociation
ReadS [GetDomainAssociation]
(Int -> ReadS GetDomainAssociation)
-> ReadS [GetDomainAssociation]
-> ReadPrec GetDomainAssociation
-> ReadPrec [GetDomainAssociation]
-> Read GetDomainAssociation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDomainAssociation]
$creadListPrec :: ReadPrec [GetDomainAssociation]
readPrec :: ReadPrec GetDomainAssociation
$creadPrec :: ReadPrec GetDomainAssociation
readList :: ReadS [GetDomainAssociation]
$creadList :: ReadS [GetDomainAssociation]
readsPrec :: Int -> ReadS GetDomainAssociation
$creadsPrec :: Int -> ReadS GetDomainAssociation
Prelude.Read, Int -> GetDomainAssociation -> ShowS
[GetDomainAssociation] -> ShowS
GetDomainAssociation -> String
(Int -> GetDomainAssociation -> ShowS)
-> (GetDomainAssociation -> String)
-> ([GetDomainAssociation] -> ShowS)
-> Show GetDomainAssociation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDomainAssociation] -> ShowS
$cshowList :: [GetDomainAssociation] -> ShowS
show :: GetDomainAssociation -> String
$cshow :: GetDomainAssociation -> String
showsPrec :: Int -> GetDomainAssociation -> ShowS
$cshowsPrec :: Int -> GetDomainAssociation -> ShowS
Prelude.Show, (forall x. GetDomainAssociation -> Rep GetDomainAssociation x)
-> (forall x. Rep GetDomainAssociation x -> GetDomainAssociation)
-> Generic GetDomainAssociation
forall x. Rep GetDomainAssociation x -> GetDomainAssociation
forall x. GetDomainAssociation -> Rep GetDomainAssociation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDomainAssociation x -> GetDomainAssociation
$cfrom :: forall x. GetDomainAssociation -> Rep GetDomainAssociation x
Prelude.Generic)

-- |
-- Create a value of 'GetDomainAssociation' 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:
--
-- 'appId', 'getDomainAssociation_appId' - The unique id for an Amplify app.
--
-- 'domainName', 'getDomainAssociation_domainName' - The name of the domain.
newGetDomainAssociation ::
  -- | 'appId'
  Prelude.Text ->
  -- | 'domainName'
  Prelude.Text ->
  GetDomainAssociation
newGetDomainAssociation :: Text -> Text -> GetDomainAssociation
newGetDomainAssociation Text
pAppId_ Text
pDomainName_ =
  GetDomainAssociation' :: Text -> Text -> GetDomainAssociation
GetDomainAssociation'
    { $sel:appId:GetDomainAssociation' :: Text
appId = Text
pAppId_,
      $sel:domainName:GetDomainAssociation' :: Text
domainName = Text
pDomainName_
    }

-- | The unique id for an Amplify app.
getDomainAssociation_appId :: Lens.Lens' GetDomainAssociation Prelude.Text
getDomainAssociation_appId :: (Text -> f Text) -> GetDomainAssociation -> f GetDomainAssociation
getDomainAssociation_appId = (GetDomainAssociation -> Text)
-> (GetDomainAssociation -> Text -> GetDomainAssociation)
-> Lens GetDomainAssociation GetDomainAssociation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDomainAssociation' {Text
appId :: Text
$sel:appId:GetDomainAssociation' :: GetDomainAssociation -> Text
appId} -> Text
appId) (\s :: GetDomainAssociation
s@GetDomainAssociation' {} Text
a -> GetDomainAssociation
s {$sel:appId:GetDomainAssociation' :: Text
appId = Text
a} :: GetDomainAssociation)

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

instance Core.AWSRequest GetDomainAssociation where
  type
    AWSResponse GetDomainAssociation =
      GetDomainAssociationResponse
  request :: GetDomainAssociation -> Request GetDomainAssociation
request = Service -> GetDomainAssociation -> Request GetDomainAssociation
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDomainAssociation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDomainAssociation)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDomainAssociation))
-> Logger
-> Service
-> Proxy GetDomainAssociation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDomainAssociation)))
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 -> DomainAssociation -> GetDomainAssociationResponse
GetDomainAssociationResponse'
            (Int -> DomainAssociation -> GetDomainAssociationResponse)
-> Either String Int
-> Either
     String (DomainAssociation -> GetDomainAssociationResponse)
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 (DomainAssociation -> GetDomainAssociationResponse)
-> Either String DomainAssociation
-> Either String GetDomainAssociationResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String DomainAssociation
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"domainAssociation")
      )

instance Prelude.Hashable GetDomainAssociation

instance Prelude.NFData GetDomainAssociation

instance Core.ToHeaders GetDomainAssociation where
  toHeaders :: GetDomainAssociation -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetDomainAssociation -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath GetDomainAssociation where
  toPath :: GetDomainAssociation -> ByteString
toPath GetDomainAssociation' {Text
domainName :: Text
appId :: Text
$sel:domainName:GetDomainAssociation' :: GetDomainAssociation -> Text
$sel:appId:GetDomainAssociation' :: GetDomainAssociation -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/apps/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
appId,
        ByteString
"/domains/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
domainName
      ]

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

-- | The result structure for the get domain association request.
--
-- /See:/ 'newGetDomainAssociationResponse' smart constructor.
data GetDomainAssociationResponse = GetDomainAssociationResponse'
  { -- | The response's http status code.
    GetDomainAssociationResponse -> Int
httpStatus :: Prelude.Int,
    -- | Describes the structure of a domain association, which associates a
    -- custom domain with an Amplify app.
    GetDomainAssociationResponse -> DomainAssociation
domainAssociation :: DomainAssociation
  }
  deriving (GetDomainAssociationResponse
-> GetDomainAssociationResponse -> Bool
(GetDomainAssociationResponse
 -> GetDomainAssociationResponse -> Bool)
-> (GetDomainAssociationResponse
    -> GetDomainAssociationResponse -> Bool)
-> Eq GetDomainAssociationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDomainAssociationResponse
-> GetDomainAssociationResponse -> Bool
$c/= :: GetDomainAssociationResponse
-> GetDomainAssociationResponse -> Bool
== :: GetDomainAssociationResponse
-> GetDomainAssociationResponse -> Bool
$c== :: GetDomainAssociationResponse
-> GetDomainAssociationResponse -> Bool
Prelude.Eq, ReadPrec [GetDomainAssociationResponse]
ReadPrec GetDomainAssociationResponse
Int -> ReadS GetDomainAssociationResponse
ReadS [GetDomainAssociationResponse]
(Int -> ReadS GetDomainAssociationResponse)
-> ReadS [GetDomainAssociationResponse]
-> ReadPrec GetDomainAssociationResponse
-> ReadPrec [GetDomainAssociationResponse]
-> Read GetDomainAssociationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDomainAssociationResponse]
$creadListPrec :: ReadPrec [GetDomainAssociationResponse]
readPrec :: ReadPrec GetDomainAssociationResponse
$creadPrec :: ReadPrec GetDomainAssociationResponse
readList :: ReadS [GetDomainAssociationResponse]
$creadList :: ReadS [GetDomainAssociationResponse]
readsPrec :: Int -> ReadS GetDomainAssociationResponse
$creadsPrec :: Int -> ReadS GetDomainAssociationResponse
Prelude.Read, Int -> GetDomainAssociationResponse -> ShowS
[GetDomainAssociationResponse] -> ShowS
GetDomainAssociationResponse -> String
(Int -> GetDomainAssociationResponse -> ShowS)
-> (GetDomainAssociationResponse -> String)
-> ([GetDomainAssociationResponse] -> ShowS)
-> Show GetDomainAssociationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDomainAssociationResponse] -> ShowS
$cshowList :: [GetDomainAssociationResponse] -> ShowS
show :: GetDomainAssociationResponse -> String
$cshow :: GetDomainAssociationResponse -> String
showsPrec :: Int -> GetDomainAssociationResponse -> ShowS
$cshowsPrec :: Int -> GetDomainAssociationResponse -> ShowS
Prelude.Show, (forall x.
 GetDomainAssociationResponse -> Rep GetDomainAssociationResponse x)
-> (forall x.
    Rep GetDomainAssociationResponse x -> GetDomainAssociationResponse)
-> Generic GetDomainAssociationResponse
forall x.
Rep GetDomainAssociationResponse x -> GetDomainAssociationResponse
forall x.
GetDomainAssociationResponse -> Rep GetDomainAssociationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDomainAssociationResponse x -> GetDomainAssociationResponse
$cfrom :: forall x.
GetDomainAssociationResponse -> Rep GetDomainAssociationResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDomainAssociationResponse' 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', 'getDomainAssociationResponse_httpStatus' - The response's http status code.
--
-- 'domainAssociation', 'getDomainAssociationResponse_domainAssociation' - Describes the structure of a domain association, which associates a
-- custom domain with an Amplify app.
newGetDomainAssociationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'domainAssociation'
  DomainAssociation ->
  GetDomainAssociationResponse
newGetDomainAssociationResponse :: Int -> DomainAssociation -> GetDomainAssociationResponse
newGetDomainAssociationResponse
  Int
pHttpStatus_
  DomainAssociation
pDomainAssociation_ =
    GetDomainAssociationResponse' :: Int -> DomainAssociation -> GetDomainAssociationResponse
GetDomainAssociationResponse'
      { $sel:httpStatus:GetDomainAssociationResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:domainAssociation:GetDomainAssociationResponse' :: DomainAssociation
domainAssociation = DomainAssociation
pDomainAssociation_
      }

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

-- | Describes the structure of a domain association, which associates a
-- custom domain with an Amplify app.
getDomainAssociationResponse_domainAssociation :: Lens.Lens' GetDomainAssociationResponse DomainAssociation
getDomainAssociationResponse_domainAssociation :: (DomainAssociation -> f DomainAssociation)
-> GetDomainAssociationResponse -> f GetDomainAssociationResponse
getDomainAssociationResponse_domainAssociation = (GetDomainAssociationResponse -> DomainAssociation)
-> (GetDomainAssociationResponse
    -> DomainAssociation -> GetDomainAssociationResponse)
-> Lens
     GetDomainAssociationResponse
     GetDomainAssociationResponse
     DomainAssociation
     DomainAssociation
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDomainAssociationResponse' {DomainAssociation
domainAssociation :: DomainAssociation
$sel:domainAssociation:GetDomainAssociationResponse' :: GetDomainAssociationResponse -> DomainAssociation
domainAssociation} -> DomainAssociation
domainAssociation) (\s :: GetDomainAssociationResponse
s@GetDomainAssociationResponse' {} DomainAssociation
a -> GetDomainAssociationResponse
s {$sel:domainAssociation:GetDomainAssociationResponse' :: DomainAssociation
domainAssociation = DomainAssociation
a} :: GetDomainAssociationResponse)

instance Prelude.NFData GetDomainAssociationResponse