{-# 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.NetworkManager.Types.LinkAssociation
-- 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.NetworkManager.Types.LinkAssociation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.NetworkManager.Types.LinkAssociationState
import qualified Amazonka.Prelude as Prelude

-- | Describes the association between a device and a link.
--
-- /See:/ 'newLinkAssociation' smart constructor.
data LinkAssociation = LinkAssociation'
  { -- | The ID of the global network.
    LinkAssociation -> Maybe Text
globalNetworkId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the link.
    LinkAssociation -> Maybe Text
linkId :: Prelude.Maybe Prelude.Text,
    -- | The device ID for the link association.
    LinkAssociation -> Maybe Text
deviceId :: Prelude.Maybe Prelude.Text,
    -- | The state of the association.
    LinkAssociation -> Maybe LinkAssociationState
linkAssociationState :: Prelude.Maybe LinkAssociationState
  }
  deriving (LinkAssociation -> LinkAssociation -> Bool
(LinkAssociation -> LinkAssociation -> Bool)
-> (LinkAssociation -> LinkAssociation -> Bool)
-> Eq LinkAssociation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LinkAssociation -> LinkAssociation -> Bool
$c/= :: LinkAssociation -> LinkAssociation -> Bool
== :: LinkAssociation -> LinkAssociation -> Bool
$c== :: LinkAssociation -> LinkAssociation -> Bool
Prelude.Eq, ReadPrec [LinkAssociation]
ReadPrec LinkAssociation
Int -> ReadS LinkAssociation
ReadS [LinkAssociation]
(Int -> ReadS LinkAssociation)
-> ReadS [LinkAssociation]
-> ReadPrec LinkAssociation
-> ReadPrec [LinkAssociation]
-> Read LinkAssociation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LinkAssociation]
$creadListPrec :: ReadPrec [LinkAssociation]
readPrec :: ReadPrec LinkAssociation
$creadPrec :: ReadPrec LinkAssociation
readList :: ReadS [LinkAssociation]
$creadList :: ReadS [LinkAssociation]
readsPrec :: Int -> ReadS LinkAssociation
$creadsPrec :: Int -> ReadS LinkAssociation
Prelude.Read, Int -> LinkAssociation -> ShowS
[LinkAssociation] -> ShowS
LinkAssociation -> String
(Int -> LinkAssociation -> ShowS)
-> (LinkAssociation -> String)
-> ([LinkAssociation] -> ShowS)
-> Show LinkAssociation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LinkAssociation] -> ShowS
$cshowList :: [LinkAssociation] -> ShowS
show :: LinkAssociation -> String
$cshow :: LinkAssociation -> String
showsPrec :: Int -> LinkAssociation -> ShowS
$cshowsPrec :: Int -> LinkAssociation -> ShowS
Prelude.Show, (forall x. LinkAssociation -> Rep LinkAssociation x)
-> (forall x. Rep LinkAssociation x -> LinkAssociation)
-> Generic LinkAssociation
forall x. Rep LinkAssociation x -> LinkAssociation
forall x. LinkAssociation -> Rep LinkAssociation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LinkAssociation x -> LinkAssociation
$cfrom :: forall x. LinkAssociation -> Rep LinkAssociation x
Prelude.Generic)

-- |
-- Create a value of 'LinkAssociation' 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:
--
-- 'globalNetworkId', 'linkAssociation_globalNetworkId' - The ID of the global network.
--
-- 'linkId', 'linkAssociation_linkId' - The ID of the link.
--
-- 'deviceId', 'linkAssociation_deviceId' - The device ID for the link association.
--
-- 'linkAssociationState', 'linkAssociation_linkAssociationState' - The state of the association.
newLinkAssociation ::
  LinkAssociation
newLinkAssociation :: LinkAssociation
newLinkAssociation =
  LinkAssociation' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe LinkAssociationState
-> LinkAssociation
LinkAssociation'
    { $sel:globalNetworkId:LinkAssociation' :: Maybe Text
globalNetworkId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:linkId:LinkAssociation' :: Maybe Text
linkId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceId:LinkAssociation' :: Maybe Text
deviceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:linkAssociationState:LinkAssociation' :: Maybe LinkAssociationState
linkAssociationState = Maybe LinkAssociationState
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the global network.
linkAssociation_globalNetworkId :: Lens.Lens' LinkAssociation (Prelude.Maybe Prelude.Text)
linkAssociation_globalNetworkId :: (Maybe Text -> f (Maybe Text))
-> LinkAssociation -> f LinkAssociation
linkAssociation_globalNetworkId = (LinkAssociation -> Maybe Text)
-> (LinkAssociation -> Maybe Text -> LinkAssociation)
-> Lens LinkAssociation LinkAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinkAssociation' {Maybe Text
globalNetworkId :: Maybe Text
$sel:globalNetworkId:LinkAssociation' :: LinkAssociation -> Maybe Text
globalNetworkId} -> Maybe Text
globalNetworkId) (\s :: LinkAssociation
s@LinkAssociation' {} Maybe Text
a -> LinkAssociation
s {$sel:globalNetworkId:LinkAssociation' :: Maybe Text
globalNetworkId = Maybe Text
a} :: LinkAssociation)

-- | The ID of the link.
linkAssociation_linkId :: Lens.Lens' LinkAssociation (Prelude.Maybe Prelude.Text)
linkAssociation_linkId :: (Maybe Text -> f (Maybe Text))
-> LinkAssociation -> f LinkAssociation
linkAssociation_linkId = (LinkAssociation -> Maybe Text)
-> (LinkAssociation -> Maybe Text -> LinkAssociation)
-> Lens LinkAssociation LinkAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinkAssociation' {Maybe Text
linkId :: Maybe Text
$sel:linkId:LinkAssociation' :: LinkAssociation -> Maybe Text
linkId} -> Maybe Text
linkId) (\s :: LinkAssociation
s@LinkAssociation' {} Maybe Text
a -> LinkAssociation
s {$sel:linkId:LinkAssociation' :: Maybe Text
linkId = Maybe Text
a} :: LinkAssociation)

-- | The device ID for the link association.
linkAssociation_deviceId :: Lens.Lens' LinkAssociation (Prelude.Maybe Prelude.Text)
linkAssociation_deviceId :: (Maybe Text -> f (Maybe Text))
-> LinkAssociation -> f LinkAssociation
linkAssociation_deviceId = (LinkAssociation -> Maybe Text)
-> (LinkAssociation -> Maybe Text -> LinkAssociation)
-> Lens LinkAssociation LinkAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinkAssociation' {Maybe Text
deviceId :: Maybe Text
$sel:deviceId:LinkAssociation' :: LinkAssociation -> Maybe Text
deviceId} -> Maybe Text
deviceId) (\s :: LinkAssociation
s@LinkAssociation' {} Maybe Text
a -> LinkAssociation
s {$sel:deviceId:LinkAssociation' :: Maybe Text
deviceId = Maybe Text
a} :: LinkAssociation)

-- | The state of the association.
linkAssociation_linkAssociationState :: Lens.Lens' LinkAssociation (Prelude.Maybe LinkAssociationState)
linkAssociation_linkAssociationState :: (Maybe LinkAssociationState -> f (Maybe LinkAssociationState))
-> LinkAssociation -> f LinkAssociation
linkAssociation_linkAssociationState = (LinkAssociation -> Maybe LinkAssociationState)
-> (LinkAssociation
    -> Maybe LinkAssociationState -> LinkAssociation)
-> Lens
     LinkAssociation
     LinkAssociation
     (Maybe LinkAssociationState)
     (Maybe LinkAssociationState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinkAssociation' {Maybe LinkAssociationState
linkAssociationState :: Maybe LinkAssociationState
$sel:linkAssociationState:LinkAssociation' :: LinkAssociation -> Maybe LinkAssociationState
linkAssociationState} -> Maybe LinkAssociationState
linkAssociationState) (\s :: LinkAssociation
s@LinkAssociation' {} Maybe LinkAssociationState
a -> LinkAssociation
s {$sel:linkAssociationState:LinkAssociation' :: Maybe LinkAssociationState
linkAssociationState = Maybe LinkAssociationState
a} :: LinkAssociation)

instance Core.FromJSON LinkAssociation where
  parseJSON :: Value -> Parser LinkAssociation
parseJSON =
    String
-> (Object -> Parser LinkAssociation)
-> Value
-> Parser LinkAssociation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LinkAssociation"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe LinkAssociationState
-> LinkAssociation
LinkAssociation'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe LinkAssociationState
 -> LinkAssociation)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe LinkAssociationState -> LinkAssociation)
forall (f :: * -> *) a b. Functor 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
"GlobalNetworkId")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe LinkAssociationState -> LinkAssociation)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe LinkAssociationState -> LinkAssociation)
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
"LinkId")
            Parser
  (Maybe Text -> Maybe LinkAssociationState -> LinkAssociation)
-> Parser (Maybe Text)
-> Parser (Maybe LinkAssociationState -> LinkAssociation)
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
"DeviceId")
            Parser (Maybe LinkAssociationState -> LinkAssociation)
-> Parser (Maybe LinkAssociationState) -> Parser LinkAssociation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe LinkAssociationState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LinkAssociationState")
      )

instance Prelude.Hashable LinkAssociation

instance Prelude.NFData LinkAssociation