{-# 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.UpdateVirtualInterfaceAttributes
-- 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 specified attributes of the specified virtual private
-- interface.
--
-- Setting the MTU of a virtual interface to 9001 (jumbo frames) can cause
-- an update to the underlying physical connection if it wasn\'t updated to
-- support jumbo frames. Updating the connection disrupts network
-- connectivity for all virtual interfaces associated with the connection
-- for up to 30 seconds. To check whether your connection supports jumbo
-- frames, call DescribeConnections. To check whether your virtual q
-- interface supports jumbo frames, call DescribeVirtualInterfaces.
module Amazonka.DirectConnect.UpdateVirtualInterfaceAttributes
  ( -- * Creating a Request
    UpdateVirtualInterfaceAttributes (..),
    newUpdateVirtualInterfaceAttributes,

    -- * Request Lenses
    updateVirtualInterfaceAttributes_mtu,
    updateVirtualInterfaceAttributes_virtualInterfaceId,

    -- * Destructuring the Response
    VirtualInterface (..),
    newVirtualInterface,

    -- * Response Lenses
    virtualInterface_bgpPeers,
    virtualInterface_virtualGatewayId,
    virtualInterface_mtu,
    virtualInterface_routeFilterPrefixes,
    virtualInterface_customerAddress,
    virtualInterface_vlan,
    virtualInterface_location,
    virtualInterface_amazonAddress,
    virtualInterface_addressFamily,
    virtualInterface_virtualInterfaceState,
    virtualInterface_connectionId,
    virtualInterface_awsLogicalDeviceId,
    virtualInterface_directConnectGatewayId,
    virtualInterface_amazonSideAsn,
    virtualInterface_virtualInterfaceType,
    virtualInterface_asn,
    virtualInterface_authKey,
    virtualInterface_jumboFrameCapable,
    virtualInterface_customerRouterConfig,
    virtualInterface_ownerAccount,
    virtualInterface_region,
    virtualInterface_virtualInterfaceName,
    virtualInterface_awsDeviceV2,
    virtualInterface_virtualInterfaceId,
    virtualInterface_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:/ 'newUpdateVirtualInterfaceAttributes' smart constructor.
data UpdateVirtualInterfaceAttributes = UpdateVirtualInterfaceAttributes'
  { -- | The maximum transmission unit (MTU), in bytes. The supported values are
    -- 1500 and 9001. The default value is 1500.
    UpdateVirtualInterfaceAttributes -> Maybe Int
mtu :: Prelude.Maybe Prelude.Int,
    -- | The ID of the virtual private interface.
    UpdateVirtualInterfaceAttributes -> Text
virtualInterfaceId :: Prelude.Text
  }
  deriving (UpdateVirtualInterfaceAttributes
-> UpdateVirtualInterfaceAttributes -> Bool
(UpdateVirtualInterfaceAttributes
 -> UpdateVirtualInterfaceAttributes -> Bool)
-> (UpdateVirtualInterfaceAttributes
    -> UpdateVirtualInterfaceAttributes -> Bool)
-> Eq UpdateVirtualInterfaceAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateVirtualInterfaceAttributes
-> UpdateVirtualInterfaceAttributes -> Bool
$c/= :: UpdateVirtualInterfaceAttributes
-> UpdateVirtualInterfaceAttributes -> Bool
== :: UpdateVirtualInterfaceAttributes
-> UpdateVirtualInterfaceAttributes -> Bool
$c== :: UpdateVirtualInterfaceAttributes
-> UpdateVirtualInterfaceAttributes -> Bool
Prelude.Eq, ReadPrec [UpdateVirtualInterfaceAttributes]
ReadPrec UpdateVirtualInterfaceAttributes
Int -> ReadS UpdateVirtualInterfaceAttributes
ReadS [UpdateVirtualInterfaceAttributes]
(Int -> ReadS UpdateVirtualInterfaceAttributes)
-> ReadS [UpdateVirtualInterfaceAttributes]
-> ReadPrec UpdateVirtualInterfaceAttributes
-> ReadPrec [UpdateVirtualInterfaceAttributes]
-> Read UpdateVirtualInterfaceAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateVirtualInterfaceAttributes]
$creadListPrec :: ReadPrec [UpdateVirtualInterfaceAttributes]
readPrec :: ReadPrec UpdateVirtualInterfaceAttributes
$creadPrec :: ReadPrec UpdateVirtualInterfaceAttributes
readList :: ReadS [UpdateVirtualInterfaceAttributes]
$creadList :: ReadS [UpdateVirtualInterfaceAttributes]
readsPrec :: Int -> ReadS UpdateVirtualInterfaceAttributes
$creadsPrec :: Int -> ReadS UpdateVirtualInterfaceAttributes
Prelude.Read, Int -> UpdateVirtualInterfaceAttributes -> ShowS
[UpdateVirtualInterfaceAttributes] -> ShowS
UpdateVirtualInterfaceAttributes -> String
(Int -> UpdateVirtualInterfaceAttributes -> ShowS)
-> (UpdateVirtualInterfaceAttributes -> String)
-> ([UpdateVirtualInterfaceAttributes] -> ShowS)
-> Show UpdateVirtualInterfaceAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateVirtualInterfaceAttributes] -> ShowS
$cshowList :: [UpdateVirtualInterfaceAttributes] -> ShowS
show :: UpdateVirtualInterfaceAttributes -> String
$cshow :: UpdateVirtualInterfaceAttributes -> String
showsPrec :: Int -> UpdateVirtualInterfaceAttributes -> ShowS
$cshowsPrec :: Int -> UpdateVirtualInterfaceAttributes -> ShowS
Prelude.Show, (forall x.
 UpdateVirtualInterfaceAttributes
 -> Rep UpdateVirtualInterfaceAttributes x)
-> (forall x.
    Rep UpdateVirtualInterfaceAttributes x
    -> UpdateVirtualInterfaceAttributes)
-> Generic UpdateVirtualInterfaceAttributes
forall x.
Rep UpdateVirtualInterfaceAttributes x
-> UpdateVirtualInterfaceAttributes
forall x.
UpdateVirtualInterfaceAttributes
-> Rep UpdateVirtualInterfaceAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateVirtualInterfaceAttributes x
-> UpdateVirtualInterfaceAttributes
$cfrom :: forall x.
UpdateVirtualInterfaceAttributes
-> Rep UpdateVirtualInterfaceAttributes x
Prelude.Generic)

-- |
-- Create a value of 'UpdateVirtualInterfaceAttributes' 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:
--
-- 'mtu', 'updateVirtualInterfaceAttributes_mtu' - The maximum transmission unit (MTU), in bytes. The supported values are
-- 1500 and 9001. The default value is 1500.
--
-- 'virtualInterfaceId', 'updateVirtualInterfaceAttributes_virtualInterfaceId' - The ID of the virtual private interface.
newUpdateVirtualInterfaceAttributes ::
  -- | 'virtualInterfaceId'
  Prelude.Text ->
  UpdateVirtualInterfaceAttributes
newUpdateVirtualInterfaceAttributes :: Text -> UpdateVirtualInterfaceAttributes
newUpdateVirtualInterfaceAttributes
  Text
pVirtualInterfaceId_ =
    UpdateVirtualInterfaceAttributes' :: Maybe Int -> Text -> UpdateVirtualInterfaceAttributes
UpdateVirtualInterfaceAttributes'
      { $sel:mtu:UpdateVirtualInterfaceAttributes' :: Maybe Int
mtu =
          Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:virtualInterfaceId:UpdateVirtualInterfaceAttributes' :: Text
virtualInterfaceId = Text
pVirtualInterfaceId_
      }

-- | The maximum transmission unit (MTU), in bytes. The supported values are
-- 1500 and 9001. The default value is 1500.
updateVirtualInterfaceAttributes_mtu :: Lens.Lens' UpdateVirtualInterfaceAttributes (Prelude.Maybe Prelude.Int)
updateVirtualInterfaceAttributes_mtu :: (Maybe Int -> f (Maybe Int))
-> UpdateVirtualInterfaceAttributes
-> f UpdateVirtualInterfaceAttributes
updateVirtualInterfaceAttributes_mtu = (UpdateVirtualInterfaceAttributes -> Maybe Int)
-> (UpdateVirtualInterfaceAttributes
    -> Maybe Int -> UpdateVirtualInterfaceAttributes)
-> Lens
     UpdateVirtualInterfaceAttributes
     UpdateVirtualInterfaceAttributes
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVirtualInterfaceAttributes' {Maybe Int
mtu :: Maybe Int
$sel:mtu:UpdateVirtualInterfaceAttributes' :: UpdateVirtualInterfaceAttributes -> Maybe Int
mtu} -> Maybe Int
mtu) (\s :: UpdateVirtualInterfaceAttributes
s@UpdateVirtualInterfaceAttributes' {} Maybe Int
a -> UpdateVirtualInterfaceAttributes
s {$sel:mtu:UpdateVirtualInterfaceAttributes' :: Maybe Int
mtu = Maybe Int
a} :: UpdateVirtualInterfaceAttributes)

-- | The ID of the virtual private interface.
updateVirtualInterfaceAttributes_virtualInterfaceId :: Lens.Lens' UpdateVirtualInterfaceAttributes Prelude.Text
updateVirtualInterfaceAttributes_virtualInterfaceId :: (Text -> f Text)
-> UpdateVirtualInterfaceAttributes
-> f UpdateVirtualInterfaceAttributes
updateVirtualInterfaceAttributes_virtualInterfaceId = (UpdateVirtualInterfaceAttributes -> Text)
-> (UpdateVirtualInterfaceAttributes
    -> Text -> UpdateVirtualInterfaceAttributes)
-> Lens
     UpdateVirtualInterfaceAttributes
     UpdateVirtualInterfaceAttributes
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVirtualInterfaceAttributes' {Text
virtualInterfaceId :: Text
$sel:virtualInterfaceId:UpdateVirtualInterfaceAttributes' :: UpdateVirtualInterfaceAttributes -> Text
virtualInterfaceId} -> Text
virtualInterfaceId) (\s :: UpdateVirtualInterfaceAttributes
s@UpdateVirtualInterfaceAttributes' {} Text
a -> UpdateVirtualInterfaceAttributes
s {$sel:virtualInterfaceId:UpdateVirtualInterfaceAttributes' :: Text
virtualInterfaceId = Text
a} :: UpdateVirtualInterfaceAttributes)

instance
  Core.AWSRequest
    UpdateVirtualInterfaceAttributes
  where
  type
    AWSResponse UpdateVirtualInterfaceAttributes =
      VirtualInterface
  request :: UpdateVirtualInterfaceAttributes
-> Request UpdateVirtualInterfaceAttributes
request = Service
-> UpdateVirtualInterfaceAttributes
-> Request UpdateVirtualInterfaceAttributes
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateVirtualInterfaceAttributes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse UpdateVirtualInterfaceAttributes)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateVirtualInterfaceAttributes))
-> Logger
-> Service
-> Proxy UpdateVirtualInterfaceAttributes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse UpdateVirtualInterfaceAttributes)))
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 VirtualInterface
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance
  Prelude.Hashable
    UpdateVirtualInterfaceAttributes

instance
  Prelude.NFData
    UpdateVirtualInterfaceAttributes

instance
  Core.ToHeaders
    UpdateVirtualInterfaceAttributes
  where
  toHeaders :: UpdateVirtualInterfaceAttributes -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> UpdateVirtualInterfaceAttributes -> 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.UpdateVirtualInterfaceAttributes" ::
                          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 UpdateVirtualInterfaceAttributes where
  toJSON :: UpdateVirtualInterfaceAttributes -> Value
toJSON UpdateVirtualInterfaceAttributes' {Maybe Int
Text
virtualInterfaceId :: Text
mtu :: Maybe Int
$sel:virtualInterfaceId:UpdateVirtualInterfaceAttributes' :: UpdateVirtualInterfaceAttributes -> Text
$sel:mtu:UpdateVirtualInterfaceAttributes' :: UpdateVirtualInterfaceAttributes -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"mtu" 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
mtu,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"virtualInterfaceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
virtualInterfaceId)
          ]
      )

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

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