{-# 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.CreateDomainAssociation
-- 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)
--
-- Creates a new domain association for an Amplify app. This action
-- associates a custom domain with the Amplify app
module Amazonka.Amplify.CreateDomainAssociation
  ( -- * Creating a Request
    CreateDomainAssociation (..),
    newCreateDomainAssociation,

    -- * Request Lenses
    createDomainAssociation_enableAutoSubDomain,
    createDomainAssociation_autoSubDomainCreationPatterns,
    createDomainAssociation_autoSubDomainIAMRole,
    createDomainAssociation_appId,
    createDomainAssociation_domainName,
    createDomainAssociation_subDomainSettings,

    -- * Destructuring the Response
    CreateDomainAssociationResponse (..),
    newCreateDomainAssociationResponse,

    -- * Response Lenses
    createDomainAssociationResponse_httpStatus,
    createDomainAssociationResponse_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 create domain association request.
--
-- /See:/ 'newCreateDomainAssociation' smart constructor.
data CreateDomainAssociation = CreateDomainAssociation'
  { -- | Enables the automated creation of subdomains for branches.
    CreateDomainAssociation -> Maybe Bool
enableAutoSubDomain :: Prelude.Maybe Prelude.Bool,
    -- | Sets the branch patterns for automatic subdomain creation.
    CreateDomainAssociation -> Maybe [Text]
autoSubDomainCreationPatterns :: Prelude.Maybe [Prelude.Text],
    -- | The required AWS Identity and Access Management (IAM) service role for
    -- the Amazon Resource Name (ARN) for automatically creating subdomains.
    CreateDomainAssociation -> Maybe Text
autoSubDomainIAMRole :: Prelude.Maybe Prelude.Text,
    -- | The unique ID for an Amplify app.
    CreateDomainAssociation -> Text
appId :: Prelude.Text,
    -- | The domain name for the domain association.
    CreateDomainAssociation -> Text
domainName :: Prelude.Text,
    -- | The setting for the subdomain.
    CreateDomainAssociation -> [SubDomainSetting]
subDomainSettings :: [SubDomainSetting]
  }
  deriving (CreateDomainAssociation -> CreateDomainAssociation -> Bool
(CreateDomainAssociation -> CreateDomainAssociation -> Bool)
-> (CreateDomainAssociation -> CreateDomainAssociation -> Bool)
-> Eq CreateDomainAssociation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDomainAssociation -> CreateDomainAssociation -> Bool
$c/= :: CreateDomainAssociation -> CreateDomainAssociation -> Bool
== :: CreateDomainAssociation -> CreateDomainAssociation -> Bool
$c== :: CreateDomainAssociation -> CreateDomainAssociation -> Bool
Prelude.Eq, ReadPrec [CreateDomainAssociation]
ReadPrec CreateDomainAssociation
Int -> ReadS CreateDomainAssociation
ReadS [CreateDomainAssociation]
(Int -> ReadS CreateDomainAssociation)
-> ReadS [CreateDomainAssociation]
-> ReadPrec CreateDomainAssociation
-> ReadPrec [CreateDomainAssociation]
-> Read CreateDomainAssociation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDomainAssociation]
$creadListPrec :: ReadPrec [CreateDomainAssociation]
readPrec :: ReadPrec CreateDomainAssociation
$creadPrec :: ReadPrec CreateDomainAssociation
readList :: ReadS [CreateDomainAssociation]
$creadList :: ReadS [CreateDomainAssociation]
readsPrec :: Int -> ReadS CreateDomainAssociation
$creadsPrec :: Int -> ReadS CreateDomainAssociation
Prelude.Read, Int -> CreateDomainAssociation -> ShowS
[CreateDomainAssociation] -> ShowS
CreateDomainAssociation -> String
(Int -> CreateDomainAssociation -> ShowS)
-> (CreateDomainAssociation -> String)
-> ([CreateDomainAssociation] -> ShowS)
-> Show CreateDomainAssociation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDomainAssociation] -> ShowS
$cshowList :: [CreateDomainAssociation] -> ShowS
show :: CreateDomainAssociation -> String
$cshow :: CreateDomainAssociation -> String
showsPrec :: Int -> CreateDomainAssociation -> ShowS
$cshowsPrec :: Int -> CreateDomainAssociation -> ShowS
Prelude.Show, (forall x.
 CreateDomainAssociation -> Rep CreateDomainAssociation x)
