{-# 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.MigrationHubStrategy.GetAssessment
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the status of an on-going assessment.
module Amazonka.MigrationHubStrategy.GetAssessment
  ( -- * Creating a Request
    GetAssessment (..),
    newGetAssessment,

    -- * Request Lenses
    getAssessment_id,

    -- * Destructuring the Response
    GetAssessmentResponse (..),
    newGetAssessmentResponse,

    -- * Response Lenses
    getAssessmentResponse_assessmentTargets,
    getAssessmentResponse_dataCollectionDetails,
    getAssessmentResponse_id,
    getAssessmentResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'GetAssessment' 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', 'getAssessment_id' - The @assessmentid@ returned by StartAssessment.
newGetAssessment ::
  -- | 'id'
  Prelude.Text ->
  GetAssessment
newGetAssessment :: Text -> GetAssessment
newGetAssessment Text
pId_ = GetAssessment' {$sel:id:GetAssessment' :: Text
id = Text
pId_}

-- | The @assessmentid@ returned by StartAssessment.
getAssessment_id :: Lens.Lens' GetAssessment Prelude.Text
getAssessment_id :: Lens' GetAssessment Text
getAssessment_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAssessment' {Text
id :: Text
$sel:id:GetAssessment' :: GetAssessment -> Text
id} -> Text
id) (\s :: GetAssessment
s@GetAssessment' {} Text
a -> GetAssessment
s {$sel:id:GetAssessment' :: Text
id = Text
a} :: GetAssessment)

instance Core.AWSRequest GetAssessment where
  type
    AWSResponse GetAssessment =
      GetAssessmentResponse
  request :: (Service -> Service) -> GetAssessment -> Request GetAssessment
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetAssessment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAssessment)))
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 [AssessmentTarget]
-> Maybe DataCollectionDetails
-> Maybe Text
-> Int
-> GetAssessmentResponse
GetAssessmentResponse'
            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
"assessmentTargets"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            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
"dataCollectionDetails")
            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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

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

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

instance Data.ToHeaders GetAssessment where
  toHeaders :: GetAssessment -> 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.ToPath GetAssessment where
  toPath :: GetAssessment -> ByteString
toPath GetAssessment' {Text
id :: Text
$sel:id:GetAssessment' :: GetAssessment -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/get-assessment/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id]

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

-- | /See:/ 'newGetAssessmentResponse' smart constructor.
data GetAssessmentResponse = GetAssessmentResponse'
  { -- | List of criteria for assessment.
    GetAssessmentResponse -> Maybe [AssessmentTarget]
assessmentTargets :: Prelude.Maybe [AssessmentTarget],
    -- | Detailed information about the assessment.
    GetAssessmentResponse -> Maybe DataCollectionDetails
dataCollectionDetails :: Prelude.Maybe DataCollectionDetails,
    -- | The ID for the specific assessment task.
    GetAssessmentResponse -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetAssessmentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetAssessmentResponse -> GetAssessmentResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAssessmentResponse -> GetAssessmentResponse -> Bool
$c/= :: GetAssessmentResponse -> GetAssessmentResponse -> Bool
== :: GetAssessmentResponse -> GetAssessmentResponse -> Bool
$c== :: GetAssessmentResponse -> GetAssessmentResponse -> Bool
Prelude.Eq, ReadPrec [GetAssessmentResponse]
ReadPrec GetAssessmentResponse
Int -> ReadS GetAssessmentResponse
ReadS [GetAssessmentResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAssessmentResponse]
$creadListPrec :: ReadPrec [GetAssessmentResponse]
readPrec :: ReadPrec GetAssessmentResponse
$creadPrec :: ReadPrec GetAssessmentResponse
readList :: ReadS [GetAssessmentResponse]
$creadList :: ReadS [GetAssessmentResponse]
readsPrec :: Int -> ReadS GetAssessmentResponse
$creadsPrec :: Int -> ReadS GetAssessmentResponse
Prelude.Read, Int -> GetAssessmentResponse -> ShowS
[GetAssessmentResponse] -> ShowS
GetAssessmentResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAssessmentResponse] -> ShowS
$cshowList :: [GetAssessmentResponse] -> ShowS
show :: GetAssessmentResponse -> String
$cshow :: GetAssessmentResponse -> String
showsPrec :: Int -> GetAssessmentResponse -> ShowS
$cshowsPrec :: Int -> GetAssessmentResponse -> ShowS
Prelude.Show, forall x. Rep GetAssessmentResponse x -> GetAssessmentResponse
forall x. GetAssessmentResponse -> Rep GetAssessmentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAssessmentResponse x -> GetAssessmentResponse
$cfrom :: forall x. GetAssessmentResponse -> Rep GetAssessmentResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetAssessmentResponse' 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:
--
-- 'assessmentTargets', 'getAssessmentResponse_assessmentTargets' - List of criteria for assessment.
--
-- 'dataCollectionDetails', 'getAssessmentResponse_dataCollectionDetails' - Detailed information about the assessment.
--
-- 'id', 'getAssessmentResponse_id' - The ID for the specific assessment task.
--
-- 'httpStatus', 'getAssessmentResponse_httpStatus' - The response's http status code.
newGetAssessmentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAssessmentResponse
newGetAssessmentResponse :: Int -> GetAssessmentResponse
newGetAssessmentResponse Int
pHttpStatus_ =
  GetAssessmentResponse'
    { $sel:assessmentTargets:GetAssessmentResponse' :: Maybe [AssessmentTarget]
assessmentTargets =
        forall a. Maybe a
Prelude.Nothing,
      $sel:dataCollectionDetails:GetAssessmentResponse' :: Maybe DataCollectionDetails
dataCollectionDetails = forall a. Maybe a
Prelude.Nothing,
      $sel:id:GetAssessmentResponse' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAssessmentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | List of criteria for assessment.
getAssessmentResponse_assessmentTargets :: Lens.Lens' GetAssessmentResponse (Prelude.Maybe [AssessmentTarget])
getAssessmentResponse_assessmentTargets :: Lens' GetAssessmentResponse (Maybe [AssessmentTarget])
getAssessmentResponse_assessmentTargets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAssessmentResponse' {Maybe [AssessmentTarget]
assessmentTargets :: Maybe [AssessmentTarget]
$sel:assessmentTargets:GetAssessmentResponse' :: GetAssessmentResponse -> Maybe [AssessmentTarget]
assessmentTargets} -> Maybe [AssessmentTarget]
assessmentTargets) (\s :: GetAssessmentResponse
s@GetAssessmentResponse' {} Maybe [AssessmentTarget]
a -> GetAssessmentResponse
s {$sel:assessmentTargets:GetAssessmentResponse' :: Maybe [AssessmentTarget]
assessmentTargets = Maybe [AssessmentTarget]
a} :: GetAssessmentResponse) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Detailed information about the assessment.
getAssessmentResponse_dataCollectionDetails :: Lens.Lens' GetAssessmentResponse (Prelude.Maybe DataCollectionDetails)
getAssessmentResponse_dataCollectionDetails :: Lens' GetAssessmentResponse (Maybe DataCollectionDetails)
getAssessmentResponse_dataCollectionDetails = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAssessmentResponse' {Maybe DataCollectionDetails
dataCollectionDetails :: Maybe DataCollectionDetails
$sel:dataCollectionDetails:GetAssessmentResponse' :: GetAssessmentResponse -> Maybe DataCollectionDetails
dataCollectionDetails} -> Maybe DataCollectionDetails
dataCollectionDetails) (\s :: GetAssessmentResponse
s@GetAssessmentResponse' {} Maybe DataCollectionDetails
a -> GetAssessmentResponse
s {$sel:dataCollectionDetails:GetAssessmentResponse' :: Maybe DataCollectionDetails
dataCollectionDetails = Maybe DataCollectionDetails
a} :: GetAssessmentResponse)

-- | The ID for the specific assessment task.
getAssessmentResponse_id :: Lens.Lens' GetAssessmentResponse (Prelude.Maybe Prelude.Text)
getAssessmentResponse_id :: Lens' GetAssessmentResponse (Maybe Text)
getAssessmentResponse_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAssessmentResponse' {Maybe Text
id :: Maybe Text
$sel:id:GetAssessmentResponse' :: GetAssessmentResponse -> Maybe Text
id} -> Maybe Text
id) (\s :: GetAssessmentResponse
s@GetAssessmentResponse' {} Maybe Text
a -> GetAssessmentResponse
s {$sel:id:GetAssessmentResponse' :: Maybe Text
id = Maybe Text
a} :: GetAssessmentResponse)

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

instance Prelude.NFData GetAssessmentResponse where
  rnf :: GetAssessmentResponse -> ()
rnf GetAssessmentResponse' {Int
Maybe [AssessmentTarget]
Maybe Text
Maybe DataCollectionDetails
httpStatus :: Int
id :: Maybe Text
dataCollectionDetails :: Maybe DataCollectionDetails
assessmentTargets :: Maybe [AssessmentTarget]
$sel:httpStatus:GetAssessmentResponse' :: GetAssessmentResponse -> Int
$sel:id:GetAssessmentResponse' :: GetAssessmentResponse -> Maybe Text
$sel:dataCollectionDetails:GetAssessmentResponse' :: GetAssessmentResponse -> Maybe DataCollectionDetails
$sel:assessmentTargets:GetAssessmentResponse' :: GetAssessmentResponse -> Maybe [AssessmentTarget]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AssessmentTarget]
assessmentTargets
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DataCollectionDetails
dataCollectionDetails
      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 Int
httpStatus