{-# 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-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)
--
-- Describes a solution. For more information on solutions, see
-- 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.Lens as Lens
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
(DescribeSolution -> DescribeSolution -> Bool)
-> (DescribeSolution -> DescribeSolution -> Bool)
-> Eq DescribeSolution
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]
(Int -> ReadS DescribeSolution)
-> ReadS [DescribeSolution]
-> ReadPrec DescribeSolution
-> ReadPrec [DescribeSolution]
-> Read 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
(Int -> DescribeSolution -> ShowS)
-> (DescribeSolution -> String)
-> ([DescribeSolution] -> ShowS)
-> Show DescribeSolution
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. DescribeSolution -> Rep DescribeSolution x)
-> (forall x. Rep DescribeSolution x -> DescribeSolution)
-> Generic DescribeSolution
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' :: Text -> DescribeSolution
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 :: (Text -> f Text) -> DescribeSolution -> f DescribeSolution
describeSolution_solutionArn = (DescribeSolution -> Text)
-> (DescribeSolution -> Text -> DescribeSolution)
-> Lens DescribeSolution DescribeSolution Text Text
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 :: DescribeSolution -> Request DescribeSolution
request = Service -> DescribeSolution -> Request DescribeSolution
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeSolution
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeSolution)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeSolution))
-> Logger
-> Service
-> Proxy DescribeSolution
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeSolution)))
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 Solution -> Int -> DescribeSolutionResponse
DescribeSolutionResponse'
            (Maybe Solution -> Int -> DescribeSolutionResponse)
-> Either String (Maybe Solution)
-> Either String (Int -> DescribeSolutionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Solution)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"solution")
            Either String (Int -> DescribeSolutionResponse)
-> Either String Int -> Either String DescribeSolutionResponse
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 DescribeSolution

instance Prelude.NFData DescribeSolution

instance Core.ToHeaders DescribeSolution where
  toHeaders :: DescribeSolution -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeSolution -> 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
"AmazonPersonalize.DescribeSolution" ::
                          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 DescribeSolution where
  toJSON :: DescribeSolution -> Value
toJSON DescribeSolution' {Text
solutionArn :: Text
$sel:solutionArn:DescribeSolution' :: DescribeSolution -> 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
"solutionArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
solutionArn)]
      )

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

instance Core.ToQuery DescribeSolution where
  toQuery :: DescribeSolution -> QueryString
toQuery = QueryString -> DescribeSolution -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DescribeSolutionResponse -> DescribeSolutionResponse -> Bool)
-> (DescribeSolutionResponse -> DescribeSolutionResponse -> Bool)
-> Eq DescribeSolutionResponse
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]
(Int -> ReadS DescribeSolutionResponse)
-> ReadS [DescribeSolutionResponse]
-> ReadPrec DescribeSolutionResponse
-> ReadPrec [DescribeSolutionResponse]
-> Read 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
(Int -> DescribeSolutionResponse -> ShowS)
-> (DescribeSolutionResponse -> String)
-> ([DescribeSolutionResponse] -> ShowS)
-> Show DescribeSolutionResponse
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.
 DescribeSolutionResponse -> Rep DescribeSolutionResponse x)
-> (forall x.
    Rep DescribeSolutionResponse x -> DescribeSolutionResponse)
-> Generic DescribeSolutionResponse
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' :: Maybe Solution -> Int -> DescribeSolutionResponse
DescribeSolutionResponse'
    { $sel:solution:DescribeSolutionResponse' :: Maybe Solution
solution =
        Maybe 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 :: (Maybe Solution -> f (Maybe Solution))
-> DescribeSolutionResponse -> f DescribeSolutionResponse
describeSolutionResponse_solution = (DescribeSolutionResponse -> Maybe Solution)
-> (DescribeSolutionResponse
    -> Maybe Solution -> DescribeSolutionResponse)
-> Lens
     DescribeSolutionResponse
     DescribeSolutionResponse
     (Maybe Solution)
     (Maybe 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 :: (Int -> f Int)
-> DescribeSolutionResponse -> f DescribeSolutionResponse
describeSolutionResponse_httpStatus = (DescribeSolutionResponse -> Int)
-> (DescribeSolutionResponse -> Int -> DescribeSolutionResponse)
-> Lens DescribeSolutionResponse DescribeSolutionResponse Int Int
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