{-# 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.ConnectionAlias
-- 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.ConnectionAlias where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkSpaces.Types.ConnectionAliasAssociation
import Amazonka.WorkSpaces.Types.ConnectionAliasState

-- | Describes 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:/ 'newConnectionAlias' smart constructor.
data ConnectionAlias = ConnectionAlias'
  { -- | The current state of the connection alias.
    ConnectionAlias -> Maybe ConnectionAliasState
state :: Prelude.Maybe ConnectionAliasState,
    -- | The identifier of the Amazon Web Services account that owns the
    -- connection alias.
    ConnectionAlias -> Maybe Text
ownerAccountId :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the connection alias.
    ConnectionAlias -> Maybe Text
aliasId :: Prelude.Maybe Prelude.Text,
    -- | The association status of the connection alias.
    ConnectionAlias -> Maybe (NonEmpty ConnectionAliasAssociation)
associations :: Prelude.Maybe (Prelude.NonEmpty ConnectionAliasAssociation),
    -- | The connection string specified for the connection alias. The connection
    -- string must be in the form of a fully qualified domain name (FQDN), such
    -- as @www.example.com@.
    ConnectionAlias -> Maybe Text
connectionString :: Prelude.Maybe Prelude.Text
  }
  deriving (ConnectionAlias -> ConnectionAlias -> Bool
(ConnectionAlias -> ConnectionAlias -> Bool)
-> (ConnectionAlias -> ConnectionAlias -> Bool)
-> Eq ConnectionAlias
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectionAlias -> ConnectionAlias -> Bool
$c/= :: ConnectionAlias -> ConnectionAlias -> Bool
== :: ConnectionAlias -> ConnectionAlias -> Bool
$c== :: ConnectionAlias -> ConnectionAlias -> Bool
Prelude.Eq, ReadPrec [ConnectionAlias]
ReadPrec ConnectionAlias
Int -> ReadS ConnectionAlias
ReadS [ConnectionAlias]
(Int -> ReadS ConnectionAlias)
-> ReadS [ConnectionAlias]
-> ReadPrec ConnectionAlias
-> ReadPrec [ConnectionAlias]
-> Read ConnectionAlias
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConnectionAlias]
$creadListPrec :: ReadPrec [ConnectionAlias]
readPrec :: ReadPrec ConnectionAlias
$creadPrec :: ReadPrec ConnectionAlias
readList :: ReadS [ConnectionAlias]
$creadList :: ReadS [ConnectionAlias]
readsPrec :: Int -> ReadS ConnectionAlias
$creadsPrec :: Int -> ReadS ConnectionAlias
Prelude.Read, Int -> ConnectionAlias -> ShowS
[ConnectionAlias] -> ShowS
ConnectionAlias -> String
(Int -> ConnectionAlias -> ShowS)
-> (ConnectionAlias -> String)
-> ([ConnectionAlias] -> ShowS)
-> Show ConnectionAlias
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnectionAlias] -> ShowS
$cshowList :: [ConnectionAlias] -> ShowS
show :: ConnectionAlias -> String
$cshow :: ConnectionAlias -> String
showsPrec :: Int -> ConnectionAlias -> ShowS
$cshowsPrec :: Int -> ConnectionAlias -> ShowS
Prelude.Show, (forall x. ConnectionAlias -> Rep ConnectionAlias x)
-> (forall x. Rep ConnectionAlias x -> ConnectionAlias)
-> Generic ConnectionAlias
forall x. Rep ConnectionAlias x -> ConnectionAlias
forall x. ConnectionAlias -> Rep ConnectionAlias x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConnectionAlias x -> ConnectionAlias
$cfrom :: forall x. ConnectionAlias -> Rep ConnectionAlias x
Prelude.Generic)

-- |
-- Create a value of 'ConnectionAlias' 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:
--
-- 'state', 'connectionAlias_state' - The current state of the connection alias.
--
-- 'ownerAccountId', 'connectionAlias_ownerAccountId' - The identifier of the Amazon Web Services account that owns the
-- connection alias.
--
-- 'aliasId', 'connectionAlias_aliasId' - The identifier of the connection alias.
--
-- 'associations', 'connectionAlias_associations' - The association status of the connection alias.
--
-- 'connectionString', 'connectionAlias_connectionString' - The connection string specified for the connection alias. The connection
-- string must be in the form of a fully qualified domain name (FQDN), such
-- as @www.example.com@.
newConnectionAlias ::
  ConnectionAlias
newConnectionAlias :: ConnectionAlias
newConnectionAlias =
  ConnectionAlias' :: Maybe ConnectionAliasState
-> Maybe Text
-> Maybe Text
-> Maybe (NonEmpty ConnectionAliasAssociation)
-> Maybe Text
-> ConnectionAlias
ConnectionAlias'
    { $sel:state:ConnectionAlias' :: Maybe ConnectionAliasState
state = Maybe ConnectionAliasState
forall a. Maybe a
Prelude.Nothing,
      $sel:ownerAccountId:ConnectionAlias' :: Maybe Text
ownerAccountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:aliasId:ConnectionAlias' :: Maybe Text
aliasId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:associations:ConnectionAlias' :: Maybe (NonEmpty ConnectionAliasAssociation)
associations = Maybe (NonEmpty ConnectionAliasAssociation)
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionString:ConnectionAlias' :: Maybe Text
connectionString = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The current state of the connection alias.
connectionAlias_state :: Lens.Lens' ConnectionAlias (Prelude.Maybe ConnectionAliasState)
connectionAlias_state :: (Maybe ConnectionAliasState -> f (Maybe ConnectionAliasState))
-> ConnectionAlias -> f ConnectionAlias
connectionAlias_state = (ConnectionAlias -> Maybe ConnectionAliasState)
-> (ConnectionAlias
    -> Maybe ConnectionAliasState -> ConnectionAlias)
-> Lens
     ConnectionAlias
     ConnectionAlias
     (Maybe ConnectionAliasState)
     (Maybe ConnectionAliasState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionAlias' {Maybe ConnectionAliasState
state :: Maybe ConnectionAliasState
$sel:state:ConnectionAlias' :: ConnectionAlias -> Maybe ConnectionAliasState
state} -> Maybe ConnectionAliasState
state) (\s :: ConnectionAlias
s@ConnectionAlias' {} Maybe ConnectionAliasState
a -> ConnectionAlias
s {$sel:state:ConnectionAlias' :: Maybe ConnectionAliasState
state = Maybe ConnectionAliasState
a} :: ConnectionAlias)

-- | The identifier of the Amazon Web Services account that owns the
-- connection alias.
connectionAlias_ownerAccountId :: Lens.Lens' ConnectionAlias (Prelude.Maybe Prelude.Text)
connectionAlias_ownerAccountId :: (Maybe Text -> f (Maybe Text))
-> ConnectionAlias -> f ConnectionAlias
connectionAlias_ownerAccountId = (ConnectionAlias -> Maybe Text)
-> (ConnectionAlias -> Maybe Text -> ConnectionAlias)
-> Lens ConnectionAlias ConnectionAlias (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionAlias' {Maybe Text
ownerAccountId :: Maybe Text
$sel:ownerAccountId:ConnectionAlias' :: ConnectionAlias -> Maybe Text
ownerAccountId} -> Maybe Text
ownerAccountId) (\s :: ConnectionAlias
s@ConnectionAlias' {} Maybe Text
a -> ConnectionAlias
s {$sel:ownerAccountId:ConnectionAlias' :: Maybe Text
ownerAccountId = Maybe Text
a} :: ConnectionAlias)

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

-- | The association status of the connection alias.
connectionAlias_associations :: Lens.Lens' ConnectionAlias (Prelude.Maybe (Prelude.NonEmpty ConnectionAliasAssociation))
connectionAlias_associations :: (Maybe (NonEmpty ConnectionAliasAssociation)
 -> f (Maybe (NonEmpty ConnectionAliasAssociation)))
-> ConnectionAlias -> f ConnectionAlias
connectionAlias_associations = (ConnectionAlias -> Maybe (NonEmpty ConnectionAliasAssociation))
-> (ConnectionAlias
    -> Maybe (NonEmpty ConnectionAliasAssociation) -> ConnectionAlias)
-> Lens
     ConnectionAlias
     ConnectionAlias
     (Maybe (NonEmpty ConnectionAliasAssociation))
     (Maybe (NonEmpty ConnectionAliasAssociation))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionAlias' {Maybe (NonEmpty ConnectionAliasAssociation)
associations :: Maybe (NonEmpty ConnectionAliasAssociation)
$sel:associations:ConnectionAlias' :: ConnectionAlias -> Maybe (NonEmpty ConnectionAliasAssociation)
associations} -> Maybe (NonEmpty ConnectionAliasAssociation)
associations) (\s :: ConnectionAlias
s@ConnectionAlias' {} Maybe (NonEmpty ConnectionAliasAssociation)
a -> ConnectionAlias
s {$sel:associations:ConnectionAlias' :: Maybe (NonEmpty ConnectionAliasAssociation)
associations = Maybe (NonEmpty ConnectionAliasAssociation)
a} :: ConnectionAlias) ((Maybe (NonEmpty ConnectionAliasAssociation)
  -> f (Maybe (NonEmpty ConnectionAliasAssociation)))
 -> ConnectionAlias -> f ConnectionAlias)
-> ((Maybe (NonEmpty ConnectionAliasAssociation)
     -> f (Maybe (NonEmpty ConnectionAliasAssociation)))
    -> Maybe (NonEmpty ConnectionAliasAssociation)
    -> f (Maybe (NonEmpty ConnectionAliasAssociation)))
-> (Maybe (NonEmpty ConnectionAliasAssociation)
    -> f (Maybe (NonEmpty ConnectionAliasAssociation)))
-> ConnectionAlias
-> f ConnectionAlias
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ConnectionAliasAssociation)
  (NonEmpty ConnectionAliasAssociation)
  (NonEmpty ConnectionAliasAssociation)
  (NonEmpty ConnectionAliasAssociation)
-> Iso
     (Maybe (NonEmpty ConnectionAliasAssociation))
     (Maybe (NonEmpty ConnectionAliasAssociation))
     (Maybe (NonEmpty ConnectionAliasAssociation))
     (Maybe (NonEmpty ConnectionAliasAssociation))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty ConnectionAliasAssociation)
  (NonEmpty ConnectionAliasAssociation)
  (NonEmpty ConnectionAliasAssociation)
  (NonEmpty ConnectionAliasAssociation)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The connection string specified for the connection alias. The connection
-- string must be in the form of a fully qualified domain name (FQDN), such
-- as @www.example.com@.
connectionAlias_connectionString :: Lens.Lens' ConnectionAlias (Prelude.Maybe Prelude.Text)
connectionAlias_connectionString :: (Maybe Text -> f (Maybe Text))
-> ConnectionAlias -> f ConnectionAlias
connectionAlias_connectionString = (ConnectionAlias -> Maybe Text)
-> (ConnectionAlias -> Maybe Text -> ConnectionAlias)
-> Lens ConnectionAlias ConnectionAlias (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionAlias' {Maybe Text
connectionString :: Maybe Text
$sel:connectionString:ConnectionAlias' :: ConnectionAlias -> Maybe Text
connectionString} -> Maybe Text
connectionString) (\s :: ConnectionAlias
s@ConnectionAlias' {} Maybe Text
a -> ConnectionAlias
s {$sel:connectionString:ConnectionAlias' :: Maybe Text
connectionString = Maybe Text
a} :: ConnectionAlias)

instance Core.FromJSON ConnectionAlias where
  parseJSON :: Value -> Parser ConnectionAlias
parseJSON =
    String
-> (Object -> Parser ConnectionAlias)
-> Value
-> Parser ConnectionAlias
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConnectionAlias"
      ( \Object
x ->
          Maybe ConnectionAliasState
-> Maybe Text
-> Maybe Text
-> Maybe (NonEmpty ConnectionAliasAssociation)
-> Maybe Text
-> ConnectionAlias
ConnectionAlias'
            (Maybe ConnectionAliasState
 -> Maybe Text
 -> Maybe Text
 -> Maybe (NonEmpty ConnectionAliasAssociation)
 -> Maybe Text
 -> ConnectionAlias)
-> Parser (Maybe ConnectionAliasState)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe (NonEmpty ConnectionAliasAssociation)
      -> Maybe Text
      -> ConnectionAlias)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ConnectionAliasState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe (NonEmpty ConnectionAliasAssociation)
   -> Maybe Text
   -> ConnectionAlias)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe (NonEmpty ConnectionAliasAssociation)
      -> Maybe Text
      -> ConnectionAlias)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OwnerAccountId")
            Parser
  (Maybe Text
   -> Maybe (NonEmpty ConnectionAliasAssociation)
   -> Maybe Text
   -> ConnectionAlias)
-> Parser (Maybe Text)
-> Parser
     (Maybe (NonEmpty ConnectionAliasAssociation)
      -> Maybe Text -> ConnectionAlias)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AliasId")
            Parser
  (Maybe (NonEmpty ConnectionAliasAssociation)
   -> Maybe Text -> ConnectionAlias)
-> Parser (Maybe (NonEmpty ConnectionAliasAssociation))
-> Parser (Maybe Text -> ConnectionAlias)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (NonEmpty ConnectionAliasAssociation))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Associations")
            Parser (Maybe Text -> ConnectionAlias)
-> Parser (Maybe Text) -> Parser ConnectionAlias
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConnectionString")
      )

instance Prelude.Hashable ConnectionAlias

instance Prelude.NFData ConnectionAlias