{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.VirtualMachine
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.BackupGateway.Types.VirtualMachine where

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

-- | A virtual machine that is on a hypervisor.
--
-- /See:/ 'newVirtualMachine' smart constructor.
data VirtualMachine = VirtualMachine'
  { -- | The host name of the virtual machine.
    VirtualMachine -> Maybe Text
hostName :: Prelude.Maybe Prelude.Text,
    -- | The ID of the virtual machine\'s hypervisor.
    VirtualMachine -> Maybe Text
hypervisorId :: Prelude.Maybe Prelude.Text,
    -- | The most recent date a virtual machine was backed up, in Unix format and
    -- UTC time.
    VirtualMachine -> Maybe POSIX
lastBackupDate :: Prelude.Maybe Data.POSIX,
    -- | The name of the virtual machine.
    VirtualMachine -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The path of the virtual machine.
    VirtualMachine -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the virtual machine. For example,
    -- @arn:aws:backup-gateway:us-west-1:0000000000000:vm\/vm-0000ABCDEFGIJKL@.
    VirtualMachine -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text
  }
  deriving (VirtualMachine -> VirtualMachine -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualMachine -> VirtualMachine -> Bool
$c/= :: VirtualMachine -> VirtualMachine -> Bool
== :: VirtualMachine -> VirtualMachine -> Bool
$c== :: VirtualMachine -> VirtualMachine -> Bool
Prelude.Eq, ReadPrec [VirtualMachine]
ReadPrec VirtualMachine
Int -> ReadS VirtualMachine
ReadS [VirtualMachine]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualMachine]
$creadListPrec :: ReadPrec [VirtualMachine]
readPrec :: ReadPrec VirtualMachine
$creadPrec :: ReadPrec VirtualMachine
readList :: ReadS [VirtualMachine]
$creadList :: ReadS [VirtualMachine]
readsPrec :: Int -> ReadS VirtualMachine
$creadsPrec :: Int -> ReadS VirtualMachine
Prelude.Read, Int -> VirtualMachine -> ShowS
[VirtualMachine] -> ShowS
VirtualMachine -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualMachine] -> ShowS
$cshowList :: [VirtualMachine] -> ShowS
show :: VirtualMachine -> String
$cshow :: VirtualMachine -> String
showsPrec :: Int -> VirtualMachine -> ShowS
$cshowsPrec :: Int -> VirtualMachine -> ShowS
Prelude.Show, forall x. Rep VirtualMachine x -> VirtualMachine
forall x. VirtualMachine -> Rep VirtualMachine x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VirtualMachine x -> VirtualMachine
$cfrom :: forall x. VirtualMachine -> Rep VirtualMachine x
Prelude.Generic)

-- |
-- Create a value of 'VirtualMachine' 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:
--
-- 'hostName', 'virtualMachine_hostName' - The host name of the virtual machine.
--
-- 'hypervisorId', 'virtualMachine_hypervisorId' - The ID of the virtual machine\'s hypervisor.
--
-- 'lastBackupDate', 'virtualMachine_lastBackupDate' - The most recent date a virtual machine was backed up, in Unix format and
-- UTC time.
--
-- 'name', 'virtualMachine_name' - The name of the virtual machine.
--
-- 'path', 'virtualMachine_path' - The path of the virtual machine.
--
-- 'resourceArn', 'virtualMachine_resourceArn' - The Amazon Resource Name (ARN) of the virtual machine. For example,
-- @arn:aws:backup-gateway:us-west-1:0000000000000:vm\/vm-0000ABCDEFGIJKL@.
newVirtualMachine ::
  VirtualMachine
newVirtualMachine :: VirtualMachine
newVirtualMachine =
  VirtualMachine'
    { $sel:hostName:VirtualMachine' :: Maybe Text
hostName = forall a. Maybe a
Prelude.Nothing,
      $sel:hypervisorId:VirtualMachine' :: Maybe Text
hypervisorId = forall a. Maybe a
Prelude.Nothing,
      $sel:lastBackupDate:VirtualMachine' :: Maybe POSIX
lastBackupDate = forall a. Maybe a
Prelude.Nothing,
      $sel:name:VirtualMachine' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:path:VirtualMachine' :: Maybe Text
path = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:VirtualMachine' :: Maybe Text
resourceArn = forall a. Maybe a
Prelude.Nothing
    }

-- | The host name of the virtual machine.
virtualMachine_hostName :: Lens.Lens' VirtualMachine (Prelude.Maybe Prelude.Text)
virtualMachine_hostName :: Lens' VirtualMachine (Maybe Text)
virtualMachine_hostName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualMachine' {Maybe Text
hostName :: Maybe Text
$sel:hostName:VirtualMachine' :: VirtualMachine -> Maybe Text
hostName} -> Maybe Text
hostName) (\s :: VirtualMachine
s@VirtualMachine' {} Maybe Text
a -> VirtualMachine
s {$sel:hostName:VirtualMachine' :: Maybe Text
hostName = Maybe Text
a} :: VirtualMachine)

-- | The ID of the virtual machine\'s hypervisor.
virtualMachine_hypervisorId :: Lens.Lens' VirtualMachine (Prelude.Maybe Prelude.Text)
virtualMachine_hypervisorId :: Lens' VirtualMachine (Maybe Text)
virtualMachine_hypervisorId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualMachine' {Maybe Text
hypervisorId :: Maybe Text
$sel:hypervisorId:VirtualMachine' :: VirtualMachine -> Maybe Text
hypervisorId} -> Maybe Text
hypervisorId) (\s :: VirtualMachine
s@VirtualMachine' {} Maybe Text
a -> VirtualMachine
s {$sel:hypervisorId:VirtualMachine' :: Maybe Text
hypervisorId = Maybe Text
a} :: VirtualMachine)

-- | The most recent date a virtual machine was backed up, in Unix format and
-- UTC time.
virtualMachine_lastBackupDate :: Lens.Lens' VirtualMachine (Prelude.Maybe Prelude.UTCTime)
virtualMachine_lastBackupDate :: Lens' VirtualMachine (Maybe UTCTime)
virtualMachine_lastBackupDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualMachine' {Maybe POSIX
lastBackupDate :: Maybe POSIX
$sel:lastBackupDate:VirtualMachine' :: VirtualMachine -> Maybe POSIX
lastBackupDate} -> Maybe POSIX
lastBackupDate) (\s :: VirtualMachine
s@VirtualMachine' {} Maybe POSIX
a -> VirtualMachine
s {$sel:lastBackupDate:VirtualMachine' :: Maybe POSIX
lastBackupDate = Maybe POSIX
a} :: VirtualMachine) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The name of the virtual machine.
virtualMachine_name :: Lens.Lens' VirtualMachine (Prelude.Maybe Prelude.Text)
virtualMachine_name :: Lens' VirtualMachine (Maybe Text)
virtualMachine_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualMachine' {Maybe Text
name :: Maybe Text
$sel:name:VirtualMachine' :: VirtualMachine -> Maybe Text
name} -> Maybe Text
name) (\s :: VirtualMachine
s@VirtualMachine' {} Maybe Text
a -> VirtualMachine
s {$sel:name:VirtualMachine' :: Maybe Text
name = Maybe Text
a} :: VirtualMachine)

-- | The path of the virtual machine.
virtualMachine_path :: Lens.Lens' VirtualMachine (Prelude.Maybe Prelude.Text)
virtualMachine_path :: Lens' VirtualMachine (Maybe Text)
virtualMachine_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualMachine' {Maybe Text
path :: Maybe Text
$sel:path:VirtualMachine' :: VirtualMachine -> Maybe Text
path} -> Maybe Text
path) (\s :: VirtualMachine
s@VirtualMachine' {} Maybe Text
a -> VirtualMachine
s {$sel:path:VirtualMachine' :: Maybe Text
path = Maybe Text
a} :: VirtualMachine)

-- | The Amazon Resource Name (ARN) of the virtual machine. For example,
-- @arn:aws:backup-gateway:us-west-1:0000000000000:vm\/vm-0000ABCDEFGIJKL@.
virtualMachine_resourceArn :: Lens.Lens' VirtualMachine (Prelude.Maybe Prelude.Text)
virtualMachine_resourceArn :: Lens' VirtualMachine (Maybe Text)
virtualMachine_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualMachine' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:VirtualMachine' :: VirtualMachine -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: VirtualMachine
s@VirtualMachine' {} Maybe Text
a -> VirtualMachine
s {$sel:resourceArn:VirtualMachine' :: Maybe Text
resourceArn = Maybe Text
a} :: VirtualMachine)

instance Data.FromJSON VirtualMachine where
  parseJSON :: Value -> Parser VirtualMachine
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VirtualMachine"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> VirtualMachine
VirtualMachine'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"HostName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"HypervisorId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LastBackupDate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Path")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ResourceArn")
      )

instance Prelude.Hashable VirtualMachine where
  hashWithSalt :: Int -> VirtualMachine -> Int
hashWithSalt Int
_salt VirtualMachine' {Maybe Text
Maybe POSIX
resourceArn :: Maybe Text
path :: Maybe Text
name :: Maybe Text
lastBackupDate :: Maybe POSIX
hypervisorId :: Maybe Text
hostName :: Maybe Text
$sel:resourceArn:VirtualMachine' :: VirtualMachine -> Maybe Text
$sel:path:VirtualMachine' :: VirtualMachine -> Maybe Text
$sel:name:VirtualMachine' :: VirtualMachine -> Maybe Text
$sel:lastBackupDate:VirtualMachine' :: VirtualMachine -> Maybe POSIX
$sel:hypervisorId:VirtualMachine' :: VirtualMachine -> Maybe Text
$sel:hostName:VirtualMachine' :: VirtualMachine -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hostName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hypervisorId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastBackupDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
path
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceArn

instance Prelude.NFData VirtualMachine where
  rnf :: VirtualMachine -> ()
rnf VirtualMachine' {Maybe Text
Maybe POSIX
resourceArn :: Maybe Text
path :: Maybe Text
name :: Maybe Text
lastBackupDate :: Maybe POSIX
hypervisorId :: Maybe Text
hostName :: Maybe Text
$sel:resourceArn:VirtualMachine' :: VirtualMachine -> Maybe Text
$sel:path:VirtualMachine' :: VirtualMachine -> Maybe Text
$sel:name:VirtualMachine' :: VirtualMachine -> Maybe Text
$sel:lastBackupDate:VirtualMachine' :: VirtualMachine -> Maybe POSIX
$sel:hypervisorId:VirtualMachine' :: VirtualMachine -> Maybe Text
$sel:hostName:VirtualMachine' :: VirtualMachine -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hostName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hypervisorId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastBackupDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
path
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceArn