{-# 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.AppRunner.PauseService
-- 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)
--
-- Pause an active App Runner service. App Runner reduces compute capacity
-- for the service to zero and loses state (for example, ephemeral storage
-- is removed).
--
-- This is an asynchronous operation. On a successful call, you can use the
-- returned @OperationId@ and the ListOperations call to track the
-- operation\'s progress.
module Amazonka.AppRunner.PauseService
  ( -- * Creating a Request
    PauseService (..),
    newPauseService,

    -- * Request Lenses
    pauseService_serviceArn,

    -- * Destructuring the Response
    PauseServiceResponse (..),
    newPauseServiceResponse,

    -- * Response Lenses
    pauseServiceResponse_operationId,
    pauseServiceResponse_httpStatus,
    pauseServiceResponse_service,
  )
where

import Amazonka.AppRunner.Types
import qualified Amazonka.Core as Core
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:/ 'newPauseService' smart constructor.
data PauseService = PauseService'
  { -- | The Amazon Resource Name (ARN) of the App Runner service that you want
    -- to pause.
    PauseService -> Text
serviceArn :: Prelude.Text
  }
  deriving (PauseService -> PauseService -> Bool
(PauseService -> PauseService -> Bool)
-> (PauseService -> PauseService -> Bool) -> Eq PauseService
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PauseService -> PauseService -> Bool
$c/= :: PauseService -> PauseService -> Bool
== :: PauseService -> PauseService -> Bool
$c== :: PauseService -> PauseService -> Bool
Prelude.Eq, ReadPrec [PauseService]
ReadPrec PauseService
Int -> ReadS PauseService
ReadS [PauseService]
(Int -> ReadS PauseService)
-> ReadS [PauseService]
-> ReadPrec PauseService
-> ReadPrec [PauseService]
-> Read PauseService
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PauseService]
$creadListPrec :: ReadPrec [PauseService]
readPrec :: ReadPrec PauseService
$creadPrec :: ReadPrec PauseService
readList :: ReadS [PauseService]
$creadList :: ReadS [PauseService]
readsPrec :: Int -> ReadS PauseService
$creadsPrec :: Int -> ReadS PauseService
Prelude.Read, Int -> PauseService -> ShowS
[PauseService] -> ShowS
PauseService -> String
(Int -> PauseService -> ShowS)
-> (PauseService -> String)
-> ([PauseService] -> ShowS)
-> Show PauseService
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PauseService] -> ShowS
$cshowList :: [PauseService] -> ShowS
show :: PauseService -> String
$cshow :: PauseService -> String
showsPrec :: Int -> PauseService -> ShowS
$cshowsPrec :: Int -> PauseService -> ShowS
Prelude.Show, (forall x. PauseService -> Rep PauseService x)
-> (forall x. Rep PauseService x -> PauseService)
-> Generic PauseService
forall x. Rep PauseService x -> PauseService
forall x. PauseService -> Rep PauseService x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PauseService x -> PauseService
$cfrom :: forall x. PauseService -> Rep PauseService x
Prelude.Generic)

-- |
-- Create a value of 'PauseService' 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:
--
-- 'serviceArn', 'pauseService_serviceArn' - The Amazon Resource Name (ARN) of the App Runner service that you want
-- to pause.
newPauseService ::
  -- | 'serviceArn'
  Prelude.Text ->
  PauseService
newPauseService :: Text -> PauseService
newPauseService Text
pServiceArn_ =
  PauseService' :: Text -> PauseService
PauseService' {$sel:serviceArn:PauseService' :: Text
serviceArn = Text
pServiceArn_}

-- | The Amazon Resource Name (ARN) of the App Runner service that you want
-- to pause.
pauseService_serviceArn :: Lens.Lens' PauseService Prelude.Text
pauseService_serviceArn :: (Text -> f Text) -> PauseService -> f PauseService
pauseService_serviceArn = (PauseService -> Text)
-> (PauseService -> Text -> PauseService)
-> Lens PauseService PauseService Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PauseService' {Text
serviceArn :: Text
$sel:serviceArn:PauseService' :: PauseService -> Text
serviceArn} -> Text
serviceArn) (\s :: PauseService
s@PauseService' {} Text
a -> PauseService
s {$sel:serviceArn:PauseService' :: Text
serviceArn = Text
a} :: PauseService)

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

instance Prelude.Hashable PauseService

instance Prelude.NFData PauseService

instance Core.ToHeaders PauseService where
  toHeaders :: PauseService -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PauseService -> 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
"AppRunner.PauseService" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON PauseService where
  toJSON :: PauseService -> Value
toJSON PauseService' {Text
serviceArn :: Text
$sel:serviceArn:PauseService' :: PauseService -> 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
"ServiceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serviceArn)]
      )

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

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

-- | /See:/ 'newPauseServiceResponse' smart constructor.
data PauseServiceResponse = PauseServiceResponse'
  { -- | The unique ID of the asynchronous operation that this request started.
    -- You can use it combined with the ListOperations call to track the
    -- operation\'s progress.
    PauseServiceResponse -> Maybe Text
operationId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    PauseServiceResponse -> Int
httpStatus :: Prelude.Int,
    -- | A description of the App Runner service that this request just paused.
    PauseServiceResponse -> Service
service :: Service
  }
  deriving (PauseServiceResponse -> PauseServiceResponse -> Bool
(PauseServiceResponse -> PauseServiceResponse -> Bool)
-> (PauseServiceResponse -> PauseServiceResponse -> Bool)
-> Eq PauseServiceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PauseServiceResponse -> PauseServiceResponse -> Bool
$c/= :: PauseServiceResponse -> PauseServiceResponse -> Bool
== :: PauseServiceResponse -> PauseServiceResponse -> Bool
$c== :: PauseServiceResponse -> PauseServiceResponse -> Bool
Prelude.Eq, Int -> PauseServiceResponse -> ShowS
[PauseServiceResponse] -> ShowS
PauseServiceResponse -> String
(Int -> PauseServiceResponse -> ShowS)
-> (PauseServiceResponse -> String)
-> ([PauseServiceResponse] -> ShowS)
-> Show PauseServiceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PauseServiceResponse] -> ShowS
$cshowList :: [PauseServiceResponse] -> ShowS
show :: PauseServiceResponse -> String
$cshow :: PauseServiceResponse -> String
showsPrec :: Int -> PauseServiceResponse -> ShowS
$cshowsPrec :: Int -> PauseServiceResponse -> ShowS
Prelude.Show, (forall x. PauseServiceResponse -> Rep PauseServiceResponse x)
-> (forall x. Rep PauseServiceResponse x -> PauseServiceResponse)
-> Generic PauseServiceResponse
forall x. Rep PauseServiceResponse x -> PauseServiceResponse
forall x. PauseServiceResponse -> Rep PauseServiceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PauseServiceResponse x -> PauseServiceResponse
$cfrom :: forall x. PauseServiceResponse -> Rep PauseServiceResponse x
Prelude.Generic)

-- |
-- Create a value of 'PauseServiceResponse' 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:
--
-- 'operationId', 'pauseServiceResponse_operationId' - The unique ID of the asynchronous operation that this request started.
-- You can use it combined with the ListOperations call to track the
-- operation\'s progress.
--
-- 'httpStatus', 'pauseServiceResponse_httpStatus' - The response's http status code.
--
-- 'service', 'pauseServiceResponse_service' - A description of the App Runner service that this request just paused.
newPauseServiceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'service'
  Service ->
  PauseServiceResponse
newPauseServiceResponse :: Int -> Service -> PauseServiceResponse
newPauseServiceResponse Int
pHttpStatus_ Service
pService_ =
  PauseServiceResponse' :: Maybe Text -> Int -> Service -> PauseServiceResponse
PauseServiceResponse'
    { $sel:operationId:PauseServiceResponse' :: Maybe Text
operationId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PauseServiceResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:service:PauseServiceResponse' :: Service
service = Service
pService_
    }

-- | The unique ID of the asynchronous operation that this request started.
-- You can use it combined with the ListOperations call to track the
-- operation\'s progress.
pauseServiceResponse_operationId :: Lens.Lens' PauseServiceResponse (Prelude.Maybe Prelude.Text)
pauseServiceResponse_operationId :: (Maybe Text -> f (Maybe Text))
-> PauseServiceResponse -> f PauseServiceResponse
pauseServiceResponse_operationId = (PauseServiceResponse -> Maybe Text)
-> (PauseServiceResponse -> Maybe Text -> PauseServiceResponse)
-> Lens
     PauseServiceResponse PauseServiceResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PauseServiceResponse' {Maybe Text
operationId :: Maybe Text
$sel:operationId:PauseServiceResponse' :: PauseServiceResponse -> Maybe Text
operationId} -> Maybe Text
operationId) (\s :: PauseServiceResponse
s@PauseServiceResponse' {} Maybe Text
a -> PauseServiceResponse
s {$sel:operationId:PauseServiceResponse' :: Maybe Text
operationId = Maybe Text
a} :: PauseServiceResponse)

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

-- | A description of the App Runner service that this request just paused.
pauseServiceResponse_service :: Lens.Lens' PauseServiceResponse Service
pauseServiceResponse_service :: (Service -> f Service)
-> PauseServiceResponse -> f PauseServiceResponse
pauseServiceResponse_service = (PauseServiceResponse -> Service)
-> (PauseServiceResponse -> Service -> PauseServiceResponse)
-> Lens PauseServiceResponse PauseServiceResponse Service Service
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PauseServiceResponse' {Service
service :: Service
$sel:service:PauseServiceResponse' :: PauseServiceResponse -> Service
service} -> Service
service) (\s :: PauseServiceResponse
s@PauseServiceResponse' {} Service
a -> PauseServiceResponse
s {$sel:service:PauseServiceResponse' :: Service
service = Service
a} :: PauseServiceResponse)

instance Prelude.NFData PauseServiceResponse