{-# 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.DisassociateDomain
-- 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)
--
-- Disassociates a domain from Amazon WorkLink. End users lose the ability
-- to access the domain with Amazon WorkLink.
module Amazonka.WorkLink.DisassociateDomain
  ( -- * Creating a Request
    DisassociateDomain (..),
    newDisassociateDomain,

    -- * Request Lenses
    disassociateDomain_fleetArn,
    disassociateDomain_domainName,

    -- * Destructuring the Response
    DisassociateDomainResponse (..),
    newDisassociateDomainResponse,

    -- * Response Lenses
    disassociateDomainResponse_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:/ 'newDisassociateDomain' smart constructor.
data DisassociateDomain = DisassociateDomain'
  { -- | The ARN of the fleet.
    DisassociateDomain -> Text
fleetArn :: Prelude.Text,
    -- | The name of the domain.
    DisassociateDomain -> Text
domainName :: Prelude.Text
  }
  deriving (DisassociateDomain -> DisassociateDomain -> Bool
(DisassociateDomain -> DisassociateDomain -> Bool)
-> (DisassociateDomain -> DisassociateDomain -> Bool)
-> Eq DisassociateDomain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateDomain -> DisassociateDomain -> Bool
$c/= :: DisassociateDomain -> DisassociateDomain -> Bool
== :: DisassociateDomain -> DisassociateDomain -> Bool
$c== :: DisassociateDomain -> DisassociateDomain -> Bool
Prelude.Eq, ReadPrec [DisassociateDomain]
ReadPrec DisassociateDomain
Int -> ReadS DisassociateDomain
ReadS [DisassociateDomain]
(Int -> ReadS DisassociateDomain)
-> ReadS [DisassociateDomain]
-> ReadPrec DisassociateDomain
-> ReadPrec [DisassociateDomain]
-> Read DisassociateDomain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateDomain]
$creadListPrec :: ReadPrec [DisassociateDomain]
readPrec :: ReadPrec DisassociateDomain
$creadPrec :: ReadPrec DisassociateDomain
readList :: ReadS [DisassociateDomain]
$creadList :: ReadS [DisassociateDomain]
readsPrec :: Int -> ReadS DisassociateDomain
$creadsPrec :: Int -> ReadS DisassociateDomain
Prelude.Read, Int -> DisassociateDomain -> ShowS
[DisassociateDomain] -> ShowS
DisassociateDomain -> String
(Int -> DisassociateDomain -> ShowS)
-> (DisassociateDomain -> String)
-> ([DisassociateDomain] -> ShowS)
-> Show DisassociateDomain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateDomain] -> ShowS
$cshowList :: [DisassociateDomain] -> ShowS
show :: DisassociateDomain -> String
$cshow :: DisassociateDomain -> String
showsPrec :: Int -> DisassociateDomain -> ShowS
$cshowsPrec :: Int -> DisassociateDomain -> ShowS
Prelude.Show, (forall x. DisassociateDomain -> Rep DisassociateDomain x)
-> (forall x. Rep DisassociateDomain x -> DisassociateDomain)
-> Generic DisassociateDomain
forall x. Rep DisassociateDomain x -> DisassociateDomain
forall x. DisassociateDomain -> Rep DisassociateDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateDomain x -> DisassociateDomain
$cfrom :: forall x. DisassociateDomain -> Rep DisassociateDomain x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateDomain' 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:
--
-- 'fleetArn', 'disassociateDomain_fleetArn' - The ARN of the fleet.
--
-- 'domainName', 'disassociateDomain_domainName' - The name of the domain.
newDisassociateDomain ::
  -- | 'fleetArn'
  Prelude.Text ->
  -- | 'domainName'
  Prelude.Text ->
  DisassociateDomain
newDisassociateDomain :: Text -> Text -> DisassociateDomain
newDisassociateDomain Text
pFleetArn_ Text
pDomainName_ =
  DisassociateDomain' :: Text -> Text -> DisassociateDomain
DisassociateDomain'
    { $sel:fleetArn:DisassociateDomain' :: Text
fleetArn = Text
pFleetArn_,
      $sel:domainName:DisassociateDomain' :: Text
domainName = Text
pDomainName_
    }

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

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

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

instance Prelude.NFData DisassociateDomain

instance Core.ToHeaders DisassociateDomain where
  toHeaders :: DisassociateDomain -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisassociateDomain -> 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 DisassociateDomain where
  toJSON :: DisassociateDomain -> Value
toJSON DisassociateDomain' {Text
domainName :: Text
fleetArn :: Text
$sel:domainName:DisassociateDomain' :: DisassociateDomain -> Text
$sel:fleetArn:DisassociateDomain' :: DisassociateDomain -> 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
"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)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DisassociateDomainResponse