{-# 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.DnsRequestAction
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GuardDuty.Types.DnsRequestAction where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the DNS_REQUEST action described in this
-- finding.
--
-- /See:/ 'newDnsRequestAction' smart constructor.
data DnsRequestAction = DnsRequestAction'
  { -- | Indicates whether the targeted port is blocked.
    DnsRequestAction -> Maybe Bool
blocked :: Prelude.Maybe Prelude.Bool,
    -- | The domain information for the API request.
    DnsRequestAction -> Maybe Text
domain :: Prelude.Maybe Prelude.Text,
    -- | The network connection protocol observed in the activity that prompted
    -- GuardDuty to generate the finding.
    DnsRequestAction -> Maybe Text
protocol :: Prelude.Maybe Prelude.Text
  }
  deriving (DnsRequestAction -> DnsRequestAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DnsRequestAction -> DnsRequestAction -> Bool
$c/= :: DnsRequestAction -> DnsRequestAction -> Bool
== :: DnsRequestAction -> DnsRequestAction -> Bool
$c== :: DnsRequestAction -> DnsRequestAction -> Bool
Prelude.Eq, ReadPrec [DnsRequestAction]
ReadPrec DnsRequestAction
Int -> ReadS DnsRequestAction
ReadS [DnsRequestAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DnsRequestAction]
$creadListPrec :: ReadPrec [DnsRequestAction]
readPrec :: ReadPrec DnsRequestAction
$creadPrec :: ReadPrec DnsRequestAction
readList :: ReadS [DnsRequestAction]
$creadList :: ReadS [DnsRequestAction]
readsPrec :: Int -> ReadS DnsRequestAction
$creadsPrec :: Int -> ReadS DnsRequestAction
Prelude.Read, Int -> DnsRequestAction -> ShowS
[DnsRequestAction] -> ShowS
DnsRequestAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DnsRequestAction] -> ShowS
$cshowList :: [DnsRequestAction] -> ShowS
show :: DnsRequestAction -> String
$cshow :: DnsRequestAction -> String
showsPrec :: Int -> DnsRequestAction -> ShowS
$cshowsPrec :: Int -> DnsRequestAction -> ShowS
Prelude.Show, forall x. Rep DnsRequestAction x -> DnsRequestAction
forall x. DnsRequestAction -> Rep DnsRequestAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DnsRequestAction x -> DnsRequestAction
$cfrom :: forall x. DnsRequestAction -> Rep DnsRequestAction x
Prelude.Generic)

-- |
-- Create a value of 'DnsRequestAction' 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:
--
-- 'blocked', 'dnsRequestAction_blocked' - Indicates whether the targeted port is blocked.
--
-- 'domain', 'dnsRequestAction_domain' - The domain information for the API request.
--
-- 'protocol', 'dnsRequestAction_protocol' - The network connection protocol observed in the activity that prompted
-- GuardDuty to generate the finding.
newDnsRequestAction ::
  DnsRequestAction
newDnsRequestAction :: DnsRequestAction
newDnsRequestAction =
  DnsRequestAction'
    { $sel:blocked:DnsRequestAction' :: Maybe Bool
blocked = forall a. Maybe a
Prelude.Nothing,
      $sel:domain:DnsRequestAction' :: Maybe Text
domain = forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:DnsRequestAction' :: Maybe Text
protocol = forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether the targeted port is blocked.
dnsRequestAction_blocked :: Lens.Lens' DnsRequestAction (Prelude.Maybe Prelude.Bool)
dnsRequestAction_blocked :: Lens' DnsRequestAction (Maybe Bool)
dnsRequestAction_blocked = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DnsRequestAction' {Maybe Bool
blocked :: Maybe Bool
$sel:blocked:DnsRequestAction' :: DnsRequestAction -> Maybe Bool
blocked} -> Maybe Bool
blocked) (\s :: DnsRequestAction
s@DnsRequestAction' {} Maybe Bool
a -> DnsRequestAction
s {$sel:blocked:DnsRequestAction' :: Maybe Bool
blocked = Maybe Bool
a} :: DnsRequestAction)

-- | The domain information for the API request.
dnsRequestAction_domain :: Lens.Lens' DnsRequestAction (Prelude.Maybe Prelude.Text)
dnsRequestAction_domain :: Lens' DnsRequestAction (Maybe Text)
dnsRequestAction_domain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DnsRequestAction' {Maybe Text
domain :: Maybe Text
$sel:domain:DnsRequestAction' :: DnsRequestAction -> Maybe Text
domain} -> Maybe Text
domain) (\s :: DnsRequestAction
s@DnsRequestAction' {} Maybe Text
a -> DnsRequestAction
s {$sel:domain:DnsRequestAction' :: Maybe Text
domain = Maybe Text
a} :: DnsRequestAction)

-- | The network connection protocol observed in the activity that prompted
-- GuardDuty to generate the finding.
dnsRequestAction_protocol :: Lens.Lens' DnsRequestAction (Prelude.Maybe Prelude.Text)
dnsRequestAction_protocol :: Lens' DnsRequestAction (Maybe Text)
dnsRequestAction_protocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DnsRequestAction' {Maybe Text
protocol :: Maybe Text
$sel:protocol:DnsRequestAction' :: DnsRequestAction -> Maybe Text
protocol} -> Maybe Text
protocol) (\s :: DnsRequestAction
s@DnsRequestAction' {} Maybe Text
a -> DnsRequestAction
s {$sel:protocol:DnsRequestAction' :: Maybe Text
protocol = Maybe Text
a} :: DnsRequestAction)

instance Data.FromJSON DnsRequestAction where
  parseJSON :: Value -> Parser DnsRequestAction
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DnsRequestAction"
      ( \Object
x ->
          Maybe Bool -> Maybe Text -> Maybe Text -> DnsRequestAction
DnsRequestAction'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"blocked")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"domain")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"protocol")
      )

instance Prelude.Hashable DnsRequestAction where
  hashWithSalt :: Int -> DnsRequestAction -> Int
hashWithSalt Int
_salt DnsRequestAction' {Maybe Bool
Maybe Text
protocol :: Maybe Text
domain :: Maybe Text
blocked :: Maybe Bool
$sel:protocol:DnsRequestAction' :: DnsRequestAction -> Maybe Text
$sel:domain:DnsRequestAction' :: DnsRequestAction -> Maybe Text
$sel:blocked:DnsRequestAction' :: DnsRequestAction -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
blocked
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
domain
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
protocol

instance Prelude.NFData DnsRequestAction where
  rnf :: DnsRequestAction -> ()
rnf DnsRequestAction' {Maybe Bool
Maybe Text
protocol :: Maybe Text
domain :: Maybe Text
blocked :: Maybe Bool
$sel:protocol:DnsRequestAction' :: DnsRequestAction -> Maybe Text
$sel:domain:DnsRequestAction' :: DnsRequestAction -> Maybe Text
$sel:blocked:DnsRequestAction' :: DnsRequestAction -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
blocked
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
domain
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
protocol