{-# 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.GetSystemTemplate
-- 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.
module Amazonka.IoTThingsGraph.GetSystemTemplate
  ( -- * Creating a Request
    GetSystemTemplate (..),
    newGetSystemTemplate,

    -- * Request Lenses
    getSystemTemplate_revisionNumber,
    getSystemTemplate_id,

    -- * Destructuring the Response
    GetSystemTemplateResponse (..),
    newGetSystemTemplateResponse,

    -- * Response Lenses
    getSystemTemplateResponse_description,
    getSystemTemplateResponse_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:/ 'newGetSystemTemplate' smart constructor.
data GetSystemTemplate = GetSystemTemplate'
  { -- | The number that specifies the revision of the system to get.
    GetSystemTemplate -> Maybe Integer
revisionNumber :: Prelude.Maybe Prelude.Integer,
    -- | The ID of the system to get. This ID must be in the user\'s namespace.
    --
    -- The ID should be in the following format.
    --
    -- @urn:tdm:REGION\/ACCOUNT ID\/default:system:SYSTEMNAME@
    GetSystemTemplate -> Text
id :: Prelude.Text
  }
  deriving (GetSystemTemplate -> GetSystemTemplate -> Bool
(GetSystemTemplate -> GetSystemTemplate -> Bool)
-> (GetSystemTemplate -> GetSystemTemplate -> Bool)
-> Eq GetSystemTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetSystemTemplate -> GetSystemTemplate -> Bool
$c/= :: GetSystemTemplate -> GetSystemTemplate -> Bool
== :: GetSystemTemplate -> GetSystemTemplate -> Bool
$c== :: GetSystemTemplate -> GetSystemTemplate -> Bool
Prelude.Eq, ReadPrec [GetSystemTemplate]
ReadPrec GetSystemTemplate
Int -> ReadS GetSystemTemplate
ReadS [GetSystemTemplate]
(Int -> ReadS GetSystemTemplate)
-> ReadS [GetSystemTemplate]
-> ReadPrec GetSystemTemplate
-> ReadPrec [GetSystemTemplate]
-> Read GetSystemTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetSystemTemplate]
$creadListPrec :: ReadPrec [GetSystemTemplate]
readPrec :: ReadPrec GetSystemTemplate
$creadPrec :: ReadPrec GetSystemTemplate
readList :: ReadS [GetSystemTemplate]
$creadList :: ReadS [GetSystemTemplate]
readsPrec :: Int -> ReadS GetSystemTemplate
$creadsPrec :: Int -> ReadS GetSystemTemplate
Prelude.Read, Int -> GetSystemTemplate -> ShowS
[GetSystemTemplate] -> ShowS
GetSystemTemplate -> String
(Int -> GetSystemTemplate -> ShowS)
-> (GetSystemTemplate -> String)
-> ([GetSystemTemplate] -> ShowS)
-> Show GetSystemTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetSystemTemplate] -> ShowS
$cshowList :: [GetSystemTemplate] -> ShowS
show :: GetSystemTemplate -> String
$cshow :: GetSystemTemplate -> String
showsPrec :: Int -> GetSystemTemplate -> ShowS
$cshowsPrec :: Int -> GetSystemTemplate -> ShowS
Prelude.Show, (forall x. GetSystemTemplate -> Rep GetSystemTemplate x)
-> (forall x. Rep GetSystemTemplate x -> GetSystemTemplate)
-> Generic GetSystemTemplate
forall x. Rep GetSystemTemplate x -> GetSystemTemplate
forall x. GetSystemTemplate -> Rep GetSystemTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetSystemTemplate x -> GetSystemTemplate
$cfrom :: forall x. GetSystemTemplate -> Rep GetSystemTemplate x
Prelude.Generic)

-- |
-- Create a value of 'GetSystemTemplate' 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:
--
-- 'revisionNumber', 'getSystemTemplate_revisionNumber' - The number that specifies the revision of the system to get.
--
-- 'id', 'getSystemTemplate_id' - The ID of the system to get. This ID must be in the user\'s namespace.
--
-- The ID should be in the following format.
--
-- @urn:tdm:REGION\/ACCOUNT ID\/default:system:SYSTEMNAME@
newGetSystemTemplate ::
  -- | 'id'
  Prelude.Text ->
  GetSystemTemplate
newGetSystemTemplate :: Text -> GetSystemTemplate
newGetSystemTemplate Text
pId_ =
  GetSystemTemplate' :: Maybe Integer -> Text -> GetSystemTemplate
GetSystemTemplate'
    { $sel:revisionNumber:GetSystemTemplate' :: Maybe Integer
revisionNumber =
        Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:id:GetSystemTemplate' :: Text
id = Text
pId_
    }

-- | The number that specifies the revision of the system to get.
getSystemTemplate_revisionNumber :: Lens.Lens' GetSystemTemplate (Prelude.Maybe Prelude.Integer)
getSystemTemplate_revisionNumber :: (Maybe Integer -> f (Maybe Integer))
-> GetSystemTemplate -> f GetSystemTemplate
getSystemTemplate_revisionNumber = (GetSystemTemplate -> Maybe Integer)
-> (GetSystemTemplate -> Maybe Integer -> GetSystemTemplate)
-> Lens
     GetSystemTemplate GetSystemTemplate (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSystemTemplate' {Maybe Integer
revisionNumber :: Maybe Integer
$sel:revisionNumber:GetSystemTemplate' :: GetSystemTemplate -> Maybe Integer
revisionNumber} -> Maybe Integer
revisionNumber) (\s :: GetSystemTemplate
s@GetSystemTemplate' {} Maybe Integer
a -> GetSystemTemplate
s {$sel:revisionNumber:GetSystemTemplate' :: Maybe Integer
revisionNumber = Maybe Integer
a} :: GetSystemTemplate)

-- | The ID of the system to get. This ID must be in the user\'s namespace.
--
-- The ID should be in the following format.
--
-- @urn:tdm:REGION\/ACCOUNT ID\/default:system:SYSTEMNAME@
getSystemTemplate_id :: Lens.Lens' GetSystemTemplate Prelude.Text
getSystemTemplate_id :: (Text -> f Text) -> GetSystemTemplate -> f GetSystemTemplate
getSystemTemplate_id = (GetSystemTemplate -> Text)
-> (GetSystemTemplate -> Text -> GetSystemTemplate)
-> Lens GetSystemTemplate GetSystemTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSystemTemplate' {Text
id :: Text
$sel:id:GetSystemTemplate' :: GetSystemTemplate -> Text
id} -> Text
id) (\s :: GetSystemTemplate
s@GetSystemTemplate' {} Text
a -> GetSystemTemplate
s {$sel:id:GetSystemTemplate' :: Text
id = Text
a} :: GetSystemTemplate)

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

instance Prelude.NFData GetSystemTemplate

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

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

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

-- |
-- Create a value of 'GetSystemTemplateResponse' 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', 'getSystemTemplateResponse_description' - An object that contains summary data about the system.
--
-- 'httpStatus', 'getSystemTemplateResponse_httpStatus' - The response's http status code.
newGetSystemTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetSystemTemplateResponse
newGetSystemTemplateResponse :: Int -> GetSystemTemplateResponse
newGetSystemTemplateResponse Int
pHttpStatus_ =
  GetSystemTemplateResponse' :: Maybe SystemTemplateDescription -> Int -> GetSystemTemplateResponse
GetSystemTemplateResponse'
    { $sel:description:GetSystemTemplateResponse' :: Maybe SystemTemplateDescription
description =
        Maybe SystemTemplateDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetSystemTemplateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that contains summary data about the system.
getSystemTemplateResponse_description :: Lens.Lens' GetSystemTemplateResponse (Prelude.Maybe SystemTemplateDescription)
getSystemTemplateResponse_description :: (Maybe SystemTemplateDescription
 -> f (Maybe SystemTemplateDescription))
-> GetSystemTemplateResponse -> f GetSystemTemplateResponse
getSystemTemplateResponse_description = (GetSystemTemplateResponse -> Maybe SystemTemplateDescription)
-> (GetSystemTemplateResponse
    -> Maybe SystemTemplateDescription -> GetSystemTemplateResponse)
-> Lens
     GetSystemTemplateResponse
     GetSystemTemplateResponse
     (Maybe SystemTemplateDescription)
     (Maybe SystemTemplateDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetSystemTemplateResponse' {Maybe SystemTemplateDescription
description :: Maybe SystemTemplateDescription
$sel:description:GetSystemTemplateResponse' :: GetSystemTemplateResponse -> Maybe SystemTemplateDescription
description} -> Maybe SystemTemplateDescription
description) (\s :: GetSystemTemplateResponse
s@GetSystemTemplateResponse' {} Maybe SystemTemplateDescription
a -> GetSystemTemplateResponse
s {$sel:description:GetSystemTemplateResponse' :: Maybe SystemTemplateDescription
description = Maybe SystemTemplateDescription
a} :: GetSystemTemplateResponse)

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

instance Prelude.NFData GetSystemTemplateResponse