{-# 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.Personalize.DescribeSolution
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes a solution. For more information on solutions, see
-- <https://docs.aws.amazon.com/personalize/latest/dg/API_CreateSolution.html CreateSolution>.
module Amazonka.Personalize.DescribeSolution
  ( -- * Creating a Request
    DescribeSolution (..),
    newDescribeSolution,

    -- * Request Lenses
    describeSolution_solutionArn,

    -- * Destructuring the Response
    DescribeSolutionResponse (..),
    newDescribeSolutionResponse,

    -- * Response Lenses
    describeSolutionResponse_solution,
    describeSolutionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeSolution' smart constructor.
data DescribeSolution = DescribeSolution'
  { -- | The Amazon Resource Name (ARN) of the solution to describe.
    DescribeSolution -> Text
solutionArn :: Prelude.Text
  }
  deriving (DescribeSolution -> DescribeSolution -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSolution -> DescribeSolution -> Bool
$c/= :: DescribeSolution -> DescribeSolution -> Bool
== :: DescribeSolution -> DescribeSolution -> Bool
$c== :: DescribeSolution -> DescribeSolution -> Bool
Prelude.Eq, ReadPrec [DescribeSolution]
ReadPrec DescribeSolution
Int -> ReadS DescribeSolution
ReadS [DescribeSolution]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeSolution]
$creadListPrec :: ReadPrec [DescribeSolution]
readPrec :: ReadPrec DescribeSolution
$creadPrec :: ReadPrec DescribeSolution
readList :: ReadS [DescribeSolution]
$creadList :: ReadS [DescribeSolution]
readsPrec :: Int -> ReadS DescribeSolution
$creadsPrec :: Int -> ReadS DescribeSolution
Prelude.Read, Int -> DescribeSolution -> ShowS
[DescribeSolution] -> ShowS
DescribeSolution -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSolution] -> ShowS
$cshowList :: [DescribeSolution] -> ShowS
show :: DescribeSolution -> String
$cshow :: DescribeSolution -> String
showsPrec :: Int -> DescribeSolution -> ShowS
$cshowsPrec :: Int -> DescribeSolution -> ShowS
Prelude.Show, forall x. Rep DescribeSolution x -> DescribeSolution
forall x. DescribeSolution -> Rep DescribeSolution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeSolution x -> DescribeSolution
$cfrom :: forall x. DescribeSolution -> Rep DescribeSolution x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSolution' 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:
--
-- 'solutionArn', 'describeSolution_solutionArn' - The Amazon Resource Name (ARN) of the solution to describe.
newDescribeSolution ::
  -- | 'solutionArn'
  Prelude.Text ->
  DescribeSolution
newDescribeSolution :: Text -> DescribeSolution
newDescribeSolution Text
pSolutionArn_ =
  DescribeSolution' {$sel:solutionArn:DescribeSolution' :: Text
solutionArn = Text
pSolutionArn_}

-- | The Amazon Resource Name (ARN) of the solution to describe.
describeSolution_solutionArn :: Lens.Lens' DescribeSolution Prelude.Text
describeSolution_solutionArn :: Lens' DescribeSolution Text
describeSolution_solutionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSolution' {Text
solutionArn :: Text
$sel:solutionArn:DescribeSolution' :: DescribeSolution -> Text
solutionArn} -> Text
solutionArn) (\s :: DescribeSolution
s@DescribeSolution' {} Text
a -> DescribeSolution
s {$sel:solutionArn:DescribeSolution' :: Text
solutionArn = Text
a} :: DescribeSolution)

instance Core.AWSRequest DescribeSolution where
  type
    AWSResponse DescribeSolution =
      DescribeSolutionResponse
  request :: (Service -> Service)
-> DescribeSolution -> Request DescribeSolution
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 DescribeSolution
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeSolution)))
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 Solution -> Int -> DescribeSolutionResponse
DescribeSolutionResponse'
            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
"solution")
            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 DescribeSolution where
  hashWithSalt :: Int -> DescribeSolution -> Int
hashWithSalt Int
_salt DescribeSolution' {Text
solutionArn :: Text
$sel:solutionArn:DescribeSolution' :: DescribeSolution -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
solutionArn

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

instance Data.ToHeaders DescribeSolution where
  toHeaders :: DescribeSolution -> 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
"AmazonPersonalize.DescribeSolution" ::
                          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 DescribeSolution where
  toJSON :: DescribeSolution -> Value
toJSON DescribeSolution' {Text
solutionArn :: Text
$sel:solutionArn:DescribeSolution' :: DescribeSolution -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"solutionArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
solutionArn)]
      )

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

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

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

-- |
-- Create a value of 'DescribeSolutionResponse' 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:
--
-- 'solution', 'describeSolutionResponse_solution' - An object that describes the solution.
--
-- 'httpStatus', 'describeSolutionResponse_httpStatus' - The response's http status code.
newDescribeSolutionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeSolutionResponse
newDescribeSolutionResponse :: Int -> DescribeSolutionResponse
newDescribeSolutionResponse Int
pHttpStatus_ =
  DescribeSolutionResponse'
    { $sel:solution:DescribeSolutionResponse' :: Maybe Solution
solution =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeSolutionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that describes the solution.
describeSolutionResponse_solution :: Lens.Lens' DescribeSolutionResponse (Prelude.Maybe Solution)
describeSolutionResponse_solution :: Lens' DescribeSolutionResponse (Maybe Solution)
describeSolutionResponse_solution = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSolutionResponse' {Maybe Solution
solution :: Maybe Solution
$sel:solution:DescribeSolutionResponse' :: DescribeSolutionResponse -> Maybe Solution
solution} -> Maybe Solution
solution) (\s :: DescribeSolutionResponse
s@DescribeSolutionResponse' {} Maybe Solution
a -> DescribeSolutionResponse
s {$sel:solution:DescribeSolutionResponse' :: Maybe Solution
solution = Maybe Solution
a} :: DescribeSolutionResponse)

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

instance Prelude.NFData DescribeSolutionResponse where
  rnf :: DescribeSolutionResponse -> ()
rnf DescribeSolutionResponse' {Int
Maybe Solution
httpStatus :: Int
solution :: Maybe Solution
$sel:httpStatus:DescribeSolutionResponse' :: DescribeSolutionResponse -> Int
$sel:solution:DescribeSolutionResponse' :: DescribeSolutionResponse -> Maybe Solution
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Solution
solution
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus