{-# 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.DeleteConnectionAlias
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified connection alias. For more information, see
-- <https://docs.aws.amazon.com/workspaces/latest/adminguide/cross-region-redirection.html Cross-Region Redirection for Amazon WorkSpaces>.
--
-- __If you will no longer be using a fully qualified domain name (FQDN) as
-- the registration code for your WorkSpaces users, you must take certain
-- precautions to prevent potential security issues.__ For more
-- information, see
-- <https://docs.aws.amazon.com/workspaces/latest/adminguide/cross-region-redirection.html#cross-region-redirection-security-considerations Security Considerations if You Stop Using Cross-Region Redirection>.
--
-- To delete a connection alias that has been shared, the shared account
-- must first disassociate the connection alias from any directories it has
-- been associated with. Then you must unshare the connection alias from
-- the account it has been shared with. You can delete a connection alias
-- only after it is no longer shared with any accounts or associated with
-- any directories.
module Amazonka.WorkSpaces.DeleteConnectionAlias
  ( -- * Creating a Request
    DeleteConnectionAlias (..),
    newDeleteConnectionAlias,

    -- * Request Lenses
    deleteConnectionAlias_aliasId,

    -- * Destructuring the Response
    DeleteConnectionAliasResponse (..),
    newDeleteConnectionAliasResponse,

    -- * Response Lenses
    deleteConnectionAliasResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WorkSpaces.Types

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

-- |
-- Create a value of 'DeleteConnectionAlias' 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', 'deleteConnectionAlias_aliasId' - The identifier of the connection alias to delete.
newDeleteConnectionAlias ::
  -- | 'aliasId'
  Prelude.Text ->
  DeleteConnectionAlias
newDeleteConnectionAlias :: Text -> DeleteConnectionAlias
newDeleteConnectionAlias Text
pAliasId_ =
  DeleteConnectionAlias' {$sel:aliasId:DeleteConnectionAlias' :: Text
aliasId = Text
pAliasId_}

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

instance Core.AWSRequest DeleteConnectionAlias where
  type
    AWSResponse DeleteConnectionAlias =
      DeleteConnectionAliasResponse
  request :: (Service -> Service)
-> DeleteConnectionAlias -> Request DeleteConnectionAlias
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteConnectionAlias
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteConnectionAlias)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteConnectionAliasResponse
DeleteConnectionAliasResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteConnectionAlias where
  hashWithSalt :: Int -> DeleteConnectionAlias -> Int
hashWithSalt Int
_salt DeleteConnectionAlias' {Text
aliasId :: Text
$sel:aliasId:DeleteConnectionAlias' :: DeleteConnectionAlias -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
aliasId

instance Prelude.NFData DeleteConnectionAlias where
  rnf :: DeleteConnectionAlias -> ()
rnf DeleteConnectionAlias' {Text
aliasId :: Text
$sel:aliasId:DeleteConnectionAlias' :: DeleteConnectionAlias -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
aliasId

instance Data.ToHeaders DeleteConnectionAlias where
  toHeaders :: DeleteConnectionAlias -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"WorkspacesService.DeleteConnectionAlias" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteConnectionAlias where
  toJSON :: DeleteConnectionAlias -> Value
toJSON DeleteConnectionAlias' {Text
aliasId :: Text
$sel:aliasId:DeleteConnectionAlias' :: DeleteConnectionAlias -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"AliasId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
aliasId)]
      )

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

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

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

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

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

instance Prelude.NFData DeleteConnectionAliasResponse where
  rnf :: DeleteConnectionAliasResponse -> ()
rnf DeleteConnectionAliasResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteConnectionAliasResponse' :: DeleteConnectionAliasResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus