{-# 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.DeleteSchema
-- 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)
--
-- Deletes a schema. Before deleting a schema, you must delete all datasets
-- referencing the schema. For more information on schemas, see
-- CreateSchema.
module Amazonka.Personalize.DeleteSchema
  ( -- * Creating a Request
    DeleteSchema (..),
    newDeleteSchema,

    -- * Request Lenses
    deleteSchema_schemaArn,

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

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

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

instance Core.AWSRequest DeleteSchema where
  type AWSResponse DeleteSchema = DeleteSchemaResponse
  request :: DeleteSchema -> Request DeleteSchema
request = Service -> DeleteSchema -> Request DeleteSchema
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteSchema
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteSchema)))
response = AWSResponse DeleteSchema
-> Logger
-> Service
-> Proxy DeleteSchema
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteSchema)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeleteSchema
DeleteSchemaResponse
DeleteSchemaResponse'

instance Prelude.Hashable DeleteSchema

instance Prelude.NFData DeleteSchema

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

instance Core.ToJSON DeleteSchema where
  toJSON :: DeleteSchema -> Value
toJSON DeleteSchema' {Text
schemaArn :: Text
$sel:schemaArn:DeleteSchema' :: DeleteSchema -> 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 DeleteSchema where
  toPath :: DeleteSchema -> ByteString
toPath = ByteString -> DeleteSchema -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DeleteSchemaResponse' 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.
newDeleteSchemaResponse ::
  DeleteSchemaResponse
newDeleteSchemaResponse :: DeleteSchemaResponse
newDeleteSchemaResponse = DeleteSchemaResponse
DeleteSchemaResponse'

instance Prelude.NFData DeleteSchemaResponse