{-# 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.CloudTrail.PutEventSelectors
-- 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)
--
-- Configures an event selector or advanced event selectors for your trail.
-- Use event selectors or advanced event selectors to specify management
-- and data event settings for your trail. By default, trails created
-- without specific event selectors are configured to log all read and
-- write management events, and no data events.
--
-- When an event occurs in your account, CloudTrail evaluates the event
-- selectors or advanced event selectors in all trails. For each trail, if
-- the event matches any event selector, the trail processes and logs the
-- event. If the event doesn\'t match any event selector, the trail
-- doesn\'t log the event.
--
-- Example
--
-- 1.  You create an event selector for a trail and specify that you want
--     write-only events.
--
-- 2.  The EC2 @GetConsoleOutput@ and @RunInstances@ API operations occur
--     in your account.
--
-- 3.  CloudTrail evaluates whether the events match your event selectors.
--
-- 4.  The @RunInstances@ is a write-only event and it matches your event
--     selector. The trail logs the event.
--
-- 5.  The @GetConsoleOutput@ is a read-only event that doesn\'t match your
--     event selector. The trail doesn\'t log the event.
--
-- The @PutEventSelectors@ operation must be called from the region in
-- which the trail was created; otherwise, an @InvalidHomeRegionException@
-- exception is thrown.
--
-- You can configure up to five event selectors for each trail. For more
-- information, see
-- <https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-management-and-data-events-with-cloudtrail.html Logging data and management events for trails>
-- and
-- <https://docs.aws.amazon.com/awscloudtrail/latest/userguide/WhatIsCloudTrail-Limits.html Quotas in CloudTrail>
-- in the /CloudTrail User Guide/.
--
-- You can add advanced event selectors, and conditions for your advanced
-- event selectors, up to a maximum of 500 values for all conditions and
-- selectors on a trail. You can use either @AdvancedEventSelectors@ or
-- @EventSelectors@, but not both. If you apply @AdvancedEventSelectors@ to
-- a trail, any existing @EventSelectors@ are overwritten. For more
-- information about advanced event selectors, see
-- <https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html Logging data events for trails>
-- in the /CloudTrail User Guide/.
module Amazonka.CloudTrail.PutEventSelectors
  ( -- * Creating a Request
    PutEventSelectors (..),
    newPutEventSelectors,

    -- * Request Lenses
    putEventSelectors_eventSelectors,
    putEventSelectors_advancedEventSelectors,
    putEventSelectors_trailName,

    -- * Destructuring the Response
    PutEventSelectorsResponse (..),
    newPutEventSelectorsResponse,

    -- * Response Lenses
    putEventSelectorsResponse_trailARN,
    putEventSelectorsResponse_eventSelectors,
    putEventSelectorsResponse_advancedEventSelectors,
    putEventSelectorsResponse_httpStatus,
  )
where

import Amazonka.CloudTrail.Types
import qualified Amazonka.Core as Core
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:/ 'newPutEventSelectors' smart constructor.
data PutEventSelectors = PutEventSelectors'
  { -- | Specifies the settings for your event selectors. You can configure up to
    -- five event selectors for a trail. You can use either @EventSelectors@ or
    -- @AdvancedEventSelectors@ in a @PutEventSelectors@ request, but not both.
    -- If you apply @EventSelectors@ to a trail, any existing
    -- @AdvancedEventSelectors@ are overwritten.
    PutEventSelectors -> Maybe [EventSelector]
eventSelectors :: Prelude.Maybe [EventSelector],
    -- | Specifies the settings for advanced event selectors. You can add
    -- advanced event selectors, and conditions for your advanced event
    -- selectors, up to a maximum of 500 values for all conditions and
    -- selectors on a trail. You can use either @AdvancedEventSelectors@ or
    -- @EventSelectors@, but not both. If you apply @AdvancedEventSelectors@ to
    -- a trail, any existing @EventSelectors@ are overwritten. For more
    -- information about advanced event selectors, see
    -- <https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html Logging data events for trails>
    -- in the /CloudTrail User Guide/.
    PutEventSelectors -> Maybe [AdvancedEventSelector]
advancedEventSelectors :: Prelude.Maybe [AdvancedEventSelector],
    -- | Specifies the name of the trail or trail ARN. If you specify a trail
    -- name, the string must meet the following requirements:
    --
    -- -   Contain only ASCII letters (a-z, A-Z), numbers (0-9), periods (.),
    --     underscores (_), or dashes (-)
    --
    -- -   Start with a letter or number, and end with a letter or number
    --
    -- -   Be between 3 and 128 characters
    --
    -- -   Have no adjacent periods, underscores or dashes. Names like
    --     @my-_namespace@ and @my--namespace@ are not valid.
    --
    -- -   Not be in IP address format (for example, 192.168.5.4)
    --
    -- If you specify a trail ARN, it must be in the following format.
    --
    -- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@
    PutEventSelectors -> Text
trailName :: Prelude.Text
  }
  deriving (PutEventSelectors -> PutEventSelectors -> Bool
(PutEventSelectors -> PutEventSelectors -> Bool)
-> (PutEventSelectors -> PutEventSelectors -> Bool)
-> Eq PutEventSelectors
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEventSelectors -> PutEventSelectors -> Bool
$c/= :: PutEventSelectors -> PutEventSelectors -> Bool
== :: PutEventSelectors -> PutEventSelectors -> Bool
$c== :: PutEventSelectors -> PutEventSelectors -> Bool
Prelude.Eq, ReadPrec [PutEventSelectors]
ReadPrec PutEventSelectors
Int -> ReadS PutEventSelectors
ReadS [PutEventSelectors]
(Int -> ReadS PutEventSelectors)
-> ReadS [PutEventSelectors]
-> ReadPrec PutEventSelectors
-> ReadPrec [PutEventSelectors]
-> Read PutEventSelectors
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEventSelectors]
$creadListPrec :: ReadPrec [PutEventSelectors]
readPrec :: ReadPrec PutEventSelectors
$creadPrec :: ReadPrec PutEventSelectors
readList :: ReadS [PutEventSelectors]
$creadList :: ReadS [PutEventSelectors]
readsPrec :: Int -> ReadS PutEventSelectors
$creadsPrec :: Int -> ReadS PutEventSelectors
Prelude.Read, Int -> PutEventSelectors -> ShowS
[PutEventSelectors] -> ShowS
PutEventSelectors -> String
(Int -> PutEventSelectors -> ShowS)
-> (PutEventSelectors -> String)
-> ([PutEventSelectors] -> ShowS)
-> Show PutEventSelectors
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEventSelectors] -> ShowS
$cshowList :: [PutEventSelectors] -> ShowS
show :: PutEventSelectors -> String
$cshow :: PutEventSelectors -> String
showsPrec :: Int -> PutEventSelectors -> ShowS
$cshowsPrec :: Int -> PutEventSelectors -> ShowS
Prelude.Show, (forall x. PutEventSelectors -> Rep PutEventSelectors x)
-> (forall x. Rep PutEventSelectors x -> PutEventSelectors)
-> Generic PutEventSelectors
forall x. Rep PutEventSelectors x -> PutEventSelectors
forall x. PutEventSelectors -> Rep PutEventSelectors x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutEventSelectors x -> PutEventSelectors
$cfrom :: forall x. PutEventSelectors -> Rep PutEventSelectors x
Prelude.Generic)

-- |
-- Create a value of 'PutEventSelectors' 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:
--
-- 'eventSelectors', 'putEventSelectors_eventSelectors' - Specifies the settings for your event selectors. You can configure up to
-- five event selectors for a trail. You can use either @EventSelectors@ or
-- @AdvancedEventSelectors@ in a @PutEventSelectors@ request, but not both.
-- If you apply @EventSelectors@ to a trail, any existing
-- @AdvancedEventSelectors@ are overwritten.
--
-- 'advancedEventSelectors', 'putEventSelectors_advancedEventSelectors' - Specifies the settings for advanced event selectors. You can add
-- advanced event selectors, and conditions for your advanced event
-- selectors, up to a maximum of 500 values for all conditions and
-- selectors on a trail. You can use either @AdvancedEventSelectors@ or
-- @EventSelectors@, but not both. If you apply @AdvancedEventSelectors@ to
-- a trail, any existing @EventSelectors@ are overwritten. For more
-- information about advanced event selectors, see
-- <https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html Logging data events for trails>
-- in the /CloudTrail User Guide/.
--
-- 'trailName', 'putEventSelectors_trailName' - Specifies the name of the trail or trail ARN. If you specify a trail
-- name, the string must meet the following requirements:
--
-- -   Contain only ASCII letters (a-z, A-Z), numbers (0-9), periods (.),
--     underscores (_), or dashes (-)
--
-- -   Start with a letter or number, and end with a letter or number
--
-- -   Be between 3 and 128 characters
--
-- -   Have no adjacent periods, underscores or dashes. Names like
--     @my-_namespace@ and @my--namespace@ are not valid.
--
-- -   Not be in IP address format (for example, 192.168.5.4)
--
-- If you specify a trail ARN, it must be in the following format.
--
-- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@
newPutEventSelectors ::
  -- | 'trailName'
  Prelude.Text ->
  PutEventSelectors
newPutEventSelectors :: Text -> PutEventSelectors
newPutEventSelectors Text
pTrailName_ =
  PutEventSelectors' :: Maybe [EventSelector]
-> Maybe [AdvancedEventSelector] -> Text -> PutEventSelectors
PutEventSelectors'
    { $sel:eventSelectors:PutEventSelectors' :: Maybe [EventSelector]
eventSelectors =
        Maybe [EventSelector]
forall a. Maybe a
Prelude.Nothing,
      $sel:advancedEventSelectors:PutEventSelectors' :: Maybe [AdvancedEventSelector]
advancedEventSelectors = Maybe [AdvancedEventSelector]
forall a. Maybe a
Prelude.Nothing,
      $sel:trailName:PutEventSelectors' :: Text
trailName = Text
pTrailName_
    }

-- | Specifies the settings for your event selectors. You can configure up to
-- five event selectors for a trail. You can use either @EventSelectors@ or
-- @AdvancedEventSelectors@ in a @PutEventSelectors@ request, but not both.
-- If you apply @EventSelectors@ to a trail, any existing
-- @AdvancedEventSelectors@ are overwritten.
putEventSelectors_eventSelectors :: Lens.Lens' PutEventSelectors (Prelude.Maybe [EventSelector])
putEventSelectors_eventSelectors :: (Maybe [EventSelector] -> f (Maybe [EventSelector]))
-> PutEventSelectors -> f PutEventSelectors
putEventSelectors_eventSelectors = (PutEventSelectors -> Maybe [EventSelector])
-> (PutEventSelectors
    -> Maybe [EventSelector] -> PutEventSelectors)
-> Lens
     PutEventSelectors
     PutEventSelectors
     (Maybe [EventSelector])
     (Maybe [EventSelector])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventSelectors' {Maybe [EventSelector]
eventSelectors :: Maybe [EventSelector]
$sel:eventSelectors:PutEventSelectors' :: PutEventSelectors -> Maybe [EventSelector]
eventSelectors} -> Maybe [EventSelector]
eventSelectors) (\s :: PutEventSelectors
s@PutEventSelectors' {} Maybe [EventSelector]
a -> PutEventSelectors
s {$sel:eventSelectors:PutEventSelectors' :: Maybe [EventSelector]
eventSelectors = Maybe [EventSelector]
a} :: PutEventSelectors) ((Maybe [EventSelector] -> f (Maybe [EventSelector]))
 -> PutEventSelectors -> f PutEventSelectors)
-> ((Maybe [EventSelector] -> f (Maybe [EventSelector]))
    -> Maybe [EventSelector] -> f (Maybe [EventSelector]))
-> (Maybe [EventSelector] -> f (Maybe [EventSelector]))
-> PutEventSelectors
-> f PutEventSelectors
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [EventSelector] [EventSelector] [EventSelector] [EventSelector]
-> Iso
     (Maybe [EventSelector])
     (Maybe [EventSelector])
     (Maybe [EventSelector])
     (Maybe [EventSelector])
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
  [EventSelector] [EventSelector] [EventSelector] [EventSelector]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the settings for advanced event selectors. You can add
-- advanced event selectors, and conditions for your advanced event
-- selectors, up to a maximum of 500 values for all conditions and
-- selectors on a trail. You can use either @AdvancedEventSelectors@ or
-- @EventSelectors@, but not both. If you apply @AdvancedEventSelectors@ to
-- a trail, any existing @EventSelectors@ are overwritten. For more
-- information about advanced event selectors, see
-- <https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html Logging data events for trails>
-- in the /CloudTrail User Guide/.
putEventSelectors_advancedEventSelectors :: Lens.Lens' PutEventSelectors (Prelude.Maybe [AdvancedEventSelector])
putEventSelectors_advancedEventSelectors :: (Maybe [AdvancedEventSelector]
 -> f (Maybe [AdvancedEventSelector]))
-> PutEventSelectors -> f PutEventSelectors
putEventSelectors_advancedEventSelectors = (PutEventSelectors -> Maybe [AdvancedEventSelector])
-> (PutEventSelectors
    -> Maybe [AdvancedEventSelector] -> PutEventSelectors)
-> Lens
     PutEventSelectors
     PutEventSelectors
     (Maybe [AdvancedEventSelector])
     (Maybe [AdvancedEventSelector])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventSelectors' {Maybe [AdvancedEventSelector]
advancedEventSelectors :: Maybe [AdvancedEventSelector]
$sel:advancedEventSelectors:PutEventSelectors' :: PutEventSelectors -> Maybe [AdvancedEventSelector]
advancedEventSelectors} -> Maybe [AdvancedEventSelector]
advancedEventSelectors) (\s :: PutEventSelectors
s@PutEventSelectors' {} Maybe [AdvancedEventSelector]
a -> PutEventSelectors
s {$sel:advancedEventSelectors:PutEventSelectors' :: Maybe [AdvancedEventSelector]
advancedEventSelectors = Maybe [AdvancedEventSelector]
a} :: PutEventSelectors) ((Maybe [AdvancedEventSelector]
  -> f (Maybe [AdvancedEventSelector]))
 -> PutEventSelectors -> f PutEventSelectors)
-> ((Maybe [AdvancedEventSelector]
     -> f (Maybe [AdvancedEventSelector]))
    -> Maybe [AdvancedEventSelector]
    -> f (Maybe [AdvancedEventSelector]))
-> (Maybe [AdvancedEventSelector]
    -> f (Maybe [AdvancedEventSelector]))
-> PutEventSelectors
-> f PutEventSelectors
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AdvancedEventSelector]
  [AdvancedEventSelector]
  [AdvancedEventSelector]
  [AdvancedEventSelector]
-> Iso
     (Maybe [AdvancedEventSelector])
     (Maybe [AdvancedEventSelector])
     (Maybe [AdvancedEventSelector])
     (Maybe [AdvancedEventSelector])
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
  [AdvancedEventSelector]
  [AdvancedEventSelector]
  [AdvancedEventSelector]
  [AdvancedEventSelector]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the name of the trail or trail ARN. If you specify a trail
-- name, the string must meet the following requirements:
--
-- -   Contain only ASCII letters (a-z, A-Z), numbers (0-9), periods (.),
--     underscores (_), or dashes (-)
--
-- -   Start with a letter or number, and end with a letter or number
--
-- -   Be between 3 and 128 characters
--
-- -   Have no adjacent periods, underscores or dashes. Names like
--     @my-_namespace@ and @my--namespace@ are not valid.
--
-- -   Not be in IP address format (for example, 192.168.5.4)
--
-- If you specify a trail ARN, it must be in the following format.
--
-- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@
putEventSelectors_trailName :: Lens.Lens' PutEventSelectors Prelude.Text
putEventSelectors_trailName :: (Text -> f Text) -> PutEventSelectors -> f PutEventSelectors
putEventSelectors_trailName = (PutEventSelectors -> Text)
-> (PutEventSelectors -> Text -> PutEventSelectors)
-> Lens PutEventSelectors PutEventSelectors Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventSelectors' {Text
trailName :: Text
$sel:trailName:PutEventSelectors' :: PutEventSelectors -> Text
trailName} -> Text
trailName) (\s :: PutEventSelectors
s@PutEventSelectors' {} Text
a -> PutEventSelectors
s {$sel:trailName:PutEventSelectors' :: Text
trailName = Text
a} :: PutEventSelectors)

instance Core.AWSRequest PutEventSelectors where
  type
    AWSResponse PutEventSelectors =
      PutEventSelectorsResponse
  request :: PutEventSelectors -> Request PutEventSelectors
request = Service -> PutEventSelectors -> Request PutEventSelectors
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutEventSelectors
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutEventSelectors)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PutEventSelectors))
-> Logger
-> Service
-> Proxy PutEventSelectors
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutEventSelectors)))
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 ->
          Maybe Text
-> Maybe [EventSelector]
-> Maybe [AdvancedEventSelector]
-> Int
-> PutEventSelectorsResponse
PutEventSelectorsResponse'
            (Maybe Text
 -> Maybe [EventSelector]
 -> Maybe [AdvancedEventSelector]
 -> Int
 -> PutEventSelectorsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [EventSelector]
      -> Maybe [AdvancedEventSelector]
      -> Int
      -> PutEventSelectorsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"TrailARN")
            Either
  String
  (Maybe [EventSelector]
   -> Maybe [AdvancedEventSelector]
   -> Int
   -> PutEventSelectorsResponse)
-> Either String (Maybe [EventSelector])
-> Either
     String
     (Maybe [AdvancedEventSelector] -> Int -> PutEventSelectorsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [EventSelector]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"EventSelectors" Either String (Maybe (Maybe [EventSelector]))
-> Maybe [EventSelector] -> Either String (Maybe [EventSelector])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [EventSelector]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String
  (Maybe [AdvancedEventSelector] -> Int -> PutEventSelectorsResponse)
-> Either String (Maybe [AdvancedEventSelector])
-> Either String (Int -> PutEventSelectorsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Either String (Maybe (Maybe [AdvancedEventSelector]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AdvancedEventSelectors"
                            Either String (Maybe (Maybe [AdvancedEventSelector]))
-> Maybe [AdvancedEventSelector]
-> Either String (Maybe [AdvancedEventSelector])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [AdvancedEventSelector]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> PutEventSelectorsResponse)
-> Either String Int -> Either String PutEventSelectorsResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable PutEventSelectors

instance Prelude.NFData PutEventSelectors

instance Core.ToHeaders PutEventSelectors where
  toHeaders :: PutEventSelectors -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutEventSelectors -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.PutEventSelectors" ::
                          Prelude.ByteString
                      ),
            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 PutEventSelectors where
  toJSON :: PutEventSelectors -> Value
toJSON PutEventSelectors' {Maybe [AdvancedEventSelector]
Maybe [EventSelector]
Text
trailName :: Text
advancedEventSelectors :: Maybe [AdvancedEventSelector]
eventSelectors :: Maybe [EventSelector]
$sel:trailName:PutEventSelectors' :: PutEventSelectors -> Text
$sel:advancedEventSelectors:PutEventSelectors' :: PutEventSelectors -> Maybe [AdvancedEventSelector]
$sel:eventSelectors:PutEventSelectors' :: PutEventSelectors -> Maybe [EventSelector]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EventSelectors" Text -> [EventSelector] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([EventSelector] -> Pair) -> Maybe [EventSelector] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [EventSelector]
eventSelectors,
            (Text
"AdvancedEventSelectors" Text -> [AdvancedEventSelector] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([AdvancedEventSelector] -> Pair)
-> Maybe [AdvancedEventSelector] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AdvancedEventSelector]
advancedEventSelectors,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TrailName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
trailName)
          ]
      )

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

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

-- | /See:/ 'newPutEventSelectorsResponse' smart constructor.
data PutEventSelectorsResponse = PutEventSelectorsResponse'
  { -- | Specifies the ARN of the trail that was updated with event selectors.
    -- The following is the format of a trail ARN.
    --
    -- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@
    PutEventSelectorsResponse -> Maybe Text
trailARN :: Prelude.Maybe Prelude.Text,
    -- | Specifies the event selectors configured for your trail.
    PutEventSelectorsResponse -> Maybe [EventSelector]
eventSelectors :: Prelude.Maybe [EventSelector],
    -- | Specifies the advanced event selectors configured for your trail.
    PutEventSelectorsResponse -> Maybe [AdvancedEventSelector]
advancedEventSelectors :: Prelude.Maybe [AdvancedEventSelector],
    -- | The response's http status code.
    PutEventSelectorsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutEventSelectorsResponse -> PutEventSelectorsResponse -> Bool
(PutEventSelectorsResponse -> PutEventSelectorsResponse -> Bool)
-> (PutEventSelectorsResponse -> PutEventSelectorsResponse -> Bool)
-> Eq PutEventSelectorsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEventSelectorsResponse -> PutEventSelectorsResponse -> Bool
$c/= :: PutEventSelectorsResponse -> PutEventSelectorsResponse -> Bool
== :: PutEventSelectorsResponse -> PutEventSelectorsResponse -> Bool
$c== :: PutEventSelectorsResponse -> PutEventSelectorsResponse -> Bool
Prelude.Eq, ReadPrec [PutEventSelectorsResponse]
ReadPrec PutEventSelectorsResponse
Int -> ReadS PutEventSelectorsResponse
ReadS [PutEventSelectorsResponse]
(Int -> ReadS PutEventSelectorsResponse)
-> ReadS [PutEventSelectorsResponse]
-> ReadPrec PutEventSelectorsResponse
-> ReadPrec [PutEventSelectorsResponse]
-> Read PutEventSelectorsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEventSelectorsResponse]
$creadListPrec :: ReadPrec [PutEventSelectorsResponse]
readPrec :: ReadPrec PutEventSelectorsResponse
$creadPrec :: ReadPrec PutEventSelectorsResponse
readList :: ReadS [PutEventSelectorsResponse]
$creadList :: ReadS [PutEventSelectorsResponse]
readsPrec :: Int -> ReadS PutEventSelectorsResponse
$creadsPrec :: Int -> ReadS PutEventSelectorsResponse
Prelude.Read, Int -> PutEventSelectorsResponse -> ShowS
[PutEventSelectorsResponse] -> ShowS
PutEventSelectorsResponse -> String
(Int -> PutEventSelectorsResponse -> ShowS)
-> (PutEventSelectorsResponse -> String)
-> ([PutEventSelectorsResponse] -> ShowS)
-> Show PutEventSelectorsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEventSelectorsResponse] -> ShowS
$cshowList :: [PutEventSelectorsResponse] -> ShowS
show :: PutEventSelectorsResponse -> String
$cshow :: PutEventSelectorsResponse -> String
showsPrec :: Int -> PutEventSelectorsResponse -> ShowS
$cshowsPrec :: Int -> PutEventSelectorsResponse -> ShowS
Prelude.Show, (forall x.
 PutEventSelectorsResponse -> Rep PutEventSelectorsResponse x)
-> (forall x.
    Rep PutEventSelectorsResponse x -> PutEventSelectorsResponse)
-> Generic PutEventSelectorsResponse
forall x.
Rep PutEventSelectorsResponse x -> PutEventSelectorsResponse
forall x.
PutEventSelectorsResponse -> Rep PutEventSelectorsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutEventSelectorsResponse x -> PutEventSelectorsResponse
$cfrom :: forall x.
PutEventSelectorsResponse -> Rep PutEventSelectorsResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutEventSelectorsResponse' 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:
--
-- 'trailARN', 'putEventSelectorsResponse_trailARN' - Specifies the ARN of the trail that was updated with event selectors.
-- The following is the format of a trail ARN.
--
-- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@
--
-- 'eventSelectors', 'putEventSelectorsResponse_eventSelectors' - Specifies the event selectors configured for your trail.
--
-- 'advancedEventSelectors', 'putEventSelectorsResponse_advancedEventSelectors' - Specifies the advanced event selectors configured for your trail.
--
-- 'httpStatus', 'putEventSelectorsResponse_httpStatus' - The response's http status code.
newPutEventSelectorsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutEventSelectorsResponse
newPutEventSelectorsResponse :: Int -> PutEventSelectorsResponse
newPutEventSelectorsResponse Int
pHttpStatus_ =
  PutEventSelectorsResponse' :: Maybe Text
-> Maybe [EventSelector]
-> Maybe [AdvancedEventSelector]
-> Int
-> PutEventSelectorsResponse
PutEventSelectorsResponse'
    { $sel:trailARN:PutEventSelectorsResponse' :: Maybe Text
trailARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventSelectors:PutEventSelectorsResponse' :: Maybe [EventSelector]
eventSelectors = Maybe [EventSelector]
forall a. Maybe a
Prelude.Nothing,
      $sel:advancedEventSelectors:PutEventSelectorsResponse' :: Maybe [AdvancedEventSelector]
advancedEventSelectors = Maybe [AdvancedEventSelector]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutEventSelectorsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Specifies the ARN of the trail that was updated with event selectors.
-- The following is the format of a trail ARN.
--
-- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@
putEventSelectorsResponse_trailARN :: Lens.Lens' PutEventSelectorsResponse (Prelude.Maybe Prelude.Text)
putEventSelectorsResponse_trailARN :: (Maybe Text -> f (Maybe Text))
-> PutEventSelectorsResponse -> f PutEventSelectorsResponse
putEventSelectorsResponse_trailARN = (PutEventSelectorsResponse -> Maybe Text)
-> (PutEventSelectorsResponse
    -> Maybe Text -> PutEventSelectorsResponse)
-> Lens
     PutEventSelectorsResponse
     PutEventSelectorsResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventSelectorsResponse' {Maybe Text
trailARN :: Maybe Text
$sel:trailARN:PutEventSelectorsResponse' :: PutEventSelectorsResponse -> Maybe Text
trailARN} -> Maybe Text
trailARN) (\s :: PutEventSelectorsResponse
s@PutEventSelectorsResponse' {} Maybe Text
a -> PutEventSelectorsResponse
s {$sel:trailARN:PutEventSelectorsResponse' :: Maybe Text
trailARN = Maybe Text
a} :: PutEventSelectorsResponse)

-- | Specifies the event selectors configured for your trail.
putEventSelectorsResponse_eventSelectors :: Lens.Lens' PutEventSelectorsResponse (Prelude.Maybe [EventSelector])
putEventSelectorsResponse_eventSelectors :: (Maybe [EventSelector] -> f (Maybe [EventSelector]))
-> PutEventSelectorsResponse -> f PutEventSelectorsResponse
putEventSelectorsResponse_eventSelectors = (PutEventSelectorsResponse -> Maybe [EventSelector])
-> (PutEventSelectorsResponse
    -> Maybe [EventSelector] -> PutEventSelectorsResponse)
-> Lens
     PutEventSelectorsResponse
     PutEventSelectorsResponse
     (Maybe [EventSelector])
     (Maybe [EventSelector])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventSelectorsResponse' {Maybe [EventSelector]
eventSelectors :: Maybe [EventSelector]
$sel:eventSelectors:PutEventSelectorsResponse' :: PutEventSelectorsResponse -> Maybe [EventSelector]
eventSelectors} -> Maybe [EventSelector]
eventSelectors) (\s :: PutEventSelectorsResponse
s@PutEventSelectorsResponse' {} Maybe [EventSelector]
a -> PutEventSelectorsResponse
s {$sel:eventSelectors:PutEventSelectorsResponse' :: Maybe [EventSelector]
eventSelectors = Maybe [EventSelector]
a} :: PutEventSelectorsResponse) ((Maybe [EventSelector] -> f (Maybe [EventSelector]))
 -> PutEventSelectorsResponse -> f PutEventSelectorsResponse)
-> ((Maybe [EventSelector] -> f (Maybe [EventSelector]))
    -> Maybe [EventSelector] -> f (Maybe [EventSelector]))
-> (Maybe [EventSelector] -> f (Maybe [EventSelector]))
-> PutEventSelectorsResponse
-> f PutEventSelectorsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [EventSelector] [EventSelector] [EventSelector] [EventSelector]
-> Iso
     (Maybe [EventSelector])
     (Maybe [EventSelector])
     (Maybe [EventSelector])
     (Maybe [EventSelector])
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
  [EventSelector] [EventSelector] [EventSelector] [EventSelector]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the advanced event selectors configured for your trail.
putEventSelectorsResponse_advancedEventSelectors :: Lens.Lens' PutEventSelectorsResponse (Prelude.Maybe [AdvancedEventSelector])
putEventSelectorsResponse_advancedEventSelectors :: (Maybe [AdvancedEventSelector]
 -> f (Maybe [AdvancedEventSelector]))
-> PutEventSelectorsResponse -> f PutEventSelectorsResponse
putEventSelectorsResponse_advancedEventSelectors = (PutEventSelectorsResponse -> Maybe [AdvancedEventSelector])
-> (PutEventSelectorsResponse
    -> Maybe [AdvancedEventSelector] -> PutEventSelectorsResponse)
-> Lens
     PutEventSelectorsResponse
     PutEventSelectorsResponse
     (Maybe [AdvancedEventSelector])
     (Maybe [AdvancedEventSelector])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventSelectorsResponse' {Maybe [AdvancedEventSelector]
advancedEventSelectors :: Maybe [AdvancedEventSelector]
$sel:advancedEventSelectors:PutEventSelectorsResponse' :: PutEventSelectorsResponse -> Maybe [AdvancedEventSelector]
advancedEventSelectors} -> Maybe [AdvancedEventSelector]
advancedEventSelectors) (\s :: PutEventSelectorsResponse
s@PutEventSelectorsResponse' {} Maybe [AdvancedEventSelector]
a -> PutEventSelectorsResponse
s {$sel:advancedEventSelectors:PutEventSelectorsResponse' :: Maybe [AdvancedEventSelector]
advancedEventSelectors = Maybe [AdvancedEventSelector]
a} :: PutEventSelectorsResponse) ((Maybe [AdvancedEventSelector]
  -> f (Maybe [AdvancedEventSelector]))
 -> PutEventSelectorsResponse -> f PutEventSelectorsResponse)
-> ((Maybe [AdvancedEventSelector]
     -> f (Maybe [AdvancedEventSelector]))
    -> Maybe [AdvancedEventSelector]
    -> f (Maybe [AdvancedEventSelector]))
-> (Maybe [AdvancedEventSelector]
    -> f (Maybe [AdvancedEventSelector]))
-> PutEventSelectorsResponse
-> f PutEventSelectorsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AdvancedEventSelector]
  [AdvancedEventSelector]
  [AdvancedEventSelector]
  [AdvancedEventSelector]
-> Iso
     (Maybe [AdvancedEventSelector])
     (Maybe [AdvancedEventSelector])
     (Maybe [AdvancedEventSelector])
     (Maybe [AdvancedEventSelector])
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
  [AdvancedEventSelector]
  [AdvancedEventSelector]
  [AdvancedEventSelector]
  [AdvancedEventSelector]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData PutEventSelectorsResponse