{-# 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.PutLabel
-- 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 label. A label classifies an event as fraudulent or
-- legitimate. Labels are associated with event types and used to train
-- supervised machine learning models in Amazon Fraud Detector.
module Amazonka.FraudDetector.PutLabel
  ( -- * Creating a Request
    PutLabel (..),
    newPutLabel,

    -- * Request Lenses
    putLabel_description,
    putLabel_tags,
    putLabel_name,

    -- * Destructuring the Response
    PutLabelResponse (..),
    newPutLabelResponse,

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

-- |
-- Create a value of 'PutLabel' 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', 'putLabel_description' - The label description.
--
-- 'tags', 'putLabel_tags' -
--
-- 'name', 'putLabel_name' - The label name.
newPutLabel ::
  -- | 'name'
  Prelude.Text ->
  PutLabel
newPutLabel :: Text -> PutLabel
newPutLabel Text
pName_ =
  PutLabel' :: Maybe Text -> Maybe [Tag] -> Text -> PutLabel
PutLabel'
    { $sel:description:PutLabel' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:PutLabel' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:PutLabel' :: Text
name = Text
pName_
    }

-- | The label description.
putLabel_description :: Lens.Lens' PutLabel (Prelude.Maybe Prelude.Text)
putLabel_description :: (Maybe Text -> f (Maybe Text)) -> PutLabel -> f PutLabel
putLabel_description = (PutLabel -> Maybe Text)
-> (PutLabel -> Maybe Text -> PutLabel)
-> Lens PutLabel PutLabel (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutLabel' {Maybe Text
description :: Maybe Text
$sel:description:PutLabel' :: PutLabel -> Maybe Text
description} -> Maybe Text
description) (\s :: PutLabel
s@PutLabel' {} Maybe Text
a -> PutLabel
s {$sel:description:PutLabel' :: Maybe Text
description = Maybe Text
a} :: PutLabel)

-- |
putLabel_tags :: Lens.Lens' PutLabel (Prelude.Maybe [Tag])
putLabel_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> PutLabel -> f PutLabel
putLabel_tags = (PutLabel -> Maybe [Tag])
-> (PutLabel -> Maybe [Tag] -> PutLabel)
-> Lens PutLabel PutLabel (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutLabel' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:PutLabel' :: PutLabel -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: PutLabel
s@PutLabel' {} Maybe [Tag]
a -> PutLabel
s {$sel:tags:PutLabel' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: PutLabel) ((Maybe [Tag] -> f (Maybe [Tag])) -> PutLabel -> f PutLabel)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> PutLabel
-> f PutLabel
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 label name.
putLabel_name :: Lens.Lens' PutLabel Prelude.Text
putLabel_name :: (Text -> f Text) -> PutLabel -> f PutLabel
putLabel_name = (PutLabel -> Text)
-> (PutLabel -> Text -> PutLabel)
-> Lens PutLabel PutLabel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutLabel' {Text
name :: Text
$sel:name:PutLabel' :: PutLabel -> Text
name} -> Text
name) (\s :: PutLabel
s@PutLabel' {} Text
a -> PutLabel
s {$sel:name:PutLabel' :: Text
name = Text
a} :: PutLabel)

instance Core.AWSRequest PutLabel where
  type AWSResponse PutLabel = PutLabelResponse
  request :: PutLabel -> Request PutLabel
request = Service -> PutLabel -> Request PutLabel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutLabel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutLabel)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse PutLabel))
-> Logger
-> Service
-> Proxy PutLabel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutLabel)))
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 -> PutLabelResponse
PutLabelResponse'
            (Int -> PutLabelResponse)
-> Either String Int -> Either String PutLabelResponse
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 PutLabel

instance Prelude.NFData PutLabel

instance Core.ToHeaders PutLabel where
  toHeaders :: PutLabel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutLabel -> 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.PutLabel" ::
                          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 PutLabel where
  toJSON :: PutLabel -> Value
toJSON PutLabel' {Maybe [Tag]
Maybe Text
Text
name :: Text
tags :: Maybe [Tag]
description :: Maybe Text
$sel:name:PutLabel' :: PutLabel -> Text
$sel:tags:PutLabel' :: PutLabel -> Maybe [Tag]
$sel:description:PutLabel' :: PutLabel -> 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 PutLabel where
  toPath :: PutLabel -> ByteString
toPath = ByteString -> PutLabel -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance Prelude.NFData PutLabelResponse