{-# 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.DeleteSystemInstance
-- 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 system instance. Only system instances that have never been
-- deployed, or that have been undeployed can be deleted.
--
-- Users can create a new system instance that has the same ID as a deleted
-- system instance.
module Amazonka.IoTThingsGraph.DeleteSystemInstance
  ( -- * Creating a Request
    DeleteSystemInstance (..),
    newDeleteSystemInstance,

    -- * Request Lenses
    deleteSystemInstance_id,

    -- * Destructuring the Response
    DeleteSystemInstanceResponse (..),
    newDeleteSystemInstanceResponse,

    -- * Response Lenses
    deleteSystemInstanceResponse_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:/ 'newDeleteSystemInstance' smart constructor.
data DeleteSystemInstance = DeleteSystemInstance'
  { -- | The ID of the system instance to be deleted.
    DeleteSystemInstance -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (DeleteSystemInstance -> DeleteSystemInstance -> Bool
(DeleteSystemInstance -> DeleteSystemInstance -> Bool)
-> (DeleteSystemInstance -> DeleteSystemInstance -> Bool)
-> Eq DeleteSystemInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteSystemInstance -> DeleteSystemInstance -> Bool
$c/= :: DeleteSystemInstance -> DeleteSystemInstance -> Bool
== :: DeleteSystemInstance -> DeleteSystemInstance -> Bool
$c== :: DeleteSystemInstance -> DeleteSystemInstance -> Bool
Prelude.Eq, ReadPrec [DeleteSystemInstance]
ReadPrec DeleteSystemInstance
Int -> ReadS DeleteSystemInstance
ReadS [DeleteSystemInstance]
(Int -> ReadS DeleteSystemInstance)
-> ReadS [DeleteSystemInstance]
-> ReadPrec DeleteSystemInstance
-> ReadPrec [DeleteSystemInstance]
-> Read DeleteSystemInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteSystemInstance]
$creadListPrec :: ReadPrec [DeleteSystemInstance]
readPrec :: ReadPrec DeleteSystemInstance
$creadPrec :: ReadPrec DeleteSystemInstance
readList :: ReadS [DeleteSystemInstance]
$creadList :: ReadS [DeleteSystemInstance]
readsPrec :: Int -> ReadS DeleteSystemInstance
$creadsPrec :: Int -> ReadS DeleteSystemInstance
Prelude.Read, Int -> DeleteSystemInstance -> ShowS
[DeleteSystemInstance] -> ShowS
DeleteSystemInstance -> String
(Int -> DeleteSystemInstance -> ShowS)
-> (DeleteSystemInstance -> String)
-> ([DeleteSystemInstance] -> ShowS)
-> Show DeleteSystemInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteSystemInstance] -> ShowS
$cshowList :: [DeleteSystemInstance] -> ShowS
show :: DeleteSystemInstance -> String
$cshow :: DeleteSystemInstance -> String
showsPrec :: Int -> DeleteSystemInstance -> ShowS
$cshowsPrec :: Int -> DeleteSystemInstance -> ShowS
Prelude.Show, (forall x. DeleteSystemInstance -> Rep DeleteSystemInstance x)
-> (forall x. Rep DeleteSystemInstance x -> DeleteSystemInstance)
-> Generic DeleteSystemInstance
forall x. Rep DeleteSystemInstance x -> DeleteSystemInstance
forall x. DeleteSystemInstance -> Rep DeleteSystemInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteSystemInstance x -> DeleteSystemInstance
$cfrom :: forall x. DeleteSystemInstance -> Rep DeleteSystemInstance x
Prelude.Generic)

-- |
-- Create a value of 'DeleteSystemInstance' 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:
--
-- 'id', 'deleteSystemInstance_id' - The ID of the system instance to be deleted.
newDeleteSystemInstance ::
  DeleteSystemInstance
newDeleteSystemInstance :: DeleteSystemInstance
newDeleteSystemInstance =
  DeleteSystemInstance' :: Maybe Text -> DeleteSystemInstance
DeleteSystemInstance' {$sel:id:DeleteSystemInstance' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The ID of the system instance to be deleted.
deleteSystemInstance_id :: Lens.Lens' DeleteSystemInstance (Prelude.Maybe Prelude.Text)
deleteSystemInstance_id :: (Maybe Text -> f (Maybe Text))
-> DeleteSystemInstance -> f DeleteSystemInstance
deleteSystemInstance_id = (DeleteSystemInstance -> Maybe Text)
-> (DeleteSystemInstance -> Maybe Text -> DeleteSystemInstance)
-> Lens
     DeleteSystemInstance DeleteSystemInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSystemInstance' {Maybe Text
id :: Maybe Text
$sel:id:DeleteSystemInstance' :: DeleteSystemInstance -> Maybe Text
id} -> Maybe Text
id) (\s :: DeleteSystemInstance
s@DeleteSystemInstance' {} Maybe Text
a -> DeleteSystemInstance
s {$sel:id:DeleteSystemInstance' :: Maybe Text
id = Maybe Text
a} :: DeleteSystemInstance)

instance Core.AWSRequest DeleteSystemInstance where
  type
    AWSResponse DeleteSystemInstance =
      DeleteSystemInstanceResponse
  request :: DeleteSystemInstance -> Request DeleteSystemInstance
request = Service -> DeleteSystemInstance -> Request DeleteSystemInstance
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteSystemInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteSystemInstance)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteSystemInstance))
-> Logger
-> Service
-> Proxy DeleteSystemInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteSystemInstance)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteSystemInstanceResponse
DeleteSystemInstanceResponse'
            (Int -> DeleteSystemInstanceResponse)
-> Either String Int -> Either String DeleteSystemInstanceResponse
forall (f :: * -> *) a b. Functor 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 DeleteSystemInstance

instance Prelude.NFData DeleteSystemInstance

instance Core.ToHeaders DeleteSystemInstance where
  toHeaders :: DeleteSystemInstance -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteSystemInstance -> 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.DeleteSystemInstance" ::
                          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 DeleteSystemInstance where
  toJSON :: DeleteSystemInstance -> Value
toJSON DeleteSystemInstance' {Maybe Text
id :: Maybe Text
$sel:id:DeleteSystemInstance' :: DeleteSystemInstance -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ([Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes [(Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
id])

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

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

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

-- |
-- Create a value of 'DeleteSystemInstanceResponse' 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:
--
-- 'httpStatus', 'deleteSystemInstanceResponse_httpStatus' - The response's http status code.
newDeleteSystemInstanceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteSystemInstanceResponse
newDeleteSystemInstanceResponse :: Int -> DeleteSystemInstanceResponse
newDeleteSystemInstanceResponse Int
pHttpStatus_ =
  DeleteSystemInstanceResponse' :: Int -> DeleteSystemInstanceResponse
DeleteSystemInstanceResponse'
    { $sel:httpStatus:DeleteSystemInstanceResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeleteSystemInstanceResponse