{-# 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.DeleteLag
-- 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)
--
-- Deletes the specified link aggregation group (LAG). You cannot delete a
-- LAG if it has active virtual interfaces or hosted connections.
module Amazonka.DirectConnect.DeleteLag
  ( -- * Creating a Request
    DeleteLag (..),
    newDeleteLag,

    -- * Request Lenses
    deleteLag_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:/ 'newDeleteLag' smart constructor.
data DeleteLag = DeleteLag'
  { -- | The ID of the LAG.
    DeleteLag -> Text
lagId :: Prelude.Text
  }
  deriving (DeleteLag -> DeleteLag -> Bool
(DeleteLag -> DeleteLag -> Bool)
-> (DeleteLag -> DeleteLag -> Bool) -> Eq DeleteLag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteLag -> DeleteLag -> Bool
$c/= :: DeleteLag -> DeleteLag -> Bool
== :: DeleteLag -> DeleteLag -> Bool
$c== :: DeleteLag -> DeleteLag -> Bool
Prelude.Eq, ReadPrec [DeleteLag]
ReadPrec DeleteLag
Int -> ReadS DeleteLag
ReadS [DeleteLag]
(Int -> ReadS DeleteLag)
-> ReadS [DeleteLag]
-> ReadPrec DeleteLag
-> ReadPrec [DeleteLag]
-> Read DeleteLag
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteLag]
$creadListPrec :: ReadPrec [DeleteLag]
readPrec :: ReadPrec DeleteLag
$creadPrec :: ReadPrec DeleteLag
readList :: ReadS [DeleteLag]
$creadList :: ReadS [DeleteLag]
readsPrec :: Int -> ReadS DeleteLag
$creadsPrec :: Int -> ReadS DeleteLag
Prelude.Read, Int -> DeleteLag -> ShowS
[DeleteLag] -> ShowS
DeleteLag -> String
(Int -> DeleteLag -> ShowS)
-> (DeleteLag -> String)
-> ([DeleteLag] -> ShowS)
-> Show DeleteLag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteLag] -> ShowS
$cshowList :: [DeleteLag] -> ShowS
show :: DeleteLag -> String
$cshow :: DeleteLag -> String
showsPrec :: Int -> DeleteLag -> ShowS
$cshowsPrec :: Int -> DeleteLag -> ShowS
Prelude.Show, (forall x. DeleteLag -> Rep DeleteLag x)
-> (forall x. Rep DeleteLag x -> DeleteLag) -> Generic DeleteLag
forall x. Rep DeleteLag x -> DeleteLag
forall x. DeleteLag -> Rep DeleteLag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteLag x -> DeleteLag
$cfrom :: forall x. DeleteLag -> Rep DeleteLag x
Prelude.Generic)

-- |
-- Create a value of 'DeleteLag' 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:
--
-- 'lagId', 'deleteLag_lagId' - The ID of the LAG.
newDeleteLag ::
  -- | 'lagId'
  Prelude.Text ->
  DeleteLag
newDeleteLag :: Text -> DeleteLag
newDeleteLag Text
pLagId_ = DeleteLag' :: Text -> DeleteLag
DeleteLag' {$sel:lagId:DeleteLag' :: Text
lagId = Text
pLagId_}

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

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

instance Prelude.NFData DeleteLag

instance Core.ToHeaders DeleteLag where
  toHeaders :: DeleteLag -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteLag -> 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.DeleteLag" :: 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 DeleteLag where
  toJSON :: DeleteLag -> Value
toJSON DeleteLag' {Text
lagId :: Text
$sel:lagId:DeleteLag' :: DeleteLag -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [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 DeleteLag where
  toPath :: DeleteLag -> ByteString
toPath = ByteString -> DeleteLag -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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