{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.ConnectionAliasPermission
-- 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)
module Amazonka.WorkSpaces.Types.ConnectionAliasPermission where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the permissions for a connection alias. Connection aliases are
-- used for cross-Region redirection. For more information, see
-- <https://docs.aws.amazon.com/workspaces/latest/adminguide/cross-region-redirection.html Cross-Region Redirection for Amazon WorkSpaces>.
--
-- /See:/ 'newConnectionAliasPermission' smart constructor.
data ConnectionAliasPermission = ConnectionAliasPermission'
  { -- | The identifier of the Amazon Web Services account that the connection
    -- alias is shared with.
    ConnectionAliasPermission -> Text
sharedAccountId :: Prelude.Text,
    -- | Indicates whether the specified Amazon Web Services account is allowed
    -- to associate the connection alias with a directory.
    ConnectionAliasPermission -> Bool
allowAssociation :: Prelude.Bool
  }
  deriving (ConnectionAliasPermission -> ConnectionAliasPermission -> Bool
(ConnectionAliasPermission -> ConnectionAliasPermission -> Bool)
-> (ConnectionAliasPermission -> ConnectionAliasPermission -> Bool)
-> Eq ConnectionAliasPermission
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectionAliasPermission -> ConnectionAliasPermission -> Bool
$c/= :: ConnectionAliasPermission -> ConnectionAliasPermission -> Bool
== :: ConnectionAliasPermission -> ConnectionAliasPermission -> Bool
$c== :: ConnectionAliasPermission -> ConnectionAliasPermission -> Bool
Prelude.Eq, ReadPrec [ConnectionAliasPermission]
ReadPrec ConnectionAliasPermission
Int -> ReadS ConnectionAliasPermission
ReadS [ConnectionAliasPermission]
(Int -> ReadS ConnectionAliasPermission)
-> ReadS [ConnectionAliasPermission]
-> ReadPrec ConnectionAliasPermission
-> ReadPrec [ConnectionAliasPermission]
-> Read ConnectionAliasPermission
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConnectionAliasPermission]
$creadListPrec :: ReadPrec [ConnectionAliasPermission]
readPrec :: ReadPrec ConnectionAliasPermission
$creadPrec :: ReadPrec ConnectionAliasPermission
readList :: ReadS [ConnectionAliasPermission]
$creadList :: ReadS [ConnectionAliasPermission]
readsPrec :: Int -> ReadS ConnectionAliasPermission
$creadsPrec :: Int -> ReadS ConnectionAliasPermission
Prelude.Read, Int -> ConnectionAliasPermission -> ShowS
[ConnectionAliasPermission] -> ShowS
ConnectionAliasPermission -> String
(Int -> ConnectionAliasPermission -> ShowS)
-> (ConnectionAliasPermission -> String)
-> ([ConnectionAliasPermission] -> ShowS)
-> Show ConnectionAliasPermission
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnectionAliasPermission] -> ShowS
$cshowList :: [ConnectionAliasPermission] -> ShowS
show :: ConnectionAliasPermission -> String
$cshow :: ConnectionAliasPermission -> String
showsPrec :: Int -> ConnectionAliasPermission -> ShowS
$cshowsPrec :: Int -> ConnectionAliasPermission -> ShowS
Prelude.Show, (forall x.
 ConnectionAliasPermission -> Rep ConnectionAliasPermission x)
-> (forall x.
    Rep ConnectionAliasPermission x -> ConnectionAliasPermission)
-> Generic ConnectionAliasPermission
forall x.
Rep ConnectionAliasPermission x -> ConnectionAliasPermission
forall x.
ConnectionAliasPermission -> Rep ConnectionAliasPermission x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConnectionAliasPermission x -> ConnectionAliasPermission
$cfrom :: forall x.
ConnectionAliasPermission -> Rep ConnectionAliasPermission x
Prelude.Generic)

-- |
-- Create a value of 'ConnectionAliasPermission' 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:
--
-- 'sharedAccountId', 'connectionAliasPermission_sharedAccountId' - The identifier of the Amazon Web Services account that the connection
-- alias is shared with.
--
-- 'allowAssociation', 'connectionAliasPermission_allowAssociation' - Indicates whether the specified Amazon Web Services account is allowed
-- to associate the connection alias with a directory.
newConnectionAliasPermission ::
  -- | 'sharedAccountId'
  Prelude.Text ->
  -- | 'allowAssociation'
  Prelude.Bool ->
  ConnectionAliasPermission
newConnectionAliasPermission :: Text -> Bool -> ConnectionAliasPermission
newConnectionAliasPermission
  Text
pSharedAccountId_
  Bool
pAllowAssociation_ =
    ConnectionAliasPermission' :: Text -> Bool -> ConnectionAliasPermission
ConnectionAliasPermission'
      { $sel:sharedAccountId:ConnectionAliasPermission' :: Text
sharedAccountId =
          Text
pSharedAccountId_,
        $sel:allowAssociation:ConnectionAliasPermission' :: Bool
allowAssociation = Bool
pAllowAssociation_
      }

-- | The identifier of the Amazon Web Services account that the connection
-- alias is shared with.
connectionAliasPermission_sharedAccountId :: Lens.Lens' ConnectionAliasPermission Prelude.Text
connectionAliasPermission_sharedAccountId :: (Text -> f Text)
-> ConnectionAliasPermission -> f ConnectionAliasPermission
connectionAliasPermission_sharedAccountId = (ConnectionAliasPermission -> Text)
-> (ConnectionAliasPermission -> Text -> ConnectionAliasPermission)
-> Lens
     ConnectionAliasPermission ConnectionAliasPermission Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionAliasPermission' {Text
sharedAccountId :: Text
$sel:sharedAccountId:ConnectionAliasPermission' :: ConnectionAliasPermission -> Text
sharedAccountId} -> Text
sharedAccountId) (\s :: ConnectionAliasPermission
s@ConnectionAliasPermission' {} Text
a -> ConnectionAliasPermission
s {$sel:sharedAccountId:ConnectionAliasPermission' :: Text
sharedAccountId = Text
a} :: ConnectionAliasPermission)

-- | Indicates whether the specified Amazon Web Services account is allowed
-- to associate the connection alias with a directory.
connectionAliasPermission_allowAssociation :: Lens.Lens' ConnectionAliasPermission Prelude.Bool
connectionAliasPermission_allowAssociation :: (Bool -> f Bool)
-> ConnectionAliasPermission -> f ConnectionAliasPermission
connectionAliasPermission_allowAssociation = (ConnectionAliasPermission -> Bool)
-> (ConnectionAliasPermission -> Bool -> ConnectionAliasPermission)
-> Lens
     ConnectionAliasPermission ConnectionAliasPermission Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionAliasPermission' {Bool
allowAssociation :: Bool
$sel:allowAssociation:ConnectionAliasPermission' :: ConnectionAliasPermission -> Bool
allowAssociation} -> Bool
allowAssociation) (\s :: ConnectionAliasPermission
s@ConnectionAliasPermission' {} Bool
a -> ConnectionAliasPermission
s {$sel:allowAssociation:ConnectionAliasPermission' :: Bool
allowAssociation = Bool
a} :: ConnectionAliasPermission)

instance Core.FromJSON ConnectionAliasPermission where
  parseJSON :: Value -> Parser ConnectionAliasPermission
parseJSON =
    String
-> (Object -> Parser ConnectionAliasPermission)
-> Value
-> Parser ConnectionAliasPermission
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConnectionAliasPermission"
      ( \Object
x ->
          Text -> Bool -> ConnectionAliasPermission
ConnectionAliasPermission'
            (Text -> Bool -> ConnectionAliasPermission)
-> Parser Text -> Parser (Bool -> ConnectionAliasPermission)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SharedAccountId")
            Parser (Bool -> ConnectionAliasPermission)
-> Parser Bool -> Parser ConnectionAliasPermission
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AllowAssociation")
      )

instance Prelude.Hashable ConnectionAliasPermission

instance Prelude.NFData ConnectionAliasPermission

instance Core.ToJSON ConnectionAliasPermission where
  toJSON :: ConnectionAliasPermission -> Value
toJSON ConnectionAliasPermission' {Bool
Text
allowAssociation :: Bool
sharedAccountId :: Text
$sel:allowAssociation:ConnectionAliasPermission' :: ConnectionAliasPermission -> Bool
$sel:sharedAccountId:ConnectionAliasPermission' :: ConnectionAliasPermission -> 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
"SharedAccountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sharedAccountId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AllowAssociation" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
allowAssociation)
          ]
      )