{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 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:/ '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
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]
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
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. 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'
    { $sel:description:PutLabel' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:PutLabel' :: Maybe [Tag]
tags = 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 :: Lens' PutLabel (Maybe Text)
putLabel_description = 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 :: Lens' PutLabel (Maybe [Tag])
putLabel_tags = 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) 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 label name.
putLabel_name :: Lens.Lens' PutLabel Prelude.Text
putLabel_name :: Lens' PutLabel Text
putLabel_name = 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 :: (Service -> Service) -> PutLabel -> Request PutLabel
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 PutLabel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutLabel)))
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 -> PutLabelResponse
PutLabelResponse'
            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 PutLabel where
  hashWithSalt :: Int -> PutLabel -> Int
hashWithSalt Int
_salt 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
..} =
    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 PutLabel where
  rnf :: PutLabel -> ()
rnf 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
..} =
    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 PutLabel where
  toHeaders :: PutLabel -> 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.PutLabel" ::
                          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 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
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 PutLabel where
  toPath :: PutLabel -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery PutLabel where
  toQuery :: PutLabel -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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' {$sel:httpStatus:PutLabelResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
putLabelResponse_httpStatus :: Lens.Lens' PutLabelResponse Prelude.Int
putLabelResponse_httpStatus :: Lens' PutLabelResponse Int
putLabelResponse_httpStatus = 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 where
  rnf :: PutLabelResponse -> ()
rnf PutLabelResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutLabelResponse' :: PutLabelResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus