{-# 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.CreateThreatIntelSet
-- 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 new ThreatIntelSet. ThreatIntelSets consist of known malicious
-- IP addresses. GuardDuty generates findings based on ThreatIntelSets.
-- Only users of the administrator account can use this operation.
module Amazonka.GuardDuty.CreateThreatIntelSet
  ( -- * Creating a Request
    CreateThreatIntelSet (..),
    newCreateThreatIntelSet,

    -- * Request Lenses
    createThreatIntelSet_clientToken,
    createThreatIntelSet_tags,
    createThreatIntelSet_detectorId,
    createThreatIntelSet_name,
    createThreatIntelSet_format,
    createThreatIntelSet_location,
    createThreatIntelSet_activate,

    -- * Destructuring the Response
    CreateThreatIntelSetResponse (..),
    newCreateThreatIntelSetResponse,

    -- * Response Lenses
    createThreatIntelSetResponse_httpStatus,
    createThreatIntelSetResponse_threatIntelSetId,
  )
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:/ 'newCreateThreatIntelSet' smart constructor.
data CreateThreatIntelSet = CreateThreatIntelSet'
  { -- | The idempotency token for the create request.
    CreateThreatIntelSet -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The tags to be added to a new threat list resource.
    CreateThreatIntelSet -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The unique ID of the detector of the GuardDuty account that you want to
    -- create a threatIntelSet for.
    CreateThreatIntelSet -> Text
detectorId :: Prelude.Text,
    -- | A user-friendly ThreatIntelSet name displayed in all findings that are
    -- generated by activity that involves IP addresses included in this
    -- ThreatIntelSet.
    CreateThreatIntelSet -> Text
name :: Prelude.Text,
    -- | The format of the file that contains the ThreatIntelSet.
    CreateThreatIntelSet -> ThreatIntelSetFormat
format :: ThreatIntelSetFormat,
    -- | The URI of the file that contains the ThreatIntelSet. For example:
    -- https:\/\/s3.us-west-2.amazonaws.com\/my-bucket\/my-object-key.
    CreateThreatIntelSet -> Text
location :: Prelude.Text,
    -- | A Boolean value that indicates whether GuardDuty is to start using the
    -- uploaded ThreatIntelSet.
    CreateThreatIntelSet -> Bool
activate :: Prelude.Bool
  }
  deriving (CreateThreatIntelSet -> CreateThreatIntelSet -> Bool
(CreateThreatIntelSet -> CreateThreatIntelSet -> Bool)
-> (CreateThreatIntelSet -> CreateThreatIntelSet -> Bool)
-> Eq CreateThreatIntelSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateThreatIntelSet -> CreateThreatIntelSet -> Bool
$c/= :: CreateThreatIntelSet -> CreateThreatIntelSet -> Bool
== :: CreateThreatIntelSet -> CreateThreatIntelSet -> Bool
$c== :: CreateThreatIntelSet -> CreateThreatIntelSet -> Bool
Prelude.Eq, ReadPrec [CreateThreatIntelSet]
ReadPrec CreateThreatIntelSet
Int -> ReadS CreateThreatIntelSet
ReadS [CreateThreatIntelSet]
(Int -> ReadS CreateThreatIntelSet)
-> ReadS [CreateThreatIntelSet]
-> ReadPrec CreateThreatIntelSet
-> ReadPrec [CreateThreatIntelSet]
-> Read CreateThreatIntelSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateThreatIntelSet]
$creadListPrec :: ReadPrec [CreateThreatIntelSet]
readPrec :: ReadPrec CreateThreatIntelSet
$creadPrec :: ReadPrec CreateThreatIntelSet
readList :: ReadS [CreateThreatIntelSet]
$creadList :: ReadS [CreateThreatIntelSet]
readsPrec :: Int -> ReadS CreateThreatIntelSet
$creadsPrec :: Int -> ReadS CreateThreatIntelSet
Prelude.Read, Int -> CreateThreatIntelSet -> ShowS
[CreateThreatIntelSet] -> ShowS
CreateThreatIntelSet -> String
(Int -> CreateThreatIntelSet -> ShowS)
-> (CreateThreatIntelSet -> String)
-> ([CreateThreatIntelSet] -> ShowS)
-> Show CreateThreatIntelSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateThreatIntelSet] -> ShowS
$cshowList :: [CreateThreatIntelSet] -> ShowS
show :: CreateThreatIntelSet -> String
$cshow :: CreateThreatIntelSet -> String
showsPrec :: Int -> CreateThreatIntelSet -> ShowS
$cshowsPrec :: Int -> CreateThreatIntelSet -> ShowS
Prelude.Show, (forall x. CreateThreatIntelSet -> Rep CreateThreatIntelSet x)
-> (forall x. Rep CreateThreatIntelSet x -> CreateThreatIntelSet)
-> Generic CreateThreatIntelSet
forall x. Rep CreateThreatIntelSet x -> CreateThreatIntelSet
forall x. CreateThreatIntelSet -> Rep CreateThreatIntelSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateThreatIntelSet x -> CreateThreatIntelSet
$cfrom :: forall x. CreateThreatIntelSet -> Rep CreateThreatIntelSet x
Prelude.Generic)

