{-# 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.ResumeService
-- 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)
--
-- Resume an active App Runner service. App Runner provisions compute
-- capacity for the service.
--
-- 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.ResumeService
  ( -- * Creating a Request
    ResumeService (..),
    newResumeService,

    -- * Request Lenses
    resumeService_serviceArn,

    -- * Destructuring the Response
    ResumeServiceResponse (..),
    newResumeServiceResponse,

    -- * Response Lenses
    resumeServiceResponse_operationId,
    resumeServiceResponse_httpStatus,
    resumeServiceResponse_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:/ 'newResumeService' smart constructor.
data ResumeService = ResumeService'
  { -- | The Amazon Resource Name (ARN) of the App Runner service that you want
    -- to resume.
    ResumeService -> Text
serviceArn :: Prelude.Text
  }
  deriving (ResumeService -> ResumeService -> Bool
(ResumeService -> ResumeService -> Bool)
-> (ResumeService -> ResumeService -> Bool) -> Eq ResumeService
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResumeService -> ResumeService -> Bool
$c/= :: ResumeService -> ResumeService -> Bool
== :: ResumeService -> ResumeService -> Bool
$c== :: ResumeService -> ResumeService -> Bool
Prelude.Eq, ReadPrec [ResumeService]
ReadPrec ResumeService
Int -> ReadS ResumeService
ReadS [ResumeService]
(Int -> ReadS ResumeService)
-> ReadS [ResumeService]
-> ReadPrec ResumeService
-> ReadPrec [ResumeService]
-> Read ResumeService
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResumeService]
$creadListPrec :: ReadPrec [ResumeService]
readPrec :: ReadPrec ResumeService
$creadPrec :: ReadPrec ResumeService
readList :: ReadS [ResumeService]
$creadList :: ReadS [ResumeService]
readsPrec :: Int -> ReadS ResumeService
$creadsPrec :: Int -> ReadS ResumeService
Prelude.Read, Int -> ResumeService -> ShowS
[ResumeService] -> ShowS
ResumeService -> String
(Int -> ResumeService -> ShowS)
-> (ResumeService -> String)
-> ([ResumeService] -> ShowS)
-> Show ResumeService
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResumeService] -> ShowS
$cshowList :: [ResumeService] -> ShowS
show :: ResumeService -> String
$cshow :: ResumeService -> String
showsPrec :: Int -> ResumeService -> ShowS
$cshowsPrec :: Int -> ResumeService -> ShowS
Prelude.Show, (forall x. ResumeService -> Rep ResumeService x)
-> (forall x. Rep ResumeService x -> ResumeService)
-> Generic ResumeService
forall x. Rep ResumeService x -> ResumeService
forall x. ResumeService -> Rep ResumeService x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResumeService x -> ResumeService
$cfrom :: forall x. ResumeService -> Rep ResumeService x
Prelude.Generic)

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

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

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

instance Prelude.NFData ResumeService

instance Core.ToHeaders ResumeService where
  toHeaders :: ResumeService -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ResumeService -> 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.ResumeService" :: 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 ResumeService where
  toJSON :: ResumeService -> Value
toJSON ResumeService' {Text
serviceArn :: Text
$sel:serviceArn:ResumeService' :: ResumeService -> 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 ResumeService where
  toPath :: ResumeService -> ByteString
toPath = ByteString -> ResumeService -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newResumeServiceResponse' smart constructor.
data ResumeServiceResponse = ResumeServiceResponse'
  { -- | 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.
    ResumeServiceResponse -> Maybe Text
operationId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ResumeServiceResponse -> Int
httpStatus :: Prelude.Int,
    -- | A description of the App Runner service that this request just resumed.
    ResumeServiceResponse -> Service
service :: Service
  }
  deriving (ResumeServiceResponse -> ResumeServiceResponse -> Bool
(ResumeServiceResponse -> ResumeServiceResponse -> Bool)
-> (ResumeServiceResponse -> ResumeServiceResponse -> Bool)
-> Eq ResumeServiceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResumeServiceResponse -> ResumeServiceResponse -> Bool
$c/= :: ResumeServiceResponse -> ResumeServiceResponse -> Bool
== :: ResumeServiceResponse -> ResumeServiceResponse -> Bool
$c== :: ResumeServiceResponse -> ResumeServiceResponse -> Bool
Prelude.Eq, Int -> ResumeServiceResponse -> ShowS
[ResumeServiceResponse] -> ShowS
ResumeServiceResponse -> String
(Int -> ResumeServiceResponse -> ShowS)
-> (ResumeServiceResponse -> String)
-> ([ResumeServiceResponse] -> ShowS)
-> Show ResumeServiceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResumeServiceResponse] -> ShowS
$cshowList :: [ResumeServiceResponse] -> ShowS
show :: ResumeServiceResponse -> String
$cshow :: ResumeServiceResponse -> String
showsPrec :: Int -> ResumeServiceResponse -> ShowS
$cshowsPrec :: Int -> ResumeServiceResponse -> ShowS
Prelude.Show, (forall x. ResumeServiceResponse -> Rep ResumeServiceResponse x)
-> (forall x. Rep ResumeServiceResponse x -> ResumeServiceResponse)
-> Generic ResumeServiceResponse
forall x. Rep ResumeServiceResponse x -> ResumeServiceResponse
forall x. ResumeServiceResponse -> Rep ResumeServiceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResumeServiceResponse x -> ResumeServiceResponse
$cfrom :: forall x. ResumeServiceResponse -> Rep ResumeServiceResponse x
Prelude.Generic)

-- |
-- Create a value of 'ResumeServiceResponse' 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', 'resumeServiceResponse_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', 'resumeServiceResponse_httpStatus' - The response's http status code.
--
-- 'service', 'resumeServiceResponse_service' - A description of the App Runner service that this request just resumed.
newResumeServiceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'service'
  Service ->
  ResumeServiceResponse
newResumeServiceResponse :: Int -> Service -> ResumeServiceResponse
newResumeServiceResponse Int
pHttpStatus_ Service
pService_ =
  ResumeServiceResponse' :: Maybe Text -> Int -> Service -> ResumeServiceResponse
ResumeServiceResponse'
    { $sel:operationId:ResumeServiceResponse' :: Maybe Text
operationId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ResumeServiceResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:service:ResumeServiceResponse' :: 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.
resumeServiceResponse_operationId :: Lens.Lens' ResumeServiceResponse (Prelude.Maybe Prelude.Text)
resumeServiceResponse_operationId :: (Maybe Text -> f (Maybe Text))
-> ResumeServiceResponse -> f ResumeServiceResponse
resumeServiceResponse_operationId = (ResumeServiceResponse -> Maybe Text)
-> (ResumeServiceResponse -> Maybe Text -> ResumeServiceResponse)
-> Lens
     ResumeServiceResponse
     ResumeServiceResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResumeServiceResponse' {Maybe Text
operationId :: Maybe Text
$sel:operationId:ResumeServiceResponse' :: ResumeServiceResponse -> Maybe Text
operationId} -> Maybe Text
operationId) (\s :: ResumeServiceResponse
s@ResumeServiceResponse' {} Maybe Text
a -> ResumeServiceResponse
s {$sel:operationId:ResumeServiceResponse' :: Maybe Text
operationId = Maybe Text
a} :: ResumeServiceResponse)

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

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

instance Prelude.NFData ResumeServiceResponse