{-# 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-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)
--
-- 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_nextToken,
    getVariables_name,
    getVariables_maxResults,

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

    -- * Response Lenses
    getVariablesResponse_variables,
    getVariablesResponse_nextToken,
    getVariablesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.FraudDetector.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:/ 'newGetVariables' smart constructor.
data GetVariables = GetVariables'
  { -- | The next page token of the get variable request.
    GetVariables -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the variable.
    GetVariables -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The max size per page determined for the get variable request.
    GetVariables -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (GetVariables -> GetVariables -> Bool
(GetVariables -> GetVariables -> Bool)
-> (GetVariables -> GetVariables -> Bool) -> Eq GetVariables
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]
(Int -> ReadS GetVariables)
-> ReadS [GetVariables]
-> ReadPrec GetVariables
-> ReadPrec [GetVariables]
-> Read 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
(Int -> GetVariables -> ShowS)
-> (GetVariables -> String)
-> ([GetVariables] -> ShowS)
-> Show GetVariables
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. GetVariables -> Rep GetVariables x)
-> (forall x. Rep GetVariables x -> GetVariables)
-> Generic GetVariables
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:
--
-- 'nextToken', 'getVariables_nextToken' - The next page token of the get variable request.
--
-- 'name', 'getVariables_name' - The name of the variable.
--
-- 'maxResults', 'getVariables_maxResults' - The max size per page determined for the get variable request.
newGetVariables ::
  GetVariables
newGetVariables :: GetVariables
newGetVariables =
  GetVariables' :: Maybe Text -> Maybe Text -> Maybe Natural -> GetVariables
GetVariables'
    { $sel:nextToken:GetVariables' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetVariables' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetVariables' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The next page token of the get variable request.
getVariables_nextToken :: Lens.Lens' GetVariables (Prelude.Maybe Prelude.Text)
getVariables_nextToken :: (Maybe Text -> f (Maybe Text)) -> GetVariables -> f GetVariables
getVariables_nextToken = (GetVariables -> Maybe Text)
-> (GetVariables -> Maybe Text -> GetVariables)
-> Lens GetVariables GetVariables (Maybe Text) (Maybe Text)
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)

-- | The name of the variable.
getVariables_name :: Lens.Lens' GetVariables (Prelude.Maybe Prelude.Text)
getVariables_name :: (Maybe Text -> f (Maybe Text)) -> GetVariables -> f GetVariables
getVariables_name = (GetVariables -> Maybe Text)
-> (GetVariables -> Maybe Text -> GetVariables)
-> Lens GetVariables GetVariables (Maybe Text) (Maybe Text)
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 max size per page determined for the get variable request.
getVariables_maxResults :: Lens.Lens' GetVariables (Prelude.Maybe Prelude.Natural)
getVariables_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> GetVariables -> f GetVariables
getVariables_maxResults = (GetVariables -> Maybe Natural)
-> (GetVariables -> Maybe Natural -> GetVariables)
-> Lens GetVariables GetVariables (Maybe Natural) (Maybe Natural)
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)

instance Core.AWSRequest GetVariables where
  type AWSResponse GetVariables = GetVariablesResponse
  request :: GetVariables -> Request GetVariables
request = Service -> GetVariables -> Request GetVariables
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetVariables
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetVariables)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetVariables))
-> Logger
-> Service
-> Proxy GetVariables
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetVariables)))
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 [Variable] -> Maybe Text -> Int -> GetVariablesResponse
GetVariablesResponse'
            (Maybe [Variable] -> Maybe Text -> Int -> GetVariablesResponse)
-> Either String (Maybe [Variable])
-> Either String (Maybe Text -> Int -> GetVariablesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Variable]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"variables" Either String (Maybe (Maybe [Variable]))
-> Maybe [Variable] -> Either String (Maybe [Variable])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Variable]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> GetVariablesResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetVariablesResponse)
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
"nextToken")
            Either String (Int -> GetVariablesResponse)
-> Either String Int -> Either String GetVariablesResponse
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 GetVariables

instance Prelude.NFData GetVariables

instance Core.ToHeaders GetVariables where
  toHeaders :: GetVariables -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetVariables -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSHawksNestServiceFacade.GetVariables" ::
                          Prelude.ByteString
                      ),
            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 GetVariables where
  toJSON :: GetVariables -> Value
toJSON GetVariables' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
name :: Maybe Text
nextToken :: Maybe Text
$sel:maxResults:GetVariables' :: GetVariables -> Maybe Natural
$sel:name:GetVariables' :: GetVariables -> Maybe Text
$sel:nextToken:GetVariables' :: GetVariables -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"nextToken" 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
nextToken,
            (Text
"name" 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
name,
            (Text
"maxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
          ]
      )

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

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

-- | /See:/ 'newGetVariablesResponse' smart constructor.
data GetVariablesResponse = GetVariablesResponse'
  { -- | The names of the variables returned.
    GetVariablesResponse -> Maybe [Variable]
variables :: Prelude.Maybe [Variable],
    -- | The next page token to be used in subsequent requests.
    GetVariablesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetVariablesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetVariablesResponse -> GetVariablesResponse -> Bool
(GetVariablesResponse -> GetVariablesResponse -> Bool)
-> (GetVariablesResponse -> GetVariablesResponse -> Bool)
-> Eq GetVariablesResponse
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]
(Int -> ReadS GetVariablesResponse)
-> ReadS [GetVariablesResponse]
-> ReadPrec GetVariablesResponse
-> ReadPrec [GetVariablesResponse]
-> Read 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
(Int -> GetVariablesResponse -> ShowS)
-> (GetVariablesResponse -> String)
-> ([GetVariablesResponse] -> ShowS)
-> Show GetVariablesResponse
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. GetVariablesResponse -> Rep GetVariablesResponse x)
-> (forall x. Rep GetVariablesResponse x -> GetVariablesResponse)
-> Generic GetVariablesResponse
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:
--
-- 'variables', 'getVariablesResponse_variables' - The names of the variables returned.
--
-- 'nextToken', 'getVariablesResponse_nextToken' - The next page token to be used in subsequent requests.
--
-- 'httpStatus', 'getVariablesResponse_httpStatus' - The response's http status code.
newGetVariablesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetVariablesResponse
newGetVariablesResponse :: Int -> GetVariablesResponse
newGetVariablesResponse Int
pHttpStatus_ =
  GetVariablesResponse' :: Maybe [Variable] -> Maybe Text -> Int -> GetVariablesResponse
GetVariablesResponse'
    { $sel:variables:GetVariablesResponse' :: Maybe [Variable]
variables = Maybe [Variable]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetVariablesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetVariablesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The names of the variables returned.
getVariablesResponse_variables :: Lens.Lens' GetVariablesResponse (Prelude.Maybe [Variable])
getVariablesResponse_variables :: (Maybe [Variable] -> f (Maybe [Variable]))
-> GetVariablesResponse -> f GetVariablesResponse
getVariablesResponse_variables = (GetVariablesResponse -> Maybe [Variable])
-> (GetVariablesResponse
    -> Maybe [Variable] -> GetVariablesResponse)
-> Lens
     GetVariablesResponse
     GetVariablesResponse
     (Maybe [Variable])
     (Maybe [Variable])
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) ((Maybe [Variable] -> f (Maybe [Variable]))
 -> GetVariablesResponse -> f GetVariablesResponse)
-> ((Maybe [Variable] -> f (Maybe [Variable]))
    -> Maybe [Variable] -> f (Maybe [Variable]))
-> (Maybe [Variable] -> f (Maybe [Variable]))
-> GetVariablesResponse
-> f GetVariablesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Variable] [Variable] [Variable] [Variable]
-> Iso
     (Maybe [Variable])
     (Maybe [Variable])
     (Maybe [Variable])
     (Maybe [Variable])
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 [Variable] [Variable] [Variable] [Variable]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The next page token to be used in subsequent requests.
getVariablesResponse_nextToken :: Lens.Lens' GetVariablesResponse (Prelude.Maybe Prelude.Text)
getVariablesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetVariablesResponse -> f GetVariablesResponse
getVariablesResponse_nextToken = (GetVariablesResponse -> Maybe Text)
-> (GetVariablesResponse -> Maybe Text -> GetVariablesResponse)
-> Lens
     GetVariablesResponse GetVariablesResponse (Maybe Text) (Maybe Text)
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 response's http status code.
getVariablesResponse_httpStatus :: Lens.Lens' GetVariablesResponse Prelude.Int
getVariablesResponse_httpStatus :: (Int -> f Int) -> GetVariablesResponse -> f GetVariablesResponse
getVariablesResponse_httpStatus = (GetVariablesResponse -> Int)
-> (GetVariablesResponse -> Int -> GetVariablesResponse)
-> Lens GetVariablesResponse GetVariablesResponse Int Int
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