{-# 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.CodeDeploy.GetOnPremisesInstance
-- 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 information about an on-premises instance.
module Amazonka.CodeDeploy.GetOnPremisesInstance
  ( -- * Creating a Request
    GetOnPremisesInstance (..),
    newGetOnPremisesInstance,

    -- * Request Lenses
    getOnPremisesInstance_instanceName,

    -- * Destructuring the Response
    GetOnPremisesInstanceResponse (..),
    newGetOnPremisesInstanceResponse,

    -- * Response Lenses
    getOnPremisesInstanceResponse_instanceInfo,
    getOnPremisesInstanceResponse_httpStatus,
  )
where

import Amazonka.CodeDeploy.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the input of a @GetOnPremisesInstance@ operation.
--
-- /See:/ 'newGetOnPremisesInstance' smart constructor.
data GetOnPremisesInstance = GetOnPremisesInstance'
  { -- | The name of the on-premises instance about which to get information.
    GetOnPremisesInstance -> Text
instanceName :: Prelude.Text
  }
  deriving (GetOnPremisesInstance -> GetOnPremisesInstance -> Bool
(GetOnPremisesInstance -> GetOnPremisesInstance -> Bool)
-> (GetOnPremisesInstance -> GetOnPremisesInstance -> Bool)
-> Eq GetOnPremisesInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetOnPremisesInstance -> GetOnPremisesInstance -> Bool
$c/= :: GetOnPremisesInstance -> GetOnPremisesInstance -> Bool
== :: GetOnPremisesInstance -> GetOnPremisesInstance -> Bool
$c== :: GetOnPremisesInstance -> GetOnPremisesInstance -> Bool
Prelude.Eq, ReadPrec [GetOnPremisesInstance]
ReadPrec GetOnPremisesInstance
Int -> ReadS GetOnPremisesInstance
ReadS [GetOnPremisesInstance]
(Int -> ReadS GetOnPremisesInstance)
-> ReadS [GetOnPremisesInstance]
-> ReadPrec GetOnPremisesInstance
-> ReadPrec [GetOnPremisesInstance]
-> Read GetOnPremisesInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetOnPremisesInstance]
$creadListPrec :: ReadPrec [GetOnPremisesInstance]
readPrec :: ReadPrec GetOnPremisesInstance
$creadPrec :: ReadPrec GetOnPremisesInstance
readList :: ReadS [GetOnPremisesInstance]
$creadList :: ReadS [GetOnPremisesInstance]
readsPrec :: Int -> ReadS GetOnPremisesInstance
$creadsPrec :: Int -> ReadS GetOnPremisesInstance
Prelude.Read, Int -> GetOnPremisesInstance -> ShowS
[GetOnPremisesInstance] -> ShowS
GetOnPremisesInstance -> String
(Int -> GetOnPremisesInstance -> ShowS)
-> (GetOnPremisesInstance -> String)
-> ([GetOnPremisesInstance] -> ShowS)
-> Show GetOnPremisesInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetOnPremisesInstance] -> ShowS
$cshowList :: [GetOnPremisesInstance] -> ShowS
show :: GetOnPremisesInstance -> String
$cshow :: GetOnPremisesInstance -> String
showsPrec :: Int -> GetOnPremisesInstance -> ShowS
$cshowsPrec :: Int -> GetOnPremisesInstance -> ShowS
Prelude.Show, (forall x. GetOnPremisesInstance -> Rep GetOnPremisesInstance x)
-> (forall x. Rep GetOnPremisesInstance x -> GetOnPremisesInstance)
-> Generic GetOnPremisesInstance
forall x. Rep GetOnPremisesInstance x -> GetOnPremisesInstance
forall x. GetOnPremisesInstance -> Rep GetOnPremisesInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetOnPremisesInstance x -> GetOnPremisesInstance
$cfrom :: forall x. GetOnPremisesInstance -> Rep GetOnPremisesInstance x
Prelude.Generic)

-- |
-- Create a value of 'GetOnPremisesInstance' 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', 'getOnPremisesInstance_instanceName' - The name of the on-premises instance about which to get information.
newGetOnPremisesInstance ::
  -- | 'instanceName'
  Prelude.Text ->
  GetOnPremisesInstance
newGetOnPremisesInstance :: Text -> GetOnPremisesInstance
newGetOnPremisesInstance Text
pInstanceName_ =
  GetOnPremisesInstance' :: Text -> GetOnPremisesInstance
GetOnPremisesInstance'
    { $sel:instanceName:GetOnPremisesInstance' :: Text
instanceName =
        Text
pInstanceName_
    }

-- | The name of the on-premises instance about which to get information.
getOnPremisesInstance_instanceName :: Lens.Lens' GetOnPremisesInstance Prelude.Text
getOnPremisesInstance_instanceName :: (Text -> f Text)
-> GetOnPremisesInstance -> f GetOnPremisesInstance
getOnPremisesInstance_instanceName = (GetOnPremisesInstance -> Text)
-> (GetOnPremisesInstance -> Text -> GetOnPremisesInstance)
-> Lens GetOnPremisesInstance GetOnPremisesInstance Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOnPremisesInstance' {Text
instanceName :: Text
$sel:instanceName:GetOnPremisesInstance' :: GetOnPremisesInstance -> Text
instanceName} -> Text
instanceName) (\s :: GetOnPremisesInstance
s@GetOnPremisesInstance' {} Text
a -> GetOnPremisesInstance
s {$sel:instanceName:GetOnPremisesInstance' :: Text
instanceName = Text
a} :: GetOnPremisesInstance)

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

instance Prelude.NFData GetOnPremisesInstance

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

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

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

-- | Represents the output of a @GetOnPremisesInstance@ operation.
--
-- /See:/ 'newGetOnPremisesInstanceResponse' smart constructor.
data GetOnPremisesInstanceResponse = GetOnPremisesInstanceResponse'
  { -- | Information about the on-premises instance.
    GetOnPremisesInstanceResponse -> Maybe InstanceInfo
instanceInfo :: Prelude.Maybe InstanceInfo,
    -- | The response's http status code.
    GetOnPremisesInstanceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetOnPremisesInstanceResponse
-> GetOnPremisesInstanceResponse -> Bool
(GetOnPremisesInstanceResponse
 -> GetOnPremisesInstanceResponse -> Bool)
-> (GetOnPremisesInstanceResponse
    -> GetOnPremisesInstanceResponse -> Bool)
-> Eq GetOnPremisesInstanceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetOnPremisesInstanceResponse
-> GetOnPremisesInstanceResponse -> Bool
$c/= :: GetOnPremisesInstanceResponse
-> GetOnPremisesInstanceResponse -> Bool
== :: GetOnPremisesInstanceResponse
-> GetOnPremisesInstanceResponse -> Bool
$c== :: GetOnPremisesInstanceResponse
-> GetOnPremisesInstanceResponse -> Bool
Prelude.Eq, ReadPrec [GetOnPremisesInstanceResponse]
ReadPrec GetOnPremisesInstanceResponse
Int -> ReadS GetOnPremisesInstanceResponse
ReadS [GetOnPremisesInstanceResponse]
(Int -> ReadS GetOnPremisesInstanceResponse)
-> ReadS [GetOnPremisesInstanceResponse]
-> ReadPrec GetOnPremisesInstanceResponse
-> ReadPrec [GetOnPremisesInstanceResponse]
-> Read GetOnPremisesInstanceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetOnPremisesInstanceResponse]
$creadListPrec :: ReadPrec [GetOnPremisesInstanceResponse]
readPrec :: ReadPrec GetOnPremisesInstanceResponse
$creadPrec :: ReadPrec GetOnPremisesInstanceResponse
readList :: ReadS [GetOnPremisesInstanceResponse]
$creadList :: ReadS [GetOnPremisesInstanceResponse]
readsPrec :: Int -> ReadS GetOnPremisesInstanceResponse
$creadsPrec :: Int -> ReadS GetOnPremisesInstanceResponse
Prelude.Read, Int -> GetOnPremisesInstanceResponse -> ShowS
[GetOnPremisesInstanceResponse] -> ShowS
GetOnPremisesInstanceResponse -> String
(Int -> GetOnPremisesInstanceResponse -> ShowS)
-> (GetOnPremisesInstanceResponse -> String)
-> ([GetOnPremisesInstanceResponse] -> ShowS)
-> Show GetOnPremisesInstanceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetOnPremisesInstanceResponse] -> ShowS
$cshowList :: [GetOnPremisesInstanceResponse] -> ShowS
show :: GetOnPremisesInstanceResponse -> String
$cshow :: GetOnPremisesInstanceResponse -> String
showsPrec :: Int -> GetOnPremisesInstanceResponse -> ShowS
$cshowsPrec :: Int -> GetOnPremisesInstanceResponse -> ShowS
Prelude.Show, (forall x.
 GetOnPremisesInstanceResponse
 -> Rep GetOnPremisesInstanceResponse x)
-> (forall x.
    Rep GetOnPremisesInstanceResponse x
    -> GetOnPremisesInstanceResponse)
-> Generic GetOnPremisesInstanceResponse
forall x.
Rep GetOnPremisesInstanceResponse x
-> GetOnPremisesInstanceResponse
forall x.
GetOnPremisesInstanceResponse
-> Rep GetOnPremisesInstanceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetOnPremisesInstanceResponse x
-> GetOnPremisesInstanceResponse
$cfrom :: forall x.
GetOnPremisesInstanceResponse
-> Rep GetOnPremisesInstanceResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetOnPremisesInstanceResponse' 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:
--
-- 'instanceInfo', 'getOnPremisesInstanceResponse_instanceInfo' - Information about the on-premises instance.
--
-- 'httpStatus', 'getOnPremisesInstanceResponse_httpStatus' - The response's http status code.
newGetOnPremisesInstanceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetOnPremisesInstanceResponse
newGetOnPremisesInstanceResponse :: Int -> GetOnPremisesInstanceResponse
newGetOnPremisesInstanceResponse Int
pHttpStatus_ =
  GetOnPremisesInstanceResponse' :: Maybe InstanceInfo -> Int -> GetOnPremisesInstanceResponse
GetOnPremisesInstanceResponse'
    { $sel:instanceInfo:GetOnPremisesInstanceResponse' :: Maybe InstanceInfo
instanceInfo =
        Maybe InstanceInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetOnPremisesInstanceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the on-premises instance.
getOnPremisesInstanceResponse_instanceInfo :: Lens.Lens' GetOnPremisesInstanceResponse (Prelude.Maybe InstanceInfo)
getOnPremisesInstanceResponse_instanceInfo :: (Maybe InstanceInfo -> f (Maybe InstanceInfo))
-> GetOnPremisesInstanceResponse -> f GetOnPremisesInstanceResponse
getOnPremisesInstanceResponse_instanceInfo = (GetOnPremisesInstanceResponse -> Maybe InstanceInfo)
-> (GetOnPremisesInstanceResponse
    -> Maybe InstanceInfo -> GetOnPremisesInstanceResponse)
-> Lens
     GetOnPremisesInstanceResponse
     GetOnPremisesInstanceResponse
     (Maybe InstanceInfo)
     (Maybe InstanceInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetOnPremisesInstanceResponse' {Maybe InstanceInfo
instanceInfo :: Maybe InstanceInfo
$sel:instanceInfo:GetOnPremisesInstanceResponse' :: GetOnPremisesInstanceResponse -> Maybe InstanceInfo
instanceInfo} -> Maybe InstanceInfo
instanceInfo) (\s :: GetOnPremisesInstanceResponse
s@GetOnPremisesInstanceResponse' {} Maybe InstanceInfo
a -> GetOnPremisesInstanceResponse
s {$sel:instanceInfo:GetOnPremisesInstanceResponse' :: Maybe InstanceInfo
instanceInfo = Maybe InstanceInfo
a} :: GetOnPremisesInstanceResponse)

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

instance Prelude.NFData GetOnPremisesInstanceResponse