{-# 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.SSM.GetAutomationExecution
-- 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)
--
-- Get detailed information about a particular Automation execution.
module Amazonka.SSM.GetAutomationExecution
  ( -- * Creating a Request
    GetAutomationExecution (..),
    newGetAutomationExecution,

    -- * Request Lenses
    getAutomationExecution_automationExecutionId,

    -- * Destructuring the Response
    GetAutomationExecutionResponse (..),
    newGetAutomationExecutionResponse,

    -- * Response Lenses
    getAutomationExecutionResponse_automationExecution,
    getAutomationExecutionResponse_httpStatus,
  )
where

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
import Amazonka.SSM.Types

-- | /See:/ 'newGetAutomationExecution' smart constructor.
data GetAutomationExecution = GetAutomationExecution'
  { -- | The unique identifier for an existing automation execution to examine.
    -- The execution ID is returned by StartAutomationExecution when the
    -- execution of an Automation runbook is initiated.
    GetAutomationExecution -> Text
automationExecutionId :: Prelude.Text
  }
  deriving (GetAutomationExecution -> GetAutomationExecution -> Bool
(GetAutomationExecution -> GetAutomationExecution -> Bool)
-> (GetAutomationExecution -> GetAutomationExecution -> Bool)
-> Eq GetAutomationExecution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAutomationExecution -> GetAutomationExecution -> Bool
$c/= :: GetAutomationExecution -> GetAutomationExecution -> Bool
== :: GetAutomationExecution -> GetAutomationExecution -> Bool
$c== :: GetAutomationExecution -> GetAutomationExecution -> Bool
Prelude.Eq, ReadPrec [GetAutomationExecution]
ReadPrec GetAutomationExecution
Int -> ReadS GetAutomationExecution
ReadS [GetAutomationExecution]
(Int -> ReadS GetAutomationExecution)
-> ReadS [GetAutomationExecution]
-> ReadPrec GetAutomationExecution
-> ReadPrec [GetAutomationExecution]
-> Read GetAutomationExecution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAutomationExecution]
$creadListPrec :: ReadPrec [GetAutomationExecution]
readPrec :: ReadPrec GetAutomationExecution
$creadPrec :: ReadPrec GetAutomationExecution
readList :: ReadS [GetAutomationExecution]
$creadList :: ReadS [GetAutomationExecution]
readsPrec :: Int -> ReadS GetAutomationExecution
$creadsPrec :: Int -> ReadS GetAutomationExecution
Prelude.Read, Int -> GetAutomationExecution -> ShowS
[GetAutomationExecution] -> ShowS
GetAutomationExecution -> String
(Int -> GetAutomationExecution -> ShowS)
-> (GetAutomationExecution -> String)
-> ([GetAutomationExecution] -> ShowS)
-> Show GetAutomationExecution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAutomationExecution] -> ShowS
$cshowList :: [GetAutomationExecution] -> ShowS
show :: GetAutomationExecution -> String
$cshow :: GetAutomationExecution -> String
showsPrec :: Int -> GetAutomationExecution -> ShowS
$cshowsPrec :: Int -> GetAutomationExecution -> ShowS
Prelude.Show, (forall x. GetAutomationExecution -> Rep GetAutomationExecution x)
-> (forall x.
    Rep GetAutomationExecution x -> GetAutomationExecution)
-> Generic GetAutomationExecution
forall x. Rep GetAutomationExecution x -> GetAutomationExecution
forall x. GetAutomationExecution -> Rep GetAutomationExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAutomationExecution x -> GetAutomationExecution
$cfrom :: forall x. GetAutomationExecution -> Rep GetAutomationExecution x
Prelude.Generic)

-- |
-- Create a value of 'GetAutomationExecution' 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:
--
-- 'automationExecutionId', 'getAutomationExecution_automationExecutionId' - The unique identifier for an existing automation execution to examine.
-- The execution ID is returned by StartAutomationExecution when the
-- execution of an Automation runbook is initiated.
newGetAutomationExecution ::
  -- | 'automationExecutionId'
  Prelude.Text ->
  GetAutomationExecution
newGetAutomationExecution :: Text -> GetAutomationExecution
newGetAutomationExecution Text
pAutomationExecutionId_ =
  GetAutomationExecution' :: Text -> GetAutomationExecution
GetAutomationExecution'
    { $sel:automationExecutionId:GetAutomationExecution' :: Text
automationExecutionId =
        Text
pAutomationExecutionId_
    }

-- | The unique identifier for an existing automation execution to examine.
-- The execution ID is returned by StartAutomationExecution when the
-- execution of an Automation runbook is initiated.
getAutomationExecution_automationExecutionId :: Lens.Lens' GetAutomationExecution Prelude.Text
getAutomationExecution_automationExecutionId :: (Text -> f Text)
-> GetAutomationExecution -> f GetAutomationExecution
getAutomationExecution_automationExecutionId = (GetAutomationExecution -> Text)
-> (GetAutomationExecution -> Text -> GetAutomationExecution)
-> Lens GetAutomationExecution GetAutomationExecution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAutomationExecution' {Text
automationExecutionId :: Text
$sel:automationExecutionId:GetAutomationExecution' :: GetAutomationExecution -> Text
automationExecutionId} -> Text
automationExecutionId) (\s :: GetAutomationExecution
s@GetAutomationExecution' {} Text
a -> GetAutomationExecution
s {$sel:automationExecutionId:GetAutomationExecution' :: Text
automationExecutionId = Text
a} :: GetAutomationExecution)

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

instance Prelude.NFData GetAutomationExecution

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

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

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

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

-- |
-- Create a value of 'GetAutomationExecutionResponse' 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:
--
-- 'automationExecution', 'getAutomationExecutionResponse_automationExecution' - Detailed information about the current state of an automation execution.
--
-- 'httpStatus', 'getAutomationExecutionResponse_httpStatus' - The response's http status code.
newGetAutomationExecutionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAutomationExecutionResponse
newGetAutomationExecutionResponse :: Int -> GetAutomationExecutionResponse
newGetAutomationExecutionResponse Int
pHttpStatus_ =
  GetAutomationExecutionResponse' :: Maybe AutomationExecution -> Int -> GetAutomationExecutionResponse
GetAutomationExecutionResponse'
    { $sel:automationExecution:GetAutomationExecutionResponse' :: Maybe AutomationExecution
automationExecution =
        Maybe AutomationExecution
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAutomationExecutionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Detailed information about the current state of an automation execution.
getAutomationExecutionResponse_automationExecution :: Lens.Lens' GetAutomationExecutionResponse (Prelude.Maybe AutomationExecution)
getAutomationExecutionResponse_automationExecution :: (Maybe AutomationExecution -> f (Maybe AutomationExecution))
-> GetAutomationExecutionResponse
-> f GetAutomationExecutionResponse
getAutomationExecutionResponse_automationExecution = (GetAutomationExecutionResponse -> Maybe AutomationExecution)
-> (GetAutomationExecutionResponse
    -> Maybe AutomationExecution -> GetAutomationExecutionResponse)
-> Lens
     GetAutomationExecutionResponse
     GetAutomationExecutionResponse
     (Maybe AutomationExecution)
     (Maybe AutomationExecution)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAutomationExecutionResponse' {Maybe AutomationExecution
automationExecution :: Maybe AutomationExecution
$sel:automationExecution:GetAutomationExecutionResponse' :: GetAutomationExecutionResponse -> Maybe AutomationExecution
automationExecution} -> Maybe AutomationExecution
automationExecution) (\s :: GetAutomationExecutionResponse
s@GetAutomationExecutionResponse' {} Maybe AutomationExecution
a -> GetAutomationExecutionResponse
s {$sel:automationExecution:GetAutomationExecutionResponse' :: Maybe AutomationExecution
automationExecution = Maybe AutomationExecution
a} :: GetAutomationExecutionResponse)

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

instance
  Prelude.NFData
    GetAutomationExecutionResponse