{-# 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.BackupGateway.GetVirtualMachine
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- By providing the ARN (Amazon Resource Name), this API returns the
-- virtual machine.
module Amazonka.BackupGateway.GetVirtualMachine
  ( -- * Creating a Request
    GetVirtualMachine (..),
    newGetVirtualMachine,

    -- * Request Lenses
    getVirtualMachine_resourceArn,

    -- * Destructuring the Response
    GetVirtualMachineResponse (..),
    newGetVirtualMachineResponse,

    -- * Response Lenses
    getVirtualMachineResponse_virtualMachine,
    getVirtualMachineResponse_httpStatus,
  )
where

import Amazonka.BackupGateway.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetVirtualMachine' smart constructor.
data GetVirtualMachine = GetVirtualMachine'
  { -- | The Amazon Resource Name (ARN) of the virtual machine.
    GetVirtualMachine -> Text
resourceArn :: Prelude.Text
  }
  deriving (GetVirtualMachine -> GetVirtualMachine -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetVirtualMachine -> GetVirtualMachine -> Bool
$c/= :: GetVirtualMachine -> GetVirtualMachine -> Bool
== :: GetVirtualMachine -> GetVirtualMachine -> Bool
$c== :: GetVirtualMachine -> GetVirtualMachine -> Bool
Prelude.Eq, ReadPrec [GetVirtualMachine]
ReadPrec GetVirtualMachine
Int -> ReadS GetVirtualMachine
ReadS [GetVirtualMachine]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetVirtualMachine]
$creadListPrec :: ReadPrec [GetVirtualMachine]
readPrec :: ReadPrec GetVirtualMachine
$creadPrec :: ReadPrec GetVirtualMachine
readList :: ReadS [GetVirtualMachine]
$creadList :: ReadS [GetVirtualMachine]
readsPrec :: Int -> ReadS GetVirtualMachine
$creadsPrec :: Int -> ReadS GetVirtualMachine
Prelude.Read, Int -> GetVirtualMachine -> ShowS
[GetVirtualMachine] -> ShowS
GetVirtualMachine -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetVirtualMachine] -> ShowS
$cshowList :: [GetVirtualMachine] -> ShowS
show :: GetVirtualMachine -> String
$cshow :: GetVirtualMachine -> String
showsPrec :: Int -> GetVirtualMachine -> ShowS
$cshowsPrec :: Int -> GetVirtualMachine -> ShowS
Prelude.Show, forall x. Rep GetVirtualMachine x -> GetVirtualMachine
forall x. GetVirtualMachine -> Rep GetVirtualMachine x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetVirtualMachine x -> GetVirtualMachine
$cfrom :: forall x. GetVirtualMachine -> Rep GetVirtualMachine x
Prelude.Generic)

-- |
-- Create a value of 'GetVirtualMachine' 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:
--
-- 'resourceArn', 'getVirtualMachine_resourceArn' - The Amazon Resource Name (ARN) of the virtual machine.
newGetVirtualMachine ::
  -- | 'resourceArn'
  Prelude.Text ->
  GetVirtualMachine
newGetVirtualMachine :: Text -> GetVirtualMachine
newGetVirtualMachine Text
pResourceArn_ =
  GetVirtualMachine' {$sel:resourceArn:GetVirtualMachine' :: Text
resourceArn = Text
pResourceArn_}

-- | The Amazon Resource Name (ARN) of the virtual machine.
getVirtualMachine_resourceArn :: Lens.Lens' GetVirtualMachine Prelude.Text
getVirtualMachine_resourceArn :: Lens' GetVirtualMachine Text
getVirtualMachine_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVirtualMachine' {Text
resourceArn :: Text
$sel:resourceArn:GetVirtualMachine' :: GetVirtualMachine -> Text
resourceArn} -> Text
resourceArn) (\s :: GetVirtualMachine
s@GetVirtualMachine' {} Text
a -> GetVirtualMachine
s {$sel:resourceArn:GetVirtualMachine' :: Text
resourceArn = Text
a} :: GetVirtualMachine)

instance Core.AWSRequest GetVirtualMachine where
  type
    AWSResponse GetVirtualMachine =
      GetVirtualMachineResponse
  request :: (Service -> Service)
-> GetVirtualMachine -> Request GetVirtualMachine
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetVirtualMachine
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetVirtualMachine)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe VirtualMachineDetails -> Int -> GetVirtualMachineResponse
GetVirtualMachineResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"VirtualMachine")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetVirtualMachine where
  hashWithSalt :: Int -> GetVirtualMachine -> Int
hashWithSalt Int
_salt GetVirtualMachine' {Text
resourceArn :: Text
$sel:resourceArn:GetVirtualMachine' :: GetVirtualMachine -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn

instance Prelude.NFData GetVirtualMachine where
  rnf :: GetVirtualMachine -> ()
rnf GetVirtualMachine' {Text
resourceArn :: Text
$sel:resourceArn:GetVirtualMachine' :: GetVirtualMachine -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
resourceArn

instance Data.ToHeaders GetVirtualMachine where
  toHeaders :: GetVirtualMachine -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"BackupOnPremises_v20210101.GetVirtualMachine" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetVirtualMachine where
  toJSON :: GetVirtualMachine -> Value
toJSON GetVirtualMachine' {Text
resourceArn :: Text
$sel:resourceArn:GetVirtualMachine' :: GetVirtualMachine -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ResourceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceArn)]
      )

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

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

-- | /See:/ 'newGetVirtualMachineResponse' smart constructor.
data GetVirtualMachineResponse = GetVirtualMachineResponse'
  { -- | This object contains the basic attributes of @VirtualMachine@ contained
    -- by the output of @GetVirtualMachine@
    GetVirtualMachineResponse -> Maybe VirtualMachineDetails
virtualMachine :: Prelude.Maybe VirtualMachineDetails,
    -- | The response's http status code.
    GetVirtualMachineResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetVirtualMachineResponse -> GetVirtualMachineResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetVirtualMachineResponse -> GetVirtualMachineResponse -> Bool
$c/= :: GetVirtualMachineResponse -> GetVirtualMachineResponse -> Bool
== :: GetVirtualMachineResponse -> GetVirtualMachineResponse -> Bool
$c== :: GetVirtualMachineResponse -> GetVirtualMachineResponse -> Bool
Prelude.Eq, ReadPrec [GetVirtualMachineResponse]
ReadPrec GetVirtualMachineResponse
Int -> ReadS GetVirtualMachineResponse
ReadS [GetVirtualMachineResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetVirtualMachineResponse]
$creadListPrec :: ReadPrec [GetVirtualMachineResponse]
readPrec :: ReadPrec GetVirtualMachineResponse
$creadPrec :: ReadPrec GetVirtualMachineResponse
readList :: ReadS [GetVirtualMachineResponse]
$creadList :: ReadS [GetVirtualMachineResponse]
readsPrec :: Int -> ReadS GetVirtualMachineResponse
$creadsPrec :: Int -> ReadS GetVirtualMachineResponse
Prelude.Read, Int -> GetVirtualMachineResponse -> ShowS
[GetVirtualMachineResponse] -> ShowS
GetVirtualMachineResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetVirtualMachineResponse] -> ShowS
$cshowList :: [GetVirtualMachineResponse] -> ShowS
show :: GetVirtualMachineResponse -> String
$cshow :: GetVirtualMachineResponse -> String
showsPrec :: Int -> GetVirtualMachineResponse -> ShowS
$cshowsPrec :: Int -> GetVirtualMachineResponse -> ShowS
Prelude.Show, forall x.
Rep GetVirtualMachineResponse x -> GetVirtualMachineResponse
forall x.
GetVirtualMachineResponse -> Rep GetVirtualMachineResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetVirtualMachineResponse x -> GetVirtualMachineResponse
$cfrom :: forall x.
GetVirtualMachineResponse -> Rep GetVirtualMachineResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetVirtualMachineResponse' 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:
--
-- 'virtualMachine', 'getVirtualMachineResponse_virtualMachine' - This object contains the basic attributes of @VirtualMachine@ contained
-- by the output of @GetVirtualMachine@
--
-- 'httpStatus', 'getVirtualMachineResponse_httpStatus' - The response's http status code.
newGetVirtualMachineResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetVirtualMachineResponse
newGetVirtualMachineResponse :: Int -> GetVirtualMachineResponse
newGetVirtualMachineResponse Int
pHttpStatus_ =
  GetVirtualMachineResponse'
    { $sel:virtualMachine:GetVirtualMachineResponse' :: Maybe VirtualMachineDetails
virtualMachine =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetVirtualMachineResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | This object contains the basic attributes of @VirtualMachine@ contained
-- by the output of @GetVirtualMachine@
getVirtualMachineResponse_virtualMachine :: Lens.Lens' GetVirtualMachineResponse (Prelude.Maybe VirtualMachineDetails)
getVirtualMachineResponse_virtualMachine :: Lens' GetVirtualMachineResponse (Maybe VirtualMachineDetails)
getVirtualMachineResponse_virtualMachine = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetVirtualMachineResponse' {Maybe VirtualMachineDetails
virtualMachine :: Maybe VirtualMachineDetails
$sel:virtualMachine:GetVirtualMachineResponse' :: GetVirtualMachineResponse -> Maybe VirtualMachineDetails
virtualMachine} -> Maybe VirtualMachineDetails
virtualMachine) (\s :: GetVirtualMachineResponse
s@GetVirtualMachineResponse' {} Maybe VirtualMachineDetails
a -> GetVirtualMachineResponse
s {$sel:virtualMachine:GetVirtualMachineResponse' :: Maybe VirtualMachineDetails
virtualMachine = Maybe VirtualMachineDetails
a} :: GetVirtualMachineResponse)

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

instance Prelude.NFData GetVirtualMachineResponse where
  rnf :: GetVirtualMachineResponse -> ()
rnf GetVirtualMachineResponse' {Int
Maybe VirtualMachineDetails
httpStatus :: Int
virtualMachine :: Maybe VirtualMachineDetails
$sel:httpStatus:GetVirtualMachineResponse' :: GetVirtualMachineResponse -> Int
$sel:virtualMachine:GetVirtualMachineResponse' :: GetVirtualMachineResponse -> Maybe VirtualMachineDetails
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe VirtualMachineDetails
virtualMachine
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus