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

    -- * Request Lenses
    batchGetVariable_names,

    -- * Destructuring the Response
    BatchGetVariableResponse (..),
    newBatchGetVariableResponse,

    -- * Response Lenses
    batchGetVariableResponse_errors,
    batchGetVariableResponse_variables,
    batchGetVariableResponse_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:/ 'newBatchGetVariable' smart constructor.
data BatchGetVariable = BatchGetVariable'
  { -- | The list of variable names to get.
    BatchGetVariable -> NonEmpty Text
names :: Prelude.NonEmpty Prelude.Text
  }
  deriving (BatchGetVariable -> BatchGetVariable -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetVariable -> BatchGetVariable -> Bool
$c/= :: BatchGetVariable -> BatchGetVariable -> Bool
== :: BatchGetVariable -> BatchGetVariable -> Bool
$c== :: BatchGetVariable -> BatchGetVariable -> Bool
Prelude.Eq, ReadPrec [BatchGetVariable]
ReadPrec BatchGetVariable
Int -> ReadS BatchGetVariable
ReadS [BatchGetVariable]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetVariable]
$creadListPrec :: ReadPrec [BatchGetVariable]
readPrec :: ReadPrec BatchGetVariable
$creadPrec :: ReadPrec BatchGetVariable
readList :: ReadS [BatchGetVariable]
$creadList :: ReadS [BatchGetVariable]
readsPrec :: Int -> ReadS BatchGetVariable
$creadsPrec :: Int -> ReadS BatchGetVariable
Prelude.Read, Int -> BatchGetVariable -> ShowS
[BatchGetVariable] -> ShowS
BatchGetVariable -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetVariable] -> ShowS
$cshowList :: [BatchGetVariable] -> ShowS
show :: BatchGetVariable -> String
$cshow :: BatchGetVariable -> String
showsPrec :: Int -> BatchGetVariable -> ShowS
$cshowsPrec :: Int -> BatchGetVariable -> ShowS
Prelude.Show, forall x. Rep BatchGetVariable x -> BatchGetVariable
forall x. BatchGetVariable -> Rep BatchGetVariable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetVariable x -> BatchGetVariable
$cfrom :: forall x. BatchGetVariable -> Rep BatchGetVariable x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetVariable' 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:
--
-- 'names', 'batchGetVariable_names' - The list of variable names to get.
newBatchGetVariable ::
  -- | 'names'
  Prelude.NonEmpty Prelude.Text ->
  BatchGetVariable
newBatchGetVariable :: NonEmpty Text -> BatchGetVariable
newBatchGetVariable NonEmpty Text
pNames_ =
  BatchGetVariable'
    { $sel:names:BatchGetVariable' :: NonEmpty Text
names =
        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 Text
pNames_
    }

-- | The list of variable names to get.
batchGetVariable_names :: Lens.Lens' BatchGetVariable (Prelude.NonEmpty Prelude.Text)
batchGetVariable_names :: Lens' BatchGetVariable (NonEmpty Text)
batchGetVariable_names = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetVariable' {NonEmpty Text
names :: NonEmpty Text
$sel:names:BatchGetVariable' :: BatchGetVariable -> NonEmpty Text
names} -> NonEmpty Text
names) (\s :: BatchGetVariable
s@BatchGetVariable' {} NonEmpty Text
a -> BatchGetVariable
s {$sel:names:BatchGetVariable' :: NonEmpty Text
names = NonEmpty Text
a} :: BatchGetVariable) 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 BatchGetVariable where
  type
    AWSResponse BatchGetVariable =
      BatchGetVariableResponse
  request :: (Service -> Service)
-> BatchGetVariable -> Request BatchGetVariable
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 BatchGetVariable
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchGetVariable)))
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 [BatchGetVariableError]
-> Maybe [Variable] -> Int -> BatchGetVariableResponse
BatchGetVariableResponse'
            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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"variables" 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 BatchGetVariable where
  hashWithSalt :: Int -> BatchGetVariable -> Int
