{-# 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.UpdateConnectionAliasPermission
-- 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)
--
-- Shares or unshares a connection alias with one account by specifying
-- whether that account has permission to associate the connection alias
-- with a directory. If the association permission is granted, the
-- connection alias is shared with that account. If the association
-- permission is revoked, the connection alias is unshared with the
-- account. 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@.
--
-- -   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.UpdateConnectionAliasPermission
  ( -- * Creating a Request
    UpdateConnectionAliasPermission (..),
    newUpdateConnectionAliasPermission,

    -- * Request Lenses
    updateConnectionAliasPermission_aliasId,
    updateConnectionAliasPermission_connectionAliasPermission,

    -- * Destructuring the Response
    UpdateConnectionAliasPermissionResponse (..),
    newUpdateConnectionAliasPermissionResponse,

    -- * Response Lenses
    updateConnectionAliasPermissionResponse_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:/ 'newUpdateConnectionAliasPermission' smart constructor.
data UpdateConnectionAliasPermission = UpdateConnectionAliasPermission'
  { -- | The identifier of the connection alias that you want to update
    -- permissions for.
    UpdateConnectionAliasPermission -> Text
aliasId :: Prelude.Text,
    -- | Indicates whether to share or unshare the connection alias with the
    -- specified Amazon Web Services account.
    UpdateConnectionAliasPermission -> ConnectionAliasPermission
connectionAliasPermission :: ConnectionAliasPermission
  }
  deriving (UpdateConnectionAliasPermission
-> UpdateConnectionAliasPermission -> Bool
(UpdateConnectionAliasPermission
 -> UpdateConnectionAliasPermission -> Bool)
-> (UpdateConnectionAliasPermission
    -> UpdateConnectionAliasPermission -> Bool)
-> Eq UpdateConnectionAliasPermission
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateConnectionAliasPermission
-> UpdateConnectionAliasPermission -> Bool
$c/= :: UpdateConnectionAliasPermission
-> UpdateConnectionAliasPermission -> Bool
== :: UpdateConnectionAliasPermission
-> UpdateConnectionAliasPermission -> Bool
$c== :: UpdateConnectionAliasPermission
-> UpdateConnectionAliasPermission -> Bool
Prelude.Eq, ReadPrec [UpdateConnectionAliasPermission]
ReadPrec UpdateConnectionAliasPermission
Int -> ReadS UpdateConnectionAliasPermission
ReadS [UpdateConnectionAliasPermission]
(Int -> ReadS UpdateConnectionAliasPermission)
-> ReadS [UpdateConnectionAliasPermission]
-> ReadPrec UpdateConnectionAliasPermission
-> ReadPrec [UpdateConnectionAliasPermission]
-> Read UpdateConnectionAliasPermission
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateConnectionAliasPermission]
$creadListPrec :: ReadPrec [UpdateConnectionAliasPermission]
readPrec :: ReadPrec UpdateConnectionAliasPermission
$creadPrec :: ReadPrec UpdateConnectionAliasPermission
readList :: ReadS [UpdateConnectionAliasPermission]
$creadList :: ReadS [UpdateConnectionAliasPermission]
readsPrec :: Int -> ReadS UpdateConnectionAliasPermission
$creadsPrec :: Int -> ReadS UpdateConnectionAliasPermission
Prelude.Read, Int -> UpdateConnectionAliasPermission -> ShowS
[UpdateConnectionAliasPermission] -> ShowS
UpdateConnectionAliasPermission -> String
(Int -> UpdateConnectionAliasPermission -> ShowS)
-> (UpdateConnectionAliasPermission -> String)
-> ([UpdateConnectionAliasPermission] -> ShowS)
-> Show UpdateConnectionAliasPermission
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateConnectionAliasPermission] -> ShowS
$cshowList :: [UpdateConnectionAliasPermission] -> ShowS
show :: UpdateConnectionAliasPermission -> String
$cshow :: UpdateConnectionAliasPermission -> String
showsPrec :: Int -> UpdateConnectionAliasPermission -> ShowS
$cshowsPrec :: Int -> UpdateConnectionAliasPermission -> ShowS
Prelude.Show, (forall x.
 UpdateConnectionAliasPermission
 -> Rep UpdateConnectionAliasPermission x)
-> (forall x.
    Rep UpdateConnectionAliasPermission x
    -> UpdateConnectionAliasPermission)
-> Generic UpdateConnectionAliasPermission
forall x.
Rep UpdateConnectionAliasPermission x
-> UpdateConnectionAliasPermission
forall x.
UpdateConnectionAliasPermission
-> Rep UpdateConnectionAliasPermission x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateConnectionAliasPermission x
-> UpdateConnectionAliasPermission
$cfrom :: forall x.
UpdateConnectionAliasPermission
-> Rep UpdateConnectionAliasPermission x
Prelude.Generic)

-- |
-- Create a value of 'UpdateConnectionAliasPermission' 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', 'updateConnectionAliasPermission_aliasId' - The identifier of the connection alias that you want to update
-- permissions for.
--
-- 'connectionAliasPermission', 'updateConnectionAliasPermission_connectionAliasPermission' - Indicates whether to share or unshare the connection alias with the
-- specified Amazon Web Services account.
newUpdateConnectionAliasPermission ::
  -- | 'aliasId'
  Prelude.Text ->
  -- | 'connectionAliasPermission'
  ConnectionAliasPermission ->
  UpdateConnectionAliasPermission
newUpdateConnectionAliasPermission :: Text
-> ConnectionAliasPermission -> UpdateConnectionAliasPermission
newUpdateConnectionAliasPermission
  Text
pAliasId_
  ConnectionAliasPermission
pConnectionAliasPermission_ =
    UpdateConnectionAliasPermission' :: Text
-> ConnectionAliasPermission -> UpdateConnectionAliasPermission
UpdateConnectionAliasPermission'
      { $sel:aliasId:UpdateConnectionAliasPermission' :: Text
aliasId =
          Text
pAliasId_,
        $sel:connectionAliasPermission:UpdateConnectionAliasPermission' :: ConnectionAliasPermission
connectionAliasPermission =
          ConnectionAliasPermission
pConnectionAliasPermission_
      }

-- | The identifier of the connection alias that you want to update
-- permissions for.
updateConnectionAliasPermission_aliasId :: Lens.Lens' UpdateConnectionAliasPermission Prelude.Text
updateConnectionAliasPermission_aliasId :: (Text -> f Text)
-> UpdateConnectionAliasPermission
-> f UpdateConnectionAliasPermission
updateConnectionAliasPermission_aliasId = (UpdateConnectionAliasPermission -> Text)
-> (UpdateConnectionAliasPermission
    -> Text -> UpdateConnectionAliasPermission)
-> Lens
     UpdateConnectionAliasPermission
     UpdateConnectionAliasPermission
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnectionAliasPermission' {Text
aliasId :: Text
$sel:aliasId:UpdateConnectionAliasPermission' :: UpdateConnectionAliasPermission -> Text
aliasId} -> Text
aliasId) (\s :: UpdateConnectionAliasPermission
s@UpdateConnectionAliasPermission' {} Text
a -> UpdateConnectionAliasPermission
s {$sel:aliasId:UpdateConnectionAliasPermission' :: Text
aliasId = Text
a} :: UpdateConnectionAliasPermission)

-- | Indicates whether to share or unshare the connection alias with the
-- specified Amazon Web Services account.
updateConnectionAliasPermission_connectionAliasPermission :: Lens.Lens' UpdateConnectionAliasPermission ConnectionAliasPermission
updateConnectionAliasPermission_connectionAliasPermission :: (ConnectionAliasPermission -> f ConnectionAliasPermission)
-> UpdateConnectionAliasPermission
-> f UpdateConnectionAliasPermission
updateConnectionAliasPermission_connectionAliasPermission = (UpdateConnectionAliasPermission -> ConnectionAliasPermission)
-> (UpdateConnectionAliasPermission
    -> ConnectionAliasPermission -> UpdateConnectionAliasPermission)
-> Lens
     UpdateConnectionAliasPermission
     UpdateConnectionAliasPermission
     ConnectionAliasPermission
     ConnectionAliasPermission
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnectionAliasPermission' {ConnectionAliasPermission
connectionAliasPermission :: ConnectionAliasPermission
$sel:connectionAliasPermission:UpdateConnectionAliasPermission' :: UpdateConnectionAliasPermission -> ConnectionAliasPermission
connectionAliasPermission} -> ConnectionAliasPermission
connectionAliasPermission) (\s :: UpdateConnectionAliasPermission
s@UpdateConnectionAliasPermission' {} ConnectionAliasPermission
a -> UpdateConnectionAliasPermission
s {$sel:connectionAliasPermission:UpdateConnectionAliasPermission' :: ConnectionAliasPermission
connectionAliasPermission = ConnectionAliasPermission
a} :: UpdateConnectionAliasPermission)

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

instance
  Prelude.NFData
    UpdateConnectionAliasPermission

instance
  Core.ToHeaders
    UpdateConnectionAliasPermission
  where
  toHeaders :: UpdateConnectionAliasPermission -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> UpdateConnectionAliasPermission -> 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.UpdateConnectionAliasPermission" ::
                          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 UpdateConnectionAliasPermission where
  toJSON :: UpdateConnectionAliasPermission -> Value
toJSON UpdateConnectionAliasPermission' {Text
ConnectionAliasPermission
connectionAliasPermission :: ConnectionAliasPermission
aliasId :: Text
$sel:connectionAliasPermission:UpdateConnectionAliasPermission' :: UpdateConnectionAliasPermission -> ConnectionAliasPermission
$sel:aliasId:UpdateConnectionAliasPermission' :: UpdateConnectionAliasPermission -> 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ConnectionAliasPermission"
                  Text -> ConnectionAliasPermission -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ConnectionAliasPermission
connectionAliasPermission
              )
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    UpdateConnectionAliasPermissionResponse