{-# 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.Rekognition.StopProjectVersion
-- 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)
--
-- Stops a running model. The operation might take a while to complete. To
-- check the current status, call DescribeProjectVersions.
module Amazonka.Rekognition.StopProjectVersion
  ( -- * Creating a Request
    StopProjectVersion (..),
    newStopProjectVersion,

    -- * Request Lenses
    stopProjectVersion_projectVersionArn,

    -- * Destructuring the Response
    StopProjectVersionResponse (..),
    newStopProjectVersionResponse,

    -- * Response Lenses
    stopProjectVersionResponse_status,
    stopProjectVersionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newStopProjectVersion' smart constructor.
data StopProjectVersion = StopProjectVersion'
  { -- | The Amazon Resource Name (ARN) of the model version that you want to
    -- delete.
    --
    -- This operation requires permissions to perform the
    -- @rekognition:StopProjectVersion@ action.
    StopProjectVersion -> Text
projectVersionArn :: Prelude.Text
  }
  deriving (StopProjectVersion -> StopProjectVersion -> Bool
(StopProjectVersion -> StopProjectVersion -> Bool)
-> (StopProjectVersion -> StopProjectVersion -> Bool)
-> Eq StopProjectVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopProjectVersion -> StopProjectVersion -> Bool
$c/= :: StopProjectVersion -> StopProjectVersion -> Bool
== :: StopProjectVersion -> StopProjectVersion -> Bool
$c== :: StopProjectVersion -> StopProjectVersion -> Bool
Prelude.Eq, ReadPrec [StopProjectVersion]
ReadPrec StopProjectVersion
Int -> ReadS StopProjectVersion
ReadS [StopProjectVersion]
(Int -> ReadS StopProjectVersion)
-> ReadS [StopProjectVersion]
-> ReadPrec StopProjectVersion
-> ReadPrec [StopProjectVersion]
-> Read StopProjectVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopProjectVersion]
$creadListPrec :: ReadPrec [StopProjectVersion]
readPrec :: ReadPrec StopProjectVersion
$creadPrec :: ReadPrec StopProjectVersion
readList :: ReadS [StopProjectVersion]
$creadList :: ReadS [StopProjectVersion]
readsPrec :: Int -> ReadS StopProjectVersion
$creadsPrec :: Int -> ReadS StopProjectVersion
Prelude.Read, Int -> StopProjectVersion -> ShowS
[StopProjectVersion] -> ShowS
StopProjectVersion -> String
(Int -> StopProjectVersion -> ShowS)
-> (StopProjectVersion -> String)
-> ([StopProjectVersion] -> ShowS)
-> Show StopProjectVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopProjectVersion] -> ShowS
$cshowList :: [StopProjectVersion] -> ShowS
show :: StopProjectVersion -> String
$cshow :: StopProjectVersion -> String
showsPrec :: Int -> StopProjectVersion -> ShowS
$cshowsPrec :: Int -> StopProjectVersion -> ShowS
Prelude.Show, (forall x. StopProjectVersion -> Rep StopProjectVersion x)
-> (forall x. Rep StopProjectVersion x -> StopProjectVersion)
-> Generic StopProjectVersion
forall x. Rep StopProjectVersion x -> StopProjectVersion
forall x. StopProjectVersion -> Rep StopProjectVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopProjectVersion x -> StopProjectVersion
$cfrom :: forall x. StopProjectVersion -> Rep StopProjectVersion x
Prelude.Generic)

-- |
-- Create a value of 'StopProjectVersion' 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:
--
-- 'projectVersionArn', 'stopProjectVersion_projectVersionArn' - The Amazon Resource Name (ARN) of the model version that you want to
-- delete.
--
-- This operation requires permissions to perform the
-- @rekognition:StopProjectVersion@ action.
newStopProjectVersion ::
  -- | 'projectVersionArn'
  Prelude.Text ->
  StopProjectVersion
newStopProjectVersion :: Text -> StopProjectVersion
newStopProjectVersion Text
pProjectVersionArn_ =
  StopProjectVersion' :: Text -> StopProjectVersion
StopProjectVersion'
    { $sel:projectVersionArn:StopProjectVersion' :: Text
projectVersionArn =
        Text
pProjectVersionArn_
    }

-- | The Amazon Resource Name (ARN) of the model version that you want to
-- delete.
--
-- This operation requires permissions to perform the
-- @rekognition:StopProjectVersion@ action.
stopProjectVersion_projectVersionArn :: Lens.Lens' StopProjectVersion Prelude.Text
stopProjectVersion_projectVersionArn :: (Text -> f Text) -> StopProjectVersion -> f StopProjectVersion
stopProjectVersion_projectVersionArn = (StopProjectVersion -> Text)
-> (StopProjectVersion -> Text -> StopProjectVersion)
-> Lens StopProjectVersion StopProjectVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopProjectVersion' {Text
projectVersionArn :: Text
$sel:projectVersionArn:StopProjectVersion' :: StopProjectVersion -> Text
projectVersionArn} -> Text
projectVersionArn) (\s :: StopProjectVersion
s@StopProjectVersion' {} Text
a -> StopProjectVersion
s {$sel:projectVersionArn:StopProjectVersion' :: Text
projectVersionArn = Text
a} :: StopProjectVersion)

instance Core.AWSRequest StopProjectVersion where
  type
    AWSResponse StopProjectVersion =
      StopProjectVersionResponse
  request :: StopProjectVersion -> Request StopProjectVersion
request = Service -> StopProjectVersion -> Request StopProjectVersion
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopProjectVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopProjectVersion)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StopProjectVersion))
-> Logger
-> Service
-> Proxy StopProjectVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopProjectVersion)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ProjectVersionStatus -> Int -> StopProjectVersionResponse
StopProjectVersionResponse'
            (Maybe ProjectVersionStatus -> Int -> StopProjectVersionResponse)
-> Either String (Maybe ProjectVersionStatus)
-> Either String (Int -> StopProjectVersionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ProjectVersionStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Status")
            Either String (Int -> StopProjectVersionResponse)
-> Either String Int -> Either String StopProjectVersionResponse
forall (f :: * -> *) a b. Applicative f => 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 StopProjectVersion

instance Prelude.NFData StopProjectVersion

instance Core.ToHeaders StopProjectVersion where
  toHeaders :: StopProjectVersion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StopProjectVersion -> 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
"RekognitionService.StopProjectVersion" ::
                          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 StopProjectVersion where
  toJSON :: StopProjectVersion -> Value
toJSON StopProjectVersion' {Text
projectVersionArn :: Text
$sel:projectVersionArn:StopProjectVersion' :: StopProjectVersion -> 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
"ProjectVersionArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
projectVersionArn)
          ]
      )

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

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

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

-- |
-- Create a value of 'StopProjectVersionResponse' 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:
--
-- 'status', 'stopProjectVersionResponse_status' - The current status of the stop operation.
--
-- 'httpStatus', 'stopProjectVersionResponse_httpStatus' - The response's http status code.
newStopProjectVersionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopProjectVersionResponse
newStopProjectVersionResponse :: Int -> StopProjectVersionResponse
newStopProjectVersionResponse Int
pHttpStatus_ =
  StopProjectVersionResponse' :: Maybe ProjectVersionStatus -> Int -> StopProjectVersionResponse
StopProjectVersionResponse'
    { $sel:status:StopProjectVersionResponse' :: Maybe ProjectVersionStatus
status =
        Maybe ProjectVersionStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopProjectVersionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The current status of the stop operation.
stopProjectVersionResponse_status :: Lens.Lens' StopProjectVersionResponse (Prelude.Maybe ProjectVersionStatus)
stopProjectVersionResponse_status :: (Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> StopProjectVersionResponse -> f StopProjectVersionResponse
stopProjectVersionResponse_status = (StopProjectVersionResponse -> Maybe ProjectVersionStatus)
-> (StopProjectVersionResponse
    -> Maybe ProjectVersionStatus -> StopProjectVersionResponse)
-> Lens
     StopProjectVersionResponse
     StopProjectVersionResponse
     (Maybe ProjectVersionStatus)
     (Maybe ProjectVersionStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopProjectVersionResponse' {Maybe ProjectVersionStatus
status :: Maybe ProjectVersionStatus
$sel:status:StopProjectVersionResponse' :: StopProjectVersionResponse -> Maybe ProjectVersionStatus
status} -> Maybe ProjectVersionStatus
status) (\s :: StopProjectVersionResponse
s@StopProjectVersionResponse' {} Maybe ProjectVersionStatus
a -> StopProjectVersionResponse
s {$sel:status:StopProjectVersionResponse' :: Maybe ProjectVersionStatus
status = Maybe ProjectVersionStatus
a} :: StopProjectVersionResponse)

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

instance Prelude.NFData StopProjectVersionResponse