{-# 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.NotifyApplicationState
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Sets the migration state of an application. For a given application
-- identified by the value passed to @ApplicationId@, its status is set or
-- updated by passing one of three values to @Status@:
-- @NOT_STARTED | IN_PROGRESS | COMPLETED@.
module Amazonka.MigrationHub.NotifyApplicationState
  ( -- * Creating a Request
    NotifyApplicationState (..),
    newNotifyApplicationState,

    -- * Request Lenses
    notifyApplicationState_dryRun,
    notifyApplicationState_updateDateTime,
    notifyApplicationState_applicationId,
    notifyApplicationState_status,

    -- * Destructuring the Response
    NotifyApplicationStateResponse (..),
    newNotifyApplicationStateResponse,

    -- * Response Lenses
    notifyApplicationStateResponse_httpStatus,
  )
where

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

-- | /See:/ 'newNotifyApplicationState' smart constructor.
data NotifyApplicationState = NotifyApplicationState'
  { -- | Optional boolean flag to indicate whether any effect should take place.
    -- Used to test if the caller has permission to make the call.
    NotifyApplicationState -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The timestamp when the application state changed.
    NotifyApplicationState -> Maybe POSIX
updateDateTime :: Prelude.Maybe Data.POSIX,
    -- | The configurationId in Application Discovery Service that uniquely
    -- identifies the grouped application.
    NotifyApplicationState -> Text
applicationId :: Prelude.Text,
    -- | Status of the application - Not Started, In-Progress, Complete.
    NotifyApplicationState -> ApplicationStatus
status :: ApplicationStatus
  }
  deriving (NotifyApplicationState -> NotifyApplicationState -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotifyApplicationState -> NotifyApplicationState -> Bool
$c/= :: NotifyApplicationState -> NotifyApplicationState -> Bool
== :: NotifyApplicationState -> NotifyApplicationState -> Bool
$c== :: NotifyApplicationState -> NotifyApplicationState -> Bool
Prelude.Eq, ReadPrec [NotifyApplicationState]
ReadPrec NotifyApplicationState
Int -> ReadS NotifyApplicationState
ReadS [NotifyApplicationState]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotifyApplicationState]
$creadListPrec :: ReadPrec [NotifyApplicationState]
readPrec :: ReadPrec NotifyApplicationState
$creadPrec :: ReadPrec NotifyApplicationState
readList :: ReadS [NotifyApplicationState]
$creadList :: ReadS [NotifyApplicationState]
readsPrec :: Int -> ReadS NotifyApplicationState
$creadsPrec :: Int -> ReadS NotifyApplicationState
Prelude.Read, Int -> NotifyApplicationState -> ShowS
[NotifyApplicationState] -> ShowS
NotifyApplicationState -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotifyApplicationState] -> ShowS
$cshowList :: [NotifyApplicationState] -> ShowS
show :: NotifyApplicationState -> String
$cshow :: NotifyApplicationState -> String
showsPrec :: Int -> NotifyApplicationState -> ShowS
$cshowsPrec :: Int -> NotifyApplicationState -> ShowS
Prelude.Show, forall x. Rep NotifyApplicationState x -> NotifyApplicationState
forall x. NotifyApplicationState -> Rep NotifyApplicationState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NotifyApplicationState x -> NotifyApplicationState
$cfrom :: forall x. NotifyApplicationState -> Rep NotifyApplicationState x
Prelude.Generic)

-- |
-- Create a value of 'NotifyApplicationState' 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:
--
-- 'dryRun', 'notifyApplicationState_dryRun' - Optional boolean flag to indicate whether any effect should take place.
-- Used to test if the caller has permission to make the call.
--
-- 'updateDateTime', 'notifyApplicationState_updateDateTime' - The timestamp when the application state changed.
--
-- 'applicationId', 'notifyApplicationState_applicationId' - The configurationId in Application Discovery Service that uniquely
-- identifies the grouped application.
--
-- 'status', 'notifyApplicationState_status' - Status of the application - Not Started, In-Progress, Complete.
newNotifyApplicationState ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'status'
  ApplicationStatus ->
  NotifyApplicationState
newNotifyApplicationState :: Text -> ApplicationStatus -> NotifyApplicationState
newNotifyApplicationState Text
pApplicationId_ ApplicationStatus
pStatus_ =
  NotifyApplicationState'
    { $sel:dryRun:NotifyApplicationState' :: Maybe Bool
dryRun = forall a. Maybe a
Prelude.Nothing,
      $sel:updateDateTime:NotifyApplicationState' :: Maybe POSIX
updateDateTime = forall a. Maybe a
Prelude.Nothing,
      $sel:applicationId:NotifyApplicationState' :: Text
applicationId = Text
pApplicationId_,
      $sel:status:NotifyApplicationState' :: ApplicationStatus
status = ApplicationStatus
pStatus_
    }

-- | Optional boolean flag to indicate whether any effect should take place.
-- Used to test if the caller has permission to make the call.
notifyApplicationState_dryRun :: Lens.Lens' NotifyApplicationState (Prelude.Maybe Prelude.Bool)
notifyApplicationState_dryRun :: Lens' NotifyApplicationState (Maybe Bool)
notifyApplicationState_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyApplicationState' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:NotifyApplicationState' :: NotifyApplicationState -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: NotifyApplicationState
s@NotifyApplicationState' {} Maybe Bool
a -> NotifyApplicationState
s {$sel:dryRun:NotifyApplicationState' :: Maybe Bool
dryRun = Maybe Bool
a} :: NotifyApplicationState)

-- | The timestamp when the application state changed.
notifyApplicationState_updateDateTime :: Lens.Lens' NotifyApplicationState (Prelude.Maybe Prelude.UTCTime)
notifyApplicationState_updateDateTime :: Lens' NotifyApplicationState (Maybe UTCTime)
notifyApplicationState_updateDateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyApplicationState' {Maybe POSIX
updateDateTime :: Maybe POSIX
$sel:updateDateTime:NotifyApplicationState' :: NotifyApplicationState -> Maybe POSIX
updateDateTime} -> Maybe POSIX
updateDateTime) (\s :: NotifyApplicationState
s@NotifyApplicationState' {} Maybe POSIX
a -> NotifyApplicationState
s {$sel:updateDateTime:NotifyApplicationState' :: Maybe POSIX
updateDateTime = Maybe POSIX
a} :: NotifyApplicationState) 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 configurationId in Application Discovery Service that uniquely
-- identifies the grouped application.
notifyApplicationState_applicationId :: Lens.Lens' NotifyApplicationState Prelude.Text
notifyApplicationState_applicationId :: Lens' NotifyApplicationState Text
notifyApplicationState_applicationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyApplicationState' {Text
applicationId :: Text
$sel:applicationId:NotifyApplicationState' :: NotifyApplicationState -> Text
applicationId} -> Text
applicationId) (\s :: NotifyApplicationState
s@NotifyApplicationState' {} Text
a -> NotifyApplicationState
s {$sel:applicationId:NotifyApplicationState' :: Text
applicationId = Text
a} :: NotifyApplicationState)

-- | Status of the application - Not Started, In-Progress, Complete.
notifyApplicationState_status :: Lens.Lens' NotifyApplicationState ApplicationStatus
notifyApplicationState_status :: Lens' NotifyApplicationState ApplicationStatus
notifyApplicationState_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyApplicationState' {ApplicationStatus
status :: ApplicationStatus
$sel:status:NotifyApplicationState' :: NotifyApplicationState -> ApplicationStatus
status} -> ApplicationStatus
status) (\s :: NotifyApplicationState
s@NotifyApplicationState' {} ApplicationStatus
a -> NotifyApplicationState
s {$sel:status:NotifyApplicationState' :: ApplicationStatus
status = ApplicationStatus
a} :: NotifyApplicationState)

instance Core.AWSRequest NotifyApplicationState where
  type
    AWSResponse NotifyApplicationState =
      NotifyApplicationStateResponse
  request :: (Service -> Service)
-> NotifyApplicationState -> Request NotifyApplicationState
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 NotifyApplicationState
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse NotifyApplicationState)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> NotifyApplicationStateResponse
NotifyApplicationStateResponse'
            forall (f :: * -> *) a b. Functor 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 NotifyApplicationState where
  hashWithSalt :: Int -> NotifyApplicationState -> Int
hashWithSalt Int
_salt NotifyApplicationState' {Maybe Bool
Maybe POSIX
Text
ApplicationStatus
status :: ApplicationStatus
applicationId :: Text
updateDateTime :: Maybe POSIX
dryRun :: Maybe Bool
$sel:status:NotifyApplicationState' :: NotifyApplicationState -> ApplicationStatus
$sel:applicationId:NotifyApplicationState' :: NotifyApplicationState -> Text
$sel:updateDateTime:NotifyApplicationState' :: NotifyApplicationState -> Maybe POSIX
$sel:dryRun:NotifyApplicationState' :: NotifyApplicationState -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
updateDateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ApplicationStatus
status

instance Prelude.NFData NotifyApplicationState where
  rnf :: NotifyApplicationState -> ()
rnf NotifyApplicationState' {Maybe Bool
Maybe POSIX
Text
ApplicationStatus
status :: ApplicationStatus
applicationId :: Text
updateDateTime :: Maybe POSIX
dryRun :: Maybe Bool
$sel:status:NotifyApplicationState' :: NotifyApplicationState -> ApplicationStatus
$sel:applicationId:NotifyApplicationState' :: NotifyApplicationState -> Text
$sel:updateDateTime:NotifyApplicationState' :: NotifyApplicationState -> Maybe POSIX
$sel:dryRun:NotifyApplicationState' :: NotifyApplicationState -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
updateDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
applicationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ApplicationStatus
status

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

instance Data.ToJSON NotifyApplicationState where
  toJSON :: NotifyApplicationState -> Value
toJSON NotifyApplicationState' {Maybe Bool
Maybe POSIX
Text
ApplicationStatus
status :: ApplicationStatus
applicationId :: Text
updateDateTime :: Maybe POSIX
dryRun :: Maybe Bool
$sel:status:NotifyApplicationState' :: NotifyApplicationState -> ApplicationStatus
$sel:applicationId:NotifyApplicationState' :: NotifyApplicationState -> Text
$sel:updateDateTime:NotifyApplicationState' :: NotifyApplicationState -> Maybe POSIX
$sel:dryRun:NotifyApplicationState' :: NotifyApplicationState -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DryRun" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
dryRun,
            (Key
"UpdateDateTime" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
updateDateTime,
            forall a. a -> Maybe a
Prelude.Just (Key
"ApplicationId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
applicationId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Status" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ApplicationStatus
status)
          ]
      )

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

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

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

-- |
-- Create a value of 'NotifyApplicationStateResponse' 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:
--
-- 'httpStatus', 'notifyApplicationStateResponse_httpStatus' - The response's http status code.
newNotifyApplicationStateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  NotifyApplicationStateResponse
newNotifyApplicationStateResponse :: Int -> NotifyApplicationStateResponse
newNotifyApplicationStateResponse Int
pHttpStatus_ =
  NotifyApplicationStateResponse'
    { $sel:httpStatus:NotifyApplicationStateResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    NotifyApplicationStateResponse
  where
  rnf :: NotifyApplicationStateResponse -> ()
rnf NotifyApplicationStateResponse' {Int
httpStatus :: Int
$sel:httpStatus:NotifyApplicationStateResponse' :: NotifyApplicationStateResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus