{-# 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.GetOutcomes
-- 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 one or more outcomes. This is a paginated API. If you provide a
-- null @maxResults@, this actions retrieves a maximum of 100 records per
-- page. If you provide a @maxResults@, the value must be between 50 and
-- 100. To get the next page results, provide the pagination token from the
-- @GetOutcomesResult@ as part of your request. A null pagination token
-- fetches the records from the beginning.
module Amazonka.FraudDetector.GetOutcomes
  ( -- * Creating a Request
    GetOutcomes (..),
    newGetOutcomes,

    -- * Request Lenses
    getOutcomes_maxResults,
    getOutcomes_name,
    getOutcomes_nextToken,

    -- * Destructuring the Response
    GetOutcomesResponse (..),
    newGetOutcomesResponse,

    -- * Response Lenses
    getOutcomesResponse_nextToken,
    getOutcomesResponse_outcomes,
    getOutcomesResponse_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:/ 'newGetOutcomes' smart constructor.
data GetOutcomes = GetOutcomes'
  { -- | The maximum number of objects to return for the request.
    GetOutcomes -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The name of the outcome or outcomes to get.
    GetOutcomes -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The next page token for the request.
    GetOutcomes -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (GetOutcomes -> GetOutcomes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetOutcomes -> GetOutcomes -> Bool
$c/= :: GetOutcomes -> GetOutcomes -> Bool
== :: GetOutcomes -> GetOutcomes -> Bool
$c== :: GetOutcomes -> GetOutcomes -> Bool
Prelude.Eq, ReadPrec [GetOutcomes]
ReadPrec GetOutcomes
Int -> ReadS GetOutcomes
ReadS [GetOutcomes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetOutcomes]
$creadListPrec :: ReadPrec [GetOutcomes]
readPrec :: ReadPrec GetOutcomes
$creadPrec :: ReadPrec GetOutcomes
readList :: ReadS [GetOutcomes]
$creadList :: ReadS [GetOutcomes]
readsPrec :: Int -> ReadS GetOutcomes
$creadsPrec :: Int -> ReadS GetOutcomes
Prelude.Read, Int -> GetOutcomes -> ShowS
[GetOutcomes] -> ShowS
GetOutcomes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetOutcomes] -> ShowS
$cshowList :: [GetOutcomes] -> ShowS
show :: GetOutcomes -> String
$cshow :: GetOutcomes -> String
showsPrec :: Int -> GetOutcomes -> ShowS
$cshowsPrec :: Int -> GetOutcomes -> ShowS
Prelude.Show, forall x. Rep GetOutcomes x -> GetOutcomes
forall x. GetOutcomes -> Rep GetOutcomes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetOutcomes x -> GetOutcomes
$cfrom :: forall x. GetOutcomes -> Rep GetOutcomes x
Prelude.Generic)

-- |
-- Create a value of 'GetOutcomes' 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', 'getOutcomes_maxResults' - The maximum number of objects to return for the request.
--
-- 'name', 'getOutcomes_name' - The name of the outcome or outcomes to get.
--
-- 'nextToken', 'getOutcomes_nextToken' - The next page token for the request.
newGetOutcomes ::
  GetOutcomes
newGetOutcomes :: GetOutcomes
newGetOutcomes =
  GetOutcomes'
    { $sel:maxResults:GetOutcomes' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetOutcomes' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetOutcomes' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of objects to return for the request.
getOutcomes_maxResults :: Lens.Lens' GetOutcomes (Prelude.Maybe Prelude.Natural)
getOutcomes_maxResults :: Lens' GetOutcomes (Maybe Natural)
getOutcomes_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOutcomes' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetOutcomes' :: GetOutcomes -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetOutcomes
s@GetOutcomes' {} Maybe Natural
a -> GetOutcomes
s {$sel:maxResults:GetOutcomes' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetOutcomes)

-- | The name of the outcome or outcomes to get.
getOutcomes_name :: Lens.Lens' GetOutcomes (Prelude.Maybe Prelude.Text)
getOutcomes_name :: Lens' GetOutcomes (Maybe Text)
getOutcomes_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOutcomes' {Maybe Text
name :: Maybe Text
$sel:name:GetOutcomes' :: GetOutcomes -> Maybe Text
name} -> Maybe Text
name) (\s :: GetOutcomes
s@GetOutcomes' {} Maybe Text
a -> GetOutcomes
s {$sel:name:GetOutcomes' :: Maybe Text
name = Maybe Text
a} :: GetOutcomes)

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

instance Core.AWSRequest GetOutcomes where
  type AWSResponse GetOutcomes = GetOutcomesResponse
  request :: (Service -> Service) -> GetOutcomes -> Request GetOutcomes
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 GetOutcomes
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetOutcomes)))
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 [Outcome] -> Int -> GetOutcomesResponse
GetOutcomesResponse'
            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
"outcomes" 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 GetOutcomes where
  hashWithSalt :: Int -> GetOutcomes -> Int
hashWithSalt Int
_salt GetOutcomes' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:GetOutcomes' :: GetOutcomes -> Maybe Text
$sel:name:GetOutcomes' :: GetOutcomes -> Maybe Text
$sel:maxResults:GetOutcomes' :: GetOutcomes -> 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 GetOutcomes where
  rnf :: GetOutcomes -> ()
rnf GetOutcomes' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:GetOutcomes' :: GetOutcomes -> Maybe Text
$sel:name:GetOutcomes' :: GetOutcomes -> Maybe Text
$sel:maxResults:GetOutcomes' :: GetOutcomes -> 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 GetOutcomes where
  toHeaders :: GetOutcomes -> 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.GetOutcomes" ::
                          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 GetOutcomes where
  toJSON :: GetOutcomes -> Value
toJSON GetOutcomes' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:GetOutcomes' :: GetOutcomes -> Maybe Text
$sel:name:GetOutcomes' :: GetOutcomes -> Maybe Text
$sel:maxResults:GetOutcomes' :: GetOutcomes -> 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 GetOutcomes where
  toPath :: GetOutcomes -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'GetOutcomesResponse' 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', 'getOutcomesResponse_nextToken' - The next page token for subsequent requests.
--
-- 'outcomes', 'getOutcomesResponse_outcomes' - The outcomes.
--
-- 'httpStatus', 'getOutcomesResponse_httpStatus' - The response's http status code.
newGetOutcomesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetOutcomesResponse
newGetOutcomesResponse :: Int -> GetOutcomesResponse
newGetOutcomesResponse Int
pHttpStatus_ =
  GetOutcomesResponse'
    { $sel:nextToken:GetOutcomesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:outcomes:GetOutcomesResponse' :: Maybe [Outcome]
outcomes = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetOutcomesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The next page token for subsequent requests.
getOutcomesResponse_nextToken :: Lens.Lens' GetOutcomesResponse (Prelude.Maybe Prelude.Text)
getOutcomesResponse_nextToken :: Lens' GetOutcomesResponse (Maybe Text)
getOutcomesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOutcomesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetOutcomesResponse' :: GetOutcomesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetOutcomesResponse
s@GetOutcomesResponse' {} Maybe Text
a -> GetOutcomesResponse
s {$sel:nextToken:GetOutcomesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetOutcomesResponse)

-- | The outcomes.
getOutcomesResponse_outcomes :: Lens.Lens' GetOutcomesResponse (Prelude.Maybe [Outcome])
getOutcomesResponse_outcomes :: Lens' GetOutcomesResponse (Maybe [Outcome])
getOutcomesResponse_outcomes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOutcomesResponse' {Maybe [Outcome]
outcomes :: Maybe [Outcome]
$sel:outcomes:GetOutcomesResponse' :: GetOutcomesResponse -> Maybe [Outcome]
outcomes} -> Maybe [Outcome]
outcomes) (\s :: GetOutcomesResponse
s@GetOutcomesResponse' {} Maybe [Outcome]
a -> GetOutcomesResponse
s {$sel:outcomes:GetOutcomesResponse' :: Maybe [Outcome]
outcomes = Maybe [Outcome]
a} :: GetOutcomesResponse) 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.
getOutcomesResponse_httpStatus :: Lens.Lens' GetOutcomesResponse Prelude.Int
getOutcomesResponse_httpStatus :: Lens' GetOutcomesResponse Int
getOutcomesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOutcomesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetOutcomesResponse' :: GetOutcomesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetOutcomesResponse
s@GetOutcomesResponse' {} Int
a -> GetOutcomesResponse
s {$sel:httpStatus:GetOutcomesResponse' :: Int
httpStatus = Int
a} :: GetOutcomesResponse)

instance Prelude.NFData GetOutcomesResponse where
  rnf :: GetOutcomesResponse -> ()
rnf GetOutcomesResponse' {Int
Maybe [Outcome]
Maybe Text
httpStatus :: Int
outcomes :: Maybe [Outcome]
nextToken :: Maybe Text
$sel:httpStatus:GetOutcomesResponse' :: GetOutcomesResponse -> Int
$sel:outcomes:GetOutcomesResponse' :: GetOutcomesResponse -> Maybe [Outcome]
$sel:nextToken:GetOutcomesResponse' :: GetOutcomesResponse -> 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 [Outcome]
outcomes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus