{-# 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.MigrationHubOrchestrator.StartWorkflow
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Start a migration workflow.
module Amazonka.MigrationHubOrchestrator.StartWorkflow
  ( -- * Creating a Request
    StartWorkflow (..),
    newStartWorkflow,

    -- * Request Lenses
    startWorkflow_id,

    -- * Destructuring the Response
    StartWorkflowResponse (..),
    newStartWorkflowResponse,

    -- * Response Lenses
    startWorkflowResponse_arn,
    startWorkflowResponse_id,
    startWorkflowResponse_lastStartTime,
    startWorkflowResponse_status,
    startWorkflowResponse_statusMessage,
    startWorkflowResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MigrationHubOrchestrator.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newStartWorkflow' smart constructor.
data StartWorkflow = StartWorkflow'
  { -- | The ID of the migration workflow.
    StartWorkflow -> Text
id :: Prelude.Text
  }
  deriving (StartWorkflow -> StartWorkflow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartWorkflow -> StartWorkflow -> Bool
$c/= :: StartWorkflow -> StartWorkflow -> Bool
== :: StartWorkflow -> StartWorkflow -> Bool
$c== :: StartWorkflow -> StartWorkflow -> Bool
Prelude.Eq, ReadPrec [StartWorkflow]
ReadPrec StartWorkflow
Int -> ReadS StartWorkflow
ReadS [StartWorkflow]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartWorkflow]
$creadListPrec :: ReadPrec [StartWorkflow]
readPrec :: ReadPrec StartWorkflow
$creadPrec :: ReadPrec StartWorkflow
readList :: ReadS [StartWorkflow]
$creadList :: ReadS [StartWorkflow]
readsPrec :: Int -> ReadS StartWorkflow
$creadsPrec :: Int -> ReadS StartWorkflow
Prelude.Read, Int -> StartWorkflow -> ShowS
[StartWorkflow] -> ShowS
StartWorkflow -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartWorkflow] -> ShowS
$cshowList :: [StartWorkflow] -> ShowS
show :: StartWorkflow -> String
$cshow :: StartWorkflow -> String
showsPrec :: Int -> StartWorkflow -> ShowS
$cshowsPrec :: Int -> StartWorkflow -> ShowS
Prelude.Show, forall x. Rep StartWorkflow x -> StartWorkflow
forall x. StartWorkflow -> Rep StartWorkflow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartWorkflow x -> StartWorkflow
$cfrom :: forall x. StartWorkflow -> Rep StartWorkflow x
Prelude.Generic)

-- |
-- Create a value of 'StartWorkflow' 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:
--
-- 'id', 'startWorkflow_id' - The ID of the migration workflow.
newStartWorkflow ::
  -- | 'id'
  Prelude.Text ->
  StartWorkflow
newStartWorkflow :: Text -> StartWorkflow
newStartWorkflow Text
pId_ = StartWorkflow' {$sel:id:StartWorkflow' :: Text
id = Text
pId_}

-- | The ID of the migration workflow.
startWorkflow_id :: Lens.Lens' StartWorkflow Prelude.Text
startWorkflow_id :: Lens' StartWorkflow Text
startWorkflow_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartWorkflow' {Text
id :: Text
$sel:id:StartWorkflow' :: StartWorkflow -> Text
id} -> Text
id) (\s :: StartWorkflow
s@StartWorkflow' {} Text
a -> StartWorkflow
s {$sel:id:StartWorkflow' :: Text
id = Text
a} :: StartWorkflow)

instance Core.AWSRequest StartWorkflow where
  type
    AWSResponse StartWorkflow =
      StartWorkflowResponse
  request :: (Service -> Service) -> StartWorkflow -> Request StartWorkflow
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StartWorkflow
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartWorkflow)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe MigrationWorkflowStatusEnum
-> Maybe Text
-> Int
-> StartWorkflowResponse
StartWorkflowResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"id")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"lastStartTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"status")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"statusMessage")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable StartWorkflow where
  hashWithSalt :: Int -> StartWorkflow -> Int
hashWithSalt Int
_salt StartWorkflow' {Text
id :: Text
$sel:id:StartWorkflow' :: StartWorkflow -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData StartWorkflow where
  rnf :: StartWorkflow -> ()
rnf StartWorkflow' {Text
id :: Text
$sel:id:StartWorkflow' :: StartWorkflow -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance Data.ToHeaders StartWorkflow where
  toHeaders :: StartWorkflow -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StartWorkflow where
  toJSON :: StartWorkflow -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath StartWorkflow where
  toPath :: StartWorkflow -> ByteString
toPath StartWorkflow' {Text
id :: Text
$sel:id:StartWorkflow' :: StartWorkflow -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/migrationworkflow/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id, ByteString
"/start"]

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

-- | /See:/ 'newStartWorkflowResponse' smart constructor.
data StartWorkflowResponse = StartWorkflowResponse'
  { -- | The Amazon Resource Name (ARN) of the migration workflow.
    StartWorkflowResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The ID of the migration workflow.
    StartWorkflowResponse -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The time at which the migration workflow was last started.
    StartWorkflowResponse -> Maybe POSIX
lastStartTime :: Prelude.Maybe Data.POSIX,
    -- | The status of the migration workflow.
    StartWorkflowResponse -> Maybe MigrationWorkflowStatusEnum
status :: Prelude.Maybe MigrationWorkflowStatusEnum,
    -- | The status message of the migration workflow.
    StartWorkflowResponse -> Maybe Text
statusMessage :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    StartWorkflowResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartWorkflowResponse -> StartWorkflowResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartWorkflowResponse -> StartWorkflowResponse -> Bool
$c/= :: StartWorkflowResponse -> StartWorkflowResponse -> Bool
== :: StartWorkflowResponse -> StartWorkflowResponse -> Bool
$c== :: StartWorkflowResponse -> StartWorkflowResponse -> Bool
Prelude.Eq, ReadPrec [StartWorkflowResponse]
ReadPrec StartWorkflowResponse
Int -> ReadS StartWorkflowResponse
ReadS [StartWorkflowResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartWorkflowResponse]
$creadListPrec :: ReadPrec [StartWorkflowResponse]
readPrec :: ReadPrec StartWorkflowResponse
$creadPrec :: ReadPrec StartWorkflowResponse
readList :: ReadS [StartWorkflowResponse]
$creadList :: ReadS [StartWorkflowResponse]
readsPrec :: Int -> ReadS StartWorkflowResponse
$creadsPrec :: Int -> ReadS StartWorkflowResponse
Prelude.Read, Int -> StartWorkflowResponse -> ShowS
[StartWorkflowResponse] -> ShowS
StartWorkflowResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartWorkflowResponse] -> ShowS
$cshowList :: [StartWorkflowResponse] -> ShowS
show :: StartWorkflowResponse -> String
$cshow :: StartWorkflowResponse -> String
showsPrec :: Int -> StartWorkflowResponse -> ShowS
$cshowsPrec :: Int -> StartWorkflowResponse -> ShowS
Prelude.Show, forall x. Rep StartWorkflowResponse x -> StartWorkflowResponse
forall x. StartWorkflowResponse -> Rep StartWorkflowResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartWorkflowResponse x -> StartWorkflowResponse
$cfrom :: forall x. StartWorkflowResponse -> Rep StartWorkflowResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartWorkflowResponse' 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:
--
-- 'arn', 'startWorkflowResponse_arn' - The Amazon Resource Name (ARN) of the migration workflow.
--
-- 'id', 'startWorkflowResponse_id' - The ID of the migration workflow.
--
-- 'lastStartTime', 'startWorkflowResponse_lastStartTime' - The time at which the migration workflow was last started.
--
-- 'status', 'startWorkflowResponse_status' - The status of the migration workflow.
--
-- 'statusMessage', 'startWorkflowResponse_statusMessage' - The status message of the migration workflow.
--
-- 'httpStatus', 'startWorkflowResponse_httpStatus' - The response's http status code.
newStartWorkflowResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartWorkflowResponse
newStartWorkflowResponse :: Int -> StartWorkflowResponse
newStartWorkflowResponse Int
pHttpStatus_ =
  StartWorkflowResponse'
    { $sel:arn:StartWorkflowResponse' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:id:StartWorkflowResponse' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:lastStartTime:StartWorkflowResponse' :: Maybe POSIX
lastStartTime = forall a. Maybe a
Prelude.Nothing,
      $sel:status:StartWorkflowResponse' :: Maybe MigrationWorkflowStatusEnum
status = forall a. Maybe a
Prelude.Nothing,
      $sel:statusMessage:StartWorkflowResponse' :: Maybe Text
statusMessage = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartWorkflowResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the migration workflow.
startWorkflowResponse_arn :: Lens.Lens' StartWorkflowResponse (Prelude.Maybe Prelude.Text)
startWorkflowResponse_arn :: Lens' StartWorkflowResponse (Maybe Text)
startWorkflowResponse_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartWorkflowResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:StartWorkflowResponse' :: StartWorkflowResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: StartWorkflowResponse
s@StartWorkflowResponse' {} Maybe Text
a -> StartWorkflowResponse
s {$sel:arn:StartWorkflowResponse' :: Maybe Text
arn = Maybe Text
a} :: StartWorkflowResponse)

-- | The ID of the migration workflow.
startWorkflowResponse_id :: Lens.Lens' StartWorkflowResponse (Prelude.Maybe Prelude.Text)
startWorkflowResponse_id :: Lens' StartWorkflowResponse (Maybe Text)
startWorkflowResponse_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartWorkflowResponse' {Maybe Text
id :: Maybe Text
$sel:id:StartWorkflowResponse' :: StartWorkflowResponse -> Maybe Text
id} -> Maybe Text
id) (\s :: StartWorkflowResponse
s@StartWorkflowResponse' {} Maybe Text
a -> StartWorkflowResponse
s {$sel:id:StartWorkflowResponse' :: Maybe Text
id = Maybe Text
a} :: StartWorkflowResponse)

-- | The time at which the migration workflow was last started.
startWorkflowResponse_lastStartTime :: Lens.Lens' StartWorkflowResponse (Prelude.Maybe Prelude.UTCTime)
startWorkflowResponse_lastStartTime :: Lens' StartWorkflowResponse (Maybe UTCTime)
startWorkflowResponse_lastStartTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartWorkflowResponse' {Maybe POSIX
lastStartTime :: Maybe POSIX
$sel:lastStartTime:StartWorkflowResponse' :: StartWorkflowResponse -> Maybe POSIX
lastStartTime} -> Maybe POSIX
lastStartTime) (\s :: StartWorkflowResponse
s@StartWorkflowResponse' {} Maybe POSIX
a -> StartWorkflowResponse
s {$sel:lastStartTime:StartWorkflowResponse' :: Maybe POSIX
lastStartTime = Maybe POSIX
a} :: StartWorkflowResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The status of the migration workflow.
startWorkflowResponse_status :: Lens.Lens' StartWorkflowResponse (Prelude.Maybe MigrationWorkflowStatusEnum)
startWorkflowResponse_status :: Lens' StartWorkflowResponse (Maybe MigrationWorkflowStatusEnum)
startWorkflowResponse_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartWorkflowResponse' {Maybe MigrationWorkflowStatusEnum
status :: Maybe MigrationWorkflowStatusEnum
$sel:status:StartWorkflowResponse' :: StartWorkflowResponse -> Maybe MigrationWorkflowStatusEnum
status} -> Maybe MigrationWorkflowStatusEnum
status) (\s :: StartWorkflowResponse
s@StartWorkflowResponse' {} Maybe MigrationWorkflowStatusEnum
a -> StartWorkflowResponse
s {$sel:status:StartWorkflowResponse' :: Maybe MigrationWorkflowStatusEnum
status = Maybe MigrationWorkflowStatusEnum
a} :: StartWorkflowResponse)

-- | The status message of the migration workflow.
startWorkflowResponse_statusMessage :: Lens.Lens' StartWorkflowResponse (Prelude.Maybe Prelude.Text)
startWorkflowResponse_statusMessage :: Lens' StartWorkflowResponse (Maybe Text)
startWorkflowResponse_statusMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartWorkflowResponse' {Maybe Text
statusMessage :: Maybe Text
$sel:statusMessage:StartWorkflowResponse' :: StartWorkflowResponse -> Maybe Text
statusMessage} -> Maybe Text
statusMessage) (\s :: StartWorkflowResponse
s@StartWorkflowResponse' {} Maybe Text
a -> StartWorkflowResponse
s {$sel:statusMessage:StartWorkflowResponse' :: Maybe Text
statusMessage = Maybe Text
a} :: StartWorkflowResponse)

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

instance Prelude.NFData StartWorkflowResponse where
  rnf :: StartWorkflowResponse -> ()
rnf StartWorkflowResponse' {Int
Maybe Text
Maybe POSIX
Maybe MigrationWorkflowStatusEnum
httpStatus :: Int
statusMessage :: Maybe Text
status :: Maybe MigrationWorkflowStatusEnum
lastStartTime :: Maybe POSIX
id :: Maybe Text
arn :: Maybe Text
$sel:httpStatus:StartWorkflowResponse' :: StartWorkflowResponse -> Int
$sel:statusMessage:StartWorkflowResponse' :: StartWorkflowResponse -> Maybe Text
$sel:status:StartWorkflowResponse' :: StartWorkflowResponse -> Maybe MigrationWorkflowStatusEnum
$sel:lastStartTime:StartWorkflowResponse' :: StartWorkflowResponse -> Maybe POSIX
$sel:id:StartWorkflowResponse' :: StartWorkflowResponse -> Maybe Text
$sel:arn:StartWorkflowResponse' :: StartWorkflowResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastStartTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MigrationWorkflowStatusEnum
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
statusMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus