{-# 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.FraudDetector.BatchCreateVariable
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a batch of variables.
module Amazonka.FraudDetector.BatchCreateVariable
  ( -- * Creating a Request
    BatchCreateVariable (..),
    newBatchCreateVariable,

    -- * Request Lenses
    batchCreateVariable_tags,
    batchCreateVariable_variableEntries,

    -- * Destructuring the Response
    BatchCreateVariableResponse (..),
    newBatchCreateVariableResponse,

    -- * Response Lenses
    batchCreateVariableResponse_errors,
    batchCreateVariableResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FraudDetector.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newBatchCreateVariable' smart constructor.
data BatchCreateVariable = BatchCreateVariable'
  { -- | A collection of key and value pairs.
    BatchCreateVariable -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The list of variables for the batch create variable request.
    BatchCreateVariable -> NonEmpty VariableEntry
variableEntries :: Prelude.NonEmpty VariableEntry
  }
  deriving (BatchCreateVariable -> BatchCreateVariable -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchCreateVariable -> BatchCreateVariable -> Bool
$c/= :: BatchCreateVariable -> BatchCreateVariable -> Bool
== :: BatchCreateVariable -> BatchCreateVariable -> Bool
$c== :: BatchCreateVariable -> BatchCreateVariable -> Bool
Prelude.Eq, ReadPrec [BatchCreateVariable]
ReadPrec BatchCreateVariable
Int -> ReadS BatchCreateVariable
ReadS [BatchCreateVariable]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchCreateVariable]
$creadListPrec :: ReadPrec [BatchCreateVariable]
readPrec :: ReadPrec BatchCreateVariable
$creadPrec :: ReadPrec BatchCreateVariable
readList :: ReadS [BatchCreateVariable]
$creadList :: ReadS [BatchCreateVariable]
readsPrec :: Int -> ReadS BatchCreateVariable
$creadsPrec :: Int -> ReadS BatchCreateVariable
Prelude.Read, Int -> BatchCreateVariable -> ShowS
[BatchCreateVariable] -> ShowS
BatchCreateVariable -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchCreateVariable] -> ShowS
$cshowList :: [BatchCreateVariable] -> ShowS
show :: BatchCreateVariable -> String
$cshow :: BatchCreateVariable -> String
showsPrec :: Int -> BatchCreateVariable -> ShowS
$cshowsPrec :: Int -> BatchCreateVariable -> ShowS
Prelude.Show, forall x. Rep BatchCreateVariable x -> BatchCreateVariable
forall x. BatchCreateVariable -> Rep BatchCreateVariable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchCreateVariable x -> BatchCreateVariable
$cfrom :: forall x. BatchCreateVariable -> Rep BatchCreateVariable x
Prelude.Generic)

-- |
-- Create a value of 'BatchCreateVariable' 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:
--
-- 'tags', 'batchCreateVariable_tags' - A collection of key and value pairs.
--
-- 'variableEntries', 'batchCreateVariable_variableEntries' - The list of variables for the batch create variable request.
newBatchCreateVariable ::
  -- | 'variableEntries'
  Prelude.NonEmpty VariableEntry ->
  BatchCreateVariable
newBatchCreateVariable :: NonEmpty VariableEntry -> BatchCreateVariable
newBatchCreateVariable NonEmpty VariableEntry
pVariableEntries_ =
  BatchCreateVariable'
    { $sel:tags:BatchCreateVariable' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:variableEntries:BatchCreateVariable' :: NonEmpty VariableEntry
variableEntries =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty VariableEntry
pVariableEntries_
    }

-- | A collection of key and value pairs.
batchCreateVariable_tags :: Lens.Lens' BatchCreateVariable (Prelude.Maybe [Tag])
batchCreateVariable_tags :: Lens' BatchCreateVariable (Maybe [Tag])
batchCreateVariable_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateVariable' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:BatchCreateVariable' :: BatchCreateVariable -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: BatchCreateVariable
s@BatchCreateVariable' {} Maybe [Tag]
a -> BatchCreateVariable
s {$sel:tags:BatchCreateVariable' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: BatchCreateVariable) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The list of variables for the batch create variable request.
batchCreateVariable_variableEntries :: Lens.Lens' BatchCreateVariable (Prelude.NonEmpty VariableEntry)
batchCreateVariable_variableEntries :: Lens' BatchCreateVariable (NonEmpty VariableEntry)
batchCreateVariable_variableEntries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateVariable' {NonEmpty VariableEntry
variableEntries :: NonEmpty VariableEntry
$sel:variableEntries:BatchCreateVariable' :: BatchCreateVariable -> NonEmpty VariableEntry
variableEntries} -> NonEmpty VariableEntry
variableEntries) (\s :: BatchCreateVariable
s@BatchCreateVariable' {} NonEmpty VariableEntry
a -> BatchCreateVariable
s {$sel:variableEntries:BatchCreateVariable' :: NonEmpty VariableEntry
variableEntries = NonEmpty VariableEntry
a} :: BatchCreateVariable) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchCreateVariable where
  type
    AWSResponse BatchCreateVariable =
      BatchCreateVariableResponse
  request :: (Service -> Service)
-> BatchCreateVariable -> Request BatchCreateVariable
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy BatchCreateVariable
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchCreateVariable)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [BatchCreateVariableError]
-> Int -> BatchCreateVariableResponse
BatchCreateVariableResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"errors" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable BatchCreateVariable where
  hashWithSalt :: Int -> BatchCreateVariable -> Int
hashWithSalt Int
_salt BatchCreateVariable' {Maybe [Tag]
NonEmpty VariableEntry
variableEntries :: NonEmpty VariableEntry
tags :: Maybe [Tag]
$sel:variableEntries:BatchCreateVariable' :: BatchCreateVariable -> NonEmpty VariableEntry
$sel:tags:BatchCreateVariable' :: BatchCreateVariable -> Maybe [Tag]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty VariableEntry
variableEntries

instance Prelude.NFData BatchCreateVariable where
  rnf :: BatchCreateVariable -> ()
rnf BatchCreateVariable' {Maybe [Tag]
NonEmpty VariableEntry
variableEntries :: NonEmpty VariableEntry
tags :: Maybe [Tag]
$sel:variableEntries:BatchCreateVariable' :: BatchCreateVariable -> NonEmpty VariableEntry
$sel:tags:BatchCreateVariable' :: BatchCreateVariable -> Maybe [Tag]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty VariableEntry
variableEntries

instance Data.ToHeaders BatchCreateVariable where
  toHeaders :: BatchCreateVariable -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSHawksNestServiceFacade.BatchCreateVariable" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON BatchCreateVariable where
  toJSON :: BatchCreateVariable -> Value
toJSON BatchCreateVariable' {Maybe [Tag]
NonEmpty VariableEntry
variableEntries :: NonEmpty VariableEntry
tags :: Maybe [Tag]
$sel:variableEntries:BatchCreateVariable' :: BatchCreateVariable -> NonEmpty VariableEntry
$sel:tags:BatchCreateVariable' :: BatchCreateVariable -> Maybe [Tag]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"variableEntries" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty VariableEntry
variableEntries)
          ]
      )

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

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

-- | /See:/ 'newBatchCreateVariableResponse' smart constructor.
data BatchCreateVariableResponse = BatchCreateVariableResponse'
  { -- | Provides the errors for the @BatchCreateVariable@ request.
    BatchCreateVariableResponse -> Maybe [BatchCreateVariableError]
errors :: Prelude.Maybe [BatchCreateVariableError],
    -- | The response's http status code.
    BatchCreateVariableResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchCreateVariableResponse -> BatchCreateVariableResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchCreateVariableResponse -> BatchCreateVariableResponse -> Bool
$c/= :: BatchCreateVariableResponse -> BatchCreateVariableResponse -> Bool
== :: BatchCreateVariableResponse -> BatchCreateVariableResponse -> Bool
$c== :: BatchCreateVariableResponse -> BatchCreateVariableResponse -> Bool
Prelude.Eq, ReadPrec [BatchCreateVariableResponse]
ReadPrec BatchCreateVariableResponse
Int -> ReadS BatchCreateVariableResponse
ReadS [BatchCreateVariableResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchCreateVariableResponse]
$creadListPrec :: ReadPrec [BatchCreateVariableResponse]
readPrec :: ReadPrec BatchCreateVariableResponse
$creadPrec :: ReadPrec BatchCreateVariableResponse
readList :: ReadS [BatchCreateVariableResponse]
$creadList :: ReadS [BatchCreateVariableResponse]
readsPrec :: Int -> ReadS BatchCreateVariableResponse
$creadsPrec :: Int -> ReadS BatchCreateVariableResponse
Prelude.Read, Int -> BatchCreateVariableResponse -> ShowS
[BatchCreateVariableResponse] -> ShowS
BatchCreateVariableResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchCreateVariableResponse] -> ShowS
$cshowList :: [BatchCreateVariableResponse] -> ShowS
show :: BatchCreateVariableResponse -> String
$cshow :: BatchCreateVariableResponse -> String
showsPrec :: Int -> BatchCreateVariableResponse -> ShowS
$cshowsPrec :: Int -> BatchCreateVariableResponse -> ShowS
Prelude.Show, forall x.
Rep BatchCreateVariableResponse x -> BatchCreateVariableResponse
forall x.
BatchCreateVariableResponse -> Rep BatchCreateVariableResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchCreateVariableResponse x -> BatchCreateVariableResponse
$cfrom :: forall x.
BatchCreateVariableResponse -> Rep BatchCreateVariableResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchCreateVariableResponse' 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:
--
-- 'errors', 'batchCreateVariableResponse_errors' - Provides the errors for the @BatchCreateVariable@ request.
--
-- 'httpStatus', 'batchCreateVariableResponse_httpStatus' - The response's http status code.
newBatchCreateVariableResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchCreateVariableResponse
newBatchCreateVariableResponse :: Int -> BatchCreateVariableResponse
newBatchCreateVariableResponse Int
pHttpStatus_ =
  BatchCreateVariableResponse'
    { $sel:errors:BatchCreateVariableResponse' :: Maybe [BatchCreateVariableError]
errors =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchCreateVariableResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Provides the errors for the @BatchCreateVariable@ request.
batchCreateVariableResponse_errors :: Lens.Lens' BatchCreateVariableResponse (Prelude.Maybe [BatchCreateVariableError])
batchCreateVariableResponse_errors :: Lens'
  BatchCreateVariableResponse (Maybe [BatchCreateVariableError])
batchCreateVariableResponse_errors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateVariableResponse' {Maybe [BatchCreateVariableError]
errors :: Maybe [BatchCreateVariableError]
$sel:errors:BatchCreateVariableResponse' :: BatchCreateVariableResponse -> Maybe [BatchCreateVariableError]
errors} -> Maybe [BatchCreateVariableError]
errors) (\s :: BatchCreateVariableResponse
s@BatchCreateVariableResponse' {} Maybe [BatchCreateVariableError]
a -> BatchCreateVariableResponse
s {$sel:errors:BatchCreateVariableResponse' :: Maybe [BatchCreateVariableError]
errors = Maybe [BatchCreateVariableError]
a} :: BatchCreateVariableResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData BatchCreateVariableResponse where
  rnf :: BatchCreateVariableResponse -> ()
rnf BatchCreateVariableResponse' {Int
Maybe [BatchCreateVariableError]
httpStatus :: Int
errors :: Maybe [BatchCreateVariableError]
$sel:httpStatus:BatchCreateVariableResponse' :: BatchCreateVariableResponse -> Int
$sel:errors:BatchCreateVariableResponse' :: BatchCreateVariableResponse -> Maybe [BatchCreateVariableError]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [BatchCreateVariableError]
errors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus