{-# 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.IoTThingsGraph.DeleteNamespace
-- 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 the specified namespace. This action deletes all of the entities
-- in the namespace. Delete the systems and flows that use entities in the
-- namespace before performing this action.
module Amazonka.IoTThingsGraph.DeleteNamespace
  ( -- * Creating a Request
    DeleteNamespace (..),
    newDeleteNamespace,

    -- * Destructuring the Response
    DeleteNamespaceResponse (..),
    newDeleteNamespaceResponse,

    -- * Response Lenses
    deleteNamespaceResponse_namespaceArn,
    deleteNamespaceResponse_namespaceName,
    deleteNamespaceResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTThingsGraph.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

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

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

instance Prelude.NFData DeleteNamespace

instance Core.ToHeaders DeleteNamespace where
  toHeaders :: DeleteNamespace -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteNamespace -> 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
"IotThingsGraphFrontEndService.DeleteNamespace" ::
                          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 DeleteNamespace where
  toJSON :: DeleteNamespace -> Value
toJSON = Value -> DeleteNamespace -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

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

-- | /See:/ 'newDeleteNamespaceResponse' smart constructor.
data DeleteNamespaceResponse = DeleteNamespaceResponse'
  { -- | The ARN of the namespace to be deleted.
    DeleteNamespaceResponse -> Maybe Text
namespaceArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the namespace to be deleted.
    DeleteNamespaceResponse -> Maybe Text
namespaceName :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteNamespaceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteNamespaceResponse -> DeleteNamespaceResponse -> Bool
(DeleteNamespaceResponse -> DeleteNamespaceResponse -> Bool)
-> (DeleteNamespaceResponse -> DeleteNamespaceResponse -> Bool)
-> Eq DeleteNamespaceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteNamespaceResponse -> DeleteNamespaceResponse -> Bool
$c/= :: DeleteNamespaceResponse -> DeleteNamespaceResponse -> Bool
== :: DeleteNamespaceResponse -> DeleteNamespaceResponse -> Bool
$c== :: DeleteNamespaceResponse -> DeleteNamespaceResponse -> Bool
Prelude.Eq, ReadPrec [DeleteNamespaceResponse]
ReadPrec DeleteNamespaceResponse
Int -> ReadS DeleteNamespaceResponse
ReadS [DeleteNamespaceResponse]
(Int -> ReadS DeleteNamespaceResponse)
-> ReadS [DeleteNamespaceResponse]
-> ReadPrec DeleteNamespaceResponse
-> ReadPrec [DeleteNamespaceResponse]
-> Read DeleteNamespaceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteNamespaceResponse]
$creadListPrec :: ReadPrec [DeleteNamespaceResponse]
readPrec :: ReadPrec DeleteNamespaceResponse
$creadPrec :: ReadPrec DeleteNamespaceResponse
readList :: ReadS [DeleteNamespaceResponse]
$creadList :: ReadS [DeleteNamespaceResponse]
readsPrec :: Int -> ReadS DeleteNamespaceResponse
$creadsPrec :: Int -> ReadS DeleteNamespaceResponse
Prelude.Read, Int -> DeleteNamespaceResponse -> ShowS
[DeleteNamespaceResponse] -> ShowS
DeleteNamespaceResponse -> String
(Int -> DeleteNamespaceResponse -> ShowS)
-> (DeleteNamespaceResponse -> String)
-> ([DeleteNamespaceResponse] -> ShowS)
-> Show DeleteNamespaceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteNamespaceResponse] -> ShowS
$cshowList :: [DeleteNamespaceResponse] -> ShowS
show :: DeleteNamespaceResponse -> String
$cshow :: DeleteNamespaceResponse -> String
showsPrec :: Int -> DeleteNamespaceResponse -> ShowS
$cshowsPrec :: Int -> DeleteNamespaceResponse -> ShowS
Prelude.Show, (forall x.
 DeleteNamespaceResponse -> Rep DeleteNamespaceResponse x)
-> (forall x.
    Rep DeleteNamespaceResponse x -> DeleteNamespaceResponse)
-> Generic DeleteNamespaceResponse
forall x. Rep DeleteNamespaceResponse x -> DeleteNamespaceResponse
forall x. DeleteNamespaceResponse -> Rep DeleteNamespaceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteNamespaceResponse x -> DeleteNamespaceResponse
$cfrom :: forall x. DeleteNamespaceResponse -> Rep DeleteNamespaceResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteNamespaceResponse' 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:
--
-- 'namespaceArn', 'deleteNamespaceResponse_namespaceArn' - The ARN of the namespace to be deleted.
--
-- 'namespaceName', 'deleteNamespaceResponse_namespaceName' - The name of the namespace to be deleted.
--
-- 'httpStatus', 'deleteNamespaceResponse_httpStatus' - The response's http status code.
newDeleteNamespaceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteNamespaceResponse
newDeleteNamespaceResponse :: Int -> DeleteNamespaceResponse
newDeleteNamespaceResponse Int
pHttpStatus_ =
  DeleteNamespaceResponse' :: Maybe Text -> Maybe Text -> Int -> DeleteNamespaceResponse
DeleteNamespaceResponse'
    { $sel:namespaceArn:DeleteNamespaceResponse' :: Maybe Text
namespaceArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:namespaceName:DeleteNamespaceResponse' :: Maybe Text
namespaceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteNamespaceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the namespace to be deleted.
deleteNamespaceResponse_namespaceArn :: Lens.Lens' DeleteNamespaceResponse (Prelude.Maybe Prelude.Text)
deleteNamespaceResponse_namespaceArn :: (Maybe Text -> f (Maybe Text))
-> DeleteNamespaceResponse -> f DeleteNamespaceResponse
deleteNamespaceResponse_namespaceArn = (DeleteNamespaceResponse -> Maybe Text)
-> (DeleteNamespaceResponse
    -> Maybe Text -> DeleteNamespaceResponse)
-> Lens
     DeleteNamespaceResponse
     DeleteNamespaceResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNamespaceResponse' {Maybe Text
namespaceArn :: Maybe Text
$sel:namespaceArn:DeleteNamespaceResponse' :: DeleteNamespaceResponse -> Maybe Text
namespaceArn} -> Maybe Text
namespaceArn) (\s :: DeleteNamespaceResponse
s@DeleteNamespaceResponse' {} Maybe Text
a -> DeleteNamespaceResponse
s {$sel:namespaceArn:DeleteNamespaceResponse' :: Maybe Text
namespaceArn = Maybe Text
a} :: DeleteNamespaceResponse)

-- | The name of the namespace to be deleted.
deleteNamespaceResponse_namespaceName :: Lens.Lens' DeleteNamespaceResponse (Prelude.Maybe Prelude.Text)
deleteNamespaceResponse_namespaceName :: (Maybe Text -> f (Maybe Text))
-> DeleteNamespaceResponse -> f DeleteNamespaceResponse
deleteNamespaceResponse_namespaceName = (DeleteNamespaceResponse -> Maybe Text)
-> (DeleteNamespaceResponse
    -> Maybe Text -> DeleteNamespaceResponse)
-> Lens
     DeleteNamespaceResponse
     DeleteNamespaceResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNamespaceResponse' {Maybe Text
namespaceName :: Maybe Text
$sel:namespaceName:DeleteNamespaceResponse' :: DeleteNamespaceResponse -> Maybe Text
namespaceName} -> Maybe Text
namespaceName) (\s :: DeleteNamespaceResponse
s@DeleteNamespaceResponse' {} Maybe Text
a -> DeleteNamespaceResponse
s {$sel:namespaceName:DeleteNamespaceResponse' :: Maybe Text
namespaceName = Maybe Text
a} :: DeleteNamespaceResponse)

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

instance Prelude.NFData DeleteNamespaceResponse