{-# 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.DescribeSchema
-- 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 schema. For more information on schemas, see CreateSchema.
module Amazonka.Personalize.DescribeSchema
  ( -- * Creating a Request
    DescribeSchema (..),
    newDescribeSchema,

    -- * Request Lenses
    describeSchema_schemaArn,

    -- * Destructuring the Response
    DescribeSchemaResponse (..),
    newDescribeSchemaResponse,

    -- * Response Lenses
    describeSchemaResponse_schema,
    describeSchemaResponse_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:/ 'newDescribeSchema' smart constructor.
data DescribeSchema = DescribeSchema'
  { -- | The Amazon Resource Name (ARN) of the schema to retrieve.
    DescribeSchema -> Text
schemaArn :: Prelude.Text
  }
  deriving (DescribeSchema -> DescribeSchema -> Bool
(DescribeSchema -> DescribeSchema -> Bool)
-> (DescribeSchema -> DescribeSchema -> Bool) -> Eq DescribeSchema
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSchema -> DescribeSchema -> Bool
$c/= :: DescribeSchema -> DescribeSchema -> Bool
== :: DescribeSchema -> DescribeSchema -> Bool
$c== :: DescribeSchema -> DescribeSchema -> Bool
Prelude.Eq, ReadPrec [DescribeSchema]
ReadPrec DescribeSchema
Int -> ReadS DescribeSchema
ReadS [DescribeSchema]
(Int -> ReadS DescribeSchema)
-> ReadS [DescribeSchema]
-> ReadPrec DescribeSchema
-> ReadPrec [DescribeSchema]
-> Read DescribeSchema
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeSchema]
$creadListPrec :: ReadPrec [DescribeSchema]
readPrec :: ReadPrec DescribeSchema
$creadPrec :: ReadPrec DescribeSchema
readList :: ReadS [DescribeSchema]
$creadList :: ReadS [DescribeSchema]
readsPrec :: Int -> ReadS DescribeSchema
$creadsPrec :: Int -> ReadS DescribeSchema
Prelude.Read, Int -> DescribeSchema -> ShowS
[DescribeSchema] -> ShowS
DescribeSchema -> String
(Int -> DescribeSchema -> ShowS)
-> (DescribeSchema -> String)
-> ([DescribeSchema] -> ShowS)
-> Show DescribeSchema
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSchema] -> ShowS
$cshowList :: [DescribeSchema] -> ShowS
show :: DescribeSchema -> String
$cshow :: DescribeSchema -> String
showsPrec :: Int -> DescribeSchema -> ShowS
$cshowsPrec :: Int -> DescribeSchema -> ShowS
Prelude.Show, (forall x. DescribeSchema -> Rep DescribeSchema x)
-> (forall x. Rep DescribeSchema x -> DescribeSchema)
-> Generic DescribeSchema
forall x. Rep DescribeSchema x -> DescribeSchema
forall x. DescribeSchema -> Rep DescribeSchema x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeSchema x -> DescribeSchema
$cfrom :: forall x. DescribeSchema -> Rep DescribeSchema x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSchema' 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:
--
-- 'schemaArn', 'describeSchema_schemaArn' - The Amazon Resource Name (ARN) of the schema to retrieve.
newDescribeSchema ::
  -- | 'schemaArn'
  Prelude.Text ->
  DescribeSchema
newDescribeSchema :: Text -> DescribeSchema
newDescribeSchema Text
pSchemaArn_ =
  DescribeSchema' :: Text -> DescribeSchema
DescribeSchema' {$sel:schemaArn:DescribeSchema' :: Text
schemaArn = Text
pSchemaArn_}

-- | The Amazon Resource Name (ARN) of the schema to retrieve.
describeSchema_schemaArn :: Lens.Lens' DescribeSchema Prelude.Text
describeSchema_schemaArn :: (Text -> f Text) -> DescribeSchema -> f DescribeSchema
describeSchema_schemaArn = (DescribeSchema -> Text)
-> (DescribeSchema -> Text -> DescribeSchema)
-> Lens DescribeSchema DescribeSchema Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSchema' {Text
schemaArn :: Text
$sel:schemaArn:DescribeSchema' :: DescribeSchema -> Text
schemaArn} -> Text
schemaArn) (\s :: DescribeSchema
s@DescribeSchema' {} Text
a -> DescribeSchema
s {$sel:schemaArn:DescribeSchema' :: Text
schemaArn = Text
a} :: DescribeSchema)

instance Core.AWSRequest DescribeSchema where
  type
    AWSResponse DescribeSchema =
      DescribeSchemaResponse
  request :: DescribeSchema -> Request DescribeSchema
request = Service -> DescribeSchema -> Request DescribeSchema
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeSchema
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeSchema)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeSchema))
-> Logger
-> Service
-> Proxy DescribeSchema
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeSchema)))
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 DatasetSchema -> Int -> DescribeSchemaResponse
DescribeSchemaResponse'
            (Maybe DatasetSchema -> Int -> DescribeSchemaResponse)
-> Either String (Maybe DatasetSchema)
-> Either String (Int -> DescribeSchemaResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DatasetSchema)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"schema")
            Either String (Int -> DescribeSchemaResponse)
-> Either String Int -> Either String DescribeSchemaResponse
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 DescribeSchema

instance Prelude.NFData DescribeSchema

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

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

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

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

-- |
-- Create a value of 'DescribeSchemaResponse' 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:
--
-- 'schema', 'describeSchemaResponse_schema' - The requested schema.
--
-- 'httpStatus', 'describeSchemaResponse_httpStatus' - The response's http status code.
newDescribeSchemaResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeSchemaResponse
newDescribeSchemaResponse :: Int -> DescribeSchemaResponse
newDescribeSchemaResponse Int
pHttpStatus_ =
  DescribeSchemaResponse' :: Maybe DatasetSchema -> Int -> DescribeSchemaResponse
DescribeSchemaResponse'
    { $sel:schema:DescribeSchemaResponse' :: Maybe DatasetSchema
schema = Maybe DatasetSchema
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeSchemaResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The requested schema.
describeSchemaResponse_schema :: Lens.Lens' DescribeSchemaResponse (Prelude.Maybe DatasetSchema)
describeSchemaResponse_schema :: (Maybe DatasetSchema -> f (Maybe DatasetSchema))
-> DescribeSchemaResponse -> f DescribeSchemaResponse
describeSchemaResponse_schema = (DescribeSchemaResponse -> Maybe DatasetSchema)
-> (DescribeSchemaResponse
    -> Maybe DatasetSchema -> DescribeSchemaResponse)
-> Lens
     DescribeSchemaResponse
     DescribeSchemaResponse
     (Maybe DatasetSchema)
     (Maybe DatasetSchema)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSchemaResponse' {Maybe DatasetSchema
schema :: Maybe DatasetSchema
$sel:schema:DescribeSchemaResponse' :: DescribeSchemaResponse -> Maybe DatasetSchema
schema} -> Maybe DatasetSchema
schema) (\s :: DescribeSchemaResponse
s@DescribeSchemaResponse' {} Maybe DatasetSchema
a -> DescribeSchemaResponse
s {$sel:schema:DescribeSchemaResponse' :: Maybe DatasetSchema
schema = Maybe DatasetSchema
a} :: DescribeSchemaResponse)

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

instance Prelude.NFData DescribeSchemaResponse