{-# 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.DescribeMigrationTask
-- 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)
--
-- Retrieves a list of all attributes associated with a specific migration
-- task.
module Amazonka.MigrationHub.DescribeMigrationTask
  ( -- * Creating a Request
    DescribeMigrationTask (..),
    newDescribeMigrationTask,

    -- * Request Lenses
    describeMigrationTask_progressUpdateStream,
    describeMigrationTask_migrationTaskName,

    -- * Destructuring the Response
    DescribeMigrationTaskResponse (..),
    newDescribeMigrationTaskResponse,

    -- * Response Lenses
    describeMigrationTaskResponse_migrationTask,
    describeMigrationTaskResponse_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:/ 'newDescribeMigrationTask' smart constructor.
data DescribeMigrationTask = DescribeMigrationTask'
  { -- | The name of the ProgressUpdateStream.
    DescribeMigrationTask -> Text
progressUpdateStream :: Prelude.Text,
    -- | The identifier given to the MigrationTask. /Do not store personal data
    -- in this field./
    DescribeMigrationTask -> Text
migrationTaskName :: Prelude.Text
  }
  deriving (DescribeMigrationTask -> DescribeMigrationTask -> Bool
(DescribeMigrationTask -> DescribeMigrationTask -> Bool)
-> (DescribeMigrationTask -> DescribeMigrationTask -> Bool)
-> Eq DescribeMigrationTask
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeMigrationTask -> DescribeMigrationTask -> Bool
$c/= :: DescribeMigrationTask -> DescribeMigrationTask -> Bool
== :: DescribeMigrationTask -> DescribeMigrationTask -> Bool
$c== :: DescribeMigrationTask -> DescribeMigrationTask -> Bool
Prelude.Eq, ReadPrec [DescribeMigrationTask]
ReadPrec DescribeMigrationTask
Int -> ReadS DescribeMigrationTask
ReadS [DescribeMigrationTask]
(Int -> ReadS DescribeMigrationTask)
-> ReadS [DescribeMigrationTask]
-> ReadPrec DescribeMigrationTask
-> ReadPrec [DescribeMigrationTask]
-> Read DescribeMigrationTask
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeMigrationTask]
$creadListPrec :: ReadPrec [DescribeMigrationTask]
readPrec :: ReadPrec DescribeMigrationTask
$creadPrec :: ReadPrec DescribeMigrationTask
readList :: ReadS [DescribeMigrationTask]
$creadList :: ReadS [DescribeMigrationTask]
readsPrec :: Int -> ReadS DescribeMigrationTask
$creadsPrec :: Int -> ReadS DescribeMigrationTask
Prelude.Read, Int -> DescribeMigrationTask -> ShowS
[DescribeMigrationTask] -> ShowS
DescribeMigrationTask -> String
(Int -> DescribeMigrationTask -> ShowS)
-> (DescribeMigrationTask -> String)
-> ([DescribeMigrationTask] -> ShowS)
-> Show DescribeMigrationTask
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeMigrationTask] -> ShowS
$cshowList :: [DescribeMigrationTask] -> ShowS
show :: DescribeMigrationTask -> String
$cshow :: DescribeMigrationTask -> String
showsPrec :: Int -> DescribeMigrationTask -> ShowS
$cshowsPrec :: Int -> DescribeMigrationTask -> ShowS
Prelude.Show, (forall x. DescribeMigrationTask -> Rep DescribeMigrationTask x)
-> (forall x. Rep DescribeMigrationTask x -> DescribeMigrationTask)
-> Generic DescribeMigrationTask
forall x. Rep DescribeMigrationTask x -> DescribeMigrationTask
forall x. DescribeMigrationTask -> Rep DescribeMigrationTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeMigrationTask x -> DescribeMigrationTask
$cfrom :: forall x. DescribeMigrationTask -> Rep DescribeMigrationTask x
Prelude.Generic)

-- |
-- Create a value of 'DescribeMigrationTask' 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:
--
-- 'progressUpdateStream', 'describeMigrationTask_progressUpdateStream' - The name of the ProgressUpdateStream.
--
-- 'migrationTaskName', 'describeMigrationTask_migrationTaskName' - The identifier given to the MigrationTask. /Do not store personal data
-- in this field./
newDescribeMigrationTask ::
  -- | 'progressUpdateStream'
  Prelude.Text ->
  -- | 'migrationTaskName'
  Prelude.Text ->
  DescribeMigrationTask
newDescribeMigrationTask :: Text -> Text -> DescribeMigrationTask
newDescribeMigrationTask
  Text
pProgressUpdateStream_
  Text
pMigrationTaskName_ =
    DescribeMigrationTask' :: Text -> Text -> DescribeMigrationTask
DescribeMigrationTask'
      { $sel:progressUpdateStream:DescribeMigrationTask' :: Text
progressUpdateStream =
          Text
pProgressUpdateStream_,
        $sel:migrationTaskName:DescribeMigrationTask' :: Text
migrationTaskName = Text
pMigrationTaskName_
      }

-- | The name of the ProgressUpdateStream.
describeMigrationTask_progressUpdateStream :: Lens.Lens' DescribeMigrationTask Prelude.Text
describeMigrationTask_progressUpdateStream :: (Text -> f Text)
-> DescribeMigrationTask -> f DescribeMigrationTask
describeMigrationTask_progressUpdateStream = (DescribeMigrationTask -> Text)
-> (DescribeMigrationTask -> Text -> DescribeMigrationTask)
-> Lens DescribeMigrationTask DescribeMigrationTask Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMigrationTask' {Text
progressUpdateStream :: Text
$sel:progressUpdateStream:DescribeMigrationTask' :: DescribeMigrationTask -> Text
progressUpdateStream} -> Text
progressUpdateStream) (\s :: DescribeMigrationTask
s@DescribeMigrationTask' {} Text
a -> DescribeMigrationTask
s {$sel:progressUpdateStream:DescribeMigrationTask' :: Text
progressUpdateStream = Text
a} :: DescribeMigrationTask)

-- | The identifier given to the MigrationTask. /Do not store personal data
-- in this field./
describeMigrationTask_migrationTaskName :: Lens.Lens' DescribeMigrationTask Prelude.Text
describeMigrationTask_migrationTaskName :: (Text -> f Text)
-> DescribeMigrationTask -> f DescribeMigrationTask
describeMigrationTask_migrationTaskName = (DescribeMigrationTask -> Text)
-> (DescribeMigrationTask -> Text -> DescribeMigrationTask)
-> Lens DescribeMigrationTask DescribeMigrationTask Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMigrationTask' {Text
migrationTaskName :: Text
$sel:migrationTaskName:DescribeMigrationTask' :: DescribeMigrationTask -> Text
migrationTaskName} -> Text
migrationTaskName) (\s :: DescribeMigrationTask
s@DescribeMigrationTask' {} Text
a -> DescribeMigrationTask
s {$sel:migrationTaskName:DescribeMigrationTask' :: Text
migrationTaskName = Text
a} :: DescribeMigrationTask)

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

instance Prelude.NFData DescribeMigrationTask

instance Core.ToHeaders DescribeMigrationTask where
  toHeaders :: DescribeMigrationTask -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeMigrationTask -> 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.DescribeMigrationTask" ::
                          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 DescribeMigrationTask where
  toJSON :: DescribeMigrationTask -> Value
toJSON DescribeMigrationTask' {Text
migrationTaskName :: Text
progressUpdateStream :: Text
$sel:migrationTaskName:DescribeMigrationTask' :: DescribeMigrationTask -> Text
$sel:progressUpdateStream:DescribeMigrationTask' :: DescribeMigrationTask -> 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
"ProgressUpdateStream"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
progressUpdateStream
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"MigrationTaskName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
migrationTaskName)
          ]
      )

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

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

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

-- |
-- Create a value of 'DescribeMigrationTaskResponse' 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:
--
-- 'migrationTask', 'describeMigrationTaskResponse_migrationTask' - Object encapsulating information about the migration task.
--
-- 'httpStatus', 'describeMigrationTaskResponse_httpStatus' - The response's http status code.
newDescribeMigrationTaskResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeMigrationTaskResponse
newDescribeMigrationTaskResponse :: Int -> DescribeMigrationTaskResponse
newDescribeMigrationTaskResponse Int
pHttpStatus_ =
  DescribeMigrationTaskResponse' :: Maybe MigrationTask -> Int -> DescribeMigrationTaskResponse
DescribeMigrationTaskResponse'
    { $sel:migrationTask:DescribeMigrationTaskResponse' :: Maybe MigrationTask
migrationTask =
        Maybe MigrationTask
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeMigrationTaskResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Object encapsulating information about the migration task.
describeMigrationTaskResponse_migrationTask :: Lens.Lens' DescribeMigrationTaskResponse (Prelude.Maybe MigrationTask)
describeMigrationTaskResponse_migrationTask :: (Maybe MigrationTask -> f (Maybe MigrationTask))
-> DescribeMigrationTaskResponse -> f DescribeMigrationTaskResponse
describeMigrationTaskResponse_migrationTask = (DescribeMigrationTaskResponse -> Maybe MigrationTask)
-> (DescribeMigrationTaskResponse
    -> Maybe MigrationTask -> DescribeMigrationTaskResponse)
-> Lens
     DescribeMigrationTaskResponse
     DescribeMigrationTaskResponse
     (Maybe MigrationTask)
     (Maybe MigrationTask)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMigrationTaskResponse' {Maybe MigrationTask
migrationTask :: Maybe MigrationTask
$sel:migrationTask:DescribeMigrationTaskResponse' :: DescribeMigrationTaskResponse -> Maybe MigrationTask
migrationTask} -> Maybe MigrationTask
migrationTask) (\s :: DescribeMigrationTaskResponse
s@DescribeMigrationTaskResponse' {} Maybe MigrationTask
a -> DescribeMigrationTaskResponse
s {$sel:migrationTask:DescribeMigrationTaskResponse' :: Maybe MigrationTask
migrationTask = Maybe MigrationTask
a} :: DescribeMigrationTaskResponse)

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

instance Prelude.NFData DescribeMigrationTaskResponse