{-# 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-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)
--
-- 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.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:/ 'newDeleteConnectionAlias' smart constructor.
data DeleteConnectionAlias = DeleteConnectionAlias'
  { -- | The identifier of the connection alias to delete.
    DeleteConnectionAlias -> Text
aliasId :: Prelude.Text
  }
  deriving (DeleteConnectionAlias -> DeleteConnectionAlias -> Bool
(DeleteConnectionAlias -> DeleteConnectionAlias -> Bool)
-> (DeleteConnectionAlias -> DeleteConnectionAlias -> Bool)
-> Eq DeleteConnectionAlias
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]
(Int -> ReadS DeleteConnectionAlias)
-> ReadS [DeleteConnectionAlias]
-> ReadPrec DeleteConnectionAlias
-> ReadPrec [DeleteConnectionAlias]
-> Read 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
(Int -> DeleteConnectionAlias -> ShowS)
-> (DeleteConnectionAlias -> String)
-> ([DeleteConnectionAlias] -> ShowS)
-> Show DeleteConnectionAlias
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. DeleteConnectionAlias -> Rep DeleteConnectionAlias x)
-> (forall x. Rep DeleteConnectionAlias x -> DeleteConnectionAlias)
-> Generic DeleteConnectionAlias
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' :: Text -> DeleteConnectionAlias
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 :: (Text -> f Text)
-> DeleteConnectionAlias -> f DeleteConnectionAlias
deleteConnectionAlias_aliasId = (DeleteConnectionAlias -> Text)
-> (DeleteConnectionAlias -> Text -> DeleteConnectionAlias)
-> Lens DeleteConnectionAlias DeleteConnectionAlias Text Text
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 :: DeleteConnectionAlias -> Request DeleteConnectionAlias
request = Service -> DeleteConnectionAlias -> Request DeleteConnectionAlias
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteConnectionAlias
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteConnectionAlias)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteConnectionAlias))
-> Logger
-> Service
-> Proxy DeleteConnectionAlias
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteConnectionAlias)))
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 -> DeleteConnectionAliasResponse
DeleteConnectionAliasResponse'
            (Int -> DeleteConnectionAliasResponse)
-> Either String Int -> Either String DeleteConnectionAliasResponse
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 DeleteConnectionAlias

instance Prelude.NFData DeleteConnectionAlias

instance Core.ToHeaders DeleteConnectionAlias where
  toHeaders :: DeleteConnectionAlias -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteConnectionAlias -> 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.DeleteConnectionAlias" ::
                          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 DeleteConnectionAlias where
  toJSON :: DeleteConnectionAlias -> Value
toJSON DeleteConnectionAlias' {Text
aliasId :: Text
$sel:aliasId:DeleteConnectionAlias' :: DeleteConnectionAlias -> 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 DeleteConnectionAlias where
  toPath :: DeleteConnectionAlias -> ByteString
toPath = ByteString -> DeleteConnectionAlias -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DeleteConnectionAlias where
  toQuery :: DeleteConnectionAlias -> QueryString
toQuery = QueryString -> DeleteConnectionAlias -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteConnectionAliasResponse
 -> DeleteConnectionAliasResponse -> Bool)
-> (DeleteConnectionAliasResponse
    -> DeleteConnectionAliasResponse -> Bool)
-> Eq DeleteConnectionAliasResponse
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]
(Int -> ReadS DeleteConnectionAliasResponse)
-> ReadS [DeleteConnectionAliasResponse]
-> ReadPrec DeleteConnectionAliasResponse
-> ReadPrec [DeleteConnectionAliasResponse]
-> Read 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
(Int -> DeleteConnectionAliasResponse -> ShowS)
-> (DeleteConnectionAliasResponse -> String)
-> ([DeleteConnectionAliasResponse] -> ShowS)
-> Show DeleteConnectionAliasResponse
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.
 DeleteConnectionAliasResponse
 -> Rep DeleteConnectionAliasResponse x)
-> (forall x.
    Rep DeleteConnectionAliasResponse x
    -> DeleteConnectionAliasResponse)
-> Generic DeleteConnectionAliasResponse
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' :: Int -> DeleteConnectionAliasResponse
DeleteConnectionAliasResponse'
    { $sel:httpStatus:DeleteConnectionAliasResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteConnectionAliasResponse_httpStatus :: Lens.Lens' DeleteConnectionAliasResponse Prelude.Int
deleteConnectionAliasResponse_httpStatus :: (Int -> f Int)
-> DeleteConnectionAliasResponse -> f DeleteConnectionAliasResponse
deleteConnectionAliasResponse_httpStatus = (DeleteConnectionAliasResponse -> Int)
-> (DeleteConnectionAliasResponse
    -> Int -> DeleteConnectionAliasResponse)
-> Lens
     DeleteConnectionAliasResponse DeleteConnectionAliasResponse Int Int
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