{-# 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.UpdateDetectorVersionStatus
-- 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)
--
-- Updates the detector version’s status. You can perform the following
-- promotions or demotions using @UpdateDetectorVersionStatus@: @DRAFT@ to
-- @ACTIVE@, @ACTIVE@ to @INACTIVE@, and @INACTIVE@ to @ACTIVE@.
module Amazonka.FraudDetector.UpdateDetectorVersionStatus
  ( -- * Creating a Request
    UpdateDetectorVersionStatus (..),
    newUpdateDetectorVersionStatus,

    -- * Request Lenses
    updateDetectorVersionStatus_detectorId,
    updateDetectorVersionStatus_detectorVersionId,
    updateDetectorVersionStatus_status,

    -- * Destructuring the Response
    UpdateDetectorVersionStatusResponse (..),
    newUpdateDetectorVersionStatusResponse,

    -- * Response Lenses
    updateDetectorVersionStatusResponse_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:/ 'newUpdateDetectorVersionStatus' smart constructor.
data UpdateDetectorVersionStatus = UpdateDetectorVersionStatus'
  { -- | The detector ID.
    UpdateDetectorVersionStatus -> Text
detectorId :: Prelude.Text,
    -- | The detector version ID.
    UpdateDetectorVersionStatus -> Text
detectorVersionId :: Prelude.Text,
    -- | The new status.
    UpdateDetectorVersionStatus -> DetectorVersionStatus
status :: DetectorVersionStatus
  }
  deriving (UpdateDetectorVersionStatus -> UpdateDetectorVersionStatus -> Bool
(UpdateDetectorVersionStatus
 -> UpdateDetectorVersionStatus -> Bool)
-> (UpdateDetectorVersionStatus
    -> UpdateDetectorVersionStatus -> Bool)
-> Eq UpdateDetectorVersionStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDetectorVersionStatus -> UpdateDetectorVersionStatus -> Bool
$c/= :: UpdateDetectorVersionStatus -> UpdateDetectorVersionStatus -> Bool
== :: UpdateDetectorVersionStatus -> UpdateDetectorVersionStatus -> Bool
$c== :: UpdateDetectorVersionStatus -> UpdateDetectorVersionStatus -> Bool
Prelude.Eq, ReadPrec [UpdateDetectorVersionStatus]
ReadPrec UpdateDetectorVersionStatus
Int -> ReadS UpdateDetectorVersionStatus
ReadS [UpdateDetectorVersionStatus]
(Int -> ReadS UpdateDetectorVersionStatus)
-> ReadS [UpdateDetectorVersionStatus]
-> ReadPrec UpdateDetectorVersionStatus
-> ReadPrec [UpdateDetectorVersionStatus]
-> Read UpdateDetectorVersionStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDetectorVersionStatus]
$creadListPrec :: ReadPrec [UpdateDetectorVersionStatus]
readPrec :: ReadPrec UpdateDetectorVersionStatus
$creadPrec :: ReadPrec UpdateDetectorVersionStatus
readList :: ReadS [UpdateDetectorVersionStatus]
$creadList :: ReadS [UpdateDetectorVersionStatus]
readsPrec :: Int -> ReadS UpdateDetectorVersionStatus
$creadsPrec :: Int -> ReadS UpdateDetectorVersionStatus
Prelude.Read, Int -> UpdateDetectorVersionStatus -> ShowS
[UpdateDetectorVersionStatus] -> ShowS
UpdateDetectorVersionStatus -> String
(Int -> UpdateDetectorVersionStatus -> ShowS)
-> (UpdateDetectorVersionStatus -> String)
-> ([UpdateDetectorVersionStatus] -> ShowS)
-> Show UpdateDetectorVersionStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDetectorVersionStatus] -> ShowS
$cshowList :: [UpdateDetectorVersionStatus] -> ShowS
show :: UpdateDetectorVersionStatus -> String
$cshow :: UpdateDetectorVersionStatus -> String
showsPrec :: Int -> UpdateDetectorVersionStatus -> ShowS
$cshowsPrec :: Int -> UpdateDetectorVersionStatus -> ShowS
Prelude.Show, (forall x.
 UpdateDetectorVersionStatus -> Rep UpdateDetectorVersionStatus x)
-> (forall x.
    Rep UpdateDetectorVersionStatus x -> UpdateDetectorVersionStatus)
-> Generic UpdateDetectorVersionStatus
forall x.
Rep UpdateDetectorVersionStatus x -> UpdateDetectorVersionStatus
forall x.
UpdateDetectorVersionStatus -> Rep UpdateDetectorVersionStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateDetectorVersionStatus x -> UpdateDetectorVersionStatus
$cfrom :: forall x.
UpdateDetectorVersionStatus -> Rep UpdateDetectorVersionStatus x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDetectorVersionStatus' 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:
--
-- 'detectorId', 'updateDetectorVersionStatus_detectorId' - The detector ID.
--
-- 'detectorVersionId', 'updateDetectorVersionStatus_detectorVersionId' - The detector version ID.
--
-- 'status', 'updateDetectorVersionStatus_status' - The new status.
newUpdateDetectorVersionStatus ::
  -- | 'detectorId'
  Prelude.Text ->
  -- | 'detectorVersionId'
  Prelude.Text ->
  -- | 'status'
  DetectorVersionStatus ->
  UpdateDetectorVersionStatus
newUpdateDetectorVersionStatus :: Text
-> Text -> DetectorVersionStatus -> UpdateDetectorVersionStatus
newUpdateDetectorVersionStatus
  Text
pDetectorId_
  Text
pDetectorVersionId_
  DetectorVersionStatus
pStatus_ =
    UpdateDetectorVersionStatus' :: Text
-> Text -> DetectorVersionStatus -> UpdateDetectorVersionStatus
UpdateDetectorVersionStatus'
      { $sel:detectorId:UpdateDetectorVersionStatus' :: Text
detectorId =
          Text
pDetectorId_,
        $sel:detectorVersionId:UpdateDetectorVersionStatus' :: Text
detectorVersionId = Text
pDetectorVersionId_,
        $sel:status:UpdateDetectorVersionStatus' :: DetectorVersionStatus
status = DetectorVersionStatus
pStatus_
      }

-- | The detector ID.
updateDetectorVersionStatus_detectorId :: Lens.Lens' UpdateDetectorVersionStatus Prelude.Text
updateDetectorVersionStatus_detectorId :: (Text -> f Text)
-> UpdateDetectorVersionStatus -> f UpdateDetectorVersionStatus
updateDetectorVersionStatus_detectorId = (UpdateDetectorVersionStatus -> Text)
-> (UpdateDetectorVersionStatus
    -> Text -> UpdateDetectorVersionStatus)
-> Lens
     UpdateDetectorVersionStatus UpdateDetectorVersionStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDetectorVersionStatus' {Text
detectorId :: Text
$sel:detectorId:UpdateDetectorVersionStatus' :: UpdateDetectorVersionStatus -> Text
detectorId} -> Text
detectorId) (\s :: UpdateDetectorVersionStatus
s@UpdateDetectorVersionStatus' {} Text
a -> UpdateDetectorVersionStatus
s {$sel:detectorId:UpdateDetectorVersionStatus' :: Text
detectorId = Text
a} :: UpdateDetectorVersionStatus)

-- | The detector version ID.
updateDetectorVersionStatus_detectorVersionId :: Lens.Lens' UpdateDetectorVersionStatus Prelude.Text
updateDetectorVersionStatus_detectorVersionId :: (Text -> f Text)
-> UpdateDetectorVersionStatus -> f UpdateDetectorVersionStatus
updateDetectorVersionStatus_detectorVersionId = (UpdateDetectorVersionStatus -> Text)
-> (UpdateDetectorVersionStatus
    -> Text -> UpdateDetectorVersionStatus)
-> Lens
     UpdateDetectorVersionStatus UpdateDetectorVersionStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDetectorVersionStatus' {Text
detectorVersionId :: Text
$sel:detectorVersionId:UpdateDetectorVersionStatus' :: UpdateDetectorVersionStatus -> Text
detectorVersionId} -> Text
detectorVersionId) (\s :: UpdateDetectorVersionStatus
s@UpdateDetectorVersionStatus' {} Text
a -> UpdateDetectorVersionStatus
s {$sel:detectorVersionId:UpdateDetectorVersionStatus' :: Text
detectorVersionId = Text
a} :: UpdateDetectorVersionStatus)

-- | The new status.
updateDetectorVersionStatus_status :: Lens.Lens' UpdateDetectorVersionStatus DetectorVersionStatus
updateDetectorVersionStatus_status :: (DetectorVersionStatus -> f DetectorVersionStatus)
-> UpdateDetectorVersionStatus -> f UpdateDetectorVersionStatus
updateDetectorVersionStatus_status = (UpdateDetectorVersionStatus -> DetectorVersionStatus)
-> (UpdateDetectorVersionStatus
    -> DetectorVersionStatus -> UpdateDetectorVersionStatus)
-> Lens
     UpdateDetectorVersionStatus
     UpdateDetectorVersionStatus
     DetectorVersionStatus
     DetectorVersionStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDetectorVersionStatus' {DetectorVersionStatus
status :: DetectorVersionStatus
$sel:status:UpdateDetectorVersionStatus' :: UpdateDetectorVersionStatus -> DetectorVersionStatus
status} -> DetectorVersionStatus
status) (\s :: UpdateDetectorVersionStatus
s@UpdateDetectorVersionStatus' {} DetectorVersionStatus
a -> UpdateDetectorVersionStatus
s {$sel:status:UpdateDetectorVersionStatus' :: DetectorVersionStatus
status = DetectorVersionStatus
a} :: UpdateDetectorVersionStatus)

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

instance Prelude.NFData UpdateDetectorVersionStatus

instance Core.ToHeaders UpdateDetectorVersionStatus where
  toHeaders :: UpdateDetectorVersionStatus -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateDetectorVersionStatus -> 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.UpdateDetectorVersionStatus" ::
                          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 UpdateDetectorVersionStatus where
  toJSON :: UpdateDetectorVersionStatus -> Value
toJSON UpdateDetectorVersionStatus' {Text
DetectorVersionStatus
status :: DetectorVersionStatus
detectorVersionId :: Text
detectorId :: Text
$sel:status:UpdateDetectorVersionStatus' :: UpdateDetectorVersionStatus -> DetectorVersionStatus
$sel:detectorVersionId:UpdateDetectorVersionStatus' :: UpdateDetectorVersionStatus -> Text
$sel:detectorId:UpdateDetectorVersionStatus' :: UpdateDetectorVersionStatus -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"detectorId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
detectorId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"detectorVersionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
detectorVersionId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"status" Text -> DetectorVersionStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DetectorVersionStatus
status)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    UpdateDetectorVersionStatusResponse