{-# 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.UndeploySystemInstance
-- 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)
--
-- Removes a system instance from its target (Cloud or Greengrass).
module Amazonka.IoTThingsGraph.UndeploySystemInstance
  ( -- * Creating a Request
    UndeploySystemInstance (..),
    newUndeploySystemInstance,

    -- * Request Lenses
    undeploySystemInstance_id,

    -- * Destructuring the Response
    UndeploySystemInstanceResponse (..),
    newUndeploySystemInstanceResponse,

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

-- |
-- Create a value of 'UndeploySystemInstance' 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', 'undeploySystemInstance_id' - The ID of the system instance to remove from its target.
newUndeploySystemInstance ::
  UndeploySystemInstance
newUndeploySystemInstance :: UndeploySystemInstance
newUndeploySystemInstance =
  UndeploySystemInstance' :: Maybe Text -> UndeploySystemInstance
UndeploySystemInstance' {$sel:id:UndeploySystemInstance' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The ID of the system instance to remove from its target.
undeploySystemInstance_id :: Lens.Lens' UndeploySystemInstance (Prelude.Maybe Prelude.Text)
undeploySystemInstance_id :: (Maybe Text -> f (Maybe Text))
-> UndeploySystemInstance -> f UndeploySystemInstance
undeploySystemInstance_id = (UndeploySystemInstance -> Maybe Text)
-> (UndeploySystemInstance -> Maybe Text -> UndeploySystemInstance)
-> Lens
     UndeploySystemInstance
     UndeploySystemInstance
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UndeploySystemInstance' {Maybe Text
id :: Maybe Text
$sel:id:UndeploySystemInstance' :: UndeploySystemInstance -> Maybe Text
id} -> Maybe Text
id) (\s :: UndeploySystemInstance
s@UndeploySystemInstance' {} Maybe Text
a -> UndeploySystemInstance
s {$sel:id:UndeploySystemInstance' :: Maybe Text
id = Maybe Text
a} :: UndeploySystemInstance)

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

instance Prelude.NFData UndeploySystemInstance

instance Core.ToHeaders UndeploySystemInstance where
  toHeaders :: UndeploySystemInstance -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UndeploySystemInstance -> 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.UndeploySystemInstance" ::
                          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 UndeploySystemInstance where
  toJSON :: UndeploySystemInstance -> Value
toJSON UndeploySystemInstance' {Maybe Text
id :: Maybe Text
$sel:id:UndeploySystemInstance' :: UndeploySystemInstance -> 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 UndeploySystemInstance where
  toPath :: UndeploySystemInstance -> ByteString
toPath = ByteString -> UndeploySystemInstance -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newUndeploySystemInstanceResponse' smart constructor.
data UndeploySystemInstanceResponse = UndeploySystemInstanceResponse'
  { -- | An object that contains summary information about the system instance
    -- that was removed from its target.
    UndeploySystemInstanceResponse -> Maybe SystemInstanceSummary
summary :: Prelude.Maybe SystemInstanceSummary,
    -- | The response's http status code.
    UndeploySystemInstanceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UndeploySystemInstanceResponse
-> UndeploySystemInstanceResponse -> Bool
(UndeploySystemInstanceResponse
 -> UndeploySystemInstanceResponse -> Bool)
-> (UndeploySystemInstanceResponse
    -> UndeploySystemInstanceResponse -> Bool)
-> Eq UndeploySystemInstanceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UndeploySystemInstanceResponse
-> UndeploySystemInstanceResponse -> Bool
$c/= :: UndeploySystemInstanceResponse
-> UndeploySystemInstanceResponse -> Bool
== :: UndeploySystemInstanceResponse
-> UndeploySystemInstanceResponse -> Bool
$c== :: UndeploySystemInstanceResponse
-> UndeploySystemInstanceResponse -> Bool
Prelude.Eq, ReadPrec [UndeploySystemInstanceResponse]
ReadPrec UndeploySystemInstanceResponse
Int -> ReadS UndeploySystemInstanceResponse
ReadS [UndeploySystemInstanceResponse]
(Int -> ReadS UndeploySystemInstanceResponse)
-> ReadS [UndeploySystemInstanceResponse]
-> ReadPrec UndeploySystemInstanceResponse
-> ReadPrec [UndeploySystemInstanceResponse]
-> Read UndeploySystemInstanceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UndeploySystemInstanceResponse]
$creadListPrec :: ReadPrec [UndeploySystemInstanceResponse]
readPrec :: ReadPrec UndeploySystemInstanceResponse
$creadPrec :: ReadPrec UndeploySystemInstanceResponse
readList :: ReadS [UndeploySystemInstanceResponse]
$creadList :: ReadS [UndeploySystemInstanceResponse]
readsPrec :: Int -> ReadS UndeploySystemInstanceResponse
$creadsPrec :: Int -> ReadS UndeploySystemInstanceResponse
Prelude.Read, Int -> UndeploySystemInstanceResponse -> ShowS
[UndeploySystemInstanceResponse] -> ShowS
UndeploySystemInstanceResponse -> String
(Int -> UndeploySystemInstanceResponse -> ShowS)
-> (UndeploySystemInstanceResponse -> String)
-> ([UndeploySystemInstanceResponse] -> ShowS)
-> Show UndeploySystemInstanceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UndeploySystemInstanceResponse] -> ShowS
$cshowList :: [UndeploySystemInstanceResponse] -> ShowS
show :: UndeploySystemInstanceResponse -> String
$cshow :: UndeploySystemInstanceResponse -> String
showsPrec :: Int -> UndeploySystemInstanceResponse -> ShowS
$cshowsPrec :: Int -> UndeploySystemInstanceResponse -> ShowS
Prelude.Show, (forall x.
 UndeploySystemInstanceResponse
 -> Rep UndeploySystemInstanceResponse x)
-> (forall x.
    Rep UndeploySystemInstanceResponse x
    -> UndeploySystemInstanceResponse)
-> Generic UndeploySystemInstanceResponse
forall x.
Rep UndeploySystemInstanceResponse x
-> UndeploySystemInstanceResponse
forall x.
UndeploySystemInstanceResponse
-> Rep UndeploySystemInstanceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UndeploySystemInstanceResponse x
-> UndeploySystemInstanceResponse
$cfrom :: forall x.
UndeploySystemInstanceResponse
-> Rep UndeploySystemInstanceResponse x
Prelude.Generic)

-- |
-- Create a value of 'UndeploySystemInstanceResponse' 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:
--
-- 'summary', 'undeploySystemInstanceResponse_summary' - An object that contains summary information about the system instance
-- that was removed from its target.
--
-- 'httpStatus', 'undeploySystemInstanceResponse_httpStatus' - The response's http status code.
newUndeploySystemInstanceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UndeploySystemInstanceResponse
newUndeploySystemInstanceResponse :: Int -> UndeploySystemInstanceResponse
newUndeploySystemInstanceResponse Int
pHttpStatus_ =
  UndeploySystemInstanceResponse' :: Maybe SystemInstanceSummary
-> Int -> UndeploySystemInstanceResponse
UndeploySystemInstanceResponse'
    { $sel:summary:UndeploySystemInstanceResponse' :: Maybe SystemInstanceSummary
summary =
        Maybe SystemInstanceSummary
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UndeploySystemInstanceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that contains summary information about the system instance
-- that was removed from its target.
undeploySystemInstanceResponse_summary :: Lens.Lens' UndeploySystemInstanceResponse (Prelude.Maybe SystemInstanceSummary)
undeploySystemInstanceResponse_summary :: (Maybe SystemInstanceSummary -> f (Maybe SystemInstanceSummary))
-> UndeploySystemInstanceResponse
-> f UndeploySystemInstanceResponse
undeploySystemInstanceResponse_summary = (UndeploySystemInstanceResponse -> Maybe SystemInstanceSummary)
-> (UndeploySystemInstanceResponse
    -> Maybe SystemInstanceSummary -> UndeploySystemInstanceResponse)
-> Lens
     UndeploySystemInstanceResponse
     UndeploySystemInstanceResponse
     (Maybe SystemInstanceSummary)
     (Maybe SystemInstanceSummary)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UndeploySystemInstanceResponse' {Maybe SystemInstanceSummary
summary :: Maybe SystemInstanceSummary
$sel:summary:UndeploySystemInstanceResponse' :: UndeploySystemInstanceResponse -> Maybe SystemInstanceSummary
summary} -> Maybe SystemInstanceSummary
summary) (\s :: UndeploySystemInstanceResponse
s@UndeploySystemInstanceResponse' {} Maybe SystemInstanceSummary
a -> UndeploySystemInstanceResponse
s {$sel:summary:UndeploySystemInstanceResponse' :: Maybe SystemInstanceSummary
summary = Maybe SystemInstanceSummary
a} :: UndeploySystemInstanceResponse)

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

instance
  Prelude.NFData
    UndeploySystemInstanceResponse