{-# 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.IoT.CreateSecurityProfile
-- 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 Device Defender security profile.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions CreateSecurityProfile>
-- action.
module Amazonka.IoT.CreateSecurityProfile
  ( -- * Creating a Request
    CreateSecurityProfile (..),
    newCreateSecurityProfile,

    -- * Request Lenses
    createSecurityProfile_alertTargets,
    createSecurityProfile_additionalMetricsToRetainV2,
    createSecurityProfile_behaviors,
    createSecurityProfile_additionalMetricsToRetain,
    createSecurityProfile_securityProfileDescription,
    createSecurityProfile_tags,
    createSecurityProfile_securityProfileName,

    -- * Destructuring the Response
    CreateSecurityProfileResponse (..),
    newCreateSecurityProfileResponse,

    -- * Response Lenses
    createSecurityProfileResponse_securityProfileName,
    createSecurityProfileResponse_securityProfileArn,
    createSecurityProfileResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.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:/ 'newCreateSecurityProfile' smart constructor.
data CreateSecurityProfile = CreateSecurityProfile'
  { -- | Specifies the destinations to which alerts are sent. (Alerts are always
    -- sent to the console.) Alerts are generated when a device (thing)
    -- violates a behavior.
    CreateSecurityProfile
-> Maybe (HashMap AlertTargetType AlertTarget)
alertTargets :: Prelude.Maybe (Prelude.HashMap AlertTargetType AlertTarget),
    -- | A list of metrics whose data is retained (stored). By default, data is
    -- retained for any metric used in the profile\'s @behaviors@, but it is
    -- also retained for any metric specified here. Can be used with custom
    -- metrics; cannot be used with dimensions.
    CreateSecurityProfile -> Maybe [MetricToRetain]
additionalMetricsToRetainV2 :: Prelude.Maybe [MetricToRetain],
    -- | Specifies the behaviors that, when violated by a device (thing), cause
    -- an alert.
    CreateSecurityProfile -> Maybe [Behavior]
behaviors :: Prelude.Maybe [Behavior],
    -- | /Please use CreateSecurityProfileRequest$additionalMetricsToRetainV2
    -- instead./
    --
    -- A list of metrics whose data is retained (stored). By default, data is
    -- retained for any metric used in the profile\'s @behaviors@, but it is
    -- also retained for any metric specified here. Can be used with custom
    -- metrics; cannot be used with dimensions.
    CreateSecurityProfile -> Maybe [Text]
additionalMetricsToRetain :: Prelude.Maybe [Prelude.Text],
    -- | A description of the security profile.
    CreateSecurityProfile -> Maybe Text
securityProfileDescription :: Prelude.Maybe Prelude.Text,
    -- | Metadata that can be used to manage the security profile.
    CreateSecurityProfile -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name you are giving to the security profile.
    CreateSecurityProfile -> Text
securityProfileName :: Prelude.Text
  }
  deriving (CreateSecurityProfile -> CreateSecurityProfile -> Bool
(CreateSecurityProfile -> CreateSecurityProfile -> Bool)
-> (CreateSecurityProfile -> CreateSecurityProfile -> Bool)
-> Eq CreateSecurityProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSecurityProfile -> CreateSecurityProfile -> Bool
$c/= :: CreateSecurityProfile -> CreateSecurityProfile -> Bool
== :: CreateSecurityProfile -> CreateSecurityProfile -> Bool
$c== :: CreateSecurityProfile -> CreateSecurityProfile -> Bool
Prelude.Eq, ReadPrec [CreateSecurityProfile]
ReadPrec CreateSecurityProfile
Int -> ReadS CreateSecurityProfile
ReadS [CreateSecurityProfile]
(Int -> ReadS CreateSecurityProfile)
-> ReadS [CreateSecurityProfile]
-> ReadPrec CreateSecurityProfile
-> ReadPrec [CreateSecurityProfile]
-> Read CreateSecurityProfile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSecurityProfile]
$creadListPrec :: ReadPrec [CreateSecurityProfile]
readPrec :: ReadPrec CreateSecurityProfile
$creadPrec :: ReadPrec CreateSecurityProfile
readList :: ReadS [CreateSecurityProfile]
$creadList :: ReadS [CreateSecurityProfile]
readsPrec :: Int -> ReadS CreateSecurityProfile
$creadsPrec :: Int -> ReadS CreateSecurityProfile
Prelude.Read, Int -> CreateSecurityProfile -> ShowS
[CreateSecurityProfile] -> ShowS
CreateSecurityProfile -> String
(Int -> CreateSecurityProfile -> ShowS)
-> (CreateSecurityProfile -> String)
-> ([CreateSecurityProfile] -> ShowS)
-> Show CreateSecurityProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSecurityProfile] -> ShowS
$cshowList :: [CreateSecurityProfile] -> ShowS
show :: CreateSecurityProfile -> String
$cshow :: CreateSecurityProfile -> String
showsPrec :: Int -> CreateSecurityProfile -> ShowS
$cshowsPrec :: Int -> CreateSecurityProfile -> ShowS
Prelude.Show, (forall x. CreateSecurityProfile -> Rep CreateSecurityProfile x)
-> (forall x. Rep CreateSecurityProfile x -> CreateSecurityProfile)
-> Generic CreateSecurityProfile
forall x. Rep CreateSecurityProfile x -> CreateSecurityProfile
forall x. CreateSecurityProfile -> Rep CreateSecurityProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSecurityProfile x -> CreateSecurityProfile
$cfrom :: forall x. CreateSecurityProfile -> Rep CreateSecurityProfile x
Prelude.Generic)

-- |
-- Create a value of 'CreateSecurityProfile' 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:
--
-- 'alertTargets', 'createSecurityProfile_alertTargets' - Specifies the destinations to which alerts are sent. (Alerts are always
-- sent to the console.) Alerts are generated when a device (thing)
-- violates a behavior.
--
-- 'additionalMetricsToRetainV2', 'createSecurityProfile_additionalMetricsToRetainV2' - A list of metrics whose data is retained (stored). By default, data is
-- retained for any metric used in the profile\'s @behaviors@, but it is
-- also retained for any metric specified here. Can be used with custom
-- metrics; cannot be used with dimensions.
--
-- 'behaviors', 'createSecurityProfile_behaviors' - Specifies the behaviors that, when violated by a device (thing), cause
-- an alert.
--
-- 'additionalMetricsToRetain', 'createSecurityProfile_additionalMetricsToRetain' - /Please use CreateSecurityProfileRequest$additionalMetricsToRetainV2
-- instead./
--
-- A list of metrics whose data is retained (stored). By default, data is
-- retained for any metric used in the profile\'s @behaviors@, but it is
-- also retained for any metric specified here. Can be used with custom
-- metrics; cannot be used with dimensions.
--
-- 'securityProfileDescription', 'createSecurityProfile_securityProfileDescription' - A description of the security profile.
--
-- 'tags', 'createSecurityProfile_tags' - Metadata that can be used to manage the security profile.
--
-- 'securityProfileName', 'createSecurityProfile_securityProfileName' - The name you are giving to the security profile.
newCreateSecurityProfile ::
  -- | 'securityProfileName'
  Prelude.Text ->
  CreateSecurityProfile
newCreateSecurityProfile :: Text -> CreateSecurityProfile
newCreateSecurityProfile Text
pSecurityProfileName_ =
  CreateSecurityProfile' :: Maybe (HashMap AlertTargetType AlertTarget)
-> Maybe [MetricToRetain]
-> Maybe [Behavior]
-> Maybe [Text]
-> Maybe Text
-> Maybe [Tag]
-> Text
-> CreateSecurityProfile
CreateSecurityProfile'
    { $sel:alertTargets:CreateSecurityProfile' :: Maybe (HashMap AlertTargetType AlertTarget)
alertTargets =
        Maybe (HashMap AlertTargetType AlertTarget)
forall a. Maybe a
Prelude.Nothing,
      $sel:additionalMetricsToRetainV2:CreateSecurityProfile' :: Maybe [MetricToRetain]
additionalMetricsToRetainV2 = Maybe [MetricToRetain]
forall a. Maybe a
Prelude.Nothing,
      $sel:behaviors:CreateSecurityProfile' :: Maybe [Behavior]
behaviors = Maybe [Behavior]
forall a. Maybe a
Prelude.Nothing,
      $sel:additionalMetricsToRetain:CreateSecurityProfile' :: Maybe [Text]
additionalMetricsToRetain = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:securityProfileDescription:CreateSecurityProfile' :: Maybe Text
securityProfileDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateSecurityProfile' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:securityProfileName:CreateSecurityProfile' :: Text
securityProfileName = Text
pSecurityProfileName_
    }

-- | Specifies the destinations to which alerts are sent. (Alerts are always
-- sent to the console.) Alerts are generated when a device (thing)
-- violates a behavior.
createSecurityProfile_alertTargets :: Lens.Lens' CreateSecurityProfile (Prelude.Maybe (Prelude.HashMap AlertTargetType AlertTarget))
createSecurityProfile_alertTargets :: (Maybe (HashMap AlertTargetType AlertTarget)
 -> f (Maybe (HashMap AlertTargetType AlertTarget)))
-> CreateSecurityProfile -> f CreateSecurityProfile
createSecurityProfile_alertTargets = (CreateSecurityProfile
 -> Maybe (HashMap AlertTargetType AlertTarget))
-> (CreateSecurityProfile
    -> Maybe (HashMap AlertTargetType AlertTarget)
    -> CreateSecurityProfile)
-> Lens
     CreateSecurityProfile
     CreateSecurityProfile
     (Maybe (HashMap AlertTargetType AlertTarget))
     (Maybe (HashMap AlertTargetType AlertTarget))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSecurityProfile' {Maybe (HashMap AlertTargetType AlertTarget)
alertTargets :: Maybe (HashMap AlertTargetType AlertTarget)
$sel:alertTargets:CreateSecurityProfile' :: CreateSecurityProfile
-> Maybe (HashMap AlertTargetType AlertTarget)
alertTargets} -> Maybe (HashMap AlertTargetType AlertTarget)
alertTargets) (\s :: CreateSecurityProfile
s@CreateSecurityProfile' {} Maybe (HashMap AlertTargetType AlertTarget)
a -> CreateSecurityProfile
s {$sel:alertTargets:CreateSecurityProfile' :: Maybe (HashMap AlertTargetType AlertTarget)
alertTargets = Maybe (HashMap AlertTargetType AlertTarget)
a} :: CreateSecurityProfile) ((Maybe (HashMap AlertTargetType AlertTarget)
  -> f (Maybe (HashMap AlertTargetType AlertTarget)))
 -> CreateSecurityProfile -> f CreateSecurityProfile)
-> ((Maybe (HashMap AlertTargetType AlertTarget)
     -> f (Maybe (HashMap AlertTargetType AlertTarget)))
    -> Maybe (HashMap AlertTargetType AlertTarget)
    -> f (Maybe (HashMap AlertTargetType AlertTarget)))
-> (Maybe (HashMap AlertTargetType AlertTarget)
    -> f (Maybe (HashMap AlertTargetType AlertTarget)))
-> CreateSecurityProfile
-> f CreateSecurityProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap AlertTargetType AlertTarget)
  (HashMap AlertTargetType AlertTarget)
  (HashMap AlertTargetType AlertTarget)
  (HashMap AlertTargetType AlertTarget)
-> Iso
     (Maybe (HashMap AlertTargetType AlertTarget))
     (Maybe (HashMap AlertTargetType AlertTarget))
     (Maybe (HashMap AlertTargetType AlertTarget))
     (Maybe (HashMap AlertTargetType AlertTarget))
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 AlertTargetType AlertTarget)
  (HashMap AlertTargetType AlertTarget)
  (HashMap AlertTargetType AlertTarget)
  (HashMap AlertTargetType AlertTarget)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of metrics whose data is retained (stored). By default, data is
-- retained for any metric used in the profile\'s @behaviors@, but it is
-- also retained for any metric specified here. Can be used with custom
-- metrics; cannot be used with dimensions.
createSecurityProfile_additionalMetricsToRetainV2 :: Lens.Lens' CreateSecurityProfile (Prelude.Maybe [MetricToRetain])
createSecurityProfile_additionalMetricsToRetainV2 :: (Maybe [MetricToRetain] -> f (Maybe [MetricToRetain]))
-> CreateSecurityProfile -> f CreateSecurityProfile
createSecurityProfile_additionalMetricsToRetainV2 = (CreateSecurityProfile -> Maybe [MetricToRetain])
-> (CreateSecurityProfile
    -> Maybe [MetricToRetain] -> CreateSecurityProfile)
-> Lens
     CreateSecurityProfile
     CreateSecurityProfile
     (Maybe [MetricToRetain])
     (Maybe [MetricToRetain])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSecurityProfile' {Maybe [MetricToRetain]
additionalMetricsToRetainV2 :: Maybe [MetricToRetain]
$sel:additionalMetricsToRetainV2:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe [MetricToRetain]
additionalMetricsToRetainV2} -> Maybe [MetricToRetain]
additionalMetricsToRetainV2) (\s :: CreateSecurityProfile
s@CreateSecurityProfile' {} Maybe [MetricToRetain]
a -> CreateSecurityProfile
s {$sel:additionalMetricsToRetainV2:CreateSecurityProfile' :: Maybe [MetricToRetain]
additionalMetricsToRetainV2 = Maybe [MetricToRetain]
a} :: CreateSecurityProfile) ((Maybe [MetricToRetain] -> f (Maybe [MetricToRetain]))
 -> CreateSecurityProfile -> f CreateSecurityProfile)
-> ((Maybe [MetricToRetain] -> f (Maybe [MetricToRetain]))
    -> Maybe [MetricToRetain] -> f (Maybe [MetricToRetain]))
-> (Maybe [MetricToRetain] -> f (Maybe [MetricToRetain]))
-> CreateSecurityProfile
-> f CreateSecurityProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [MetricToRetain] [MetricToRetain] [MetricToRetain] [MetricToRetain]
-> Iso
     (Maybe [MetricToRetain])
     (Maybe [MetricToRetain])
     (Maybe [MetricToRetain])
     (Maybe [MetricToRetain])
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
  [MetricToRetain] [MetricToRetain] [MetricToRetain] [MetricToRetain]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the behaviors that, when violated by a device (thing), cause
-- an alert.
createSecurityProfile_behaviors :: Lens.Lens' CreateSecurityProfile (Prelude.Maybe [Behavior])
createSecurityProfile_behaviors :: (Maybe [Behavior] -> f (Maybe [Behavior]))
-> CreateSecurityProfile -> f CreateSecurityProfile
createSecurityProfile_behaviors = (CreateSecurityProfile -> Maybe [Behavior])
-> (CreateSecurityProfile
    -> Maybe [Behavior] -> CreateSecurityProfile)
-> Lens
     CreateSecurityProfile
     CreateSecurityProfile
     (Maybe [Behavior])
     (Maybe [Behavior])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSecurityProfile' {Maybe [Behavior]
behaviors :: Maybe [Behavior]
$sel:behaviors:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe [Behavior]
behaviors} -> Maybe [Behavior]
behaviors) (\s :: CreateSecurityProfile
s@CreateSecurityProfile' {} Maybe [Behavior]
a -> CreateSecurityProfile
s {$sel:behaviors:CreateSecurityProfile' :: Maybe [Behavior]
behaviors = Maybe [Behavior]
a} :: CreateSecurityProfile) ((Maybe [Behavior] -> f (Maybe [Behavior]))
 -> CreateSecurityProfile -> f CreateSecurityProfile)
-> ((Maybe [Behavior] -> f (Maybe [Behavior]))
    -> Maybe [Behavior] -> f (Maybe [Behavior]))
-> (Maybe [Behavior] -> f (Maybe [Behavior]))
-> CreateSecurityProfile
-> f CreateSecurityProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Behavior] [Behavior] [Behavior] [Behavior]
-> Iso
     (Maybe [Behavior])
     (Maybe [Behavior])
     (Maybe [Behavior])
     (Maybe [Behavior])
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 [Behavior] [Behavior] [Behavior] [Behavior]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | /Please use CreateSecurityProfileRequest$additionalMetricsToRetainV2
-- instead./
--
-- A list of metrics whose data is retained (stored). By default, data is
-- retained for any metric used in the profile\'s @behaviors@, but it is
-- also retained for any metric specified here. Can be used with custom
-- metrics; cannot be used with dimensions.
createSecurityProfile_additionalMetricsToRetain :: Lens.Lens' CreateSecurityProfile (Prelude.Maybe [Prelude.Text])
createSecurityProfile_additionalMetricsToRetain :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateSecurityProfile -> f CreateSecurityProfile
createSecurityProfile_additionalMetricsToRetain = (CreateSecurityProfile -> Maybe [Text])
-> (CreateSecurityProfile -> Maybe [Text] -> CreateSecurityProfile)
-> Lens
     CreateSecurityProfile
     CreateSecurityProfile
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSecurityProfile' {Maybe [Text]
additionalMetricsToRetain :: Maybe [Text]
$sel:additionalMetricsToRetain:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe [Text]
additionalMetricsToRetain} -> Maybe [Text]
additionalMetricsToRetain) (\s :: CreateSecurityProfile
s@CreateSecurityProfile' {} Maybe [Text]
a -> CreateSecurityProfile
s {$sel:additionalMetricsToRetain:CreateSecurityProfile' :: Maybe [Text]
additionalMetricsToRetain = Maybe [Text]
a} :: CreateSecurityProfile) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateSecurityProfile -> f CreateSecurityProfile)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateSecurityProfile
-> f CreateSecurityProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A description of the security profile.
createSecurityProfile_securityProfileDescription :: Lens.Lens' CreateSecurityProfile (Prelude.Maybe Prelude.Text)
createSecurityProfile_securityProfileDescription :: (Maybe Text -> f (Maybe Text))
-> CreateSecurityProfile -> f CreateSecurityProfile
createSecurityProfile_securityProfileDescription = (CreateSecurityProfile -> Maybe Text)
-> (CreateSecurityProfile -> Maybe Text -> CreateSecurityProfile)
-> Lens
     CreateSecurityProfile
     CreateSecurityProfile
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSecurityProfile' {Maybe Text
securityProfileDescription :: Maybe Text
$sel:securityProfileDescription:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe Text
securityProfileDescription} -> Maybe Text
securityProfileDescription) (\s :: CreateSecurityProfile
s@CreateSecurityProfile' {} Maybe Text
a -> CreateSecurityProfile
s {$sel:securityProfileDescription:CreateSecurityProfile' :: Maybe Text
securityProfileDescription = Maybe Text
a} :: CreateSecurityProfile)

-- | Metadata that can be used to manage the security profile.
createSecurityProfile_tags :: Lens.Lens' CreateSecurityProfile (Prelude.Maybe [Tag])
createSecurityProfile_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateSecurityProfile -> f CreateSecurityProfile
createSecurityProfile_tags = (CreateSecurityProfile -> Maybe [Tag])
-> (CreateSecurityProfile -> Maybe [Tag] -> CreateSecurityProfile)
-> Lens
     CreateSecurityProfile
     CreateSecurityProfile
     (Maybe [Tag])
     (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSecurityProfile' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateSecurityProfile
s@CreateSecurityProfile' {} Maybe [Tag]
a -> CreateSecurityProfile
s {$sel:tags:CreateSecurityProfile' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateSecurityProfile) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateSecurityProfile -> f CreateSecurityProfile)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateSecurityProfile
-> f CreateSecurityProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name you are giving to the security profile.
createSecurityProfile_securityProfileName :: Lens.Lens' CreateSecurityProfile Prelude.Text
createSecurityProfile_securityProfileName :: (Text -> f Text)
-> CreateSecurityProfile -> f CreateSecurityProfile
createSecurityProfile_securityProfileName = (CreateSecurityProfile -> Text)
-> (CreateSecurityProfile -> Text -> CreateSecurityProfile)
-> Lens CreateSecurityProfile CreateSecurityProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSecurityProfile' {Text
securityProfileName :: Text
$sel:securityProfileName:CreateSecurityProfile' :: CreateSecurityProfile -> Text
securityProfileName} -> Text
securityProfileName) (\s :: CreateSecurityProfile
s@CreateSecurityProfile' {} Text
a -> CreateSecurityProfile
s {$sel:securityProfileName:CreateSecurityProfile' :: Text
securityProfileName = Text
a} :: CreateSecurityProfile)

instance Core.AWSRequest CreateSecurityProfile where
  type
    AWSResponse CreateSecurityProfile =
      CreateSecurityProfileResponse
  request :: CreateSecurityProfile -> Request CreateSecurityProfile
request = Service -> CreateSecurityProfile -> Request CreateSecurityProfile
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateSecurityProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateSecurityProfile)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateSecurityProfile))
-> Logger
-> Service
-> Proxy CreateSecurityProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateSecurityProfile)))
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 Text -> Int -> CreateSecurityProfileResponse
CreateSecurityProfileResponse'
            (Maybe Text -> Maybe Text -> Int -> CreateSecurityProfileResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> CreateSecurityProfileResponse)
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
"securityProfileName")
            Either String (Maybe Text -> Int -> CreateSecurityProfileResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateSecurityProfileResponse)
forall (f :: * -> *) a b. Applicative f => 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
"securityProfileArn")
            Either String (Int -> CreateSecurityProfileResponse)
-> Either String Int -> Either String CreateSecurityProfileResponse
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 CreateSecurityProfile

instance Prelude.NFData CreateSecurityProfile

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

instance Core.ToJSON CreateSecurityProfile where
  toJSON :: CreateSecurityProfile -> Value
toJSON CreateSecurityProfile' {Maybe [Text]
Maybe [MetricToRetain]
Maybe [Behavior]
Maybe [Tag]
Maybe Text
Maybe (HashMap AlertTargetType AlertTarget)
Text
securityProfileName :: Text
tags :: Maybe [Tag]
securityProfileDescription :: Maybe Text
additionalMetricsToRetain :: Maybe [Text]
behaviors :: Maybe [Behavior]
additionalMetricsToRetainV2 :: Maybe [MetricToRetain]
alertTargets :: Maybe (HashMap AlertTargetType AlertTarget)
$sel:securityProfileName:CreateSecurityProfile' :: CreateSecurityProfile -> Text
$sel:tags:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe [Tag]
$sel:securityProfileDescription:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe Text
$sel:additionalMetricsToRetain:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe [Text]
$sel:behaviors:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe [Behavior]
$sel:additionalMetricsToRetainV2:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe [MetricToRetain]
$sel:alertTargets:CreateSecurityProfile' :: CreateSecurityProfile
-> Maybe (HashMap AlertTargetType AlertTarget)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"alertTargets" Text -> HashMap AlertTargetType AlertTarget -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap AlertTargetType AlertTarget -> Pair)
-> Maybe (HashMap AlertTargetType AlertTarget) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap AlertTargetType AlertTarget)
alertTargets,
            (Text
"additionalMetricsToRetainV2" Text -> [MetricToRetain] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([MetricToRetain] -> Pair) -> Maybe [MetricToRetain] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [MetricToRetain]
additionalMetricsToRetainV2,
            (Text
"behaviors" Text -> [Behavior] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Behavior] -> Pair) -> Maybe [Behavior] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Behavior]
behaviors,
            (Text
"additionalMetricsToRetain" 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]
additionalMetricsToRetain,
            (Text
"securityProfileDescription" 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
securityProfileDescription,
            (Text
"tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags
          ]
      )

instance Core.ToPath CreateSecurityProfile where
  toPath :: CreateSecurityProfile -> ByteString
toPath CreateSecurityProfile' {Maybe [Text]
Maybe [MetricToRetain]
Maybe [Behavior]
Maybe [Tag]
Maybe Text
Maybe (HashMap AlertTargetType AlertTarget)
Text
securityProfileName :: Text
tags :: Maybe [Tag]
securityProfileDescription :: Maybe Text
additionalMetricsToRetain :: Maybe [Text]
behaviors :: Maybe [Behavior]
additionalMetricsToRetainV2 :: Maybe [MetricToRetain]
alertTargets :: Maybe (HashMap AlertTargetType AlertTarget)
$sel:securityProfileName:CreateSecurityProfile' :: CreateSecurityProfile -> Text
$sel:tags:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe [Tag]
$sel:securityProfileDescription:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe Text
$sel:additionalMetricsToRetain:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe [Text]
$sel:behaviors:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe [Behavior]
$sel:additionalMetricsToRetainV2:CreateSecurityProfile' :: CreateSecurityProfile -> Maybe [MetricToRetain]
$sel:alertTargets:CreateSecurityProfile' :: CreateSecurityProfile
-> Maybe (HashMap AlertTargetType AlertTarget)
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/security-profiles/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
securityProfileName
      ]

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

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

-- |
-- Create a value of 'CreateSecurityProfileResponse' 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:
--
-- 'securityProfileName', 'createSecurityProfileResponse_securityProfileName' - The name you gave to the security profile.
--
-- 'securityProfileArn', 'createSecurityProfileResponse_securityProfileArn' - The ARN of the security profile.
--
-- 'httpStatus', 'createSecurityProfileResponse_httpStatus' - The response's http status code.
newCreateSecurityProfileResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateSecurityProfileResponse
newCreateSecurityProfileResponse :: Int -> CreateSecurityProfileResponse
newCreateSecurityProfileResponse Int
pHttpStatus_ =
  CreateSecurityProfileResponse' :: Maybe Text -> Maybe Text -> Int -> CreateSecurityProfileResponse
CreateSecurityProfileResponse'
    { $sel:securityProfileName:CreateSecurityProfileResponse' :: Maybe Text
securityProfileName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:securityProfileArn:CreateSecurityProfileResponse' :: Maybe Text
securityProfileArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateSecurityProfileResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name you gave to the security profile.
createSecurityProfileResponse_securityProfileName :: Lens.Lens' CreateSecurityProfileResponse (Prelude.Maybe Prelude.Text)
createSecurityProfileResponse_securityProfileName :: (Maybe Text -> f (Maybe Text))
-> CreateSecurityProfileResponse -> f CreateSecurityProfileResponse
createSecurityProfileResponse_securityProfileName = (CreateSecurityProfileResponse -> Maybe Text)
-> (CreateSecurityProfileResponse
    -> Maybe Text -> CreateSecurityProfileResponse)
-> Lens
     CreateSecurityProfileResponse
     CreateSecurityProfileResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSecurityProfileResponse' {Maybe Text
securityProfileName :: Maybe Text
$sel:securityProfileName:CreateSecurityProfileResponse' :: CreateSecurityProfileResponse -> Maybe Text
securityProfileName} -> Maybe Text
securityProfileName) (\s :: CreateSecurityProfileResponse
s@CreateSecurityProfileResponse' {} Maybe Text
a -> CreateSecurityProfileResponse
s {$sel:securityProfileName:CreateSecurityProfileResponse' :: Maybe Text
securityProfileName = Maybe Text
a} :: CreateSecurityProfileResponse)

-- | The ARN of the security profile.
createSecurityProfileResponse_securityProfileArn :: Lens.Lens' CreateSecurityProfileResponse (Prelude.Maybe Prelude.Text)
createSecurityProfileResponse_securityProfileArn :: (Maybe Text -> f (Maybe Text))
-> CreateSecurityProfileResponse -> f CreateSecurityProfileResponse
createSecurityProfileResponse_securityProfileArn = (CreateSecurityProfileResponse -> Maybe Text)
-> (CreateSecurityProfileResponse
    -> Maybe Text -> CreateSecurityProfileResponse)
-> Lens
     CreateSecurityProfileResponse
     CreateSecurityProfileResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSecurityProfileResponse' {Maybe Text
securityProfileArn :: Maybe Text
$sel:securityProfileArn:CreateSecurityProfileResponse' :: CreateSecurityProfileResponse -> Maybe Text
securityProfileArn} -> Maybe Text
securityProfileArn) (\s :: CreateSecurityProfileResponse
s@CreateSecurityProfileResponse' {} Maybe Text
a -> CreateSecurityProfileResponse
s {$sel:securityProfileArn:CreateSecurityProfileResponse' :: Maybe Text
securityProfileArn = Maybe Text
a} :: CreateSecurityProfileResponse)

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

instance Prelude.NFData CreateSecurityProfileResponse