{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.DirectConnect.UpdateLag
-- 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)
--
-- Updates the attributes of the specified link aggregation group (LAG).
--
-- You can update the following LAG attributes:
--
-- -   The name of the LAG.
--
-- -   The value for the minimum number of connections that must be
--     operational for the LAG itself to be operational.
--
-- -   The LAG\'s MACsec encryption mode.
--
--     Amazon Web Services assigns this value to each connection which is
--     part of the LAG.
--
-- -   The tags
--
-- If you adjust the threshold value for the minimum number of operational
-- connections, ensure that the new value does not cause the LAG to fall
-- below the threshold and become non-operational.
module Amazonka.DirectConnect.UpdateLag
  ( -- * Creating a Request
    UpdateLag (..),
    newUpdateLag,

    -- * Request Lenses
    updateLag_minimumLinks,
    updateLag_lagName,
    updateLag_encryptionMode,
    updateLag_lagId,

    -- * Destructuring the Response
    Lag (..),
    newLag,

    -- * Response Lenses
    lag_lagId,
    lag_macSecCapable,
    lag_connectionsBandwidth,
    lag_minimumLinks,
    lag_lagName,
    lag_location,
    lag_connections,
    lag_awsDevice,
    lag_hasLogicalRedundancy,
    lag_awsLogicalDeviceId,
    lag_allowsHostedConnections,
    lag_encryptionMode,
    lag_numberOfConnections,
    lag_jumboFrameCapable,
    lag_lagState,
    lag_ownerAccount,
    lag_region,
    lag_macSecKeys,
    lag_providerName,
    lag_awsDeviceV2,
    lag_tags,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DirectConnect.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateLag' smart constructor.
data UpdateLag = UpdateLag'
  { -- | The minimum number of physical connections that must be operational for
    -- the LAG itself to be operational.
    UpdateLag -> Maybe Int
minimumLinks :: Prelude.Maybe Prelude.Int,
    -- | The name of the LAG.
    UpdateLag -> Maybe Text
lagName :: Prelude.Maybe Prelude.Text,
    -- | The LAG MAC Security (MACsec) encryption mode.
    --
    -- Amazon Web Services applies the value to all connections which are part
    -- of the LAG.
    UpdateLag -> Maybe Text
encryptionMode :: Prelude.Maybe Prelude.Text,
    -- | The ID of the LAG.
    UpdateLag -> Text
lagId :: Prelude.Text
  }
  deriving (UpdateLag -> UpdateLag -> Bool
(UpdateLag -> UpdateLag -> Bool)
-> (UpdateLag -> UpdateLag -> Bool) -> Eq UpdateLag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateLag -> UpdateLag -> Bool
$c/= :: UpdateLag -> UpdateLag -> Bool
== :: UpdateLag -> UpdateLag -> Bool
$c== :: UpdateLag -> UpdateLag -> Bool
Prelude.Eq, ReadPrec [UpdateLag]
ReadPrec UpdateLag
Int -> ReadS UpdateLag
ReadS [UpdateLag]
(Int -> ReadS UpdateLag)
-> ReadS [UpdateLag]
-> ReadPrec UpdateLag
-> ReadPrec [UpdateLag]
-> Read UpdateLag
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateLag]
$creadListPrec :: ReadPrec [UpdateLag]
readPrec :: ReadPrec UpdateLag
$creadPrec :: ReadPrec UpdateLag
readList :: ReadS [UpdateLag]
$creadList :: ReadS [UpdateLag]
readsPrec :: Int -> ReadS UpdateLag
$creadsPrec :: Int -> ReadS UpdateLag
Prelude.Read, Int -> UpdateLag -> ShowS
[UpdateLag] -> ShowS
UpdateLag -> String
(Int -> UpdateLag -> ShowS)
-> (UpdateLag -> String)
-> ([UpdateLag] -> ShowS)
-> Show UpdateLag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateLag] -> ShowS
$cshowList :: [UpdateLag] -> ShowS
show :: UpdateLag -> String
$cshow :: UpdateLag -> String
showsPrec :: Int -> UpdateLag -> ShowS
$cshowsPrec :: Int -> UpdateLag -> ShowS
Prelude.Show, (forall x. UpdateLag -> Rep UpdateLag x)
-> (forall x. Rep UpdateLag x -> UpdateLag) -> Generic UpdateLag
forall x. Rep UpdateLag x -> UpdateLag
forall x. UpdateLag -> Rep UpdateLag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateLag x -> UpdateLag
$cfrom :: forall x. UpdateLag -> Rep UpdateLag x
Prelude.Generic)

-- |
-- Create a value of 'UpdateLag' 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:
--
-- 'minimumLinks', 'updateLag_minimumLinks' - The minimum number of physical connections that must be operational for
-- the LAG itself to be operational.
--
-- 'lagName', 'updateLag_lagName' - The name of the LAG.
--
-- 'encryptionMode', 'updateLag_encryptionMode' - The LAG MAC Security (MACsec) encryption mode.
--
-- Amazon Web Services applies the value to all connections which are part
-- of the LAG.
--
-- 'lagId', 'updateLag_lagId' - The ID of the LAG.
newUpdateLag ::
  -- | 'lagId'
  Prelude.Text ->
  UpdateLag
newUpdateLag :: Text -> UpdateLag
newUpdateLag Text
pLagId_ =
  UpdateLag' :: Maybe Int -> Maybe Text -> Maybe Text -> Text -> UpdateLag
UpdateLag'
    { $sel:minimumLinks:UpdateLag' :: Maybe Int
minimumLinks = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:lagName:UpdateLag' :: Maybe Text
lagName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionMode:UpdateLag' :: Maybe Text
encryptionMode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lagId:UpdateLag' :: Text
lagId = Text
pLagId_
    }

-- | The minimum number of physical connections that must be operational for
-- the LAG itself to be operational.
updateLag_minimumLinks :: Lens.Lens' UpdateLag (Prelude.Maybe Prelude.Int)
updateLag_minimumLinks :: (Maybe Int -> f (Maybe Int)) -> UpdateLag -> f UpdateLag
updateLag_minimumLinks = (UpdateLag -> Maybe Int)
-> (UpdateLag -> Maybe Int -> UpdateLag)
-> Lens UpdateLag UpdateLag (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLag' {Maybe Int
minimumLinks :: Maybe Int
$sel:minimumLinks:UpdateLag' :: UpdateLag -> Maybe Int
minimumLinks} -> Maybe Int
minimumLinks) (\s :: UpdateLag
s@UpdateLag' {} Maybe Int
a -> UpdateLag
s {$sel:minimumLinks:UpdateLag' :: Maybe Int
minimumLinks = Maybe Int
a} :: UpdateLag)

-- | The name of the LAG.
updateLag_lagName :: Lens.Lens' UpdateLag (Prelude.Maybe Prelude.Text)
updateLag_lagName :: (Maybe Text -> f (Maybe Text)) -> UpdateLag -> f UpdateLag
updateLag_lagName = (UpdateLag -> Maybe Text)
-> (UpdateLag -> Maybe Text -> UpdateLag)
-> Lens UpdateLag UpdateLag (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLag' {Maybe Text
lagName :: Maybe Text
$sel:lagName:UpdateLag' :: UpdateLag -> Maybe Text
lagName} -> Maybe Text
lagName) (\s :: UpdateLag
s@UpdateLag' {} Maybe Text
a -> UpdateLag
s {$sel:lagName:UpdateLag' :: Maybe Text
lagName = Maybe Text
a} :: UpdateLag)

-- | The LAG MAC Security (MACsec) encryption mode.
--
-- Amazon Web Services applies the value to all connections which are part
-- of the LAG.
updateLag_encryptionMode :: Lens.Lens' UpdateLag (Prelude.Maybe Prelude.Text)
updateLag_encryptionMode :: (Maybe Text -> f (Maybe Text)) -> UpdateLag -> f UpdateLag
updateLag_encryptionMode = (UpdateLag -> Maybe Text)
-> (UpdateLag -> Maybe Text -> UpdateLag)
-> Lens UpdateLag UpdateLag (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLag' {Maybe Text
encryptionMode :: Maybe Text
$sel:encryptionMode:UpdateLag' :: UpdateLag -> Maybe Text
encryptionMode} -> Maybe Text
encryptionMode) (\s :: UpdateLag
s@UpdateLag' {} Maybe Text
a -> UpdateLag
s {$sel:encryptionMode:UpdateLag' :: Maybe Text
encryptionMode = Maybe Text
a} :: UpdateLag)

-- | The ID of the LAG.
updateLag_lagId :: Lens.Lens' UpdateLag Prelude.Text
updateLag_lagId :: (Text -> f Text) -> UpdateLag -> f UpdateLag
updateLag_lagId = (UpdateLag -> Text)
-> (UpdateLag -> Text -> UpdateLag)
-> Lens UpdateLag UpdateLag Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLag' {Text
lagId :: Text
$sel:lagId:UpdateLag' :: UpdateLag -> Text
lagId} -> Text
lagId) (\s :: UpdateLag
s@UpdateLag' {} Text
a -> UpdateLag
s {$sel:lagId:UpdateLag' :: Text
lagId = Text
a} :: UpdateLag)

instance Core.AWSRequest UpdateLag where
  type AWSResponse UpdateLag = Lag
  request :: UpdateLag -> Request UpdateLag
request = Service -> UpdateLag -> Request UpdateLag
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateLag
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateLag)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateLag))
-> Logger
-> Service
-> Proxy UpdateLag
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateLag)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String Lag
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable UpdateLag

instance Prelude.NFData UpdateLag

instance Core.ToHeaders UpdateLag where
  toHeaders :: UpdateLag -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateLag -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"OvertureService.UpdateLag" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateLag where
  toJSON :: UpdateLag -> Value
toJSON UpdateLag' {Maybe Int
Maybe Text
Text
lagId :: Text
encryptionMode :: Maybe Text
lagName :: Maybe Text
minimumLinks :: Maybe Int
$sel:lagId:UpdateLag' :: UpdateLag -> Text
$sel:encryptionMode:UpdateLag' :: UpdateLag -> Maybe Text
$sel:lagName:UpdateLag' :: UpdateLag -> Maybe Text
$sel:minimumLinks:UpdateLag' :: UpdateLag -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"minimumLinks" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
minimumLinks,
            (Text
"lagName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
lagName,
            (Text
"encryptionMode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
encryptionMode,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"lagId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
lagId)
          ]
      )

instance Core.ToPath UpdateLag where
  toPath :: UpdateLag -> ByteString
toPath = ByteString -> UpdateLag -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery UpdateLag where
  toQuery :: UpdateLag -> QueryString
toQuery = QueryString -> UpdateLag -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty