{-# 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.WorkLink.AssociateDomain
-- 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)
--
-- Specifies a domain to be associated to Amazon WorkLink.
module Amazonka.WorkLink.AssociateDomain
  ( -- * Creating a Request
    AssociateDomain (..),
    newAssociateDomain,

    -- * Request Lenses
    associateDomain_displayName,
    associateDomain_fleetArn,
    associateDomain_domainName,
    associateDomain_acmCertificateArn,

    -- * Destructuring the Response
    AssociateDomainResponse (..),
    newAssociateDomainResponse,

    -- * Response Lenses
    associateDomainResponse_httpStatus,
  )
where

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

-- | /See:/ 'newAssociateDomain' smart constructor.
data AssociateDomain = AssociateDomain'
  { -- | The name to display.
    AssociateDomain -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the fleet.
    AssociateDomain -> Text
fleetArn :: Prelude.Text,
    -- | The fully qualified domain name (FQDN).
    AssociateDomain -> Text
domainName :: Prelude.Text,
    -- | The ARN of an issued ACM certificate that is valid for the domain being
    -- associated.
    AssociateDomain -> Text
acmCertificateArn :: Prelude.Text
  }
  deriving (AssociateDomain -> AssociateDomain -> Bool
(AssociateDomain -> AssociateDomain -> Bool)
-> (AssociateDomain -> AssociateDomain -> Bool)
-> Eq AssociateDomain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateDomain -> AssociateDomain -> Bool
$c/= :: AssociateDomain -> AssociateDomain -> Bool
== :: AssociateDomain -> AssociateDomain -> Bool
$c== :: AssociateDomain -> AssociateDomain -> Bool
Prelude.Eq, ReadPrec [AssociateDomain]
ReadPrec AssociateDomain
Int -> ReadS AssociateDomain
ReadS [AssociateDomain]
(Int -> ReadS AssociateDomain)
-> ReadS [AssociateDomain]
-> ReadPrec AssociateDomain
-> ReadPrec [AssociateDomain]
-> Read AssociateDomain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateDomain]
$creadListPrec :: ReadPrec [AssociateDomain]
readPrec :: ReadPrec AssociateDomain
$creadPrec :: ReadPrec AssociateDomain
readList :: ReadS [AssociateDomain]
$creadList :: ReadS [AssociateDomain]
readsPrec :: Int -> ReadS AssociateDomain
$creadsPrec :: Int -> ReadS AssociateDomain
Prelude.Read, Int -> AssociateDomain -> ShowS
[AssociateDomain] -> ShowS
AssociateDomain -> String
(Int -> AssociateDomain -> ShowS)
-> (AssociateDomain -> String)
-> ([AssociateDomain] -> ShowS)
-> Show AssociateDomain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateDomain] -> ShowS
$cshowList :: [AssociateDomain] -> ShowS
show :: AssociateDomain -> String
$cshow :: AssociateDomain -> String
showsPrec :: Int -> AssociateDomain -> ShowS
$cshowsPrec :: Int -> AssociateDomain -> ShowS
Prelude.Show, (forall x. AssociateDomain -> Rep AssociateDomain x)
-> (forall x. Rep AssociateDomain x -> AssociateDomain)
-> Generic AssociateDomain
forall x. Rep AssociateDomain x -> AssociateDomain
forall x. AssociateDomain -> Rep AssociateDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateDomain x -> AssociateDomain
$cfrom :: forall x. AssociateDomain -> Rep AssociateDomain x
Prelude.Generic)

-- |
-- Create a value of 'AssociateDomain' 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:
--
-- 'displayName', 'associateDomain_displayName' - The name to display.
--
-- 'fleetArn', 'associateDomain_fleetArn' - The Amazon Resource Name (ARN) of the fleet.
--
-- 'domainName', 'associateDomain_domainName' - The fully qualified domain name (FQDN).
--
-- 'acmCertificateArn', 'associateDomain_acmCertificateArn' - The ARN of an issued ACM certificate that is valid for the domain being
-- associated.
newAssociateDomain ::
  -- | 'fleetArn'
  Prelude.Text ->
  -- | 'domainName'
  Prelude.Text ->
  -- | 'acmCertificateArn'
  Prelude.Text ->
  AssociateDomain
newAssociateDomain :: Text -> Text -> Text -> AssociateDomain
newAssociateDomain
  Text
pFleetArn_
  Text
pDomainName_
  Text
pAcmCertificateArn_ =
    AssociateDomain' :: Maybe Text -> Text -> Text -> Text -> AssociateDomain
AssociateDomain'
      { $sel:displayName:AssociateDomain' :: Maybe Text
displayName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:fleetArn:AssociateDomain' :: Text
fleetArn = Text
pFleetArn_,
        $sel:domainName:AssociateDomain' :: Text
domainName = Text
pDomainName_,
        $sel:acmCertificateArn:AssociateDomain' :: Text
acmCertificateArn = Text
pAcmCertificateArn_
      }

-- | The name to display.
associateDomain_displayName :: Lens.Lens' AssociateDomain (Prelude.Maybe Prelude.Text)
associateDomain_displayName :: (Maybe Text -> f (Maybe Text))
-> AssociateDomain -> f AssociateDomain
associateDomain_displayName = (AssociateDomain -> Maybe Text)
-> (AssociateDomain -> Maybe Text -> AssociateDomain)
-> Lens AssociateDomain AssociateDomain (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateDomain' {Maybe Text
displayName :: Maybe Text
$sel:displayName:AssociateDomain' :: AssociateDomain -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: AssociateDomain
s@AssociateDomain' {} Maybe Text
a -> AssociateDomain
s {$sel:displayName:AssociateDomain' :: Maybe Text
displayName = Maybe Text
a} :: AssociateDomain)

-- | The Amazon Resource Name (ARN) of the fleet.
associateDomain_fleetArn :: Lens.Lens' AssociateDomain Prelude.Text
associateDomain_fleetArn :: (Text -> f Text) -> AssociateDomain -> f AssociateDomain
associateDomain_fleetArn = (AssociateDomain -> Text)
-> (AssociateDomain -> Text -> AssociateDomain)
-> Lens AssociateDomain AssociateDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateDomain' {Text
fleetArn :: Text
$sel:fleetArn:AssociateDomain' :: AssociateDomain -> Text
fleetArn} -> Text
fleetArn) (\s :: AssociateDomain
s@AssociateDomain' {} Text
a -> AssociateDomain
s {$sel:fleetArn:AssociateDomain' :: Text
fleetArn = Text
a} :: AssociateDomain)

-- | The fully qualified domain name (FQDN).
associateDomain_domainName :: Lens.Lens' AssociateDomain Prelude.Text
associateDomain_domainName :: (Text -> f Text) -> AssociateDomain -> f AssociateDomain
associateDomain_domainName = (AssociateDomain -> Text)
-> (AssociateDomain -> Text -> AssociateDomain)
-> Lens AssociateDomain AssociateDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateDomain' {Text
domainName :: Text
$sel:domainName:AssociateDomain' :: AssociateDomain -> Text
domainName} -> Text
domainName) (\s :: AssociateDomain
s@AssociateDomain' {} Text
a -> AssociateDomain
s {$sel:domainName:AssociateDomain' :: Text
domainName = Text
a} :: AssociateDomain)

-- | The ARN of an issued ACM certificate that is valid for the domain being
-- associated.
associateDomain_acmCertificateArn :: Lens.Lens' AssociateDomain Prelude.Text
associateDomain_acmCertificateArn :: (Text -> f Text) -> AssociateDomain -> f AssociateDomain
associateDomain_acmCertificateArn = (AssociateDomain -> Text)
-> (AssociateDomain -> Text -> AssociateDomain)
-> Lens AssociateDomain AssociateDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateDomain' {Text
acmCertificateArn :: Text
$sel:acmCertificateArn:AssociateDomain' :: AssociateDomain -> Text
acmCertificateArn} -> Text
acmCertificateArn) (\s :: AssociateDomain
s@AssociateDomain' {} Text
a -> AssociateDomain
s {$sel:acmCertificateArn:AssociateDomain' :: Text
acmCertificateArn = Text
a} :: AssociateDomain)

instance Core.AWSRequest AssociateDomain where
  type
    AWSResponse AssociateDomain =
      AssociateDomainResponse
  request :: AssociateDomain -> Request AssociateDomain
request = Service -> AssociateDomain -> Request AssociateDomain
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateDomain
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AssociateDomain)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AssociateDomain))
-> Logger
-> Service
-> Proxy AssociateDomain
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AssociateDomain)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AssociateDomainResponse
AssociateDomainResponse'
            (Int -> AssociateDomainResponse)
-> Either String Int -> Either String AssociateDomainResponse
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))
      )

instance Prelude.Hashable AssociateDomain

instance Prelude.NFData AssociateDomain

instance Core.ToHeaders AssociateDomain where
  toHeaders :: AssociateDomain -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AssociateDomain -> 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 AssociateDomain where
  toJSON :: AssociateDomain -> Value
toJSON AssociateDomain' {Maybe Text
Text
acmCertificateArn :: Text
domainName :: Text
fleetArn :: Text
displayName :: Maybe Text
$sel:acmCertificateArn:AssociateDomain' :: AssociateDomain -> Text
$sel:domainName:AssociateDomain' :: AssociateDomain -> Text
$sel:fleetArn:AssociateDomain' :: AssociateDomain -> Text
$sel:displayName:AssociateDomain' :: AssociateDomain -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DisplayName" 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
displayName,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FleetArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fleetArn),
            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
"AcmCertificateArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
acmCertificateArn)
          ]
      )

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

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

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

-- |
-- Create a value of 'AssociateDomainResponse' 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', 'associateDomainResponse_httpStatus' - The response's http status code.
newAssociateDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AssociateDomainResponse
newAssociateDomainResponse :: Int -> AssociateDomainResponse
newAssociateDomainResponse Int
pHttpStatus_ =
  AssociateDomainResponse' :: Int -> AssociateDomainResponse
AssociateDomainResponse' {$sel:httpStatus:AssociateDomainResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData AssociateDomainResponse