amazonka-lightsail-2.0: gen/Amazonka/Lightsail/GetInstance.hs
{-# 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.Lightsail.GetInstance
-- Copyright : (c) 2013-2023 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns information about a specific Amazon Lightsail instance, which is
-- a virtual private server.
module Amazonka.Lightsail.GetInstance
( -- * Creating a Request
GetInstance (..),
newGetInstance,
-- * Request Lenses
getInstance_instanceName,
-- * Destructuring the Response
GetInstanceResponse (..),
newGetInstanceResponse,
-- * Response Lenses
getInstanceResponse_instance,
getInstanceResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lightsail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
-- | /See:/ 'newGetInstance' smart constructor.
data GetInstance = GetInstance'
{ -- | The name of the instance.
instanceName :: Prelude.Text
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'GetInstance' 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:
--
-- 'instanceName', 'getInstance_instanceName' - The name of the instance.
newGetInstance ::
-- | 'instanceName'
Prelude.Text ->
GetInstance
newGetInstance pInstanceName_ =
GetInstance' {instanceName = pInstanceName_}
-- | The name of the instance.
getInstance_instanceName :: Lens.Lens' GetInstance Prelude.Text
getInstance_instanceName = Lens.lens (\GetInstance' {instanceName} -> instanceName) (\s@GetInstance' {} a -> s {instanceName = a} :: GetInstance)
instance Core.AWSRequest GetInstance where
type AWSResponse GetInstance = GetInstanceResponse
request overrides =
Request.postJSON (overrides defaultService)
response =
Response.receiveJSON
( \s h x ->
GetInstanceResponse'
Prelude.<$> (x Data..?> "instance")
Prelude.<*> (Prelude.pure (Prelude.fromEnum s))
)
instance Prelude.Hashable GetInstance where
hashWithSalt _salt GetInstance' {..} =
_salt `Prelude.hashWithSalt` instanceName
instance Prelude.NFData GetInstance where
rnf GetInstance' {..} = Prelude.rnf instanceName
instance Data.ToHeaders GetInstance where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "X-Amz-Target"
Data.=# ( "Lightsail_20161128.GetInstance" ::
Prelude.ByteString
),
"Content-Type"
Data.=# ( "application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON GetInstance where
toJSON GetInstance' {..} =
Data.object
( Prelude.catMaybes
[Prelude.Just ("instanceName" Data..= instanceName)]
)
instance Data.ToPath GetInstance where
toPath = Prelude.const "/"
instance Data.ToQuery GetInstance where
toQuery = Prelude.const Prelude.mempty
-- | /See:/ 'newGetInstanceResponse' smart constructor.
data GetInstanceResponse = GetInstanceResponse'
{ -- | An array of key-value pairs containing information about the specified
-- instance.
instance' :: Prelude.Maybe Instance,
-- | The response's http status code.
httpStatus :: Prelude.Int
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'GetInstanceResponse' 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:
--
-- 'instance'', 'getInstanceResponse_instance' - An array of key-value pairs containing information about the specified
-- instance.
--
-- 'httpStatus', 'getInstanceResponse_httpStatus' - The response's http status code.
newGetInstanceResponse ::
-- | 'httpStatus'
Prelude.Int ->
GetInstanceResponse
newGetInstanceResponse pHttpStatus_ =
GetInstanceResponse'
{ instance' = Prelude.Nothing,
httpStatus = pHttpStatus_
}
-- | An array of key-value pairs containing information about the specified
-- instance.
getInstanceResponse_instance :: Lens.Lens' GetInstanceResponse (Prelude.Maybe Instance)
getInstanceResponse_instance = Lens.lens (\GetInstanceResponse' {instance'} -> instance') (\s@GetInstanceResponse' {} a -> s {instance' = a} :: GetInstanceResponse)
-- | The response's http status code.
getInstanceResponse_httpStatus :: Lens.Lens' GetInstanceResponse Prelude.Int
getInstanceResponse_httpStatus = Lens.lens (\GetInstanceResponse' {httpStatus} -> httpStatus) (\s@GetInstanceResponse' {} a -> s {httpStatus = a} :: GetInstanceResponse)
instance Prelude.NFData GetInstanceResponse where
rnf GetInstanceResponse' {..} =
Prelude.rnf instance'
`Prelude.seq` Prelude.rnf httpStatus