{-# 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.MigrationHub.DescribeApplicationState
-- 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)
--
-- Gets the migration status of an application.
module Amazonka.MigrationHub.DescribeApplicationState
  ( -- * Creating a Request
    DescribeApplicationState (..),
    newDescribeApplicationState,

    -- * Request Lenses
    describeApplicationState_applicationId,

    -- * Destructuring the Response
    DescribeApplicationStateResponse (..),
    newDescribeApplicationStateResponse,

    -- * Response Lenses
    describeApplicationStateResponse_lastUpdatedTime,
    describeApplicationStateResponse_applicationStatus,
    describeApplicationStateResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeApplicationState' smart constructor.
data DescribeApplicationState = DescribeApplicationState'
  { -- | The configurationId in Application Discovery Service that uniquely
    -- identifies the grouped application.
    DescribeApplicationState -> Text
applicationId :: Prelude.Text
  }
  deriving (DescribeApplicationState -> DescribeApplicationState -> Bool
(DescribeApplicationState -> DescribeApplicationState -> Bool)
-> (DescribeApplicationState -> DescribeApplicationState -> Bool)
-> Eq DescribeApplicationState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeApplicationState -> DescribeApplicationState -> Bool
$c/= :: DescribeApplicationState -> DescribeApplicationState -> Bool
== :: DescribeApplicationState -> DescribeApplicationState -> Bool
$c== :: DescribeApplicationState -> DescribeApplicationState -> Bool
Prelude.Eq, ReadPrec [DescribeApplicationState]
ReadPrec DescribeApplicationState
Int -> ReadS DescribeApplicationState
ReadS [DescribeApplicationState]
(Int -> ReadS DescribeApplicationState)
-> ReadS [DescribeApplicationState]
-> ReadPrec DescribeApplicationState
-> ReadPrec [DescribeApplicationState]
-> Read DescribeApplicationState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeApplicationState]
$creadListPrec :: ReadPrec [DescribeApplicationState]
readPrec :: ReadPrec DescribeApplicationState
$creadPrec :: ReadPrec DescribeApplicationState
readList :: ReadS [DescribeApplicationState]
$creadList :: ReadS [DescribeApplicationState]
readsPrec :: Int -> ReadS DescribeApplicationState
$creadsPrec :: Int -> ReadS DescribeApplicationState
Prelude.Read, Int -> DescribeApplicationState -> ShowS
[DescribeApplicationState] -> ShowS
DescribeApplicationState -> String
(Int -> DescribeApplicationState -> ShowS)
-> (DescribeApplicationState -> String)
-> ([DescribeApplicationState] -> ShowS)
-> Show DescribeApplicationState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeApplicationState] -> ShowS
$cshowList :: [DescribeApplicationState] -> ShowS
show :: DescribeApplicationState -> String
$cshow :: DescribeApplicationState -> String
showsPrec :: Int -> DescribeApplicationState -> ShowS
$cshowsPrec :: Int -> DescribeApplicationState -> ShowS
Prelude.Show, (forall x.
 DescribeApplicationState -> Rep DescribeApplicationState x)
-> (forall x.
    Rep DescribeApplicationState x -> DescribeApplicationState)
-> Generic DescribeApplicationState
forall x.
Rep DescribeApplicationState x -> DescribeApplicationState
forall x.
DescribeApplicationState -> Rep DescribeApplicationState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeApplicationState x -> DescribeApplicationState
$cfrom :: forall x.
DescribeApplicationState -> Rep DescribeApplicationState x
Prelude.Generic)

-- |
-- Create a value of 'DescribeApplicationState' 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:
--
-- 'applicationId', 'describeApplicationState_applicationId' - The configurationId in Application Discovery Service that uniquely
-- identifies the grouped application.
newDescribeApplicationState ::
  -- | 'applicationId'
  Prelude.Text ->
  DescribeApplicationState
newDescribeApplicationState :: Text -> DescribeApplicationState
newDescribeApplicationState Text
pApplicationId_ =
  DescribeApplicationState' :: Text -> DescribeApplicationState
DescribeApplicationState'
    { $sel:applicationId:DescribeApplicationState' :: Text
applicationId =
        Text
pApplicationId_
    }

-- | The configurationId in Application Discovery Service that uniquely
-- identifies the grouped application.
describeApplicationState_applicationId :: Lens.Lens' DescribeApplicationState Prelude.Text
describeApplicationState_applicationId :: (Text -> f Text)
-> DescribeApplicationState -> f DescribeApplicationState
describeApplicationState_applicationId = (DescribeApplicationState -> Text)
-> (DescribeApplicationState -> Text -> DescribeApplicationState)
-> Lens DescribeApplicationState DescribeApplicationState Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplicationState' {Text
applicationId :: Text
$sel:applicationId:DescribeApplicationState' :: DescribeApplicationState -> Text
applicationId} -> Text
applicationId) (\s :: DescribeApplicationState
s@DescribeApplicationState' {} Text
a -> DescribeApplicationState
s {$sel:applicationId:DescribeApplicationState' :: Text
applicationId = Text
a} :: DescribeApplicationState)

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

instance Prelude.NFData DescribeApplicationState

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

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

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

-- | /See:/ 'newDescribeApplicationStateResponse' smart constructor.
data DescribeApplicationStateResponse = DescribeApplicationStateResponse'
  { -- | The timestamp when the application status was last updated.
    DescribeApplicationStateResponse -> Maybe POSIX
lastUpdatedTime :: Prelude.Maybe Core.POSIX,
    -- | Status of the application - Not Started, In-Progress, Complete.
    DescribeApplicationStateResponse -> Maybe ApplicationStatus
applicationStatus :: Prelude.Maybe ApplicationStatus,
    -- | The response's http status code.
    DescribeApplicationStateResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeApplicationStateResponse
-> DescribeApplicationStateResponse -> Bool
(DescribeApplicationStateResponse
 -> DescribeApplicationStateResponse -> Bool)
-> (DescribeApplicationStateResponse
    -> DescribeApplicationStateResponse -> Bool)
-> Eq DescribeApplicationStateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeApplicationStateResponse
-> DescribeApplicationStateResponse -> Bool
$c/= :: DescribeApplicationStateResponse
-> DescribeApplicationStateResponse -> Bool
== :: DescribeApplicationStateResponse
-> DescribeApplicationStateResponse -> Bool
$c== :: DescribeApplicationStateResponse
-> DescribeApplicationStateResponse -> Bool
Prelude.Eq, ReadPrec [DescribeApplicationStateResponse]
ReadPrec DescribeApplicationStateResponse
Int -> ReadS DescribeApplicationStateResponse
ReadS [DescribeApplicationStateResponse]
(Int -> ReadS DescribeApplicationStateResponse)
-> ReadS [DescribeApplicationStateResponse]
-> ReadPrec DescribeApplicationStateResponse
-> ReadPrec [DescribeApplicationStateResponse]
-> Read DescribeApplicationStateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeApplicationStateResponse]
$creadListPrec :: ReadPrec [DescribeApplicationStateResponse]
readPrec :: ReadPrec DescribeApplicationStateResponse
$creadPrec :: ReadPrec DescribeApplicationStateResponse
readList :: ReadS [DescribeApplicationStateResponse]
$creadList :: ReadS [DescribeApplicationStateResponse]
readsPrec :: Int -> ReadS DescribeApplicationStateResponse
$creadsPrec :: Int -> ReadS DescribeApplicationStateResponse
Prelude.Read, Int -> DescribeApplicationStateResponse -> ShowS
[DescribeApplicationStateResponse] -> ShowS
DescribeApplicationStateResponse -> String
(Int -> DescribeApplicationStateResponse -> ShowS)
-> (DescribeApplicationStateResponse -> String)
-> ([DescribeApplicationStateResponse] -> ShowS)
-> Show DescribeApplicationStateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeApplicationStateResponse] -> ShowS
$cshowList :: [DescribeApplicationStateResponse] -> ShowS
show :: DescribeApplicationStateResponse -> String
$cshow :: DescribeApplicationStateResponse -> String
showsPrec :: Int -> DescribeApplicationStateResponse -> ShowS
$cshowsPrec :: Int -> DescribeApplicationStateResponse -> ShowS
Prelude.Show, (forall x.
 DescribeApplicationStateResponse
 -> Rep DescribeApplicationStateResponse x)
-> (forall x.
    Rep DescribeApplicationStateResponse x
    -> DescribeApplicationStateResponse)
-> Generic DescribeApplicationStateResponse
forall x.
Rep DescribeApplicationStateResponse x
-> DescribeApplicationStateResponse
forall x.
DescribeApplicationStateResponse
-> Rep DescribeApplicationStateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeApplicationStateResponse x
-> DescribeApplicationStateResponse
$cfrom :: forall x.
DescribeApplicationStateResponse
-> Rep DescribeApplicationStateResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeApplicationStateResponse' 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:
--
-- 'lastUpdatedTime', 'describeApplicationStateResponse_lastUpdatedTime' - The timestamp when the application status was last updated.
--
-- 'applicationStatus', 'describeApplicationStateResponse_applicationStatus' - Status of the application - Not Started, In-Progress, Complete.
--
-- 'httpStatus', 'describeApplicationStateResponse_httpStatus' - The response's http status code.
newDescribeApplicationStateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeApplicationStateResponse
newDescribeApplicationStateResponse :: Int -> DescribeApplicationStateResponse
newDescribeApplicationStateResponse Int
pHttpStatus_ =
  DescribeApplicationStateResponse' :: Maybe POSIX
-> Maybe ApplicationStatus
-> Int
-> DescribeApplicationStateResponse
DescribeApplicationStateResponse'
    { $sel:lastUpdatedTime:DescribeApplicationStateResponse' :: Maybe POSIX
lastUpdatedTime =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationStatus:DescribeApplicationStateResponse' :: Maybe ApplicationStatus
applicationStatus = Maybe ApplicationStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeApplicationStateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The timestamp when the application status was last updated.
describeApplicationStateResponse_lastUpdatedTime :: Lens.Lens' DescribeApplicationStateResponse (Prelude.Maybe Prelude.UTCTime)
describeApplicationStateResponse_lastUpdatedTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DescribeApplicationStateResponse
-> f DescribeApplicationStateResponse
describeApplicationStateResponse_lastUpdatedTime = (DescribeApplicationStateResponse -> Maybe POSIX)
-> (DescribeApplicationStateResponse
    -> Maybe POSIX -> DescribeApplicationStateResponse)
-> Lens
     DescribeApplicationStateResponse
     DescribeApplicationStateResponse
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplicationStateResponse' {Maybe POSIX
lastUpdatedTime :: Maybe POSIX
$sel:lastUpdatedTime:DescribeApplicationStateResponse' :: DescribeApplicationStateResponse -> Maybe POSIX
lastUpdatedTime} -> Maybe POSIX
lastUpdatedTime) (\s :: DescribeApplicationStateResponse
s@DescribeApplicationStateResponse' {} Maybe POSIX
a -> DescribeApplicationStateResponse
s {$sel:lastUpdatedTime:DescribeApplicationStateResponse' :: Maybe POSIX
lastUpdatedTime = Maybe POSIX
a} :: DescribeApplicationStateResponse) ((Maybe POSIX -> f (Maybe POSIX))
 -> DescribeApplicationStateResponse
 -> f DescribeApplicationStateResponse)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DescribeApplicationStateResponse
-> f DescribeApplicationStateResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Status of the application - Not Started, In-Progress, Complete.
describeApplicationStateResponse_applicationStatus :: Lens.Lens' DescribeApplicationStateResponse (Prelude.Maybe ApplicationStatus)
describeApplicationStateResponse_applicationStatus :: (Maybe ApplicationStatus -> f (Maybe ApplicationStatus))
-> DescribeApplicationStateResponse
-> f DescribeApplicationStateResponse
describeApplicationStateResponse_applicationStatus = (DescribeApplicationStateResponse -> Maybe ApplicationStatus)
-> (DescribeApplicationStateResponse
    -> Maybe ApplicationStatus -> DescribeApplicationStateResponse)
-> Lens
     DescribeApplicationStateResponse
     DescribeApplicationStateResponse
     (Maybe ApplicationStatus)
     (Maybe ApplicationStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplicationStateResponse' {Maybe ApplicationStatus
applicationStatus :: Maybe ApplicationStatus
$sel:applicationStatus:DescribeApplicationStateResponse' :: DescribeApplicationStateResponse -> Maybe ApplicationStatus
applicationStatus} -> Maybe ApplicationStatus
applicationStatus) (\s :: DescribeApplicationStateResponse
s@DescribeApplicationStateResponse' {} Maybe ApplicationStatus
a -> DescribeApplicationStateResponse
s {$sel:applicationStatus:DescribeApplicationStateResponse' :: Maybe ApplicationStatus
applicationStatus = Maybe ApplicationStatus
a} :: DescribeApplicationStateResponse)

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

instance
  Prelude.NFData
    DescribeApplicationStateResponse