-> (forall x.
    Rep CreateDomainAssociation x -> CreateDomainAssociation)
-> Generic CreateDomainAssociation
forall x. Rep CreateDomainAssociation x -> CreateDomainAssociation
forall x. CreateDomainAssociation -> Rep CreateDomainAssociation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDomainAssociation x -> CreateDomainAssociation
$cfrom :: forall x. CreateDomainAssociation -> Rep CreateDomainAssociation x
Prelude.Generic)

-- |
-- Create a value of 'CreateDomainAssociation' 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:
--
-- 'enableAutoSubDomain', 'createDomainAssociation_enableAutoSubDomain' - Enables the automated creation of subdomains for branches.
--
-- 'autoSubDomainCreationPatterns', 'createDomainAssociation_autoSubDomainCreationPatterns' - Sets the branch patterns for automatic subdomain creation.
--
-- 'autoSubDomainIAMRole', 'createDomainAssociation_autoSubDomainIAMRole' - The required AWS Identity and Access Management (IAM) service role for
-- the Amazon Resource Name (ARN) for automatically creating subdomains.
--
-- 'appId', 'createDomainAssociation_appId' - The unique ID for an Amplify app.
--
-- 'domainName', 'createDomainAssociation_domainName' - The domain name for the domain association.
--
-- 'subDomainSettings', 'createDomainAssociation_subDomainSettings' - The setting for the subdomain.
newCreateDomainAssociation ::
  -- | 'appId'
  Prelude.Text ->
  -- | 'domainName'
  Prelude.Text ->
  CreateDomainAssociation
newCreateDomainAssociation :: Text -> Text -> CreateDomainAssociation
newCreateDomainAssociation Text
pAppId_ Text
pDomainName_ =
  CreateDomainAssociation' :: Maybe Bool
-> Maybe [Text]
-> Maybe Text
-> Text
-> Text
-> [SubDomainSetting]
-> CreateDomainAssociation
CreateDomainAssociation'
    { $sel:enableAutoSubDomain:CreateDomainAssociation' :: Maybe Bool
enableAutoSubDomain =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:autoSubDomainCreationPatterns:CreateDomainAssociation' :: Maybe [Text]
autoSubDomainCreationPatterns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:autoSubDomainIAMRole:CreateDomainAssociation' :: Maybe Text
autoSubDomainIAMRole = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:appId:CreateDomainAssociation' :: Text
appId = Text
pAppId_,
      $sel:domainName:CreateDomainAssociation' :: Text
domainName = Text
pDomainName_,
      $sel:subDomainSettings:CreateDomainAssociation' :: [SubDomainSetting]
subDomainSettings = [SubDomainSetting]
forall a. Monoid a => a
Prelude.mempty
    }

-- | Enables the automated creation of subdomains for branches.
createDomainAssociation_enableAutoSubDomain :: Lens.Lens' CreateDomainAssociation (Prelude.Maybe Prelude.Bool)
createDomainAssociation_enableAutoSubDomain :: (Maybe Bool -> f (Maybe Bool))
-> CreateDomainAssociation -> f CreateDomainAssociation
createDomainAssociation_enableAutoSubDomain = (CreateDomainAssociation -> Maybe Bool)
-> (CreateDomainAssociation
    -> Maybe Bool -> CreateDomainAssociation)
-> Lens
     CreateDomainAssociation
     CreateDomainAssociation
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDomainAssociation' {Maybe Bool
enableAutoSubDomain :: Maybe Bool
$sel:enableAutoSubDomain:CreateDomainAssociation' :: CreateDomainAssociation -> Maybe Bool
enableAutoSubDomain} -> Maybe Bool
enableAutoSubDomain) (\s :: CreateDomainAssociation
s@CreateDomainAssociation' {} Maybe Bool
a -> CreateDomainAssociation
s {$sel:enableAutoSubDomain:CreateDomainAssociation' :: Maybe Bool
enableAutoSubDomain = Maybe Bool
a} :: CreateDomainAssociation)

-- | Sets the branch patterns for automatic subdomain creation.
createDomainAssociation_autoSubDomainCreationPatterns :: Lens.Lens' CreateDomainAssociation (Prelude.Maybe [Prelude.Text])
createDomainAssociation_autoSubDomainCreationPatterns :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateDomainAssociation -> f CreateDomainAssociation
createDomainAssociation_autoSubDomainCreationPatterns = (CreateDomainAssociation -> Maybe [Text])
-> (CreateDomainAssociation
    -> Maybe [Text] -> CreateDomainAssociation)
-> Lens
     CreateDomainAssociation
     CreateDomainAssociation
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDomainAssociation' {Maybe [Text]
autoSubDomainCreationPatterns :: Maybe [Text]
$sel:autoSubDomainCreationPatterns:CreateDomainAssociation' :: CreateDomainAssociation -> Maybe [Text]
autoSubDomainCreationPatterns} -> Maybe [Text]
autoSubDomainCreationPatterns) (\s :: CreateDomainAssociation
s@CreateDomainAssociation' {} Maybe [Text]
a -> CreateDomainAssociation
s {$sel:autoSubDomainCreationPatterns:CreateDomainAssociation' :: Maybe [Text]
autoSubDomainCreationPatterns = Maybe [Text]
a} :: CreateDomainAssociation) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateDomainAssociation -> f CreateDomainAssociation)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateDomainAssociation
-> f CreateDomainAssociation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The required AWS Identity and Access Management (IAM) service role for
-- the Amazon Resource Name (ARN) for automatically creating subdomains.
createDomainAssociation_autoSubDomainIAMRole :: Lens.Lens' CreateDomainAssociation (Prelude.Maybe Prelude.Text)
createDomainAssociation_autoSubDomainIAMRole :: (Maybe Text -> f (Maybe Text))
-> CreateDomainAssociation -> f CreateDomainAssociation
createDomainAssociation_autoSubDomainIAMRole = (CreateDomainAssociation -> Maybe Text)
-> (CreateDomainAssociation
    -> Maybe Text -> CreateDomainAssociation)
-> Lens
     CreateDomainAssociation
     CreateDomainAssociation
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDomainAssociation' {Maybe Text
autoSubDomainIAMRole :: Maybe Text
$sel:autoSubDomainIAMRole:CreateDomainAssociation' :: CreateDomainAssociation -> Maybe Text
autoSubDomainIAMRole} -> Maybe Text
autoSubDomainIAMRole) (\s :: CreateDomainAssociation
s@CreateDomainAssociation' {} Maybe Text
a -> CreateDomainAssociation
s {$sel:autoSubDomainIAMRole:CreateDomainAssociation' :: Maybe Text
autoSubDomainIAMRole = Maybe Text
a} :: CreateDomainAssociation)

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

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

-- | The setting for the subdomain.
createDomainAssociation_subDomainSettings :: Lens.Lens' CreateDomainAssociation [SubDomainSetting]
createDomainAssociation_subDomainSettings :: ([SubDomainSetting] -> f [SubDomainSetting])
-> CreateDomainAssociation -> f CreateDomainAssociation
createDomainAssociation_subDomainSettings = (CreateDomainAssociation -> [SubDomainSetting])
-> (CreateDomainAssociation
    -> [SubDomainSetting] -> CreateDomainAssociation)
-> Lens
     CreateDomainAssociation
     CreateDomainAssociation
     [SubDomainSetting]
     [SubDomainSetting]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDomainAssociation' {[SubDomainSetting]
subDomainSettings :: [SubDomainSetting]
$sel:subDomainSettings:CreateDomainAssociation' :: CreateDomainAssociation -> [SubDomainSetting]
subDomainSettings} -> [SubDomainSetting]
subDomainSettings) (\s :: CreateDomainAssociation
s@CreateDomainAssociation' {} [SubDomainSetting]
a -> CreateDomainAssociation
s {$sel:subDomainSettings:CreateDomainAssociation' :: [SubDomainSetting]
subDomainSettings = [SubDomainSetting]
a} :: CreateDomainAssociation) (([SubDomainSetting] -> f [SubDomainSetting])
 -> CreateDomainAssociation -> f CreateDomainAssociation)
-> (([SubDomainSetting] -> f [SubDomainSetting])
    -> [SubDomainSetting] -> f [SubDomainSetting])
-> ([SubDomainSetting] -> f [SubDomainSetting])
-> CreateDomainAssociation
-> f CreateDomainAssociation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([SubDomainSetting] -> f [SubDomainSetting])
-> [SubDomainSetting] -> f [SubDomainSetting]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData CreateDomainAssociation

instance Core.ToHeaders CreateDomainAssociation where
  toHeaders :: CreateDomainAssociation -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateDomainAssociation -> 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.ToJSON CreateDomainAssociation where
  toJSON :: CreateDomainAssociation -> Value
toJSON CreateDomainAssociation' {[SubDomainSetting]
Maybe Bool
Maybe [Text]
Maybe Text
Text
subDomainSettings :: [SubDomainSetting]
domainName :: Text
appId :: Text
autoSubDomainIAMRole :: Maybe Text
autoSubDomainCreationPatterns :: Maybe [Text]
enableAutoSubDomain :: Maybe Bool
$sel:subDomainSettings:CreateDomainAssociation' :: CreateDomainAssociation -> [SubDomainSetting]
$sel:domainName:CreateDomainAssociation' :: CreateDomainAssociation -> Text
$sel:appId:CreateDomainAssociation' :: CreateDomainAssociation -> Text
$sel:autoSubDomainIAMRole:CreateDomainAssociation' :: CreateDomainAssociation -> Maybe Text
$sel:autoSubDomainCreationPatterns:CreateDomainAssociation' :: CreateDomainAssociation -> Maybe [Text]
$sel:enableAutoSubDomain:CreateDomainAssociation' :: CreateDomainAssociation -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"enableAutoSubDomain" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enableAutoSubDomain,
            (Text
"autoSubDomainCreationPatterns" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
autoSubDomainCreationPatterns,
            (Text
"autoSubDomainIAMRole" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
autoSubDomainIAMRole,
            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
"subDomainSettings" Text -> [SubDomainSetting] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [SubDomainSetting]
subDomainSettings)
          ]
      )

instance Core.ToPath CreateDomainAssociation where
  toPath :: CreateDomainAssociation -> ByteString
toPath CreateDomainAssociation' {[SubDomainSetting]
Maybe Bool
Maybe [Text]
Maybe Text
Text
subDomainSettings :: [SubDomainSetting]
domainName :: Text
appId :: Text
autoSubDomainIAMRole :: Maybe Text
autoSubDomainCreationPatterns :: Maybe [Text]
enableAutoSubDomain :: Maybe Bool
$sel:subDomainSettings:CreateDomainAssociation' :: CreateDomainAssociation -> [SubDomainSetting]
$sel:domainName:CreateDomainAssociation' :: CreateDomainAssociation -> Text
$sel:appId:CreateDomainAssociation' :: CreateDomainAssociation -> Text
$sel:autoSubDomainIAMRole:CreateDomainAssociation' :: CreateDomainAssociation -> Maybe Text
$sel:autoSubDomainCreationPatterns:CreateDomainAssociation' :: CreateDomainAssociation -> Maybe [Text]
$sel:enableAutoSubDomain:CreateDomainAssociation' :: CreateDomainAssociation -> Maybe Bool
..} =
    [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"]

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

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

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

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

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

instance
  Prelude.NFData
    CreateDomainAssociationResponse