{-# 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.ElasticBeanstalk.Types.EnvironmentLink
-- 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.ElasticBeanstalk.Types.EnvironmentLink where

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

-- | A link to another environment, defined in the environment\'s manifest.
-- Links provide connection information in system properties that can be
-- used to connect to another environment in the same group. See
-- <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-cfg-manifest.html Environment Manifest (env.yaml)>
-- for details.
--
-- /See:/ 'newEnvironmentLink' smart constructor.
data EnvironmentLink = EnvironmentLink'
  { -- | The name of the link.
    EnvironmentLink -> Maybe Text
linkName :: Prelude.Maybe Prelude.Text,
    -- | The name of the linked environment (the dependency).
    EnvironmentLink -> Maybe Text
environmentName :: Prelude.Maybe Prelude.Text
  }
  deriving (EnvironmentLink -> EnvironmentLink -> Bool
(EnvironmentLink -> EnvironmentLink -> Bool)
-> (EnvironmentLink -> EnvironmentLink -> Bool)
-> Eq EnvironmentLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnvironmentLink -> EnvironmentLink -> Bool
$c/= :: EnvironmentLink -> EnvironmentLink -> Bool
== :: EnvironmentLink -> EnvironmentLink -> Bool
$c== :: EnvironmentLink -> EnvironmentLink -> Bool
Prelude.Eq, ReadPrec [EnvironmentLink]
ReadPrec EnvironmentLink
Int -> ReadS EnvironmentLink
ReadS [EnvironmentLink]
(Int -> ReadS EnvironmentLink)
-> ReadS [EnvironmentLink]
-> ReadPrec EnvironmentLink
-> ReadPrec [EnvironmentLink]
-> Read EnvironmentLink
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnvironmentLink]
$creadListPrec :: ReadPrec [EnvironmentLink]
readPrec :: ReadPrec EnvironmentLink
$creadPrec :: ReadPrec EnvironmentLink
readList :: ReadS [EnvironmentLink]
$creadList :: ReadS [EnvironmentLink]
readsPrec :: Int -> ReadS EnvironmentLink
$creadsPrec :: Int -> ReadS EnvironmentLink
Prelude.Read, Int -> EnvironmentLink -> ShowS
[EnvironmentLink] -> ShowS
EnvironmentLink -> String
(Int -> EnvironmentLink -> ShowS)
-> (EnvironmentLink -> String)
-> ([EnvironmentLink] -> ShowS)
-> Show EnvironmentLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnvironmentLink] -> ShowS
$cshowList :: [EnvironmentLink] -> ShowS
show :: EnvironmentLink -> String
$cshow :: EnvironmentLink -> String
showsPrec :: Int -> EnvironmentLink -> ShowS
$cshowsPrec :: Int -> EnvironmentLink -> ShowS
Prelude.Show, (forall x. EnvironmentLink -> Rep EnvironmentLink x)
-> (forall x. Rep EnvironmentLink x -> EnvironmentLink)
-> Generic EnvironmentLink
forall x. Rep EnvironmentLink x -> EnvironmentLink
forall x. EnvironmentLink -> Rep EnvironmentLink x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnvironmentLink x -> EnvironmentLink
$cfrom :: forall x. EnvironmentLink -> Rep EnvironmentLink x
Prelude.Generic)

-- |
-- Create a value of 'EnvironmentLink' 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:
--
-- 'linkName', 'environmentLink_linkName' - The name of the link.
--
-- 'environmentName', 'environmentLink_environmentName' - The name of the linked environment (the dependency).
newEnvironmentLink ::
  EnvironmentLink
newEnvironmentLink :: EnvironmentLink
newEnvironmentLink =
  EnvironmentLink' :: Maybe Text -> Maybe Text -> EnvironmentLink
EnvironmentLink'
    { $sel:linkName:EnvironmentLink' :: Maybe Text
linkName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:environmentName:EnvironmentLink' :: Maybe Text
environmentName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the link.
environmentLink_linkName :: Lens.Lens' EnvironmentLink (Prelude.Maybe Prelude.Text)
environmentLink_linkName :: (Maybe Text -> f (Maybe Text))
-> EnvironmentLink -> f EnvironmentLink
environmentLink_linkName = (EnvironmentLink -> Maybe Text)
-> (EnvironmentLink -> Maybe Text -> EnvironmentLink)
-> Lens EnvironmentLink EnvironmentLink (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentLink' {Maybe Text
linkName :: Maybe Text
$sel:linkName:EnvironmentLink' :: EnvironmentLink -> Maybe Text
linkName} -> Maybe Text
linkName) (\s :: EnvironmentLink
s@EnvironmentLink' {} Maybe Text
a -> EnvironmentLink
s {$sel:linkName:EnvironmentLink' :: Maybe Text
linkName = Maybe Text
a} :: EnvironmentLink)

-- | The name of the linked environment (the dependency).
environmentLink_environmentName :: Lens.Lens' EnvironmentLink (Prelude.Maybe Prelude.Text)
environmentLink_environmentName :: (Maybe Text -> f (Maybe Text))
-> EnvironmentLink -> f EnvironmentLink
environmentLink_environmentName = (EnvironmentLink -> Maybe Text)
-> (EnvironmentLink -> Maybe Text -> EnvironmentLink)
-> Lens EnvironmentLink EnvironmentLink (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentLink' {Maybe Text
environmentName :: Maybe Text
$sel:environmentName:EnvironmentLink' :: EnvironmentLink -> Maybe Text
environmentName} -> Maybe Text
environmentName) (\s :: EnvironmentLink
s@EnvironmentLink' {} Maybe Text
a -> EnvironmentLink
s {$sel:environmentName:EnvironmentLink' :: Maybe Text
environmentName = Maybe Text
a} :: EnvironmentLink)

instance Core.FromXML EnvironmentLink where
  parseXML :: [Node] -> Either String EnvironmentLink
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> EnvironmentLink
EnvironmentLink'
      (Maybe Text -> Maybe Text -> EnvironmentLink)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> EnvironmentLink)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LinkName")
      Either String (Maybe Text -> EnvironmentLink)
-> Either String (Maybe Text) -> Either String EnvironmentLink
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"EnvironmentName")

instance Prelude.Hashable EnvironmentLink

instance Prelude.NFData EnvironmentLink