{-# 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.PutOutcome
-- 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 or updates an outcome.
module Amazonka.FraudDetector.PutOutcome
  ( -- * Creating a Request
    PutOutcome (..),
    newPutOutcome,

    -- * Request Lenses
    putOutcome_description,
    putOutcome_tags,
    putOutcome_name,

    -- * Destructuring the Response
    PutOutcomeResponse (..),
    newPutOutcomeResponse,

    -- * Response Lenses
    putOutcomeResponse_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:/ 'newPutOutcome' smart constructor.
data PutOutcome = PutOutcome'
  { -- | The outcome description.
    PutOutcome -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | A collection of key and value pairs.
    PutOutcome -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name of the outcome.
    PutOutcome -> Text
name :: Prelude.Text
  }
  deriving (PutOutcome -> PutOutcome -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutOutcome -> PutOutcome -> Bool
$c/= :: PutOutcome -> PutOutcome -> Bool
== :: PutOutcome -> PutOutcome -> Bool
$c== :: PutOutcome -> PutOutcome -> Bool
Prelude.Eq, ReadPrec [PutOutcome]
ReadPrec PutOutcome
Int -> ReadS PutOutcome
ReadS [PutOutcome]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutOutcome]
$creadListPrec :: ReadPrec [PutOutcome]
readPrec :: ReadPrec PutOutcome
$creadPrec :: ReadPrec PutOutcome
readList :: ReadS [PutOutcome]
$creadList :: ReadS [PutOutcome]
readsPrec :: Int -> ReadS PutOutcome
$creadsPrec :: Int -> ReadS PutOutcome
Prelude.Read, Int -> PutOutcome -> ShowS
[PutOutcome] -> ShowS
PutOutcome -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutOutcome] -> ShowS
$cshowList :: [PutOutcome] -> ShowS
show :: PutOutcome -> String
$cshow :: PutOutcome -> String
showsPrec :: Int -> PutOutcome -> ShowS
$cshowsPrec :: Int -> PutOutcome -> ShowS
Prelude.Show, forall x. Rep PutOutcome x -> PutOutcome
forall x. PutOutcome -> Rep PutOutcome x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutOutcome x -> PutOutcome
$cfrom :: forall x. PutOutcome -> Rep PutOutcome x
Prelude.Generic)

-- |
-- Create a value of 'PutOutcome' 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:
--
-- 'description', 'putOutcome_description' - The outcome description.
--
-- 'tags', 'putOutcome_tags' - A collection of key and value pairs.
--
-- 'name', 'putOutcome_name' - The name of the outcome.
newPutOutcome ::
  -- | 'name'
  Prelude.Text ->
  PutOutcome
newPutOutcome :: Text -> PutOutcome
newPutOutcome Text
pName_ =
  PutOutcome'
    { $sel:description:PutOutcome' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:PutOutcome' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:name:PutOutcome' :: Text
name = Text
pName_
    }

-- | The outcome description.
putOutcome_description :: Lens.Lens' PutOutcome (Prelude.Maybe Prelude.Text)
putOutcome_description :: Lens' PutOutcome (Maybe Text)
putOutcome_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutOutcome' {Maybe Text
description :: Maybe Text
$sel:description:PutOutcome' :: PutOutcome -> Maybe Text
description} -> Maybe Text
description) (\s :: PutOutcome
s@PutOutcome' {} Maybe Text
a -> PutOutcome
s {$sel:description:PutOutcome' :: Maybe Text
description = Maybe Text
a} :: PutOutcome)

-- | A collection of key and value pairs.
putOutcome_tags :: Lens.Lens' PutOutcome (Prelude.Maybe [Tag])
putOutcome_tags :: Lens' PutOutcome (Maybe [Tag])
putOutcome_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutOutcome' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:PutOutcome' :: PutOutcome -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: PutOutcome
s@PutOutcome' {} Maybe [Tag]
a -> PutOutcome
s {$sel:tags:PutOutcome' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: PutOutcome) 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 name of the outcome.
putOutcome_name :: Lens.Lens' PutOutcome Prelude.Text
putOutcome_name :: Lens' PutOutcome Text
putOutcome_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutOutcome' {Text
name :: Text
$sel:name:PutOutcome' :: PutOutcome -> Text
name} -> Text
name) (\s :: PutOutcome
s@PutOutcome' {} Text
a -> PutOutcome
s {$sel:name:PutOutcome' :: Text
name = Text
a} :: PutOutcome)

instance Core.AWSRequest PutOutcome where
  type AWSResponse PutOutcome = PutOutcomeResponse
  request :: (Service -> Service) -> PutOutcome -> Request PutOutcome
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 PutOutcome
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutOutcome)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutOutcomeResponse
PutOutcomeResponse'
            forall (f :: * -> *) a b. Functor 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 PutOutcome where
  hashWithSalt :: Int -> PutOutcome -> Int
hashWithSalt Int
_salt PutOutcome' {Maybe [Tag]
Maybe Text
Text
name :: Text
tags :: Maybe [Tag]
description :: Maybe Text
$sel:name:PutOutcome' :: PutOutcome -> Text
$sel:tags:PutOutcome' :: PutOutcome -> Maybe [Tag]
$sel:description:PutOutcome' :: PutOutcome -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData PutOutcome where
  rnf :: PutOutcome -> ()
rnf PutOutcome' {Maybe [Tag]
Maybe Text
Text
name :: Text
tags :: Maybe [Tag]
description :: Maybe Text
$sel:name:PutOutcome' :: PutOutcome -> Text
$sel:tags:PutOutcome' :: PutOutcome -> Maybe [Tag]
$sel:description:PutOutcome' :: PutOutcome -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Text
name

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

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

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

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

-- |
-- Create a value of 'PutOutcomeResponse' 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:
--
-- 'httpStatus', 'putOutcomeResponse_httpStatus' - The response's http status code.
newPutOutcomeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutOutcomeResponse
newPutOutcomeResponse :: Int -> PutOutcomeResponse
newPutOutcomeResponse Int
pHttpStatus_ =
  PutOutcomeResponse' {$sel:httpStatus:PutOutcomeResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData PutOutcomeResponse where
  rnf :: PutOutcomeResponse -> ()
rnf PutOutcomeResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutOutcomeResponse' :: PutOutcomeResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus