{-# 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.DisassociateMacSecKey
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes the association between a MAC Security (MACsec) security key and
-- an Direct Connect dedicated connection.
module Amazonka.DirectConnect.DisassociateMacSecKey
  ( -- * Creating a Request
    DisassociateMacSecKey (..),
    newDisassociateMacSecKey,

    -- * Request Lenses
    disassociateMacSecKey_connectionId,
    disassociateMacSecKey_secretARN,

    -- * Destructuring the Response
    DisassociateMacSecKeyResponse (..),
    newDisassociateMacSecKeyResponse,

    -- * Response Lenses
    disassociateMacSecKeyResponse_connectionId,
    disassociateMacSecKeyResponse_macSecKeys,
    disassociateMacSecKeyResponse_httpStatus,
  )
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:/ 'newDisassociateMacSecKey' smart constructor.
data DisassociateMacSecKey = DisassociateMacSecKey'
  { -- | The ID of the dedicated connection (dxcon-xxxx), or the ID of the LAG
    -- (dxlag-xxxx).
    --
    -- You can use DescribeConnections or DescribeLags to retrieve connection
    -- ID.
    DisassociateMacSecKey -> Text
connectionId :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the MAC Security (MACsec) secret key.
    --
    -- You can use DescribeConnections to retrieve the ARN of the MAC Security
    -- (MACsec) secret key.
    DisassociateMacSecKey -> Text
secretARN :: Prelude.Text
  }
  deriving (DisassociateMacSecKey -> DisassociateMacSecKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateMacSecKey -> DisassociateMacSecKey -> Bool
$c/= :: DisassociateMacSecKey -> DisassociateMacSecKey -> Bool
== :: DisassociateMacSecKey -> DisassociateMacSecKey -> Bool
$c== :: DisassociateMacSecKey -> DisassociateMacSecKey -> Bool
Prelude.Eq, ReadPrec [DisassociateMacSecKey]
ReadPrec DisassociateMacSecKey
Int -> ReadS DisassociateMacSecKey
ReadS [DisassociateMacSecKey]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateMacSecKey]
$creadListPrec :: ReadPrec [DisassociateMacSecKey]
readPrec :: ReadPrec DisassociateMacSecKey
$creadPrec :: ReadPrec DisassociateMacSecKey
readList :: ReadS [DisassociateMacSecKey]
$creadList :: ReadS [DisassociateMacSecKey]
readsPrec :: Int -> ReadS DisassociateMacSecKey
$creadsPrec :: Int -> ReadS DisassociateMacSecKey
Prelude.Read, Int -> DisassociateMacSecKey -> ShowS
[DisassociateMacSecKey] -> ShowS
DisassociateMacSecKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateMacSecKey] -> ShowS
$cshowList :: [DisassociateMacSecKey] -> ShowS
show :: DisassociateMacSecKey -> String
$cshow :: DisassociateMacSecKey -> String
showsPrec :: Int -> DisassociateMacSecKey -> ShowS
$cshowsPrec :: Int -> DisassociateMacSecKey -> ShowS
Prelude.Show, forall x. Rep DisassociateMacSecKey x -> DisassociateMacSecKey
forall x. DisassociateMacSecKey -> Rep DisassociateMacSecKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateMacSecKey x -> DisassociateMacSecKey
$cfrom :: forall x. DisassociateMacSecKey -> Rep DisassociateMacSecKey x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateMacSecKey' 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:
--
-- 'connectionId', 'disassociateMacSecKey_connectionId' - The ID of the dedicated connection (dxcon-xxxx), or the ID of the LAG
-- (dxlag-xxxx).
--
-- You can use DescribeConnections or DescribeLags to retrieve connection
-- ID.
--
-- 'secretARN', 'disassociateMacSecKey_secretARN' - The Amazon Resource Name (ARN) of the MAC Security (MACsec) secret key.
--
-- You can use DescribeConnections to retrieve the ARN of the MAC Security
-- (MACsec) secret key.
newDisassociateMacSecKey ::
  -- | 'connectionId'
  Prelude.Text ->
  -- | 'secretARN'
  Prelude.Text ->
  DisassociateMacSecKey
newDisassociateMacSecKey :: Text -> Text -> DisassociateMacSecKey
newDisassociateMacSecKey Text
pConnectionId_ Text
pSecretARN_ =
  DisassociateMacSecKey'
    { $sel:connectionId:DisassociateMacSecKey' :: Text
connectionId =
        Text
pConnectionId_,
      $sel:secretARN:DisassociateMacSecKey' :: Text
secretARN = Text
pSecretARN_
    }

-- | The ID of the dedicated connection (dxcon-xxxx), or the ID of the LAG
-- (dxlag-xxxx).
--
-- You can use DescribeConnections or DescribeLags to retrieve connection
-- ID.
disassociateMacSecKey_connectionId :: Lens.Lens' DisassociateMacSecKey Prelude.Text
disassociateMacSecKey_connectionId :: Lens' DisassociateMacSecKey Text
disassociateMacSecKey_connectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateMacSecKey' {Text
connectionId :: Text
$sel:connectionId:DisassociateMacSecKey' :: DisassociateMacSecKey -> Text
connectionId} -> Text
connectionId) (\s :: DisassociateMacSecKey
s@DisassociateMacSecKey' {} Text
a -> DisassociateMacSecKey
s {$sel:connectionId:DisassociateMacSecKey' :: Text
connectionId = Text
a} :: DisassociateMacSecKey)

-- | The Amazon Resource Name (ARN) of the MAC Security (MACsec) secret key.
--
-- You can use DescribeConnections to retrieve the ARN of the MAC Security
-- (MACsec) secret key.
disassociateMacSecKey_secretARN :: Lens.Lens' DisassociateMacSecKey Prelude.Text
disassociateMacSecKey_secretARN :: Lens' DisassociateMacSecKey Text
disassociateMacSecKey_secretARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateMacSecKey' {Text
secretARN :: Text
$sel:secretARN:DisassociateMacSecKey' :: DisassociateMacSecKey -> Text
secretARN} -> Text
secretARN) (\s :: DisassociateMacSecKey
s@DisassociateMacSecKey' {} Text
a -> DisassociateMacSecKey
s {$sel:secretARN:DisassociateMacSecKey' :: Text
secretARN = Text
a} :: DisassociateMacSecKey)

instance Core.AWSRequest DisassociateMacSecKey where
  type
    AWSResponse DisassociateMacSecKey =
      DisassociateMacSecKeyResponse
  request :: (Service -> Service)
-> DisassociateMacSecKey -> Request DisassociateMacSecKey
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 DisassociateMacSecKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateMacSecKey)))
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 ->
          Maybe Text
-> Maybe [MacSecKey] -> Int -> DisassociateMacSecKeyResponse
DisassociateMacSecKeyResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"connectionId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"macSecKeys" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DisassociateMacSecKey where
  hashWithSalt :: Int -> DisassociateMacSecKey -> Int
hashWithSalt Int
_salt DisassociateMacSecKey' {Text
secretARN :: Text
connectionId :: Text
$sel:secretARN:DisassociateMacSecKey' :: DisassociateMacSecKey -> Text
$sel:connectionId:DisassociateMacSecKey' :: DisassociateMacSecKey -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
secretARN

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

instance Data.ToHeaders DisassociateMacSecKey where
  toHeaders :: DisassociateMacSecKey -> 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.DisassociateMacSecKey" ::
                          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 DisassociateMacSecKey where
  toJSON :: DisassociateMacSecKey -> Value
toJSON DisassociateMacSecKey' {Text
secretARN :: Text
connectionId :: Text
$sel:secretARN:DisassociateMacSecKey' :: DisassociateMacSecKey -> Text
$sel:connectionId:DisassociateMacSecKey' :: DisassociateMacSecKey -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"connectionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
connectionId),
            forall a. a -> Maybe a
Prelude.Just (Key
"secretARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
secretARN)
          ]
      )

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

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

-- | /See:/ 'newDisassociateMacSecKeyResponse' smart constructor.
data DisassociateMacSecKeyResponse = DisassociateMacSecKeyResponse'
  { -- | The ID of the dedicated connection (dxcon-xxxx), or the ID of the LAG
    -- (dxlag-xxxx).
    DisassociateMacSecKeyResponse -> Maybe Text
connectionId :: Prelude.Maybe Prelude.Text,
    -- | The MAC Security (MACsec) security keys no longer associated with the
    -- dedicated connection.
    DisassociateMacSecKeyResponse -> Maybe [MacSecKey]
macSecKeys :: Prelude.Maybe [MacSecKey],
    -- | The response's http status code.
    DisassociateMacSecKeyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DisassociateMacSecKeyResponse
-> DisassociateMacSecKeyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateMacSecKeyResponse
-> DisassociateMacSecKeyResponse -> Bool
$c/= :: DisassociateMacSecKeyResponse
-> DisassociateMacSecKeyResponse -> Bool
== :: DisassociateMacSecKeyResponse
-> DisassociateMacSecKeyResponse -> Bool
$c== :: DisassociateMacSecKeyResponse
-> DisassociateMacSecKeyResponse -> Bool
Prelude.Eq, ReadPrec [DisassociateMacSecKeyResponse]
ReadPrec DisassociateMacSecKeyResponse
Int -> ReadS DisassociateMacSecKeyResponse
ReadS [DisassociateMacSecKeyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateMacSecKeyResponse]
$creadListPrec :: ReadPrec [DisassociateMacSecKeyResponse]
readPrec :: ReadPrec DisassociateMacSecKeyResponse
$creadPrec :: ReadPrec DisassociateMacSecKeyResponse
readList :: ReadS [DisassociateMacSecKeyResponse]
$creadList :: ReadS [DisassociateMacSecKeyResponse]
readsPrec :: Int -> ReadS DisassociateMacSecKeyResponse
$creadsPrec :: Int -> ReadS DisassociateMacSecKeyResponse
Prelude.Read, Int -> DisassociateMacSecKeyResponse -> ShowS
[DisassociateMacSecKeyResponse] -> ShowS
DisassociateMacSecKeyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateMacSecKeyResponse] -> ShowS
$cshowList :: [DisassociateMacSecKeyResponse] -> ShowS
show :: DisassociateMacSecKeyResponse -> String
$cshow :: DisassociateMacSecKeyResponse -> String
showsPrec :: Int -> DisassociateMacSecKeyResponse -> ShowS
$cshowsPrec :: Int -> DisassociateMacSecKeyResponse -> ShowS
Prelude.Show, forall x.
Rep DisassociateMacSecKeyResponse x
-> DisassociateMacSecKeyResponse
forall x.
DisassociateMacSecKeyResponse
-> Rep DisassociateMacSecKeyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateMacSecKeyResponse x
-> DisassociateMacSecKeyResponse
$cfrom :: forall x.
DisassociateMacSecKeyResponse
-> Rep DisassociateMacSecKeyResponse x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateMacSecKeyResponse' 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:
--
-- 'connectionId', 'disassociateMacSecKeyResponse_connectionId' - The ID of the dedicated connection (dxcon-xxxx), or the ID of the LAG
-- (dxlag-xxxx).
--
-- 'macSecKeys', 'disassociateMacSecKeyResponse_macSecKeys' - The MAC Security (MACsec) security keys no longer associated with the
-- dedicated connection.
--
-- 'httpStatus', 'disassociateMacSecKeyResponse_httpStatus' - The response's http status code.
newDisassociateMacSecKeyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateMacSecKeyResponse
newDisassociateMacSecKeyResponse :: Int -> DisassociateMacSecKeyResponse
newDisassociateMacSecKeyResponse Int
pHttpStatus_ =
  DisassociateMacSecKeyResponse'
    { $sel:connectionId:DisassociateMacSecKeyResponse' :: Maybe Text
connectionId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:macSecKeys:DisassociateMacSecKeyResponse' :: Maybe [MacSecKey]
macSecKeys = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisassociateMacSecKeyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ID of the dedicated connection (dxcon-xxxx), or the ID of the LAG
-- (dxlag-xxxx).
disassociateMacSecKeyResponse_connectionId :: Lens.Lens' DisassociateMacSecKeyResponse (Prelude.Maybe Prelude.Text)
disassociateMacSecKeyResponse_connectionId :: Lens' DisassociateMacSecKeyResponse (Maybe Text)
disassociateMacSecKeyResponse_connectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateMacSecKeyResponse' {Maybe Text
connectionId :: Maybe Text
$sel:connectionId:DisassociateMacSecKeyResponse' :: DisassociateMacSecKeyResponse -> Maybe Text
connectionId} -> Maybe Text
connectionId) (\s :: DisassociateMacSecKeyResponse
s@DisassociateMacSecKeyResponse' {} Maybe Text
a -> DisassociateMacSecKeyResponse
s {$sel:connectionId:DisassociateMacSecKeyResponse' :: Maybe Text
connectionId = Maybe Text
a} :: DisassociateMacSecKeyResponse)

-- | The MAC Security (MACsec) security keys no longer associated with the
-- dedicated connection.
disassociateMacSecKeyResponse_macSecKeys :: Lens.Lens' DisassociateMacSecKeyResponse (Prelude.Maybe [MacSecKey])
disassociateMacSecKeyResponse_macSecKeys :: Lens' DisassociateMacSecKeyResponse (Maybe [MacSecKey])
disassociateMacSecKeyResponse_macSecKeys = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateMacSecKeyResponse' {Maybe [MacSecKey]
macSecKeys :: Maybe [MacSecKey]
$sel:macSecKeys:DisassociateMacSecKeyResponse' :: DisassociateMacSecKeyResponse -> Maybe [MacSecKey]
macSecKeys} -> Maybe [MacSecKey]
macSecKeys) (\s :: DisassociateMacSecKeyResponse
s@DisassociateMacSecKeyResponse' {} Maybe [MacSecKey]
a -> DisassociateMacSecKeyResponse
s {$sel:macSecKeys:DisassociateMacSecKeyResponse' :: Maybe [MacSecKey]
macSecKeys = Maybe [MacSecKey]
a} :: DisassociateMacSecKeyResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
disassociateMacSecKeyResponse_httpStatus :: Lens.Lens' DisassociateMacSecKeyResponse Prelude.Int
disassociateMacSecKeyResponse_httpStatus :: Lens' DisassociateMacSecKeyResponse Int
disassociateMacSecKeyResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateMacSecKeyResponse' {Int
httpStatus :: Int
$sel:httpStatus:DisassociateMacSecKeyResponse' :: DisassociateMacSecKeyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DisassociateMacSecKeyResponse
s@DisassociateMacSecKeyResponse' {} Int
a -> DisassociateMacSecKeyResponse
s {$sel:httpStatus:DisassociateMacSecKeyResponse' :: Int
httpStatus = Int
a} :: DisassociateMacSecKeyResponse)

instance Prelude.NFData DisassociateMacSecKeyResponse where
  rnf :: DisassociateMacSecKeyResponse -> ()
rnf DisassociateMacSecKeyResponse' {Int
Maybe [MacSecKey]
Maybe Text
httpStatus :: Int
macSecKeys :: Maybe [MacSecKey]
connectionId :: Maybe Text
$sel:httpStatus:DisassociateMacSecKeyResponse' :: DisassociateMacSecKeyResponse -> Int
$sel:macSecKeys:DisassociateMacSecKeyResponse' :: DisassociateMacSecKeyResponse -> Maybe [MacSecKey]
$sel:connectionId:DisassociateMacSecKeyResponse' :: DisassociateMacSecKeyResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [MacSecKey]
macSecKeys
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus