{-# 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-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)
--
-- 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 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:/ '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
(PutOutcome -> PutOutcome -> Bool)
-> (PutOutcome -> PutOutcome -> Bool) -> Eq PutOutcome
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]
(Int -> ReadS PutOutcome)
-> ReadS [PutOutcome]
-> ReadPrec PutOutcome
-> ReadPrec [PutOutcome]
-> Read 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
(Int -> PutOutcome -> ShowS)
-> (PutOutcome -> String)
-> ([PutOutcome] -> ShowS)
-> Show PutOutcome
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. PutOutcome -> Rep PutOutcome x)
-> (forall x. Rep PutOutcome x -> PutOutcome) -> Generic PutOutcome
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' :: Maybe Text -> Maybe [Tag] -> Text -> PutOutcome
PutOutcome'
    { $sel:description:PutOutcome' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:PutOutcome' :: Maybe [Tag]
tags = Maybe [Tag]
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 :: (Maybe Text -> f (Maybe Text)) -> PutOutcome -> f PutOutcome
putOutcome_description = (PutOutcome -> Maybe Text)
-> (PutOutcome -> Maybe Text -> PutOutcome)
-> Lens PutOutcome PutOutcome (Maybe Text) (Maybe Text)
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 :: (Maybe [Tag] -> f (Maybe [Tag])) -> PutOutcome -> f PutOutcome
putOutcome_tags = (PutOutcome -> Maybe [Tag])
-> (PutOutcome -> Maybe [Tag] -> PutOutcome)
-> Lens PutOutcome PutOutcome (Maybe [Tag]) (Maybe [Tag])
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) ((Maybe [Tag] -> f (Maybe [Tag])) -> PutOutcome -> f PutOutcome)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> PutOutcome
-> f PutOutcome
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
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 :: (Text -> f Text) -> PutOutcome -> f PutOutcome
putOutcome_name = (PutOutcome -> Text)
-> (PutOutcome -> Text -> PutOutcome)
-> Lens PutOutcome PutOutcome Text Text
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 :: PutOutcome -> Request PutOutcome
request = Service -> PutOutcome -> Request PutOutcome
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutOutcome
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutOutcome)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse PutOutcome))
-> Logger
-> Service
-> Proxy PutOutcome
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutOutcome)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutOutcomeResponse
PutOutcomeResponse'
            (Int -> PutOutcomeResponse)
-> Either String Int -> Either String PutOutcomeResponse
forall (f :: * -> *) a b. Functor 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 PutOutcome

instance Prelude.NFData PutOutcome

instance Core.ToHeaders PutOutcome where
  toHeaders :: PutOutcome -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutOutcome -> 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.PutOutcome" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"description" 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
description,
            (Text
"tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )

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

instance Core.ToQuery PutOutcome where
  toQuery :: PutOutcome -> QueryString
toQuery = QueryString -> PutOutcome -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(PutOutcomeResponse -> PutOutcomeResponse -> Bool)
-> (PutOutcomeResponse -> PutOutcomeResponse -> Bool)
-> Eq PutOutcomeResponse
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]
(Int -> ReadS PutOutcomeResponse)
-> ReadS [PutOutcomeResponse]
-> ReadPrec PutOutcomeResponse
-> ReadPrec [PutOutcomeResponse]
-> Read 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
(Int -> PutOutcomeResponse -> ShowS)
-> (PutOutcomeResponse -> String)
-> ([PutOutcomeResponse] -> ShowS)
-> Show PutOutcomeResponse
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. PutOutcomeResponse -> Rep PutOutcomeResponse x)
-> (forall x. Rep PutOutcomeResponse x -> PutOutcomeResponse)
-> Generic PutOutcomeResponse
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' :: Int -> PutOutcomeResponse
PutOutcomeResponse' {$sel:httpStatus:PutOutcomeResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
putOutcomeResponse_httpStatus :: Lens.Lens' PutOutcomeResponse Prelude.Int
putOutcomeResponse_httpStatus :: (Int -> f Int) -> PutOutcomeResponse -> f PutOutcomeResponse
putOutcomeResponse_httpStatus = (PutOutcomeResponse -> Int)
-> (PutOutcomeResponse -> Int -> PutOutcomeResponse)
-> Lens PutOutcomeResponse PutOutcomeResponse Int Int
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