{-# 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.EC2.CreateTrafficMirrorSession
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a Traffic Mirror session.
--
-- A Traffic Mirror session actively copies packets from a Traffic Mirror
-- source to a Traffic Mirror target. Create a filter, and then assign it
-- to the session to define a subset of the traffic to mirror, for example
-- all TCP traffic.
--
-- The Traffic Mirror source and the Traffic Mirror target (monitoring
-- appliances) can be in the same VPC, or in a different VPC connected via
-- VPC peering or a transit gateway.
--
-- By default, no traffic is mirrored. Use
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateTrafficMirrorFilter.htm CreateTrafficMirrorFilter>
-- to create filter rules that specify the traffic to mirror.
module Amazonka.EC2.CreateTrafficMirrorSession
  ( -- * Creating a Request
    CreateTrafficMirrorSession (..),
    newCreateTrafficMirrorSession,

    -- * Request Lenses
    createTrafficMirrorSession_clientToken,
    createTrafficMirrorSession_description,
    createTrafficMirrorSession_dryRun,
    createTrafficMirrorSession_packetLength,
    createTrafficMirrorSession_tagSpecifications,
    createTrafficMirrorSession_virtualNetworkId,
    createTrafficMirrorSession_networkInterfaceId,
    createTrafficMirrorSession_trafficMirrorTargetId,
    createTrafficMirrorSession_trafficMirrorFilterId,
    createTrafficMirrorSession_sessionNumber,

    -- * Destructuring the Response
    CreateTrafficMirrorSessionResponse (..),
    newCreateTrafficMirrorSessionResponse,

    -- * Response Lenses
    createTrafficMirrorSessionResponse_clientToken,
    createTrafficMirrorSessionResponse_trafficMirrorSession,
    createTrafficMirrorSessionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateTrafficMirrorSession' smart constructor.
data CreateTrafficMirrorSession = CreateTrafficMirrorSession'
  { -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request. For more information, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html How to ensure idempotency>.
    CreateTrafficMirrorSession -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The description of the Traffic Mirror session.
    CreateTrafficMirrorSession -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Checks whether you have the required permissions for the action, without
    -- actually making the request, and provides an error response. If you have
    -- the required permissions, the error response is @DryRunOperation@.
    -- Otherwise, it is @UnauthorizedOperation@.
    CreateTrafficMirrorSession -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The number of bytes in each packet to mirror. These are bytes after the
    -- VXLAN header. Do not specify this parameter when you want to mirror the
    -- entire packet. To mirror a subset of the packet, set this to the length
    -- (in bytes) that you want to mirror. For example, if you set this value
    -- to 100, then the first 100 bytes that meet the filter criteria are
    -- copied to the target.
    --
    -- If you do not want to mirror the entire packet, use the @PacketLength@
    -- parameter to specify the number of bytes in each packet to mirror.
    CreateTrafficMirrorSession -> Maybe Int
packetLength :: Prelude.Maybe Prelude.Int,
    -- | The tags to assign to a Traffic Mirror session.
    CreateTrafficMirrorSession -> Maybe [TagSpecification]
tagSpecifications :: Prelude.Maybe [TagSpecification],
    -- | The VXLAN ID for the Traffic Mirror session. For more information about
    -- the VXLAN protocol, see <https://tools.ietf.org/html/rfc7348 RFC 7348>.
    -- If you do not specify a @VirtualNetworkId@, an account-wide unique id is
    -- chosen at random.
    CreateTrafficMirrorSession -> Maybe Int
virtualNetworkId :: Prelude.Maybe Prelude.Int,
    -- | The ID of the source network interface.
    CreateTrafficMirrorSession -> Text
networkInterfaceId :: Prelude.Text,
    -- | The ID of the Traffic Mirror target.
    CreateTrafficMirrorSession -> Text
trafficMirrorTargetId :: Prelude.Text,
    -- | The ID of the Traffic Mirror filter.
    CreateTrafficMirrorSession -> Text
trafficMirrorFilterId :: Prelude.Text,
    -- | The session number determines the order in which sessions are evaluated
    -- when an interface is used by multiple sessions. The first session with a
    -- matching filter is the one that mirrors the packets.
    --
    -- Valid values are 1-32766.
    CreateTrafficMirrorSession -> Int
sessionNumber :: Prelude.Int
  }
  deriving (CreateTrafficMirrorSession -> CreateTrafficMirrorSession -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTrafficMirrorSession -> CreateTrafficMirrorSession -> Bool
$c/= :: CreateTrafficMirrorSession -> CreateTrafficMirrorSession -> Bool
== :: CreateTrafficMirrorSession -> CreateTrafficMirrorSession -> Bool
$c== :: CreateTrafficMirrorSession -> CreateTrafficMirrorSession -> Bool
Prelude.Eq, ReadPrec [CreateTrafficMirrorSession]
ReadPrec CreateTrafficMirrorSession
Int -> ReadS CreateTrafficMirrorSession
ReadS [CreateTrafficMirrorSession]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTrafficMirrorSession]
$creadListPrec :: ReadPrec [CreateTrafficMirrorSession]
readPrec :: ReadPrec CreateTrafficMirrorSession
$creadPrec :: ReadPrec CreateTrafficMirrorSession
readList :: ReadS [CreateTrafficMirrorSession]
$creadList :: ReadS [CreateTrafficMirrorSession]
readsPrec :: Int -> ReadS CreateTrafficMirrorSession
$creadsPrec :: Int -> ReadS CreateTrafficMirrorSession
Prelude.Read, Int -> CreateTrafficMirrorSession -> ShowS
[CreateTrafficMirrorSession] -> ShowS
CreateTrafficMirrorSession -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTrafficMirrorSession] -> ShowS
$cshowList :: [CreateTrafficMirrorSession] -> ShowS
show :: CreateTrafficMirrorSession -> String
$cshow :: CreateTrafficMirrorSession -> String
showsPrec :: Int -> CreateTrafficMirrorSession -> ShowS
$cshowsPrec :: Int -> CreateTrafficMirrorSession -> ShowS
Prelude.Show, forall x.
Rep CreateTrafficMirrorSession x -> CreateTrafficMirrorSession
forall x.
CreateTrafficMirrorSession -> Rep CreateTrafficMirrorSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateTrafficMirrorSession x -> CreateTrafficMirrorSession
$cfrom :: forall x.
CreateTrafficMirrorSession -> Rep CreateTrafficMirrorSession x
Prelude.Generic)

-- |
-- Create a value of 'CreateTrafficMirrorSession' 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:
--
-- 'clientToken', 'createTrafficMirrorSession_clientToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html How to ensure idempotency>.
--
-- 'description', 'createTrafficMirrorSession_description' - The description of the Traffic Mirror session.
--
-- 'dryRun', 'createTrafficMirrorSession_dryRun' - Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
--
-- 'packetLength', 'createTrafficMirrorSession_packetLength' - The number of bytes in each packet to mirror. These are bytes after the
-- VXLAN header. Do not specify this parameter when you want to mirror the
-- entire packet. To mirror a subset of the packet, set this to the length
-- (in bytes) that you want to mirror. For example, if you set this value
-- to 100, then the first 100 bytes that meet the filter criteria are
-- copied to the target.
--
-- If you do not want to mirror the entire packet, use the @PacketLength@
-- parameter to specify the number of bytes in each packet to mirror.
--
-- 'tagSpecifications', 'createTrafficMirrorSession_tagSpecifications' - The tags to assign to a Traffic Mirror session.
--
-- 'virtualNetworkId', 'createTrafficMirrorSession_virtualNetworkId' - The VXLAN ID for the Traffic Mirror session. For more information about
-- the VXLAN protocol, see <https://tools.ietf.org/html/rfc7348 RFC 7348>.
-- If you do not specify a @VirtualNetworkId@, an account-wide unique id is
-- chosen at random.
--
-- 'networkInterfaceId', 'createTrafficMirrorSession_networkInterfaceId' - The ID of the source network interface.
--
-- 'trafficMirrorTargetId', 'createTrafficMirrorSession_trafficMirrorTargetId' - The ID of the Traffic Mirror target.
--
-- 'trafficMirrorFilterId', 'createTrafficMirrorSession_trafficMirrorFilterId' - The ID of the Traffic Mirror filter.
--
-- 'sessionNumber', 'createTrafficMirrorSession_sessionNumber' - The session number determines the order in which sessions are evaluated
-- when an interface is used by multiple sessions. The first session with a
-- matching filter is the one that mirrors the packets.
--
-- Valid values are 1-32766.
newCreateTrafficMirrorSession ::
  -- | 'networkInterfaceId'
  Prelude.Text ->
  -- | 'trafficMirrorTargetId'
  Prelude.Text ->
  -- | 'trafficMirrorFilterId'
  Prelude.Text ->
  -- | 'sessionNumber'
  Prelude.Int ->
  CreateTrafficMirrorSession
newCreateTrafficMirrorSession :: Text -> Text -> Text -> Int -> CreateTrafficMirrorSession
newCreateTrafficMirrorSession
  Text
pNetworkInterfaceId_
  Text
pTrafficMirrorTargetId_
  Text
pTrafficMirrorFilterId_
  Int
pSessionNumber_ =
    CreateTrafficMirrorSession'
      { $sel:clientToken:CreateTrafficMirrorSession' :: Maybe Text
clientToken =
          forall a. Maybe a
Prelude.Nothing,
        $sel:description:CreateTrafficMirrorSession' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
        $sel:dryRun:CreateTrafficMirrorSession' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
        $sel:packetLength:CreateTrafficMirrorSession' :: Maybe Int
packetLength = forall a. Maybe a
Prelude.Nothing,
        $sel:tagSpecifications:CreateTrafficMirrorSession' :: Maybe [TagSpecification]
tagSpecifications = forall a. Maybe a
Prelude.Nothing,
        $sel:virtualNetworkId:CreateTrafficMirrorSession' :: Maybe Int
virtualNetworkId = forall a. Maybe a
Prelude.Nothing,
        $sel:networkInterfaceId:CreateTrafficMirrorSession' :: Text
networkInterfaceId = Text
pNetworkInterfaceId_,
        $sel:trafficMirrorTargetId:CreateTrafficMirrorSession' :: Text
trafficMirrorTargetId = Text
pTrafficMirrorTargetId_,
        $sel:trafficMirrorFilterId:CreateTrafficMirrorSession' :: Text
trafficMirrorFilterId = Text
pTrafficMirrorFilterId_,
        $sel:sessionNumber:CreateTrafficMirrorSession' :: Int
sessionNumber = Int
pSessionNumber_
      }

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html How to ensure idempotency>.
createTrafficMirrorSession_clientToken :: Lens.Lens' CreateTrafficMirrorSession (Prelude.Maybe Prelude.Text)
createTrafficMirrorSession_clientToken :: Lens' CreateTrafficMirrorSession (Maybe Text)
createTrafficMirrorSession_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrafficMirrorSession' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateTrafficMirrorSession
s@CreateTrafficMirrorSession' {} Maybe Text
a -> CreateTrafficMirrorSession
s {$sel:clientToken:CreateTrafficMirrorSession' :: Maybe Text
clientToken = Maybe Text
a} :: CreateTrafficMirrorSession)

-- | The description of the Traffic Mirror session.
createTrafficMirrorSession_description :: Lens.Lens' CreateTrafficMirrorSession (Prelude.Maybe Prelude.Text)
createTrafficMirrorSession_description :: Lens' CreateTrafficMirrorSession (Maybe Text)
createTrafficMirrorSession_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrafficMirrorSession' {Maybe Text
description :: Maybe Text
$sel:description:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateTrafficMirrorSession
s@CreateTrafficMirrorSession' {} Maybe Text
a -> CreateTrafficMirrorSession
s {$sel:description:CreateTrafficMirrorSession' :: Maybe Text
description = Maybe Text
a} :: CreateTrafficMirrorSession)

-- | Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
createTrafficMirrorSession_dryRun :: Lens.Lens' CreateTrafficMirrorSession (Prelude.Maybe Prelude.Bool)
createTrafficMirrorSession_dryRun :: Lens' CreateTrafficMirrorSession (Maybe Bool)
createTrafficMirrorSession_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrafficMirrorSession' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: CreateTrafficMirrorSession
s@CreateTrafficMirrorSession' {} Maybe Bool
a -> CreateTrafficMirrorSession
s {$sel:dryRun:CreateTrafficMirrorSession' :: Maybe Bool
dryRun = Maybe Bool
a} :: CreateTrafficMirrorSession)

-- | The number of bytes in each packet to mirror. These are bytes after the
-- VXLAN header. Do not specify this parameter when you want to mirror the
-- entire packet. To mirror a subset of the packet, set this to the length
-- (in bytes) that you want to mirror. For example, if you set this value
-- to 100, then the first 100 bytes that meet the filter criteria are
-- copied to the target.
--
-- If you do not want to mirror the entire packet, use the @PacketLength@
-- parameter to specify the number of bytes in each packet to mirror.
createTrafficMirrorSession_packetLength :: Lens.Lens' CreateTrafficMirrorSession (Prelude.Maybe Prelude.Int)
createTrafficMirrorSession_packetLength :: Lens' CreateTrafficMirrorSession (Maybe Int)
createTrafficMirrorSession_packetLength = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrafficMirrorSession' {Maybe Int
packetLength :: Maybe Int
$sel:packetLength:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Int
packetLength} -> Maybe Int
packetLength) (\s :: CreateTrafficMirrorSession
s@CreateTrafficMirrorSession' {} Maybe Int
a -> CreateTrafficMirrorSession
s {$sel:packetLength:CreateTrafficMirrorSession' :: Maybe Int
packetLength = Maybe Int
a} :: CreateTrafficMirrorSession)

-- | The tags to assign to a Traffic Mirror session.
createTrafficMirrorSession_tagSpecifications :: Lens.Lens' CreateTrafficMirrorSession (Prelude.Maybe [TagSpecification])
createTrafficMirrorSession_tagSpecifications :: Lens' CreateTrafficMirrorSession (Maybe [TagSpecification])
createTrafficMirrorSession_tagSpecifications = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrafficMirrorSession' {Maybe [TagSpecification]
tagSpecifications :: Maybe [TagSpecification]
$sel:tagSpecifications:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe [TagSpecification]
tagSpecifications} -> Maybe [TagSpecification]
tagSpecifications) (\s :: CreateTrafficMirrorSession
s@CreateTrafficMirrorSession' {} Maybe [TagSpecification]
a -> CreateTrafficMirrorSession
s {$sel:tagSpecifications:CreateTrafficMirrorSession' :: Maybe [TagSpecification]
tagSpecifications = Maybe [TagSpecification]
a} :: CreateTrafficMirrorSession) 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 VXLAN ID for the Traffic Mirror session. For more information about
-- the VXLAN protocol, see <https://tools.ietf.org/html/rfc7348 RFC 7348>.
-- If you do not specify a @VirtualNetworkId@, an account-wide unique id is
-- chosen at random.
createTrafficMirrorSession_virtualNetworkId :: Lens.Lens' CreateTrafficMirrorSession (Prelude.Maybe Prelude.Int)
createTrafficMirrorSession_virtualNetworkId :: Lens' CreateTrafficMirrorSession (Maybe Int)
createTrafficMirrorSession_virtualNetworkId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrafficMirrorSession' {Maybe Int
virtualNetworkId :: Maybe Int
$sel:virtualNetworkId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Int
virtualNetworkId} -> Maybe Int
virtualNetworkId) (\s :: CreateTrafficMirrorSession
s@CreateTrafficMirrorSession' {} Maybe Int
a -> CreateTrafficMirrorSession
s {$sel:virtualNetworkId:CreateTrafficMirrorSession' :: Maybe Int
virtualNetworkId = Maybe Int
a} :: CreateTrafficMirrorSession)

-- | The ID of the source network interface.
createTrafficMirrorSession_networkInterfaceId :: Lens.Lens' CreateTrafficMirrorSession Prelude.Text
createTrafficMirrorSession_networkInterfaceId :: Lens' CreateTrafficMirrorSession Text
createTrafficMirrorSession_networkInterfaceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrafficMirrorSession' {Text
networkInterfaceId :: Text
$sel:networkInterfaceId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Text
networkInterfaceId} -> Text
networkInterfaceId) (\s :: CreateTrafficMirrorSession
s@CreateTrafficMirrorSession' {} Text
a -> CreateTrafficMirrorSession
s {$sel:networkInterfaceId:CreateTrafficMirrorSession' :: Text
networkInterfaceId = Text
a} :: CreateTrafficMirrorSession)

-- | The ID of the Traffic Mirror target.
createTrafficMirrorSession_trafficMirrorTargetId :: Lens.Lens' CreateTrafficMirrorSession Prelude.Text
createTrafficMirrorSession_trafficMirrorTargetId :: Lens' CreateTrafficMirrorSession Text
createTrafficMirrorSession_trafficMirrorTargetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrafficMirrorSession' {Text
trafficMirrorTargetId :: Text
$sel:trafficMirrorTargetId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Text
trafficMirrorTargetId} -> Text
trafficMirrorTargetId) (\s :: CreateTrafficMirrorSession
s@CreateTrafficMirrorSession' {} Text
a -> CreateTrafficMirrorSession
s {$sel:trafficMirrorTargetId:CreateTrafficMirrorSession' :: Text
trafficMirrorTargetId = Text
a} :: CreateTrafficMirrorSession)

-- | The ID of the Traffic Mirror filter.
createTrafficMirrorSession_trafficMirrorFilterId :: Lens.Lens' CreateTrafficMirrorSession Prelude.Text
createTrafficMirrorSession_trafficMirrorFilterId :: Lens' CreateTrafficMirrorSession Text
createTrafficMirrorSession_trafficMirrorFilterId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrafficMirrorSession' {Text
trafficMirrorFilterId :: Text
$sel:trafficMirrorFilterId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Text
trafficMirrorFilterId} -> Text
trafficMirrorFilterId) (\s :: CreateTrafficMirrorSession
s@CreateTrafficMirrorSession' {} Text
a -> CreateTrafficMirrorSession
s {$sel:trafficMirrorFilterId:CreateTrafficMirrorSession' :: Text
trafficMirrorFilterId = Text
a} :: CreateTrafficMirrorSession)

-- | The session number determines the order in which sessions are evaluated
-- when an interface is used by multiple sessions. The first session with a
-- matching filter is the one that mirrors the packets.
--
-- Valid values are 1-32766.
createTrafficMirrorSession_sessionNumber :: Lens.Lens' CreateTrafficMirrorSession Prelude.Int
createTrafficMirrorSession_sessionNumber :: Lens' CreateTrafficMirrorSession Int
createTrafficMirrorSession_sessionNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrafficMirrorSession' {Int
sessionNumber :: Int
$sel:sessionNumber:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Int
sessionNumber} -> Int
sessionNumber) (\s :: CreateTrafficMirrorSession
s@CreateTrafficMirrorSession' {} Int
a -> CreateTrafficMirrorSession
s {$sel:sessionNumber:CreateTrafficMirrorSession' :: Int
sessionNumber = Int
a} :: CreateTrafficMirrorSession)

instance Core.AWSRequest CreateTrafficMirrorSession where
  type
    AWSResponse CreateTrafficMirrorSession =
      CreateTrafficMirrorSessionResponse
  request :: (Service -> Service)
-> CreateTrafficMirrorSession -> Request CreateTrafficMirrorSession
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateTrafficMirrorSession
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateTrafficMirrorSession)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text
-> Maybe TrafficMirrorSession
-> Int
-> CreateTrafficMirrorSessionResponse
CreateTrafficMirrorSessionResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"clientToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"trafficMirrorSession")
            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 CreateTrafficMirrorSession where
  hashWithSalt :: Int -> CreateTrafficMirrorSession -> Int
hashWithSalt Int
_salt CreateTrafficMirrorSession' {Int
Maybe Bool
Maybe Int
Maybe [TagSpecification]
Maybe Text
Text
sessionNumber :: Int
trafficMirrorFilterId :: Text
trafficMirrorTargetId :: Text
networkInterfaceId :: Text
virtualNetworkId :: Maybe Int
tagSpecifications :: Maybe [TagSpecification]
packetLength :: Maybe Int
dryRun :: Maybe Bool
description :: Maybe Text
clientToken :: Maybe Text
$sel:sessionNumber:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Int
$sel:trafficMirrorFilterId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Text
$sel:trafficMirrorTargetId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Text
$sel:networkInterfaceId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Text
$sel:virtualNetworkId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Int
$sel:tagSpecifications:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe [TagSpecification]
$sel:packetLength:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Int
$sel:dryRun:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Bool
$sel:description:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Text
$sel:clientToken:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
packetLength
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [TagSpecification]
tagSpecifications
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
virtualNetworkId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
networkInterfaceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
trafficMirrorTargetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
trafficMirrorFilterId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
sessionNumber

instance Prelude.NFData CreateTrafficMirrorSession where
  rnf :: CreateTrafficMirrorSession -> ()
rnf CreateTrafficMirrorSession' {Int
Maybe Bool
Maybe Int
Maybe [TagSpecification]
Maybe Text
Text
sessionNumber :: Int
trafficMirrorFilterId :: Text
trafficMirrorTargetId :: Text
networkInterfaceId :: Text
virtualNetworkId :: Maybe Int
tagSpecifications :: Maybe [TagSpecification]
packetLength :: Maybe Int
dryRun :: Maybe Bool
description :: Maybe Text
clientToken :: Maybe Text
$sel:sessionNumber:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Int
$sel:trafficMirrorFilterId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Text
$sel:trafficMirrorTargetId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Text
$sel:networkInterfaceId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Text
$sel:virtualNetworkId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Int
$sel:tagSpecifications:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe [TagSpecification]
$sel:packetLength:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Int
$sel:dryRun:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Bool
$sel:description:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Text
$sel:clientToken:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
packetLength
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [TagSpecification]
tagSpecifications
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
virtualNetworkId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
networkInterfaceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
trafficMirrorTargetId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
trafficMirrorFilterId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
sessionNumber

instance Data.ToHeaders CreateTrafficMirrorSession where
  toHeaders :: CreateTrafficMirrorSession -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery CreateTrafficMirrorSession where
  toQuery :: CreateTrafficMirrorSession -> QueryString
toQuery CreateTrafficMirrorSession' {Int
Maybe Bool
Maybe Int
Maybe [TagSpecification]
Maybe Text
Text
sessionNumber :: Int
trafficMirrorFilterId :: Text
trafficMirrorTargetId :: Text
networkInterfaceId :: Text
virtualNetworkId :: Maybe Int
tagSpecifications :: Maybe [TagSpecification]
packetLength :: Maybe Int
dryRun :: Maybe Bool
description :: Maybe Text
clientToken :: Maybe Text
$sel:sessionNumber:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Int
$sel:trafficMirrorFilterId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Text
$sel:trafficMirrorTargetId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Text
$sel:networkInterfaceId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Text
$sel:virtualNetworkId:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Int
$sel:tagSpecifications:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe [TagSpecification]
$sel:packetLength:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Int
$sel:dryRun:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Bool
$sel:description:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Text
$sel:clientToken:CreateTrafficMirrorSession' :: CreateTrafficMirrorSession -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"CreateTrafficMirrorSession" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        ByteString
"ClientToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
clientToken,
        ByteString
"Description" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
description,
        ByteString
"DryRun" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
dryRun,
        ByteString
"PacketLength" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
packetLength,
        forall a. ToQuery a => a -> QueryString
Data.toQuery
          ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"TagSpecification"
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TagSpecification]
tagSpecifications
          ),
        ByteString
"VirtualNetworkId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
virtualNetworkId,
        ByteString
"NetworkInterfaceId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
networkInterfaceId,
        ByteString
"TrafficMirrorTargetId"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
trafficMirrorTargetId,
        ByteString
"TrafficMirrorFilterId"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
trafficMirrorFilterId,
        ByteString
"SessionNumber" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Int
sessionNumber
      ]

-- | /See:/ 'newCreateTrafficMirrorSessionResponse' smart constructor.
data CreateTrafficMirrorSessionResponse = CreateTrafficMirrorSessionResponse'
  { -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request. For more information, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html How to ensure idempotency>.
    CreateTrafficMirrorSessionResponse -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | Information about the Traffic Mirror session.
    CreateTrafficMirrorSessionResponse -> Maybe TrafficMirrorSession
trafficMirrorSession :: Prelude.Maybe TrafficMirrorSession,
    -- | The response's http status code.
    CreateTrafficMirrorSessionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateTrafficMirrorSessionResponse
-> CreateTrafficMirrorSessionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTrafficMirrorSessionResponse
-> CreateTrafficMirrorSessionResponse -> Bool
$c/= :: CreateTrafficMirrorSessionResponse
-> CreateTrafficMirrorSessionResponse -> Bool
== :: CreateTrafficMirrorSessionResponse
-> CreateTrafficMirrorSessionResponse -> Bool
$c== :: CreateTrafficMirrorSessionResponse
-> CreateTrafficMirrorSessionResponse -> Bool
Prelude.Eq, ReadPrec [CreateTrafficMirrorSessionResponse]
ReadPrec CreateTrafficMirrorSessionResponse
Int -> ReadS CreateTrafficMirrorSessionResponse
ReadS [CreateTrafficMirrorSessionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTrafficMirrorSessionResponse]
$creadListPrec :: ReadPrec [CreateTrafficMirrorSessionResponse]
readPrec :: ReadPrec CreateTrafficMirrorSessionResponse
$creadPrec :: ReadPrec CreateTrafficMirrorSessionResponse
readList :: ReadS [CreateTrafficMirrorSessionResponse]
$creadList :: ReadS [CreateTrafficMirrorSessionResponse]
readsPrec :: Int -> ReadS CreateTrafficMirrorSessionResponse
$creadsPrec :: Int -> ReadS CreateTrafficMirrorSessionResponse
Prelude.Read, Int -> CreateTrafficMirrorSessionResponse -> ShowS
[CreateTrafficMirrorSessionResponse] -> ShowS
CreateTrafficMirrorSessionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTrafficMirrorSessionResponse] -> ShowS
$cshowList :: [CreateTrafficMirrorSessionResponse] -> ShowS
show :: CreateTrafficMirrorSessionResponse -> String
$cshow :: CreateTrafficMirrorSessionResponse -> String
showsPrec :: Int -> CreateTrafficMirrorSessionResponse -> ShowS
$cshowsPrec :: Int -> CreateTrafficMirrorSessionResponse -> ShowS
Prelude.Show, forall x.
Rep CreateTrafficMirrorSessionResponse x
-> CreateTrafficMirrorSessionResponse
forall x.
CreateTrafficMirrorSessionResponse
-> Rep CreateTrafficMirrorSessionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateTrafficMirrorSessionResponse x
-> CreateTrafficMirrorSessionResponse
$cfrom :: forall x.
CreateTrafficMirrorSessionResponse
-> Rep CreateTrafficMirrorSessionResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateTrafficMirrorSessionResponse' 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:
--
-- 'clientToken', 'createTrafficMirrorSessionResponse_clientToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html How to ensure idempotency>.
--
-- 'trafficMirrorSession', 'createTrafficMirrorSessionResponse_trafficMirrorSession' - Information about the Traffic Mirror session.
--
-- 'httpStatus', 'createTrafficMirrorSessionResponse_httpStatus' - The response's http status code.
newCreateTrafficMirrorSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateTrafficMirrorSessionResponse
newCreateTrafficMirrorSessionResponse :: Int -> CreateTrafficMirrorSessionResponse
newCreateTrafficMirrorSessionResponse Int
pHttpStatus_ =
  CreateTrafficMirrorSessionResponse'
    { $sel:clientToken:CreateTrafficMirrorSessionResponse' :: Maybe Text
clientToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:trafficMirrorSession:CreateTrafficMirrorSessionResponse' :: Maybe TrafficMirrorSession
trafficMirrorSession = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateTrafficMirrorSessionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html How to ensure idempotency>.
createTrafficMirrorSessionResponse_clientToken :: Lens.Lens' CreateTrafficMirrorSessionResponse (Prelude.Maybe Prelude.Text)
createTrafficMirrorSessionResponse_clientToken :: Lens' CreateTrafficMirrorSessionResponse (Maybe Text)
createTrafficMirrorSessionResponse_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrafficMirrorSessionResponse' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateTrafficMirrorSessionResponse' :: CreateTrafficMirrorSessionResponse -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateTrafficMirrorSessionResponse
s@CreateTrafficMirrorSessionResponse' {} Maybe Text
a -> CreateTrafficMirrorSessionResponse
s {$sel:clientToken:CreateTrafficMirrorSessionResponse' :: Maybe Text
clientToken = Maybe Text
a} :: CreateTrafficMirrorSessionResponse)

-- | Information about the Traffic Mirror session.
createTrafficMirrorSessionResponse_trafficMirrorSession :: Lens.Lens' CreateTrafficMirrorSessionResponse (Prelude.Maybe TrafficMirrorSession)
createTrafficMirrorSessionResponse_trafficMirrorSession :: Lens'
  CreateTrafficMirrorSessionResponse (Maybe TrafficMirrorSession)
createTrafficMirrorSessionResponse_trafficMirrorSession = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTrafficMirrorSessionResponse' {Maybe TrafficMirrorSession
trafficMirrorSession :: Maybe TrafficMirrorSession
$sel:trafficMirrorSession:CreateTrafficMirrorSessionResponse' :: CreateTrafficMirrorSessionResponse -> Maybe TrafficMirrorSession
trafficMirrorSession} -> Maybe TrafficMirrorSession
trafficMirrorSession) (\s :: CreateTrafficMirrorSessionResponse
s@CreateTrafficMirrorSessionResponse' {} Maybe TrafficMirrorSession
a -> CreateTrafficMirrorSessionResponse
s {$sel:trafficMirrorSession:CreateTrafficMirrorSessionResponse' :: Maybe TrafficMirrorSession
trafficMirrorSession = Maybe TrafficMirrorSession
a} :: CreateTrafficMirrorSessionResponse)

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

instance
  Prelude.NFData
    CreateTrafficMirrorSessionResponse
  where
  rnf :: CreateTrafficMirrorSessionResponse -> ()
rnf CreateTrafficMirrorSessionResponse' {Int
Maybe Text
Maybe TrafficMirrorSession
httpStatus :: Int
trafficMirrorSession :: Maybe TrafficMirrorSession
clientToken :: Maybe Text
$sel:httpStatus:CreateTrafficMirrorSessionResponse' :: CreateTrafficMirrorSessionResponse -> Int
$sel:trafficMirrorSession:CreateTrafficMirrorSessionResponse' :: CreateTrafficMirrorSessionResponse -> Maybe TrafficMirrorSession
$sel:clientToken:CreateTrafficMirrorSessionResponse' :: CreateTrafficMirrorSessionResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TrafficMirrorSession
trafficMirrorSession
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus