{-# 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.Greengrass.StopBulkDeployment
-- 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 the execution of a bulk deployment. This action returns a status
-- of \'\'Stopping\'\' until the deployment is stopped. You cannot start a
-- new bulk deployment while a previous deployment is in the
-- \'\'Stopping\'\' state. This action doesn\'t rollback completed
-- deployments or cancel pending deployments.
module Amazonka.Greengrass.StopBulkDeployment
  ( -- * Creating a Request
    StopBulkDeployment (..),
    newStopBulkDeployment,

    -- * Request Lenses
    stopBulkDeployment_bulkDeploymentId,

    -- * Destructuring the Response
    StopBulkDeploymentResponse (..),
    newStopBulkDeploymentResponse,

    -- * Response Lenses
    stopBulkDeploymentResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.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:/ 'newStopBulkDeployment' smart constructor.
data StopBulkDeployment = StopBulkDeployment'
  { -- | The ID of the bulk deployment.
    StopBulkDeployment -> Text
bulkDeploymentId :: Prelude.Text
  }
  deriving (StopBulkDeployment -> StopBulkDeployment -> Bool
(StopBulkDeployment -> StopBulkDeployment -> Bool)
-> (StopBulkDeployment -> StopBulkDeployment -> Bool)
-> Eq StopBulkDeployment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopBulkDeployment -> StopBulkDeployment -> Bool
$c/= :: StopBulkDeployment -> StopBulkDeployment -> Bool
== :: StopBulkDeployment -> StopBulkDeployment -> Bool
$c== :: StopBulkDeployment -> StopBulkDeployment -> Bool
Prelude.Eq, ReadPrec [StopBulkDeployment]
ReadPrec StopBulkDeployment
Int -> ReadS StopBulkDeployment
ReadS [StopBulkDeployment]
(Int -> ReadS StopBulkDeployment)
-> ReadS [StopBulkDeployment]
-> ReadPrec StopBulkDeployment
-> ReadPrec [StopBulkDeployment]
-> Read StopBulkDeployment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopBulkDeployment]
$creadListPrec :: ReadPrec [StopBulkDeployment]
readPrec :: ReadPrec StopBulkDeployment
$creadPrec :: ReadPrec StopBulkDeployment
readList :: ReadS [StopBulkDeployment]
$creadList :: ReadS [StopBulkDeployment]
readsPrec :: Int -> ReadS StopBulkDeployment
$creadsPrec :: Int -> ReadS StopBulkDeployment
Prelude.Read, Int -> StopBulkDeployment -> ShowS
[StopBulkDeployment] -> ShowS
StopBulkDeployment -> String
(Int -> StopBulkDeployment -> ShowS)
-> (StopBulkDeployment -> String)
-> ([StopBulkDeployment] -> ShowS)
-> Show StopBulkDeployment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopBulkDeployment] -> ShowS
$cshowList :: [StopBulkDeployment] -> ShowS
show :: StopBulkDeployment -> String
$cshow :: StopBulkDeployment -> String
showsPrec :: Int -> StopBulkDeployment -> ShowS
$cshowsPrec :: Int -> StopBulkDeployment -> ShowS
Prelude.Show, (forall x. StopBulkDeployment -> Rep StopBulkDeployment x)
-> (forall x. Rep StopBulkDeployment x -> StopBulkDeployment)
-> Generic StopBulkDeployment
forall x. Rep StopBulkDeployment x -> StopBulkDeployment
forall x. StopBulkDeployment -> Rep StopBulkDeployment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopBulkDeployment x -> StopBulkDeployment
$cfrom :: forall x. StopBulkDeployment -> Rep StopBulkDeployment x
Prelude.Generic)

-- |
-- Create a value of 'StopBulkDeployment' 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:
--
-- 'bulkDeploymentId', 'stopBulkDeployment_bulkDeploymentId' - The ID of the bulk deployment.
newStopBulkDeployment ::
  -- | 'bulkDeploymentId'
  Prelude.Text ->
  StopBulkDeployment
newStopBulkDeployment :: Text -> StopBulkDeployment
newStopBulkDeployment Text
pBulkDeploymentId_ =
  StopBulkDeployment' :: Text -> StopBulkDeployment
StopBulkDeployment'
    { $sel:bulkDeploymentId:StopBulkDeployment' :: Text
bulkDeploymentId =
        Text
pBulkDeploymentId_
    }

-- | The ID of the bulk deployment.
stopBulkDeployment_bulkDeploymentId :: Lens.Lens' StopBulkDeployment Prelude.Text
stopBulkDeployment_bulkDeploymentId :: (Text -> f Text) -> StopBulkDeployment -> f StopBulkDeployment
stopBulkDeployment_bulkDeploymentId = (StopBulkDeployment -> Text)
-> (StopBulkDeployment -> Text -> StopBulkDeployment)
-> Lens StopBulkDeployment StopBulkDeployment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopBulkDeployment' {Text
bulkDeploymentId :: Text
$sel:bulkDeploymentId:StopBulkDeployment' :: StopBulkDeployment -> Text
bulkDeploymentId} -> Text
bulkDeploymentId) (\s :: StopBulkDeployment
s@StopBulkDeployment' {} Text
a -> StopBulkDeployment
s {$sel:bulkDeploymentId:StopBulkDeployment' :: Text
bulkDeploymentId = Text
a} :: StopBulkDeployment)

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

instance Prelude.NFData StopBulkDeployment

instance Core.ToHeaders StopBulkDeployment where
  toHeaders :: StopBulkDeployment -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StopBulkDeployment -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 StopBulkDeployment where
  toJSON :: StopBulkDeployment -> Value
toJSON = Value -> StopBulkDeployment -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath StopBulkDeployment where
  toPath :: StopBulkDeployment -> ByteString
toPath StopBulkDeployment' {Text
bulkDeploymentId :: Text
$sel:bulkDeploymentId:StopBulkDeployment' :: StopBulkDeployment -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/greengrass/bulk/deployments/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
bulkDeploymentId,
        ByteString
"/$stop"
      ]

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

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

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

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

instance Prelude.NFData StopBulkDeploymentResponse