hashWithSalt Int
_salt BatchGetVariable' {NonEmpty Text
names :: NonEmpty Text
$sel:names:BatchGetVariable' :: BatchGetVariable -> NonEmpty Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
names

instance Prelude.NFData BatchGetVariable where
  rnf :: BatchGetVariable -> ()
rnf BatchGetVariable' {NonEmpty Text
names :: NonEmpty Text
$sel:names:BatchGetVariable' :: BatchGetVariable -> NonEmpty Text
..} = forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
names

instance Data.ToHeaders BatchGetVariable where
  toHeaders :: BatchGetVariable -> 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.BatchGetVariable" ::
                          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 BatchGetVariable where
  toJSON :: BatchGetVariable -> Value
toJSON BatchGetVariable' {NonEmpty Text
names :: NonEmpty Text
$sel:names:BatchGetVariable' :: BatchGetVariable -> NonEmpty Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"names" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
names)]
      )

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

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

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

-- |
-- Create a value of 'BatchGetVariableResponse' 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', 'batchGetVariableResponse_errors' - The errors from the request.
--
-- 'variables', 'batchGetVariableResponse_variables' - The returned variables.
--
-- 'httpStatus', 'batchGetVariableResponse_httpStatus' - The response's http status code.
newBatchGetVariableResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchGetVariableResponse
newBatchGetVariableResponse :: Int -> BatchGetVariableResponse
newBatchGetVariableResponse Int
pHttpStatus_ =
  BatchGetVariableResponse'
    { $sel:errors:BatchGetVariableResponse' :: Maybe [BatchGetVariableError]
errors = forall a. Maybe a
Prelude.Nothing,
      $sel:variables:BatchGetVariableResponse' :: Maybe [Variable]
variables = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchGetVariableResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The errors from the request.
batchGetVariableResponse_errors :: Lens.Lens' BatchGetVariableResponse (Prelude.Maybe [BatchGetVariableError])
batchGetVariableResponse_errors :: Lens' BatchGetVariableResponse (Maybe [BatchGetVariableError])
batchGetVariableResponse_errors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetVariableResponse' {Maybe [BatchGetVariableError]
errors :: Maybe [BatchGetVariableError]
$sel:errors:BatchGetVariableResponse' :: BatchGetVariableResponse -> Maybe [BatchGetVariableError]
errors} -> Maybe [BatchGetVariableError]
errors) (\s :: BatchGetVariableResponse
s@BatchGetVariableResponse' {} Maybe [BatchGetVariableError]
a -> BatchGetVariableResponse
s {$sel:errors:BatchGetVariableResponse' :: Maybe [BatchGetVariableError]
errors = Maybe [BatchGetVariableError]
a} :: BatchGetVariableResponse) 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 returned variables.
batchGetVariableResponse_variables :: Lens.Lens' BatchGetVariableResponse (Prelude.Maybe [Variable])
batchGetVariableResponse_variables :: Lens' BatchGetVariableResponse (Maybe [Variable])
batchGetVariableResponse_variables = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetVariableResponse' {Maybe [Variable]
variables :: Maybe [Variable]
$sel:variables:BatchGetVariableResponse' :: BatchGetVariableResponse -> Maybe [Variable]
variables} -> Maybe [Variable]
variables) (\s :: BatchGetVariableResponse
s@BatchGetVariableResponse' {} Maybe [Variable]
a -> BatchGetVariableResponse
s {$sel:variables:BatchGetVariableResponse' :: Maybe [Variable]
variables = Maybe [Variable]
a} :: BatchGetVariableResponse) 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.
batchGetVariableResponse_httpStatus :: Lens.Lens' BatchGetVariableResponse Prelude.Int
batchGetVariableResponse_httpStatus :: Lens' BatchGetVariableResponse Int
batchGetVariableResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetVariableResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchGetVariableResponse' :: BatchGetVariableResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchGetVariableResponse
s@BatchGetVariableResponse' {} Int
a -> BatchGetVariableResponse
s {$sel:httpStatus:BatchGetVariableResponse' :: Int
httpStatus = Int
a} :: BatchGetVariableResponse)

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