{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.GuardDuty.Types.PortProbeAction
-- 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)
module Amazonka.GuardDuty.Types.PortProbeAction where

import qualified Amazonka.Core as Core
import Amazonka.GuardDuty.Types.PortProbeDetail
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the PORT_PROBE action described in the
-- finding.
--
-- /See:/ 'newPortProbeAction' smart constructor.
data PortProbeAction = PortProbeAction'
  { -- | A list of objects related to port probe details.
    PortProbeAction -> Maybe [PortProbeDetail]
portProbeDetails :: Prelude.Maybe [PortProbeDetail],
    -- | Indicates whether EC2 blocked the port probe to the instance, such as
    -- with an ACL.
    PortProbeAction -> Maybe Bool
blocked :: Prelude.Maybe Prelude.Bool
  }
  deriving (PortProbeAction -> PortProbeAction -> Bool
(PortProbeAction -> PortProbeAction -> Bool)
-> (PortProbeAction -> PortProbeAction -> Bool)
-> Eq PortProbeAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortProbeAction -> PortProbeAction -> Bool
$c/= :: PortProbeAction -> PortProbeAction -> Bool
== :: PortProbeAction -> PortProbeAction -> Bool
$c== :: PortProbeAction -> PortProbeAction -> Bool
Prelude.Eq, ReadPrec [PortProbeAction]
ReadPrec PortProbeAction
Int -> ReadS PortProbeAction
ReadS [PortProbeAction]
(Int -> ReadS PortProbeAction)
-> ReadS [PortProbeAction]
-> ReadPrec PortProbeAction
-> ReadPrec [PortProbeAction]
-> Read PortProbeAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PortProbeAction]
$creadListPrec :: ReadPrec [PortProbeAction]
readPrec :: ReadPrec PortProbeAction
$creadPrec :: ReadPrec PortProbeAction
readList :: ReadS [PortProbeAction]
$creadList :: ReadS [PortProbeAction]
readsPrec :: Int -> ReadS PortProbeAction
$creadsPrec :: Int -> ReadS PortProbeAction
Prelude.Read, Int -> PortProbeAction -> ShowS
[PortProbeAction] -> ShowS
PortProbeAction -> String
(Int -> PortProbeAction -> ShowS)
-> (PortProbeAction -> String)
-> ([PortProbeAction] -> ShowS)
-> Show PortProbeAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortProbeAction] -> ShowS
$cshowList :: [PortProbeAction] -> ShowS
show :: PortProbeAction -> String
$cshow :: PortProbeAction -> String
showsPrec :: Int -> PortProbeAction -> ShowS
$cshowsPrec :: Int -> PortProbeAction -> ShowS
Prelude.Show, (forall x. PortProbeAction -> Rep PortProbeAction x)
-> (forall x. Rep PortProbeAction x -> PortProbeAction)
-> Generic PortProbeAction
forall x. Rep PortProbeAction x -> PortProbeAction
forall x. PortProbeAction -> Rep PortProbeAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PortProbeAction x -> PortProbeAction
$cfrom :: forall x. PortProbeAction -> Rep PortProbeAction x
Prelude.Generic)

-- |
-- Create a value of 'PortProbeAction' 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:
--
-- 'portProbeDetails', 'portProbeAction_portProbeDetails' - A list of objects related to port probe details.
--
-- 'blocked', 'portProbeAction_blocked' - Indicates whether EC2 blocked the port probe to the instance, such as
-- with an ACL.
newPortProbeAction ::
  PortProbeAction
newPortProbeAction :: PortProbeAction
newPortProbeAction =
  PortProbeAction' :: Maybe [PortProbeDetail] -> Maybe Bool -> PortProbeAction
PortProbeAction'
    { $sel:portProbeDetails:PortProbeAction' :: Maybe [PortProbeDetail]
portProbeDetails =
        Maybe [PortProbeDetail]
forall a. Maybe a
Prelude.Nothing,
      $sel:blocked:PortProbeAction' :: Maybe Bool
blocked = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of objects related to port probe details.
portProbeAction_portProbeDetails :: Lens.Lens' PortProbeAction (Prelude.Maybe [PortProbeDetail])
portProbeAction_portProbeDetails :: (Maybe [PortProbeDetail] -> f (Maybe [PortProbeDetail]))
-> PortProbeAction -> f PortProbeAction
portProbeAction_portProbeDetails = (PortProbeAction -> Maybe [PortProbeDetail])
-> (PortProbeAction -> Maybe [PortProbeDetail] -> PortProbeAction)
-> Lens
     PortProbeAction
     PortProbeAction
     (Maybe [PortProbeDetail])
     (Maybe [PortProbeDetail])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortProbeAction' {Maybe [PortProbeDetail]
portProbeDetails :: Maybe [PortProbeDetail]
$sel:portProbeDetails:PortProbeAction' :: PortProbeAction -> Maybe [PortProbeDetail]
portProbeDetails} -> Maybe [PortProbeDetail]
portProbeDetails) (\s :: PortProbeAction
s@PortProbeAction' {} Maybe [PortProbeDetail]
a -> PortProbeAction
s {$sel:portProbeDetails:PortProbeAction' :: Maybe [PortProbeDetail]
portProbeDetails = Maybe [PortProbeDetail]
a} :: PortProbeAction) ((Maybe [PortProbeDetail] -> f (Maybe [PortProbeDetail]))
 -> PortProbeAction -> f PortProbeAction)
-> ((Maybe [PortProbeDetail] -> f (Maybe [PortProbeDetail]))
    -> Maybe [PortProbeDetail] -> f (Maybe [PortProbeDetail]))
-> (Maybe [PortProbeDetail] -> f (Maybe [PortProbeDetail]))
-> PortProbeAction
-> f PortProbeAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PortProbeDetail]
  [PortProbeDetail]
  [PortProbeDetail]
  [PortProbeDetail]
-> Iso
     (Maybe [PortProbeDetail])
     (Maybe [PortProbeDetail])
     (Maybe [PortProbeDetail])
     (Maybe [PortProbeDetail])
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 AnIso
  [PortProbeDetail]
  [PortProbeDetail]
  [PortProbeDetail]
  [PortProbeDetail]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Indicates whether EC2 blocked the port probe to the instance, such as
-- with an ACL.
portProbeAction_blocked :: Lens.Lens' PortProbeAction (Prelude.Maybe Prelude.Bool)
portProbeAction_blocked :: (Maybe Bool -> f (Maybe Bool))
-> PortProbeAction -> f PortProbeAction
portProbeAction_blocked = (PortProbeAction -> Maybe Bool)
-> (PortProbeAction -> Maybe Bool -> PortProbeAction)
-> Lens PortProbeAction PortProbeAction (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortProbeAction' {Maybe Bool
blocked :: Maybe Bool
$sel:blocked:PortProbeAction' :: PortProbeAction -> Maybe Bool
blocked} -> Maybe Bool
blocked) (\s :: PortProbeAction
s@PortProbeAction' {} Maybe Bool
a -> PortProbeAction
s {$sel:blocked:PortProbeAction' :: Maybe Bool
blocked = Maybe Bool
a} :: PortProbeAction)

instance Core.FromJSON PortProbeAction where
  parseJSON :: Value -> Parser PortProbeAction
parseJSON =
    String
-> (Object -> Parser PortProbeAction)
-> Value
-> Parser PortProbeAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PortProbeAction"
      ( \Object
x ->
          Maybe [PortProbeDetail] -> Maybe Bool -> PortProbeAction
PortProbeAction'
            (Maybe [PortProbeDetail] -> Maybe Bool -> PortProbeAction)
-> Parser (Maybe [PortProbeDetail])
-> Parser (Maybe Bool -> PortProbeAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [PortProbeDetail]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"portProbeDetails"
                            Parser (Maybe (Maybe [PortProbeDetail]))
-> Maybe [PortProbeDetail] -> Parser (Maybe [PortProbeDetail])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [PortProbeDetail]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Bool -> PortProbeAction)
-> Parser (Maybe Bool) -> Parser PortProbeAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"blocked")
      )

instance Prelude.Hashable PortProbeAction

instance Prelude.NFData PortProbeAction