{-# 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.WorkSpaces.DisassociateConnectionAlias
-- 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 connection alias from a directory. Disassociating a
-- connection alias disables cross-Region redirection between two
-- directories in different Regions. For more information, see
-- <https://docs.aws.amazon.com/workspaces/latest/adminguide/cross-region-redirection.html Cross-Region Redirection for Amazon WorkSpaces>.
--
-- Before performing this operation, call
-- <https://docs.aws.amazon.com/workspaces/latest/api/API_DescribeConnectionAliases.html DescribeConnectionAliases>
-- to make sure that the current state of the connection alias is
-- @CREATED@.
module Amazonka.WorkSpaces.DisassociateConnectionAlias
  ( -- * Creating a Request
    DisassociateConnectionAlias (..),
    newDisassociateConnectionAlias,

    -- * Request Lenses
    disassociateConnectionAlias_aliasId,

    -- * Destructuring the Response
    DisassociateConnectionAliasResponse (..),
    newDisassociateConnectionAliasResponse,

    -- * Response Lenses
    disassociateConnectionAliasResponse_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.WorkSpaces.Types

-- | /See:/ 'newDisassociateConnectionAlias' smart constructor.
data DisassociateConnectionAlias = DisassociateConnectionAlias'
  { -- | The identifier of the connection alias to disassociate.
    DisassociateConnectionAlias -> Text
aliasId :: Prelude.Text
  }
  deriving (DisassociateConnectionAlias -> DisassociateConnectionAlias -> Bool
(DisassociateConnectionAlias
 -> DisassociateConnectionAlias -> Bool)
-> (DisassociateConnectionAlias
    -> DisassociateConnectionAlias -> Bool)
-> Eq DisassociateConnectionAlias
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateConnectionAlias -> DisassociateConnectionAlias -> Bool
$c/= :: DisassociateConnectionAlias -> DisassociateConnectionAlias -> Bool
== :: DisassociateConnectionAlias -> DisassociateConnectionAlias -> Bool
$c== :: DisassociateConnectionAlias -> DisassociateConnectionAlias -> Bool
Prelude.Eq, ReadPrec [DisassociateConnectionAlias]
ReadPrec DisassociateConnectionAlias
Int -> ReadS DisassociateConnectionAlias
ReadS [DisassociateConnectionAlias]
(Int -> ReadS DisassociateConnectionAlias)
-> ReadS [DisassociateConnectionAlias]
-> ReadPrec DisassociateConnectionAlias
-> ReadPrec [DisassociateConnectionAlias]
-> Read DisassociateConnectionAlias
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateConnectionAlias]
$creadListPrec :: ReadPrec [DisassociateConnectionAlias]
readPrec :: ReadPrec DisassociateConnectionAlias
$creadPrec :: ReadPrec DisassociateConnectionAlias
readList :: ReadS [DisassociateConnectionAlias]
$creadList :: ReadS [DisassociateConnectionAlias]
readsPrec :: Int -> ReadS DisassociateConnectionAlias
$creadsPrec :: Int -> ReadS DisassociateConnectionAlias
Prelude.Read, Int -> DisassociateConnectionAlias -> ShowS
[DisassociateConnectionAlias] -> ShowS
DisassociateConnectionAlias -> String
(Int -> DisassociateConnectionAlias -> ShowS)
-> (DisassociateConnectionAlias -> String)
-> ([DisassociateConnectionAlias] -> ShowS)
-> Show DisassociateConnectionAlias
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateConnectionAlias] -> ShowS
$cshowList :: [DisassociateConnectionAlias] -> ShowS
show :: DisassociateConnectionAlias -> String
$cshow :: DisassociateConnectionAlias -> String
showsPrec :: Int -> DisassociateConnectionAlias -> ShowS
$cshowsPrec :: Int -> DisassociateConnectionAlias -> ShowS
Prelude.Show, (forall x.
 DisassociateConnectionAlias -> Rep DisassociateConnectionAlias x)
-> (forall x.
    Rep DisassociateConnectionAlias x -> DisassociateConnectionAlias)
-> Generic DisassociateConnectionAlias
forall x.
Rep DisassociateConnectionAlias x -> DisassociateConnectionAlias
forall x.
DisassociateConnectionAlias -> Rep DisassociateConnectionAlias x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateConnectionAlias x -> DisassociateConnectionAlias
$cfrom :: forall x.
DisassociateConnectionAlias -> Rep DisassociateConnectionAlias x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateConnectionAlias' 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:
--
-- 'aliasId', 'disassociateConnectionAlias_aliasId' - The identifier of the connection alias to disassociate.
newDisassociateConnectionAlias ::
  -- | 'aliasId'
  Prelude.Text ->
  DisassociateConnectionAlias
newDisassociateConnectionAlias :: Text -> DisassociateConnectionAlias
newDisassociateConnectionAlias Text
pAliasId_ =
  DisassociateConnectionAlias' :: Text -> DisassociateConnectionAlias
DisassociateConnectionAlias' {$sel:aliasId:DisassociateConnectionAlias' :: Text
aliasId = Text
pAliasId_}

-- | The identifier of the connection alias to disassociate.
disassociateConnectionAlias_aliasId :: Lens.Lens' DisassociateConnectionAlias Prelude.Text
disassociateConnectionAlias_aliasId :: (Text -> f Text)
-> DisassociateConnectionAlias -> f DisassociateConnectionAlias
disassociateConnectionAlias_aliasId = (DisassociateConnectionAlias -> Text)
-> (DisassociateConnectionAlias
    -> Text -> DisassociateConnectionAlias)
-> Lens
     DisassociateConnectionAlias DisassociateConnectionAlias Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateConnectionAlias' {Text
aliasId :: Text
$sel:aliasId:DisassociateConnectionAlias' :: DisassociateConnectionAlias -> Text
aliasId} -> Text
aliasId) (\s :: DisassociateConnectionAlias
s@DisassociateConnectionAlias' {} Text
a -> DisassociateConnectionAlias
s {$sel:aliasId:DisassociateConnectionAlias' :: Text
aliasId = Text
a} :: DisassociateConnectionAlias)

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

instance Prelude.NFData DisassociateConnectionAlias

instance Core.ToHeaders DisassociateConnectionAlias where
  toHeaders :: DisassociateConnectionAlias -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisassociateConnectionAlias -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"WorkspacesService.DisassociateConnectionAlias" ::
                          Prelude.ByteString
                      ),
            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 DisassociateConnectionAlias where
  toJSON :: DisassociateConnectionAlias -> Value
toJSON DisassociateConnectionAlias' {Text
aliasId :: Text
$sel:aliasId:DisassociateConnectionAlias' :: DisassociateConnectionAlias -> 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
"AliasId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
aliasId)]
      )

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

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

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

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

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

instance
  Prelude.NFData
    DisassociateConnectionAliasResponse