{-# 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.GuardDuty.CreateFilter
-- 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)
--
-- Creates a filter using the specified finding criteria.
module Amazonka.GuardDuty.CreateFilter
  ( -- * Creating a Request
    CreateFilter (..),
    newCreateFilter,

    -- * Request Lenses
    createFilter_clientToken,
    createFilter_action,
    createFilter_description,
    createFilter_rank,
    createFilter_tags,
    createFilter_detectorId,
    createFilter_name,
    createFilter_findingCriteria,

    -- * Destructuring the Response
    CreateFilterResponse (..),
    newCreateFilterResponse,

    -- * Response Lenses
    createFilterResponse_httpStatus,
    createFilterResponse_name,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GuardDuty.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:/ 'newCreateFilter' smart constructor.
data CreateFilter = CreateFilter'
  { -- | The idempotency token for the create request.
    CreateFilter -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | Specifies the action that is to be applied to the findings that match
    -- the filter.
    CreateFilter -> Maybe FilterAction
action :: Prelude.Maybe FilterAction,
    -- | The description of the filter.
    CreateFilter -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Specifies the position of the filter in the list of current filters.
    -- Also specifies the order in which this filter is applied to the
    -- findings.
    CreateFilter -> Maybe Natural
rank :: Prelude.Maybe Prelude.Natural,
    -- | The tags to be added to a new filter resource.
    CreateFilter -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The ID of the detector belonging to the GuardDuty account that you want
    -- to create a filter for.
    CreateFilter -> Text
detectorId :: Prelude.Text,
    -- | The name of the filter. Minimum length of 3. Maximum length of 64. Valid
    -- characters include alphanumeric characters, dot (.), underscore (_), and
    -- dash (-). Spaces are not allowed.
    CreateFilter -> Text
name :: Prelude.Text,
    -- | Represents the criteria to be used in the filter for querying findings.
    --
    -- You can only use the following attributes to query findings:
    --
    -- -   accountId
    --
    -- -   region
    --
    -- -   confidence
    --
    -- -   id
    --
    -- -   resource.accessKeyDetails.accessKeyId
    --
    -- -   resource.accessKeyDetails.principalId
    --
    -- -   resource.accessKeyDetails.userName
    --
    -- -   resource.accessKeyDetails.userType
    --
    -- -   resource.instanceDetails.iamInstanceProfile.id
    --
    -- -   resource.instanceDetails.imageId
    --
    -- -   resource.instanceDetails.instanceId
    --
    -- -   resource.instanceDetails.outpostArn
    --
    -- -   resource.instanceDetails.networkInterfaces.ipv6Addresses
    --
    -- -   resource.instanceDetails.networkInterfaces.privateIpAddresses.privateIpAddress
    --
    -- -   resource.instanceDetails.networkInterfaces.publicDnsName
    --
    -- -   resource.instanceDetails.networkInterfaces.publicIp
    --
    -- -   resource.instanceDetails.networkInterfaces.securityGroups.groupId
    --
    -- -   resource.instanceDetails.networkInterfaces.securityGroups.groupName
    --
    -- -   resource.instanceDetails.networkInterfaces.subnetId
    --
    -- -   resource.instanceDetails.networkInterfaces.vpcId
    --
    -- -   resource.instanceDetails.tags.key
    --
    -- -   resource.instanceDetails.tags.value
    --
    -- -   resource.resourceType
    --
    -- -   service.action.actionType
    --
    -- -   service.action.awsApiCallAction.api
    --
    -- -   service.action.awsApiCallAction.callerType
    --
    -- -   service.action.awsApiCallAction.errorCode
    --
    -- -   service.action.awsApiCallAction.remoteIpDetails.city.cityName
    --
    -- -   service.action.awsApiCallAction.remoteIpDetails.country.countryName
    --
    -- -   service.action.awsApiCallAction.remoteIpDetails.ipAddressV4
    --
    -- -   service.action.awsApiCallAction.remoteIpDetails.organization.asn
    --
    -- -   service.action.awsApiCallAction.remoteIpDetails.organization.asnOrg
    --
    -- -   service.action.awsApiCallAction.serviceName
    --
    -- -   service.action.dnsRequestAction.domain
    --
    -- -   service.action.networkConnectionAction.blocked
    --
    -- -   service.action.networkConnectionAction.connectionDirection
    --
    -- -   service.action.networkConnectionAction.localPortDetails.port
    --
    -- -   service.action.networkConnectionAction.protocol
    --
    -- -   service.action.networkConnectionAction.localIpDetails.ipAddressV4
    --
    -- -   service.action.networkConnectionAction.remoteIpDetails.city.cityName
    --
    -- -   service.action.networkConnectionAction.remoteIpDetails.country.countryName
    --
    -- -   service.action.networkConnectionAction.remoteIpDetails.ipAddressV4
    --
    -- -   service.action.networkConnectionAction.remoteIpDetails.organization.asn
    --
    -- -   service.action.networkConnectionAction.remoteIpDetails.organization.asnOrg
    --
    -- -   service.action.networkConnectionAction.remotePortDetails.port
    --
    -- -   service.additionalInfo.threatListName
    --
    -- -   service.archived
    --
    --     When this attribute is set to TRUE, only archived findings are
    --     listed. When it\'s set to FALSE, only unarchived findings are
    --     listed. When this attribute is not set, all existing findings are
    --     listed.
    --
    -- -   service.resourceRole
    --
    -- -   severity
    --
    -- -   type
    --
    -- -   updatedAt
    --
    --     Type: ISO 8601 string format: YYYY-MM-DDTHH:MM:SS.SSSZ or
    --     YYYY-MM-DDTHH:MM:SSZ depending on whether the value contains
    --     milliseconds.
    CreateFilter -> FindingCriteria
findingCriteria :: FindingCriteria
  }
  deriving (CreateFilter -> CreateFilter -> Bool
(CreateFilter -> CreateFilter -> Bool)
-> (CreateFilter -> CreateFilter -> Bool) -> Eq CreateFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFilter -> CreateFilter -> Bool
$c/= :: CreateFilter -> CreateFilter -> Bool
== :: CreateFilter -> CreateFilter -> Bool
$c== :: CreateFilter -> CreateFilter -> Bool
Prelude.Eq, ReadPrec [CreateFilter]
ReadPrec CreateFilter
Int -> ReadS CreateFilter
ReadS [CreateFilter]
(Int -> ReadS CreateFilter)
-> ReadS [CreateFilter]
-> ReadPrec CreateFilter
-> ReadPrec [CreateFilter]
-> Read CreateFilter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateFilter]
$creadListPrec :: ReadPrec [CreateFilter]
readPrec :: ReadPrec CreateFilter
$creadPrec :: ReadPrec CreateFilter
readList :: ReadS [CreateFilter]
$creadList :: ReadS [CreateFilter]
readsPrec :: Int -> ReadS CreateFilter
$creadsPrec :: Int -> ReadS CreateFilter
Prelude.Read, Int -> CreateFilter -> ShowS
[CreateFilter] -> ShowS
CreateFilter -> String
(Int -> CreateFilter -> ShowS)
-> (CreateFilter -> String)
-> ([CreateFilter] -> ShowS)
-> Show CreateFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFilter] -> ShowS
$cshowList :: [CreateFilter] -> ShowS
show :: CreateFilter -> String
$cshow :: CreateFilter -> String
showsPrec :: Int -> CreateFilter -> ShowS
$cshowsPrec :: Int -> CreateFilter -> ShowS
Prelude.Show, (forall x. CreateFilter -> Rep CreateFilter x)
-> (forall x. Rep CreateFilter x -> CreateFilter)
-> Generic CreateFilter
forall x. Rep CreateFilter x -> CreateFilter
forall x. CreateFilter -> Rep CreateFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateFilter x -> CreateFilter
$cfrom :: forall x. CreateFilter -> Rep CreateFilter x
Prelude.Generic)

-- |
-- Create a value of 'CreateFilter' 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', 'createFilter_clientToken' - The idempotency token for the create request.
--
-- 'action', 'createFilter_action' - Specifies the action that is to be applied to the findings that match
-- the filter.
--
-- 'description', 'createFilter_description' - The description of the filter.
--
-- 'rank', 'createFilter_rank' - Specifies the position of the filter in the list of current filters.
-- Also specifies the order in which this filter is applied to the
-- findings.
--
-- 'tags', 'createFilter_tags' - The tags to be added to a new filter resource.
--
-- 'detectorId', 'createFilter_detectorId' - The ID of the detector belonging to the GuardDuty account that you want
-- to create a filter for.
--
-- 'name', 'createFilter_name' - The name of the filter. Minimum length of 3. Maximum length of 64. Valid
-- characters include alphanumeric characters, dot (.), underscore (_), and
-- dash (-). Spaces are not allowed.
--
-- 'findingCriteria', 'createFilter_findingCriteria' - Represents the criteria to be used in the filter for querying findings.
--
-- You can only use the following attributes to query findings:
--
-- -   accountId
--
-- -   region
--
-- -   confidence
--
-- -   id
--
-- -   resource.accessKeyDetails.accessKeyId
--
-- -   resource.accessKeyDetails.principalId
--
-- -   resource.accessKeyDetails.userName
--
-- -   resource.accessKeyDetails.userType
--
-- -   resource.instanceDetails.iamInstanceProfile.id
--
-- -   resource.instanceDetails.imageId
--
-- -   resource.instanceDetails.instanceId
--
-- -   resource.instanceDetails.outpostArn
--
-- -   resource.instanceDetails.networkInterfaces.ipv6Addresses
--
-- -   resource.instanceDetails.networkInterfaces.privateIpAddresses.privateIpAddress
--
-- -   resource.instanceDetails.networkInterfaces.publicDnsName
--
-- -   resource.instanceDetails.networkInterfaces.publicIp
--
-- -   resource.instanceDetails.networkInterfaces.securityGroups.groupId
--
-- -   resource.instanceDetails.networkInterfaces.securityGroups.groupName
--
-- -   resource.instanceDetails.networkInterfaces.subnetId
--
-- -   resource.instanceDetails.networkInterfaces.vpcId
--
-- -   resource.instanceDetails.tags.key
--
-- -   resource.instanceDetails.tags.value
--
-- -   resource.resourceType
--
-- -   service.action.actionType
--
-- -   service.action.awsApiCallAction.api
--
-- -   service.action.awsApiCallAction.callerType
--
-- -   service.action.awsApiCallAction.errorCode
--
-- -   service.action.awsApiCallAction.remoteIpDetails.city.cityName
--
-- -   service.action.awsApiCallAction.remoteIpDetails.country.countryName
--
-- -   service.action.awsApiCallAction.remoteIpDetails.ipAddressV4
--
-- -   service.action.awsApiCallAction.remoteIpDetails.organization.asn
--
-- -   service.action.awsApiCallAction.remoteIpDetails.organization.asnOrg
--
-- -   service.action.awsApiCallAction.serviceName
--
-- -   service.action.dnsRequestAction.domain
--
-- -   service.action.networkConnectionAction.blocked
--
-- -   service.action.networkConnectionAction.connectionDirection
--
-- -   service.action.networkConnectionAction.localPortDetails.port
--
-- -   service.action.networkConnectionAction.protocol
--
-- -   service.action.networkConnectionAction.localIpDetails.ipAddressV4
--
-- -   service.action.networkConnectionAction.remoteIpDetails.city.cityName
--
-- -   service.action.networkConnectionAction.remoteIpDetails.country.countryName
--
-- -   service.action.networkConnectionAction.remoteIpDetails.ipAddressV4
--
-- -   service.action.networkConnectionAction.remoteIpDetails.organization.asn
--
-- -   service.action.networkConnectionAction.remoteIpDetails.organization.asnOrg
--
-- -   service.action.networkConnectionAction.remotePortDetails.port
--
-- -   service.additionalInfo.threatListName
--
-- -   service.archived
--
--     When this attribute is set to TRUE, only archived findings are
--     listed. When it\'s set to FALSE, only unarchived findings are
--     listed. When this attribute is not set, all existing findings are
--     listed.
--
-- -   service.resourceRole
--
-- -   severity
--
-- -   type
--
-- -   updatedAt
--
--     Type: ISO 8601 string format: YYYY-MM-DDTHH:MM:SS.SSSZ or
--     YYYY-MM-DDTHH:MM:SSZ depending on whether the value contains
--     milliseconds.
newCreateFilter ::
  -- | 'detectorId'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'findingCriteria'
  FindingCriteria ->
  CreateFilter
newCreateFilter :: Text -> Text -> FindingCriteria -> CreateFilter
newCreateFilter Text
pDetectorId_ Text
pName_ FindingCriteria
pFindingCriteria_ =
  CreateFilter' :: Maybe Text
-> Maybe FilterAction
-> Maybe Text
-> Maybe Natural
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> FindingCriteria
-> CreateFilter
CreateFilter'
    { $sel:clientToken:CreateFilter' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:action:CreateFilter' :: Maybe FilterAction
action = Maybe FilterAction
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateFilter' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:rank:CreateFilter' :: Maybe Natural
rank = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateFilter' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorId:CreateFilter' :: Text
detectorId = Text
pDetectorId_,
      $sel:name:CreateFilter' :: Text
name = Text
pName_,
      $sel:findingCriteria:CreateFilter' :: FindingCriteria
findingCriteria = FindingCriteria
pFindingCriteria_
    }

-- | The idempotency token for the create request.
createFilter_clientToken :: Lens.Lens' CreateFilter (Prelude.Maybe Prelude.Text)
createFilter_clientToken :: (Maybe Text -> f (Maybe Text)) -> CreateFilter -> f CreateFilter
createFilter_clientToken = (CreateFilter -> Maybe Text)
-> (CreateFilter -> Maybe Text -> CreateFilter)
-> Lens CreateFilter CreateFilter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFilter' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateFilter' :: CreateFilter -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateFilter
s@CreateFilter' {} Maybe Text
a -> CreateFilter
s {$sel:clientToken:CreateFilter' :: Maybe Text
clientToken = Maybe Text
a} :: CreateFilter)

-- | Specifies the action that is to be applied to the findings that match
-- the filter.
createFilter_action :: Lens.Lens' CreateFilter (Prelude.Maybe FilterAction)
createFilter_action :: (Maybe FilterAction -> f (Maybe FilterAction))
-> CreateFilter -> f CreateFilter
createFilter_action = (CreateFilter -> Maybe FilterAction)
-> (CreateFilter -> Maybe FilterAction -> CreateFilter)
-> Lens
     CreateFilter CreateFilter (Maybe FilterAction) (Maybe FilterAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFilter' {Maybe FilterAction
action :: Maybe FilterAction
$sel:action:CreateFilter' :: CreateFilter -> Maybe FilterAction
action} -> Maybe FilterAction
action) (\s :: CreateFilter
s@CreateFilter' {} Maybe FilterAction
a -> CreateFilter
s {$sel:action:CreateFilter' :: Maybe FilterAction
action = Maybe FilterAction
a} :: CreateFilter)

-- | The description of the filter.
createFilter_description :: Lens.Lens' CreateFilter (Prelude.Maybe Prelude.Text)
createFilter_description :: (Maybe Text -> f (Maybe Text)) -> CreateFilter -> f CreateFilter
createFilter_description = (CreateFilter -> Maybe Text)
-> (CreateFilter -> Maybe Text -> CreateFilter)
-> Lens CreateFilter CreateFilter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFilter' {Maybe Text
description :: Maybe Text
$sel:description:CreateFilter' :: CreateFilter -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateFilter
s@CreateFilter' {} Maybe Text
a -> CreateFilter
s {$sel:description:CreateFilter' :: Maybe Text
description = Maybe Text
a} :: CreateFilter)

-- | Specifies the position of the filter in the list of current filters.
-- Also specifies the order in which this filter is applied to the
-- findings.
createFilter_rank :: Lens.Lens' CreateFilter (Prelude.Maybe Prelude.Natural)
createFilter_rank :: (Maybe Natural -> f (Maybe Natural))
-> CreateFilter -> f CreateFilter
createFilter_rank = (CreateFilter -> Maybe Natural)
-> (CreateFilter -> Maybe Natural -> CreateFilter)
-> Lens CreateFilter CreateFilter (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFilter' {Maybe Natural
rank :: Maybe Natural
$sel:rank:CreateFilter' :: CreateFilter -> Maybe Natural
rank} -> Maybe Natural
rank) (\s :: CreateFilter
s@CreateFilter' {} Maybe Natural
a -> CreateFilter
s {$sel:rank:CreateFilter' :: Maybe Natural
rank = Maybe Natural
a} :: CreateFilter)

-- | The tags to be added to a new filter resource.
createFilter_tags :: Lens.Lens' CreateFilter (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createFilter_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateFilter -> f CreateFilter
createFilter_tags = (CreateFilter -> Maybe (HashMap Text Text))
-> (CreateFilter -> Maybe (HashMap Text Text) -> CreateFilter)
-> Lens
     CreateFilter
     CreateFilter
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFilter' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateFilter' :: CreateFilter -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateFilter
s@CreateFilter' {} Maybe (HashMap Text Text)
a -> CreateFilter
s {$sel:tags:CreateFilter' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateFilter) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateFilter -> f CreateFilter)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateFilter
-> f CreateFilter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the detector belonging to the GuardDuty account that you want
-- to create a filter for.
createFilter_detectorId :: Lens.Lens' CreateFilter Prelude.Text
createFilter_detectorId :: (Text -> f Text) -> CreateFilter -> f CreateFilter
createFilter_detectorId = (CreateFilter -> Text)
-> (CreateFilter -> Text -> CreateFilter)
-> Lens CreateFilter CreateFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFilter' {Text
detectorId :: Text
$sel:detectorId:CreateFilter' :: CreateFilter -> Text
detectorId} -> Text
detectorId) (\s :: CreateFilter
s@CreateFilter' {} Text
a -> CreateFilter
s {$sel:detectorId:CreateFilter' :: Text
detectorId = Text
a} :: CreateFilter)

-- | The name of the filter. Minimum length of 3. Maximum length of 64. Valid
-- characters include alphanumeric characters, dot (.), underscore (_), and
-- dash (-). Spaces are not allowed.
createFilter_name :: Lens.Lens' CreateFilter Prelude.Text
createFilter_name :: (Text -> f Text) -> CreateFilter -> f CreateFilter
createFilter_name = (CreateFilter -> Text)
-> (CreateFilter -> Text -> CreateFilter)
-> Lens CreateFilter CreateFilter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFilter' {Text
name :: Text
$sel:name:CreateFilter' :: CreateFilter -> Text
name} -> Text
name) (\s :: CreateFilter
s@CreateFilter' {} Text
a -> CreateFilter
s {$sel:name:CreateFilter' :: Text
name = Text
a} :: CreateFilter)

-- | Represents the criteria to be used in the filter for querying findings.
--
-- You can only use the following attributes to query findings:
--
-- -   accountId
--
-- -   region
--
-- -   confidence
--
-- -   id
--
-- -   resource.accessKeyDetails.accessKeyId
--
-- -   resource.accessKeyDetails.principalId
--
-- -   resource.accessKeyDetails.userName
--
-- -   resource.accessKeyDetails.userType
--
-- -   resource.instanceDetails.iamInstanceProfile.id
--
-- -   resource.instanceDetails.imageId
--
-- -   resource.instanceDetails.instanceId
--
-- -   resource.instanceDetails.outpostArn
--
-- -   resource.instanceDetails.networkInterfaces.ipv6Addresses
--
-- -   resource.instanceDetails.networkInterfaces.privateIpAddresses.privateIpAddress
--
-- -   resource.instanceDetails.networkInterfaces.publicDnsName
--
-- -   resource.instanceDetails.networkInterfaces.publicIp
--
-- -   resource.instanceDetails.networkInterfaces.securityGroups.groupId
--
-- -   resource.instanceDetails.networkInterfaces.securityGroups.groupName
--
-- -   resource.instanceDetails.networkInterfaces.subnetId
--
-- -   resource.instanceDetails.networkInterfaces.vpcId
--
-- -   resource.instanceDetails.tags.key
--
-- -   resource.instanceDetails.tags.value
--
-- -   resource.resourceType
--
-- -   service.action.actionType
--
-- -   service.action.awsApiCallAction.api
--
-- -   service.action.awsApiCallAction.callerType
--
-- -   service.action.awsApiCallAction.errorCode
--
-- -   service.action.awsApiCallAction.remoteIpDetails.city.cityName
--
-- -   service.action.awsApiCallAction.remoteIpDetails.country.countryName
--
-- -   service.action.awsApiCallAction.remoteIpDetails.ipAddressV4
--
-- -   service.action.awsApiCallAction.remoteIpDetails.organization.asn
--
-- -   service.action.awsApiCallAction.remoteIpDetails.organization.asnOrg
--
-- -   service.action.awsApiCallAction.serviceName
--
-- -   service.action.dnsRequestAction.domain
--
-- -   service.action.networkConnectionAction.blocked
--
-- -   service.action.networkConnectionAction.connectionDirection
--
-- -   service.action.networkConnectionAction.localPortDetails.port
--
-- -   service.action.networkConnectionAction.protocol
--
-- -   service.action.networkConnectionAction.localIpDetails.ipAddressV4
--
-- -   service.action.networkConnectionAction.remoteIpDetails.city.cityName
--
-- -   service.action.networkConnectionAction.remoteIpDetails.country.countryName
--
-- -   service.action.networkConnectionAction.remoteIpDetails.ipAddressV4
--
-- -   service.action.networkConnectionAction.remoteIpDetails.organization.asn
--
-- -   service.action.networkConnectionAction.remoteIpDetails.organization.asnOrg
--
-- -   service.action.networkConnectionAction.remotePortDetails.port
--
-- -   service.additionalInfo.threatListName
--
-- -   service.archived
--
--     When this attribute is set to TRUE, only archived findings are
--     listed. When it\'s set to FALSE, only unarchived findings are
--     listed. When this attribute is not set, all existing findings are
--     listed.
--
-- -   service.resourceRole
--
-- -   severity
--
-- -   type
--
-- -   updatedAt
--
--     Type: ISO 8601 string format: YYYY-MM-DDTHH:MM:SS.SSSZ or
--     YYYY-MM-DDTHH:MM:SSZ depending on whether the value contains
--     milliseconds.
createFilter_findingCriteria :: Lens.Lens' CreateFilter FindingCriteria
createFilter_findingCriteria :: (FindingCriteria -> f FindingCriteria)
-> CreateFilter -> f CreateFilter
createFilter_findingCriteria = (CreateFilter -> FindingCriteria)
-> (CreateFilter -> FindingCriteria -> CreateFilter)
-> Lens CreateFilter CreateFilter FindingCriteria FindingCriteria
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFilter' {FindingCriteria
findingCriteria :: FindingCriteria
$sel:findingCriteria:CreateFilter' :: CreateFilter -> FindingCriteria
findingCriteria} -> FindingCriteria
findingCriteria) (\s :: CreateFilter
s@CreateFilter' {} FindingCriteria
a -> CreateFilter
s {$sel:findingCriteria:CreateFilter' :: FindingCriteria
findingCriteria = FindingCriteria
a} :: CreateFilter)

instance Core.AWSRequest CreateFilter where
  type AWSResponse CreateFilter = CreateFilterResponse
  request :: CreateFilter -> Request CreateFilter
request = Service -> CreateFilter -> Request CreateFilter
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateFilter
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateFilter)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateFilter))
-> Logger
-> Service
-> Proxy CreateFilter
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateFilter)))
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 ->
          Int -> Text -> CreateFilterResponse
CreateFilterResponse'
            (Int -> Text -> CreateFilterResponse)
-> Either String Int
-> Either String (Text -> CreateFilterResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String (Text -> CreateFilterResponse)
-> Either String Text -> Either String CreateFilterResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"name")
      )

instance Prelude.Hashable CreateFilter

instance Prelude.NFData CreateFilter

instance Core.ToHeaders CreateFilter where
  toHeaders :: CreateFilter -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateFilter -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 CreateFilter where
  toJSON :: CreateFilter -> Value
toJSON CreateFilter' {Maybe Natural
Maybe Text
Maybe (HashMap Text Text)
Maybe FilterAction
Text
FindingCriteria
findingCriteria :: FindingCriteria
name :: Text
detectorId :: Text
tags :: Maybe (HashMap Text Text)
rank :: Maybe Natural
description :: Maybe Text
action :: Maybe FilterAction
clientToken :: Maybe Text
$sel:findingCriteria:CreateFilter' :: CreateFilter -> FindingCriteria
$sel:name:CreateFilter' :: CreateFilter -> Text
$sel:detectorId:CreateFilter' :: CreateFilter -> Text
$sel:tags:CreateFilter' :: CreateFilter -> Maybe (HashMap Text Text)
$sel:rank:CreateFilter' :: CreateFilter -> Maybe Natural
$sel:description:CreateFilter' :: CreateFilter -> Maybe Text
$sel:action:CreateFilter' :: CreateFilter -> Maybe FilterAction
$sel:clientToken:CreateFilter' :: CreateFilter -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"clientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            (Text
"action" Text -> FilterAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FilterAction -> Pair) -> Maybe FilterAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FilterAction
action,
            (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Text
"rank" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
rank,
            (Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"findingCriteria" Text -> FindingCriteria -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= FindingCriteria
findingCriteria)
          ]
      )

instance Core.ToPath CreateFilter where
  toPath :: CreateFilter -> ByteString
toPath CreateFilter' {Maybe Natural
Maybe Text
Maybe (HashMap Text Text)
Maybe FilterAction
Text
FindingCriteria
findingCriteria :: FindingCriteria
name :: Text
detectorId :: Text
tags :: Maybe (HashMap Text Text)
rank :: Maybe Natural
description :: Maybe Text
action :: Maybe FilterAction
clientToken :: Maybe Text
$sel:findingCriteria:CreateFilter' :: CreateFilter -> FindingCriteria
$sel:name:CreateFilter' :: CreateFilter -> Text
$sel:detectorId:CreateFilter' :: CreateFilter -> Text
$sel:tags:CreateFilter' :: CreateFilter -> Maybe (HashMap Text Text)
$sel:rank:CreateFilter' :: CreateFilter -> Maybe Natural
$sel:description:CreateFilter' :: CreateFilter -> Maybe Text
$sel:action:CreateFilter' :: CreateFilter -> Maybe FilterAction
$sel:clientToken:CreateFilter' :: CreateFilter -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/detector/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
detectorId, ByteString
"/filter"]

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

-- | /See:/ 'newCreateFilterResponse' smart constructor.
data CreateFilterResponse = CreateFilterResponse'
  { -- | The response's http status code.
    CreateFilterResponse -> Int
httpStatus :: Prelude.Int,
    -- | The name of the successfully created filter.
    CreateFilterResponse -> Text
name :: Prelude.Text
  }
  deriving (CreateFilterResponse -> CreateFilterResponse -> Bool
(CreateFilterResponse -> CreateFilterResponse -> Bool)
-> (CreateFilterResponse -> CreateFilterResponse -> Bool)
-> Eq CreateFilterResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFilterResponse -> CreateFilterResponse -> Bool
$c/= :: CreateFilterResponse -> CreateFilterResponse -> Bool
== :: CreateFilterResponse -> CreateFilterResponse -> Bool
$c== :: CreateFilterResponse -> CreateFilterResponse -> Bool
Prelude.Eq, ReadPrec [CreateFilterResponse]
ReadPrec CreateFilterResponse
Int -> ReadS CreateFilterResponse
ReadS [CreateFilterResponse]
(Int -> ReadS CreateFilterResponse)
-> ReadS [CreateFilterResponse]
-> ReadPrec CreateFilterResponse
-> ReadPrec [CreateFilterResponse]
-> Read CreateFilterResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateFilterResponse]
$creadListPrec :: ReadPrec [CreateFilterResponse]
readPrec :: ReadPrec CreateFilterResponse
$creadPrec :: ReadPrec CreateFilterResponse
readList :: ReadS [CreateFilterResponse]
$creadList :: ReadS [CreateFilterResponse]
readsPrec :: Int -> ReadS CreateFilterResponse
$creadsPrec :: Int -> ReadS CreateFilterResponse
Prelude.Read, Int -> CreateFilterResponse -> ShowS
[CreateFilterResponse] -> ShowS
CreateFilterResponse -> String
(Int -> CreateFilterResponse -> ShowS)
-> (CreateFilterResponse -> String)
-> ([CreateFilterResponse] -> ShowS)
-> Show CreateFilterResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFilterResponse] -> ShowS
$cshowList :: [CreateFilterResponse] -> ShowS
show :: CreateFilterResponse -> String
$cshow :: CreateFilterResponse -> String
showsPrec :: Int -> CreateFilterResponse -> ShowS
$cshowsPrec :: Int -> CreateFilterResponse -> ShowS
Prelude.Show, (forall x. CreateFilterResponse -> Rep CreateFilterResponse x)
-> (forall x. Rep CreateFilterResponse x -> CreateFilterResponse)
-> Generic CreateFilterResponse
forall x. Rep CreateFilterResponse x -> CreateFilterResponse
forall x. CreateFilterResponse -> Rep CreateFilterResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateFilterResponse x -> CreateFilterResponse
$cfrom :: forall x. CreateFilterResponse -> Rep CreateFilterResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateFilterResponse' 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:
--
-- 'httpStatus', 'createFilterResponse_httpStatus' - The response's http status code.
--
-- 'name', 'createFilterResponse_name' - The name of the successfully created filter.
newCreateFilterResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'name'
  Prelude.Text ->
  CreateFilterResponse
newCreateFilterResponse :: Int -> Text -> CreateFilterResponse
newCreateFilterResponse Int
pHttpStatus_ Text
pName_ =
  CreateFilterResponse' :: Int -> Text -> CreateFilterResponse
CreateFilterResponse'
    { $sel:httpStatus:CreateFilterResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:name:CreateFilterResponse' :: Text
name = Text
pName_
    }

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

-- | The name of the successfully created filter.
createFilterResponse_name :: Lens.Lens' CreateFilterResponse Prelude.Text
createFilterResponse_name :: (Text -> f Text) -> CreateFilterResponse -> f CreateFilterResponse
createFilterResponse_name = (CreateFilterResponse -> Text)
-> (CreateFilterResponse -> Text -> CreateFilterResponse)
-> Lens CreateFilterResponse CreateFilterResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFilterResponse' {Text
name :: Text
$sel:name:CreateFilterResponse' :: CreateFilterResponse -> Text
name} -> Text
name) (\s :: CreateFilterResponse
s@CreateFilterResponse' {} Text
a -> CreateFilterResponse
s {$sel:name:CreateFilterResponse' :: Text
name = Text
a} :: CreateFilterResponse)

instance Prelude.NFData CreateFilterResponse