-- |
-- Create a value of 'CreateThreatIntelSet' 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', 'createThreatIntelSet_clientToken' - The idempotency token for the create request.
--
-- 'tags', 'createThreatIntelSet_tags' - The tags to be added to a new threat list resource.
--
-- 'detectorId', 'createThreatIntelSet_detectorId' - The unique ID of the detector of the GuardDuty account that you want to
-- create a threatIntelSet for.
--
-- 'name', 'createThreatIntelSet_name' - A user-friendly ThreatIntelSet name displayed in all findings that are
-- generated by activity that involves IP addresses included in this
-- ThreatIntelSet.
--
-- 'format', 'createThreatIntelSet_format' - The format of the file that contains the ThreatIntelSet.
--
-- 'location', 'createThreatIntelSet_location' - The URI of the file that contains the ThreatIntelSet. For example:
-- https:\/\/s3.us-west-2.amazonaws.com\/my-bucket\/my-object-key.
--
-- 'activate', 'createThreatIntelSet_activate' - A Boolean value that indicates whether GuardDuty is to start using the
-- uploaded ThreatIntelSet.
newCreateThreatIntelSet ::
  -- | 'detectorId'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'format'
  ThreatIntelSetFormat ->
  -- | 'location'
  Prelude.Text ->
  -- | 'activate'
  Prelude.Bool ->
  CreateThreatIntelSet
newCreateThreatIntelSet :: Text
-> Text
-> ThreatIntelSetFormat
-> Text
-> Bool
-> CreateThreatIntelSet
newCreateThreatIntelSet
  Text
pDetectorId_
  Text
pName_
  ThreatIntelSetFormat
pFormat_
  Text
pLocation_
  Bool
pActivate_ =
    CreateThreatIntelSet' :: Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> ThreatIntelSetFormat
-> Text
-> Bool
-> CreateThreatIntelSet
CreateThreatIntelSet'
      { $sel:clientToken:CreateThreatIntelSet' :: Maybe Text
clientToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateThreatIntelSet' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:detectorId:CreateThreatIntelSet' :: Text
detectorId = Text
pDetectorId_,
        $sel:name:CreateThreatIntelSet' :: Text
name = Text
pName_,
        $sel:format:CreateThreatIntelSet' :: ThreatIntelSetFormat
format = ThreatIntelSetFormat
pFormat_,
        $sel:location:CreateThreatIntelSet' :: Text
location = Text
pLocation_,
        $sel:activate:CreateThreatIntelSet' :: Bool
activate = Bool
pActivate_
      }

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

-- | The tags to be added to a new threat list resource.
createThreatIntelSet_tags :: Lens.Lens' CreateThreatIntelSet (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createThreatIntelSet_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateThreatIntelSet -> f CreateThreatIntelSet
createThreatIntelSet_tags = (CreateThreatIntelSet -> Maybe (HashMap Text Text))
-> (CreateThreatIntelSet
    -> Maybe (HashMap Text Text) -> CreateThreatIntelSet)
-> Lens
     CreateThreatIntelSet
     CreateThreatIntelSet
     (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 (\CreateThreatIntelSet' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateThreatIntelSet' :: CreateThreatIntelSet -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateThreatIntelSet
s@CreateThreatIntelSet' {} Maybe (HashMap Text Text)
a -> CreateThreatIntelSet
s {$sel:tags:CreateThreatIntelSet' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateThreatIntelSet) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateThreatIntelSet -> f CreateThreatIntelSet)
-> ((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)))
-> CreateThreatIntelSet
-> f CreateThreatIntelSet
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 unique ID of the detector of the GuardDuty account that you want to
-- create a threatIntelSet for.
createThreatIntelSet_detectorId :: Lens.Lens' CreateThreatIntelSet Prelude.Text
createThreatIntelSet_detectorId :: (Text -> f Text) -> CreateThreatIntelSet -> f CreateThreatIntelSet
createThreatIntelSet_detectorId = (CreateThreatIntelSet -> Text)
-> (CreateThreatIntelSet -> Text -> CreateThreatIntelSet)
-> Lens CreateThreatIntelSet CreateThreatIntelSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThreatIntelSet' {Text
detectorId :: Text
$sel:detectorId:CreateThreatIntelSet' :: CreateThreatIntelSet -> Text
detectorId} -> Text
detectorId) (\s :: CreateThreatIntelSet
s@CreateThreatIntelSet' {} Text
a -> CreateThreatIntelSet
s {$sel:detectorId:CreateThreatIntelSet' :: Text
detectorId = Text
a} :: CreateThreatIntelSet)

-- | A user-friendly ThreatIntelSet name displayed in all findings that are
-- generated by activity that involves IP addresses included in this
-- ThreatIntelSet.
createThreatIntelSet_name :: Lens.Lens' CreateThreatIntelSet Prelude.Text
createThreatIntelSet_name :: (Text -> f Text) -> CreateThreatIntelSet -> f CreateThreatIntelSet
createThreatIntelSet_name = (CreateThreatIntelSet -> Text)
-> (CreateThreatIntelSet -> Text -> CreateThreatIntelSet)
-> Lens CreateThreatIntelSet CreateThreatIntelSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThreatIntelSet' {Text
name :: Text
$sel:name:CreateThreatIntelSet' :: CreateThreatIntelSet -> Text
name} -> Text
name) (\s :: CreateThreatIntelSet
s@CreateThreatIntelSet' {} Text
a -> CreateThreatIntelSet
s {$sel:name:CreateThreatIntelSet' :: Text
name = Text
a} :: CreateThreatIntelSet)

-- | The format of the file that contains the ThreatIntelSet.
createThreatIntelSet_format :: Lens.Lens' CreateThreatIntelSet ThreatIntelSetFormat
createThreatIntelSet_format :: (ThreatIntelSetFormat -> f ThreatIntelSetFormat)
-> CreateThreatIntelSet -> f CreateThreatIntelSet
createThreatIntelSet_format = (CreateThreatIntelSet -> ThreatIntelSetFormat)
-> (CreateThreatIntelSet
    -> ThreatIntelSetFormat -> CreateThreatIntelSet)
-> Lens
     CreateThreatIntelSet
     CreateThreatIntelSet
     ThreatIntelSetFormat
     ThreatIntelSetFormat
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThreatIntelSet' {ThreatIntelSetFormat
format :: ThreatIntelSetFormat
$sel:format:CreateThreatIntelSet' :: CreateThreatIntelSet -> ThreatIntelSetFormat
format} -> ThreatIntelSetFormat
format) (\s :: CreateThreatIntelSet
s@CreateThreatIntelSet' {} ThreatIntelSetFormat
a -> CreateThreatIntelSet
s {$sel:format:CreateThreatIntelSet' :: ThreatIntelSetFormat
format = ThreatIntelSetFormat
a} :: CreateThreatIntelSet)

-- | The URI of the file that contains the ThreatIntelSet. For example:
-- https:\/\/s3.us-west-2.amazonaws.com\/my-bucket\/my-object-key.
createThreatIntelSet_location :: Lens.Lens' CreateThreatIntelSet Prelude.Text
createThreatIntelSet_location :: (Text -> f Text) -> CreateThreatIntelSet -> f CreateThreatIntelSet
createThreatIntelSet_location = (CreateThreatIntelSet -> Text)
-> (CreateThreatIntelSet -> Text -> CreateThreatIntelSet)
-> Lens CreateThreatIntelSet CreateThreatIntelSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThreatIntelSet' {Text
location :: Text
$sel:location:CreateThreatIntelSet' :: CreateThreatIntelSet -> Text
location} -> Text
location) (\s :: CreateThreatIntelSet
s@CreateThreatIntelSet' {} Text
a -> CreateThreatIntelSet
s {$sel:location:CreateThreatIntelSet' :: Text
location = Text
a} :: CreateThreatIntelSet)

-- | A Boolean value that indicates whether GuardDuty is to start using the
-- uploaded ThreatIntelSet.
createThreatIntelSet_activate :: Lens.Lens' CreateThreatIntelSet Prelude.Bool
createThreatIntelSet_activate :: (Bool -> f Bool) -> CreateThreatIntelSet -> f CreateThreatIntelSet
createThreatIntelSet_activate = (CreateThreatIntelSet -> Bool)
-> (CreateThreatIntelSet -> Bool -> CreateThreatIntelSet)
-> Lens CreateThreatIntelSet CreateThreatIntelSet Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThreatIntelSet' {Bool
activate :: Bool
$sel:activate:CreateThreatIntelSet' :: CreateThreatIntelSet -> Bool
activate} -> Bool
activate) (\s :: CreateThreatIntelSet
s@CreateThreatIntelSet' {} Bool
a -> CreateThreatIntelSet
s {$sel:activate:CreateThreatIntelSet' :: Bool
activate = Bool
a} :: CreateThreatIntelSet)

instance Core.AWSRequest CreateThreatIntelSet where
  type
    AWSResponse CreateThreatIntelSet =
      CreateThreatIntelSetResponse
  request :: CreateThreatIntelSet -> Request CreateThreatIntelSet
request = Service -> CreateThreatIntelSet -> Request CreateThreatIntelSet
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateThreatIntelSet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateThreatIntelSet)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateThreatIntelSet))
-> Logger
-> Service
-> Proxy CreateThreatIntelSet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateThreatIntelSet)))
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 -> CreateThreatIntelSetResponse
CreateThreatIntelSetResponse'
            (Int -> Text -> CreateThreatIntelSetResponse)
-> Either String Int
-> Either String (Text -> CreateThreatIntelSetResponse)
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 -> CreateThreatIntelSetResponse)
-> Either String Text -> Either String CreateThreatIntelSetResponse
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
"threatIntelSetId")
      )

instance Prelude.Hashable CreateThreatIntelSet

instance Prelude.NFData CreateThreatIntelSet

instance Core.ToHeaders CreateThreatIntelSet where
  toHeaders :: CreateThreatIntelSet -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateThreatIntelSet -> 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 CreateThreatIntelSet where
  toJSON :: CreateThreatIntelSet -> Value
toJSON CreateThreatIntelSet' {Bool
Maybe Text
Maybe (HashMap Text Text)
Text
ThreatIntelSetFormat
activate :: Bool
location :: Text
format :: ThreatIntelSetFormat
name :: Text
detectorId :: Text
tags :: Maybe (HashMap Text Text)
clientToken :: Maybe Text
$sel:activate:CreateThreatIntelSet' :: CreateThreatIntelSet -> Bool
$sel:location:CreateThreatIntelSet' :: CreateThreatIntelSet -> Text
$sel:format:CreateThreatIntelSet' :: CreateThreatIntelSet -> ThreatIntelSetFormat
$sel:name:CreateThreatIntelSet' :: CreateThreatIntelSet -> Text
$sel:detectorId:CreateThreatIntelSet' :: CreateThreatIntelSet -> Text
$sel:tags:CreateThreatIntelSet' :: CreateThreatIntelSet -> Maybe (HashMap Text Text)
$sel:clientToken:CreateThreatIntelSet' :: CreateThreatIntelSet -> 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
"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
"format" Text -> ThreatIntelSetFormat -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ThreatIntelSetFormat
format),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"location" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
location),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"activate" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
activate)
          ]
      )

instance Core.ToPath CreateThreatIntelSet where
  toPath :: CreateThreatIntelSet -> ByteString
toPath CreateThreatIntelSet' {Bool
Maybe Text
Maybe (HashMap Text Text)
Text
ThreatIntelSetFormat
activate :: Bool
location :: Text
format :: ThreatIntelSetFormat
name :: Text
detectorId :: Text
tags :: Maybe (HashMap Text Text)
clientToken :: Maybe Text
$sel:activate:CreateThreatIntelSet' :: CreateThreatIntelSet -> Bool
$sel:location:CreateThreatIntelSet' :: CreateThreatIntelSet -> Text
$sel:format:CreateThreatIntelSet' :: CreateThreatIntelSet -> ThreatIntelSetFormat
$sel:name:CreateThreatIntelSet' :: CreateThreatIntelSet -> Text
$sel:detectorId:CreateThreatIntelSet' :: CreateThreatIntelSet -> Text
$sel:tags:CreateThreatIntelSet' :: CreateThreatIntelSet -> Maybe (HashMap Text Text)
$sel:clientToken:CreateThreatIntelSet' :: CreateThreatIntelSet -> 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
"/threatintelset"
      ]

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

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

-- |
-- Create a value of 'CreateThreatIntelSetResponse' 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', 'createThreatIntelSetResponse_httpStatus' - The response's http status code.
--
-- 'threatIntelSetId', 'createThreatIntelSetResponse_threatIntelSetId' - The ID of the ThreatIntelSet resource.
newCreateThreatIntelSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'threatIntelSetId'
  Prelude.Text ->
  CreateThreatIntelSetResponse
newCreateThreatIntelSetResponse :: Int -> Text -> CreateThreatIntelSetResponse
newCreateThreatIntelSetResponse
  Int
pHttpStatus_
  Text
pThreatIntelSetId_ =
    CreateThreatIntelSetResponse' :: Int -> Text -> CreateThreatIntelSetResponse
CreateThreatIntelSetResponse'
      { $sel:httpStatus:CreateThreatIntelSetResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:threatIntelSetId:CreateThreatIntelSetResponse' :: Text
threatIntelSetId = Text
pThreatIntelSetId_
      }

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

-- | The ID of the ThreatIntelSet resource.
createThreatIntelSetResponse_threatIntelSetId :: Lens.Lens' CreateThreatIntelSetResponse Prelude.Text
createThreatIntelSetResponse_threatIntelSetId :: (Text -> f Text)
-> CreateThreatIntelSetResponse -> f CreateThreatIntelSetResponse
createThreatIntelSetResponse_threatIntelSetId = (CreateThreatIntelSetResponse -> Text)
-> (CreateThreatIntelSetResponse
    -> Text -> CreateThreatIntelSetResponse)
-> Lens
     CreateThreatIntelSetResponse CreateThreatIntelSetResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThreatIntelSetResponse' {Text
threatIntelSetId :: Text
$sel:threatIntelSetId:CreateThreatIntelSetResponse' :: CreateThreatIntelSetResponse -> Text
threatIntelSetId} -> Text
threatIntelSetId) (\s :: CreateThreatIntelSetResponse
s@CreateThreatIntelSetResponse' {} Text
a -> CreateThreatIntelSetResponse
s {$sel:threatIntelSetId:CreateThreatIntelSetResponse' :: Text
threatIntelSetId = Text
a} :: CreateThreatIntelSetResponse)

instance Prelude.NFData CreateThreatIntelSetResponse