{-# 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.GetVariables
-- 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 all of the variables or the specific variable. This is a paginated
-- API. Providing null @maxSizePerPage@ results in retrieving maximum of
-- 100 records per page. If you provide @maxSizePerPage@ the value must be
-- between 50 and 100. To get the next page result, a provide a pagination
-- token from @GetVariablesResult@ as part of your request. Null pagination
-- token fetches the records from the beginning.
module Amazonka.FraudDetector.GetVariables
  ( -- * Creating a Request
    GetVariables (..),
    newGetVariables,

    -- * Request Lenses
    getVariables_maxResults,
    getVariables_name,
    getVariables_nextToken,

    -- * Destructuring the Response
    GetVariablesResponse (..),
    newGetVariablesResponse,

    -- * Response Lenses
    getVariablesResponse_nextToken,
    getVariablesResponse_variables,
    getVariablesResponse_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:/ 'newGetVariables' smart constructor.
data GetVariables = GetVariables'
  { -- | The max size per page determined for the get variable request.
    GetVariables -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The name of the variable.
    GetVariables -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The next page token of the get variable request.
    GetVariables -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (GetVariables -> GetVariables -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetVariables -> GetVariables -> Bool
$c/= :: GetVariables -> GetVariables -> Bool
== :: GetVariables -> GetVariables -> Bool
$c== :: GetVariables -> GetVariables -> Bool
Prelude.Eq, ReadPrec [GetVariables]
ReadPrec GetVariables
Int -> ReadS GetVariables
ReadS [GetVariables]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetVariables]
$creadListPrec :: ReadPrec [GetVariables]
readPrec :: ReadPrec GetVariables
$creadPrec :: ReadPrec GetVariables
readList :: ReadS [GetVariables]
$creadList :: ReadS [GetVariables]
readsPrec :: Int -> ReadS GetVariables
$creadsPrec :: Int -> ReadS GetVariables
Prelude.Read, Int -> GetVariables -> ShowS
[GetVariables] -> ShowS
GetVariables -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetVariables] -> ShowS
$cshowList :: [GetVariables] -> ShowS
show :: GetVariables -> String
$cshow :: GetVariables -> String
showsPrec :: Int -> GetVariables -> ShowS
$cshowsPrec :: Int -> GetVariables -> ShowS
Prelude.Show, forall x. Rep GetVariables x -> GetVariables
forall x. GetVariables -> Rep GetVariables x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetVariables x -> GetVariables
$cfrom :: forall x. GetVariables -> Rep GetVariables x
Prelude.Generic)

-- |
-- Create a value of 'GetVariables' 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:
--
-- 'maxResults', 'getVariables_maxResults' - The max size per page determined for the get variable request.
--
-- 'name', 'getVariables_name' - The name of the variable.
--
-- 'nextToken', 'getVariables_nextToken' - The next page token of the get variable request.
newGetVariables ::
  GetVariables
newGetVariables :: GetVariables
newGetVariables =
  GetVariables'
    { $sel:maxResults:GetVariables' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetVariables' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetVariables' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The max size per page determined for the get variable request.
getVariables_maxResults :: Lens.Lens' GetVariables (Prelude.Maybe Prelude.Natural)
getVariables_maxResults :: Lens' GetVariables (Maybe Natural)
getVariables_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVariables' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetVariables' :: GetVariables -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetVariables
s@GetVariables' {} Maybe Natural
a -> GetVariables
s {$sel:maxResults:GetVariables' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetVariables)

-- | The name of the variable.
getVariables_name :: Lens.Lens' GetVariables (Prelude.Maybe Prelude.Text)
getVariables_name :: Lens' GetVariables (Maybe Text)
getVariables_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVariables' {Maybe Text
name :: Maybe Text
$sel:name:GetVariables' :: GetVariables -> Maybe Text
name} -> Maybe Text
name) (\s :: GetVariables
s@GetVariables' {} Maybe Text
a -> GetVariables
s {$sel:name:GetVariables' :: Maybe Text
name = Maybe Text
a} :: GetVariables)

-- | The next page token of the get variable request.
getVariables_nextToken :: Lens.Lens' GetVariables (Prelude.Maybe Prelude.Text)
getVariables_nextToken :: Lens' GetVariables (Maybe Text)
getVariables_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVariables' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetVariables' :: GetVariables -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetVariables
s@GetVariables' {} Maybe Text
a -> GetVariables
s {$sel:nextToken:GetVariables' :: Maybe Text
nextToken = Maybe Text
a} :: GetVariables)

instance Core.AWSRequest GetVariables where
  type AWSResponse GetVariables = GetVariablesResponse
  request :: (Service -> Service) -> GetVariables -> Request GetVariables
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 GetVariables
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetVariables)))
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 Text -> Maybe [Variable] -> Int -> GetVariablesResponse
GetVariablesResponse'
            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
"nextToken")
            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 GetVariables where
  hashWithSalt :: Int -> GetVariables -> Int
hashWithSalt Int
_salt GetVariables' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:GetVariables' :: GetVariables -> Maybe Text
$sel:name:GetVariables' :: GetVariables -> Maybe Text
$sel:maxResults:GetVariables' :: GetVariables -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData GetVariables where
  rnf :: GetVariables -> ()
rnf GetVariables' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:GetVariables' :: GetVariables -> Maybe Text
$sel:name:GetVariables' :: GetVariables -> Maybe Text
$sel:maxResults:GetVariables' :: GetVariables -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders GetVariables where
  toHeaders :: GetVariables -> 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.GetVariables" ::
                          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 GetVariables where
  toJSON :: GetVariables -> Value
toJSON GetVariables' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:GetVariables' :: GetVariables -> Maybe Text
$sel:name:GetVariables' :: GetVariables -> Maybe Text
$sel:maxResults:GetVariables' :: GetVariables -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maxResults" 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 Natural
maxResults,
            (Key
"name" 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 Text
name,
            (Key
"nextToken" 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 Text
nextToken
          ]
      )

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

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

-- | /See:/ 'newGetVariablesResponse' smart constructor.
data GetVariablesResponse = GetVariablesResponse'
  { -- | The next page token to be used in subsequent requests.
    GetVariablesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The names of the variables returned.
    GetVariablesResponse -> Maybe [Variable]
variables :: Prelude.Maybe [Variable],
    -- | The response's http status code.
    GetVariablesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetVariablesResponse -> GetVariablesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetVariablesResponse -> GetVariablesResponse -> Bool
$c/= :: GetVariablesResponse -> GetVariablesResponse -> Bool
== :: GetVariablesResponse -> GetVariablesResponse -> Bool
$c== :: GetVariablesResponse -> GetVariablesResponse -> Bool
Prelude.Eq, ReadPrec [GetVariablesResponse]
ReadPrec GetVariablesResponse
Int -> ReadS GetVariablesResponse
ReadS [GetVariablesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetVariablesResponse]
$creadListPrec :: ReadPrec [GetVariablesResponse]
readPrec :: ReadPrec GetVariablesResponse
$creadPrec :: ReadPrec GetVariablesResponse
readList :: ReadS [GetVariablesResponse]
$creadList :: ReadS [GetVariablesResponse]
readsPrec :: Int -> ReadS GetVariablesResponse
$creadsPrec :: Int -> ReadS GetVariablesResponse
Prelude.Read, Int -> GetVariablesResponse -> ShowS
[GetVariablesResponse] -> ShowS
GetVariablesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetVariablesResponse] -> ShowS
$cshowList :: [GetVariablesResponse] -> ShowS
show :: GetVariablesResponse -> String
$cshow :: GetVariablesResponse -> String
showsPrec :: Int -> GetVariablesResponse -> ShowS
$cshowsPrec :: Int -> GetVariablesResponse -> ShowS
Prelude.Show, forall x. Rep GetVariablesResponse x -> GetVariablesResponse
forall x. GetVariablesResponse -> Rep GetVariablesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetVariablesResponse x -> GetVariablesResponse
$cfrom :: forall x. GetVariablesResponse -> Rep GetVariablesResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetVariablesResponse' 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:
--
-- 'nextToken', 'getVariablesResponse_nextToken' - The next page token to be used in subsequent requests.
--
-- 'variables', 'getVariablesResponse_variables' - The names of the variables returned.
--
-- 'httpStatus', 'getVariablesResponse_httpStatus' - The response's http status code.
newGetVariablesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetVariablesResponse
newGetVariablesResponse :: Int -> GetVariablesResponse
newGetVariablesResponse Int
pHttpStatus_ =
  GetVariablesResponse'
    { $sel:nextToken:GetVariablesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:variables:GetVariablesResponse' :: Maybe [Variable]
variables = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetVariablesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The next page token to be used in subsequent requests.
getVariablesResponse_nextToken :: Lens.Lens' GetVariablesResponse (Prelude.Maybe Prelude.Text)
getVariablesResponse_nextToken :: Lens' GetVariablesResponse (Maybe Text)
getVariablesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVariablesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetVariablesResponse' :: GetVariablesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetVariablesResponse
s@GetVariablesResponse' {} Maybe Text
a -> GetVariablesResponse
s {$sel:nextToken:GetVariablesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetVariablesResponse)

-- | The names of the variables returned.
getVariablesResponse_variables :: Lens.Lens' GetVariablesResponse (Prelude.Maybe [Variable])
getVariablesResponse_variables :: Lens' GetVariablesResponse (Maybe [Variable])
getVariablesResponse_variables = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVariablesResponse' {Maybe [Variable]
variables :: Maybe [Variable]
$sel:variables:GetVariablesResponse' :: GetVariablesResponse -> Maybe [Variable]
variables} -> Maybe [Variable]
variables) (\s :: GetVariablesResponse
s@GetVariablesResponse' {} Maybe [Variable]
a -> GetVariablesResponse
s {$sel:variables:GetVariablesResponse' :: Maybe [Variable]
variables = Maybe [Variable]
a} :: GetVariablesResponse) 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.
getVariablesResponse_httpStatus :: Lens.Lens' GetVariablesResponse Prelude.Int
getVariablesResponse_httpStatus :: Lens' GetVariablesResponse Int
getVariablesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVariablesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetVariablesResponse' :: GetVariablesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetVariablesResponse
s@GetVariablesResponse' {} Int
a -> GetVariablesResponse
s {$sel:httpStatus:GetVariablesResponse' :: Int
httpStatus = Int
a} :: GetVariablesResponse)

instance Prelude.NFData GetVariablesResponse where
  rnf :: GetVariablesResponse -> ()
rnf GetVariablesResponse' {Int
Maybe [Variable]
Maybe Text
httpStatus :: Int
variables :: Maybe [Variable]
nextToken :: Maybe Text
$sel:httpStatus:GetVariablesResponse' :: GetVariablesResponse -> Int
$sel:variables:GetVariablesResponse' :: GetVariablesResponse -> Maybe [Variable]
$sel:nextToken:GetVariablesResponse' :: GetVariablesResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      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