{-# 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.XRay.Types.Alias
-- 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.XRay.Types.Alias where

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

-- | An alias for an edge.
--
-- /See:/ 'newAlias' smart constructor.
data Alias = Alias'
  { -- | A list of names for the alias, including the canonical name.
    Alias -> Maybe [Text]
names :: Prelude.Maybe [Prelude.Text],
    -- | The canonical name of the alias.
    Alias -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The type of the alias.
    Alias -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (Alias -> Alias -> Bool
(Alias -> Alias -> Bool) -> (Alias -> Alias -> Bool) -> Eq Alias
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Alias -> Alias -> Bool
$c/= :: Alias -> Alias -> Bool
== :: Alias -> Alias -> Bool
$c== :: Alias -> Alias -> Bool
Prelude.Eq, ReadPrec [Alias]
ReadPrec Alias
Int -> ReadS Alias
ReadS [Alias]
(Int -> ReadS Alias)
-> ReadS [Alias]
-> ReadPrec Alias
-> ReadPrec [Alias]
-> Read Alias
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Alias]
$creadListPrec :: ReadPrec [Alias]
readPrec :: ReadPrec Alias
$creadPrec :: ReadPrec Alias
readList :: ReadS [Alias]
$creadList :: ReadS [Alias]
readsPrec :: Int -> ReadS Alias
$creadsPrec :: Int -> ReadS Alias
Prelude.Read, Int -> Alias -> ShowS
[Alias] -> ShowS
Alias -> String
(Int -> Alias -> ShowS)
-> (Alias -> String) -> ([Alias] -> ShowS) -> Show Alias
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Alias] -> ShowS
$cshowList :: [Alias] -> ShowS
show :: Alias -> String
$cshow :: Alias -> String
showsPrec :: Int -> Alias -> ShowS
$cshowsPrec :: Int -> Alias -> ShowS
Prelude.Show, (forall x. Alias -> Rep Alias x)
-> (forall x. Rep Alias x -> Alias) -> Generic Alias
forall x. Rep Alias x -> Alias
forall x. Alias -> Rep Alias x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Alias x -> Alias
$cfrom :: forall x. Alias -> Rep Alias x
Prelude.Generic)

-- |
-- Create a value of 'Alias' 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:
--
-- 'names', 'alias_names' - A list of names for the alias, including the canonical name.
--
-- 'name', 'alias_name' - The canonical name of the alias.
--
-- 'type'', 'alias_type' - The type of the alias.
newAlias ::
  Alias
newAlias :: Alias
newAlias =
  Alias' :: Maybe [Text] -> Maybe Text -> Maybe Text -> Alias
Alias'
    { $sel:names:Alias' :: Maybe [Text]
names = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Alias' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Alias' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of names for the alias, including the canonical name.
alias_names :: Lens.Lens' Alias (Prelude.Maybe [Prelude.Text])
alias_names :: (Maybe [Text] -> f (Maybe [Text])) -> Alias -> f Alias
alias_names = (Alias -> Maybe [Text])
-> (Alias -> Maybe [Text] -> Alias)
-> Lens Alias Alias (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alias' {Maybe [Text]
names :: Maybe [Text]
$sel:names:Alias' :: Alias -> Maybe [Text]
names} -> Maybe [Text]
names) (\s :: Alias
s@Alias' {} Maybe [Text]
a -> Alias
s {$sel:names:Alias' :: Maybe [Text]
names = Maybe [Text]
a} :: Alias) ((Maybe [Text] -> f (Maybe [Text])) -> Alias -> f Alias)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Alias
-> f Alias
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The canonical name of the alias.
alias_name :: Lens.Lens' Alias (Prelude.Maybe Prelude.Text)
alias_name :: (Maybe Text -> f (Maybe Text)) -> Alias -> f Alias
alias_name = (Alias -> Maybe Text)
-> (Alias -> Maybe Text -> Alias)
-> Lens Alias Alias (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alias' {Maybe Text
name :: Maybe Text
$sel:name:Alias' :: Alias -> Maybe Text
name} -> Maybe Text
name) (\s :: Alias
s@Alias' {} Maybe Text
a -> Alias
s {$sel:name:Alias' :: Maybe Text
name = Maybe Text
a} :: Alias)

-- | The type of the alias.
alias_type :: Lens.Lens' Alias (Prelude.Maybe Prelude.Text)
alias_type :: (Maybe Text -> f (Maybe Text)) -> Alias -> f Alias
alias_type = (Alias -> Maybe Text)
-> (Alias -> Maybe Text -> Alias)
-> Lens Alias Alias (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alias' {Maybe Text
type' :: Maybe Text
$sel:type':Alias' :: Alias -> Maybe Text
type'} -> Maybe Text
type') (\s :: Alias
s@Alias' {} Maybe Text
a -> Alias
s {$sel:type':Alias' :: Maybe Text
type' = Maybe Text
a} :: Alias)

instance Core.FromJSON Alias where
  parseJSON :: Value -> Parser Alias
parseJSON =
    String -> (Object -> Parser Alias) -> Value -> Parser Alias
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Alias"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> Maybe Text -> Alias
Alias'
            (Maybe [Text] -> Maybe Text -> Maybe Text -> Alias)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> Maybe Text -> Alias)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Names" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe Text -> Alias)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Alias)
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
"Name")
            Parser (Maybe Text -> Alias) -> Parser (Maybe Text) -> Parser Alias
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
"Type")
      )

instance Prelude.Hashable Alias

instance Prelude.NFData Alias