{-# 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.UpdateConnection
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the Direct Connect dedicated connection configuration.
--
-- You can update the following parameters for a connection:
--
-- -   The connection name
--
-- -   The connection\'s MAC Security (MACsec) encryption mode.
module Amazonka.DirectConnect.UpdateConnection
  ( -- * Creating a Request
    UpdateConnection (..),
    newUpdateConnection,

    -- * Request Lenses
    updateConnection_connectionName,
    updateConnection_encryptionMode,
    updateConnection_connectionId,

    -- * Destructuring the Response
    Connection (..),
    newConnection,

    -- * Response Lenses
    connection_awsDevice,
    connection_awsDeviceV2,
    connection_awsLogicalDeviceId,
    connection_bandwidth,
    connection_connectionId,
    connection_connectionName,
    connection_connectionState,
    connection_encryptionMode,
    connection_hasLogicalRedundancy,
    connection_jumboFrameCapable,
    connection_lagId,
    connection_loaIssueTime,
    connection_location,
    connection_macSecCapable,
    connection_macSecKeys,
    connection_ownerAccount,
    connection_partnerName,
    connection_portEncryptionStatus,
    connection_providerName,
    connection_region,
    connection_tags,
    connection_vlan,
  )
where

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

-- | /See:/ 'newUpdateConnection' smart constructor.
data UpdateConnection = UpdateConnection'
  { -- | The name of the connection.
    UpdateConnection -> Maybe Text
connectionName :: Prelude.Maybe Prelude.Text,
    -- | The connection MAC Security (MACsec) encryption mode.
    --
    -- The valid values are @no_encrypt@, @should_encrypt@, and @must_encrypt@.
    UpdateConnection -> Maybe Text
encryptionMode :: Prelude.Maybe Prelude.Text,
    -- | The ID of the dedicated connection.
    --
    -- You can use DescribeConnections to retrieve the connection ID.
    UpdateConnection -> Text
connectionId :: Prelude.Text
  }
  deriving (UpdateConnection -> UpdateConnection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateConnection -> UpdateConnection -> Bool
$c/= :: UpdateConnection -> UpdateConnection -> Bool
== :: UpdateConnection -> UpdateConnection -> Bool
$c== :: UpdateConnection -> UpdateConnection -> Bool
Prelude.Eq, ReadPrec [UpdateConnection]
ReadPrec UpdateConnection
Int -> ReadS UpdateConnection
ReadS [UpdateConnection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateConnection]
$creadListPrec :: ReadPrec [UpdateConnection]
readPrec :: ReadPrec UpdateConnection
$creadPrec :: ReadPrec UpdateConnection
readList :: ReadS [UpdateConnection]
$creadList :: ReadS [UpdateConnection]
readsPrec :: Int -> ReadS UpdateConnection
$creadsPrec :: Int -> ReadS UpdateConnection
Prelude.Read, Int -> UpdateConnection -> ShowS
[UpdateConnection] -> ShowS
UpdateConnection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateConnection] -> ShowS
$cshowList :: [UpdateConnection] -> ShowS
show :: UpdateConnection -> String
$cshow :: UpdateConnection -> String
showsPrec :: Int -> UpdateConnection -> ShowS
$cshowsPrec :: Int -> UpdateConnection -> ShowS
Prelude.Show, forall x. Rep UpdateConnection x -> UpdateConnection
forall x. UpdateConnection -> Rep UpdateConnection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateConnection x -> UpdateConnection
$cfrom :: forall x. UpdateConnection -> Rep UpdateConnection x
Prelude.Generic)

-- |
-- Create a value of 'UpdateConnection' 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:
--
-- 'connectionName', 'updateConnection_connectionName' - The name of the connection.
--
-- 'encryptionMode', 'updateConnection_encryptionMode' - The connection MAC Security (MACsec) encryption mode.
--
-- The valid values are @no_encrypt@, @should_encrypt@, and @must_encrypt@.
--
-- 'connectionId', 'updateConnection_connectionId' - The ID of the dedicated connection.
--
-- You can use DescribeConnections to retrieve the connection ID.
newUpdateConnection ::
  -- | 'connectionId'
  Prelude.Text ->
  UpdateConnection
newUpdateConnection :: Text -> UpdateConnection
newUpdateConnection Text
pConnectionId_ =
  UpdateConnection'
    { $sel:connectionName:UpdateConnection' :: Maybe Text
connectionName = forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionMode:UpdateConnection' :: Maybe Text
encryptionMode = forall a. Maybe a
Prelude.Nothing,
      $sel:connectionId:UpdateConnection' :: Text
connectionId = Text
pConnectionId_
    }

-- | The name of the connection.
updateConnection_connectionName :: Lens.Lens' UpdateConnection (Prelude.Maybe Prelude.Text)
updateConnection_connectionName :: Lens' UpdateConnection (Maybe Text)
updateConnection_connectionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnection' {Maybe Text
connectionName :: Maybe Text
$sel:connectionName:UpdateConnection' :: UpdateConnection -> Maybe Text
connectionName} -> Maybe Text
connectionName) (\s :: UpdateConnection
s@UpdateConnection' {} Maybe Text
a -> UpdateConnection
s {$sel:connectionName:UpdateConnection' :: Maybe Text
connectionName = Maybe Text
a} :: UpdateConnection)

-- | The connection MAC Security (MACsec) encryption mode.
--
-- The valid values are @no_encrypt@, @should_encrypt@, and @must_encrypt@.
updateConnection_encryptionMode :: Lens.Lens' UpdateConnection (Prelude.Maybe Prelude.Text)
updateConnection_encryptionMode :: Lens' UpdateConnection (Maybe Text)
updateConnection_encryptionMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnection' {Maybe Text
encryptionMode :: Maybe Text
$sel:encryptionMode:UpdateConnection' :: UpdateConnection -> Maybe Text
encryptionMode} -> Maybe Text
encryptionMode) (\s :: UpdateConnection
s@UpdateConnection' {} Maybe Text
a -> UpdateConnection
s {$sel:encryptionMode:UpdateConnection' :: Maybe Text
encryptionMode = Maybe Text
a} :: UpdateConnection)

-- | The ID of the dedicated connection.
--
-- You can use DescribeConnections to retrieve the connection ID.
updateConnection_connectionId :: Lens.Lens' UpdateConnection Prelude.Text
updateConnection_connectionId :: Lens' UpdateConnection Text
updateConnection_connectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConnection' {Text
connectionId :: Text
$sel:connectionId:UpdateConnection' :: UpdateConnection -> Text
connectionId} -> Text
connectionId) (\s :: UpdateConnection
s@UpdateConnection' {} Text
a -> UpdateConnection
s {$sel:connectionId:UpdateConnection' :: Text
connectionId = Text
a} :: UpdateConnection)

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

instance Prelude.Hashable UpdateConnection where
  hashWithSalt :: Int -> UpdateConnection -> Int
hashWithSalt Int
_salt UpdateConnection' {Maybe Text
Text
connectionId :: Text
encryptionMode :: Maybe Text
connectionName :: Maybe Text
$sel:connectionId:UpdateConnection' :: UpdateConnection -> Text
$sel:encryptionMode:UpdateConnection' :: UpdateConnection -> Maybe Text
$sel:connectionName:UpdateConnection' :: UpdateConnection -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
connectionName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
encryptionMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectionId

instance Prelude.NFData UpdateConnection where
  rnf :: UpdateConnection -> ()
rnf UpdateConnection' {Maybe Text
Text
connectionId :: Text
encryptionMode :: Maybe Text
connectionName :: Maybe Text
$sel:connectionId:UpdateConnection' :: UpdateConnection -> Text
$sel:encryptionMode:UpdateConnection' :: UpdateConnection -> Maybe Text
$sel:connectionName:UpdateConnection' :: UpdateConnection -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectionName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
encryptionMode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
connectionId

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

instance Data.ToJSON UpdateConnection where
  toJSON :: UpdateConnection -> Value
toJSON UpdateConnection' {Maybe Text
Text
connectionId :: Text
encryptionMode :: Maybe Text
connectionName :: Maybe Text
$sel:connectionId:UpdateConnection' :: UpdateConnection -> Text
$sel:encryptionMode:UpdateConnection' :: UpdateConnection -> Maybe Text
$sel:connectionName:UpdateConnection' :: UpdateConnection -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"connectionName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
connectionName,
            (Key
"encryptionMode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
encryptionMode,
            forall a. a -> Maybe a
Prelude.Just (Key
"connectionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
connectionId)
          ]
      )

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

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