{-# 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.GetSystemInstance
-- 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)
--
-- Gets a system instance.
module Amazonka.IoTThingsGraph.GetSystemInstance
  ( -- * Creating a Request
    GetSystemInstance (..),
    newGetSystemInstance,

    -- * Request Lenses
    getSystemInstance_id,

    -- * Destructuring the Response
    GetSystemInstanceResponse (..),
    newGetSystemInstanceResponse,

    -- * Response Lenses
    getSystemInstanceResponse_description,
    getSystemInstanceResponse_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:/ 'newGetSystemInstance' smart constructor.
data GetSystemInstance = GetSystemInstance'
  { -- | The ID of the system deployment instance. This value is returned by
    -- @CreateSystemInstance@.
    --
    -- The ID should be in the following format.
    --
    -- @urn:tdm:REGION\/ACCOUNT ID\/default:deployment:DEPLOYMENTNAME@
    GetSystemInstance -> Text
id :: Prelude.Text
  }
  deriving (GetSystemInstance -> GetSystemInstance -> Bool
(GetSystemInstance -> GetSystemInstance -> Bool)
-> (GetSystemInstance -> GetSystemInstance -> Bool)
-> Eq GetSystemInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSystemInstance -> GetSystemInstance -> Bool
$c/= :: GetSystemInstance -> GetSystemInstance -> Bool
== :: GetSystemInstance -> GetSystemInstance -> Bool
$c== :: GetSystemInstance -> GetSystemInstance -> Bool
Prelude.Eq, ReadPrec [GetSystemInstance]
ReadPrec GetSystemInstance
Int -> ReadS GetSystemInstance
ReadS [GetSystemInstance]
(Int -> ReadS GetSystemInstance)
-> ReadS [GetSystemInstance]
-> ReadPrec GetSystemInstance
-> ReadPrec [GetSystemInstance]
-> Read GetSystemInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSystemInstance]
$creadListPrec :: ReadPrec [GetSystemInstance]
readPrec :: ReadPrec GetSystemInstance
$creadPrec :: ReadPrec GetSystemInstance
readList :: ReadS [GetSystemInstance]
$creadList :: ReadS [GetSystemInstance]
readsPrec :: Int -> ReadS GetSystemInstance
$creadsPrec :: Int -> ReadS GetSystemInstance
Prelude.Read, Int -> GetSystemInstance -> ShowS
[GetSystemInstance] -> ShowS
GetSystemInstance -> String
(Int -> GetSystemInstance -> ShowS)
-> (GetSystemInstance -> String)
-> ([GetSystemInstance] -> ShowS)
-> Show GetSystemInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSystemInstance] -> ShowS
$cshowList :: [GetSystemInstance] -> ShowS
show :: GetSystemInstance -> String
$cshow :: GetSystemInstance -> String
showsPrec :: Int -> GetSystemInstance -> ShowS
$cshowsPrec :: Int -> GetSystemInstance -> ShowS
Prelude.Show, (forall x. GetSystemInstance -> Rep GetSystemInstance x)
-> (forall x. Rep GetSystemInstance x -> GetSystemInstance)
-> Generic GetSystemInstance
forall x. Rep GetSystemInstance x -> GetSystemInstance
forall x. GetSystemInstance -> Rep GetSystemInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSystemInstance x -> GetSystemInstance
$cfrom :: forall x. GetSystemInstance -> Rep GetSystemInstance x
Prelude.Generic)

-- |
-- Create a value of 'GetSystemInstance' 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', 'getSystemInstance_id' - The ID of the system deployment instance. This value is returned by
-- @CreateSystemInstance@.
--
-- The ID should be in the following format.
--
-- @urn:tdm:REGION\/ACCOUNT ID\/default:deployment:DEPLOYMENTNAME@
newGetSystemInstance ::
  -- | 'id'
  Prelude.Text ->
  GetSystemInstance
newGetSystemInstance :: Text -> GetSystemInstance
newGetSystemInstance Text
pId_ =
  GetSystemInstance' :: Text -> GetSystemInstance
GetSystemInstance' {$sel:id:GetSystemInstance' :: Text
id = Text
pId_}

-- | The ID of the system deployment instance. This value is returned by
-- @CreateSystemInstance@.
--
-- The ID should be in the following format.
--
-- @urn:tdm:REGION\/ACCOUNT ID\/default:deployment:DEPLOYMENTNAME@
getSystemInstance_id :: Lens.Lens' GetSystemInstance Prelude.Text
getSystemInstance_id :: (Text -> f Text) -> GetSystemInstance -> f GetSystemInstance
getSystemInstance_id = (GetSystemInstance -> Text)
-> (GetSystemInstance -> Text -> GetSystemInstance)
-> Lens GetSystemInstance GetSystemInstance Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSystemInstance' {Text
id :: Text
$sel:id:GetSystemInstance' :: GetSystemInstance -> Text
id} -> Text
id) (\s :: GetSystemInstance
s@GetSystemInstance' {} Text
a -> GetSystemInstance
s {$sel:id:GetSystemInstance' :: Text
id = Text
a} :: GetSystemInstance)

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

instance Prelude.NFData GetSystemInstance

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

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

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

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

-- |
-- Create a value of 'GetSystemInstanceResponse' 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:
--
-- 'description', 'getSystemInstanceResponse_description' - An object that describes the system instance.
--
-- 'httpStatus', 'getSystemInstanceResponse_httpStatus' - The response's http status code.
newGetSystemInstanceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSystemInstanceResponse
newGetSystemInstanceResponse :: Int -> GetSystemInstanceResponse
newGetSystemInstanceResponse Int
pHttpStatus_ =
  GetSystemInstanceResponse' :: Maybe SystemInstanceDescription -> Int -> GetSystemInstanceResponse
GetSystemInstanceResponse'
    { $sel:description:GetSystemInstanceResponse' :: Maybe SystemInstanceDescription
description =
        Maybe SystemInstanceDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSystemInstanceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that describes the system instance.
getSystemInstanceResponse_description :: Lens.Lens' GetSystemInstanceResponse (Prelude.Maybe SystemInstanceDescription)
getSystemInstanceResponse_description :: (Maybe SystemInstanceDescription
 -> f (Maybe SystemInstanceDescription))
-> GetSystemInstanceResponse -> f GetSystemInstanceResponse
getSystemInstanceResponse_description = (GetSystemInstanceResponse -> Maybe SystemInstanceDescription)
-> (GetSystemInstanceResponse
    -> Maybe SystemInstanceDescription -> GetSystemInstanceResponse)
-> Lens
     GetSystemInstanceResponse
     GetSystemInstanceResponse
     (Maybe SystemInstanceDescription)
     (Maybe SystemInstanceDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSystemInstanceResponse' {Maybe SystemInstanceDescription
description :: Maybe SystemInstanceDescription
$sel:description:GetSystemInstanceResponse' :: GetSystemInstanceResponse -> Maybe SystemInstanceDescription
description} -> Maybe SystemInstanceDescription
description) (\s :: GetSystemInstanceResponse
s@GetSystemInstanceResponse' {} Maybe SystemInstanceDescription
a -> GetSystemInstanceResponse
s {$sel:description:GetSystemInstanceResponse' :: Maybe SystemInstanceDescription
description = Maybe SystemInstanceDescription
a} :: GetSystemInstanceResponse)

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

instance Prelude.NFData GetSystemInstanceResponse