{-# 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.SMS.Types.VmServer
-- 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)
module Amazonka.SMS.Types.VmServer where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SMS.Types.VmManagerType
import Amazonka.SMS.Types.VmServerAddress

-- | Represents a VM server.
--
-- /See:/ 'newVmServer' smart constructor.
data VmServer = VmServer'
  { -- | The name of the VM manager.
    VmServer -> Maybe Text
vmManagerName :: Prelude.Maybe Prelude.Text,
    -- | The type of VM management product.
    VmServer -> Maybe VmManagerType
vmManagerType :: Prelude.Maybe VmManagerType,
    -- | The VM server location.
    VmServer -> Maybe VmServerAddress
vmServerAddress :: Prelude.Maybe VmServerAddress,
    -- | The name of the VM.
    VmServer -> Maybe Text
vmName :: Prelude.Maybe Prelude.Text,
    -- | The VM folder path in the vCenter Server virtual machine inventory tree.
    VmServer -> Maybe Text
vmPath :: Prelude.Maybe Prelude.Text
  }
  deriving (VmServer -> VmServer -> Bool
(VmServer -> VmServer -> Bool)
-> (VmServer -> VmServer -> Bool) -> Eq VmServer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VmServer -> VmServer -> Bool
$c/= :: VmServer -> VmServer -> Bool
== :: VmServer -> VmServer -> Bool
$c== :: VmServer -> VmServer -> Bool
Prelude.Eq, ReadPrec [VmServer]
ReadPrec VmServer
Int -> ReadS VmServer
ReadS [VmServer]
(Int -> ReadS VmServer)
-> ReadS [VmServer]
-> ReadPrec VmServer
-> ReadPrec [VmServer]
-> Read VmServer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VmServer]
$creadListPrec :: ReadPrec [VmServer]
readPrec :: ReadPrec VmServer
$creadPrec :: ReadPrec VmServer
readList :: ReadS [VmServer]
$creadList :: ReadS [VmServer]
readsPrec :: Int -> ReadS VmServer
$creadsPrec :: Int -> ReadS VmServer
Prelude.Read, Int -> VmServer -> ShowS
[VmServer] -> ShowS
VmServer -> String
(Int -> VmServer -> ShowS)
-> (VmServer -> String) -> ([VmServer] -> ShowS) -> Show VmServer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VmServer] -> ShowS
$cshowList :: [VmServer] -> ShowS
show :: VmServer -> String
$cshow :: VmServer -> String
showsPrec :: Int -> VmServer -> ShowS
$cshowsPrec :: Int -> VmServer -> ShowS
Prelude.Show, (forall x. VmServer -> Rep VmServer x)
-> (forall x. Rep VmServer x -> VmServer) -> Generic VmServer
forall x. Rep VmServer x -> VmServer
forall x. VmServer -> Rep VmServer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VmServer x -> VmServer
$cfrom :: forall x. VmServer -> Rep VmServer x
Prelude.Generic)

-- |
-- Create a value of 'VmServer' 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:
--
-- 'vmManagerName', 'vmServer_vmManagerName' - The name of the VM manager.
--
-- 'vmManagerType', 'vmServer_vmManagerType' - The type of VM management product.
--
-- 'vmServerAddress', 'vmServer_vmServerAddress' - The VM server location.
--
-- 'vmName', 'vmServer_vmName' - The name of the VM.
--
-- 'vmPath', 'vmServer_vmPath' - The VM folder path in the vCenter Server virtual machine inventory tree.
newVmServer ::
  VmServer
newVmServer :: VmServer
newVmServer =
  VmServer' :: Maybe Text
-> Maybe VmManagerType
-> Maybe VmServerAddress
-> Maybe Text
-> Maybe Text
-> VmServer
VmServer'
    { $sel:vmManagerName:VmServer' :: Maybe Text
vmManagerName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:vmManagerType:VmServer' :: Maybe VmManagerType
vmManagerType = Maybe VmManagerType
forall a. Maybe a
Prelude.Nothing,
      $sel:vmServerAddress:VmServer' :: Maybe VmServerAddress
vmServerAddress = Maybe VmServerAddress
forall a. Maybe a
Prelude.Nothing,
      $sel:vmName:VmServer' :: Maybe Text
vmName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:vmPath:VmServer' :: Maybe Text
vmPath = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the VM manager.
vmServer_vmManagerName :: Lens.Lens' VmServer (Prelude.Maybe Prelude.Text)
vmServer_vmManagerName :: (Maybe Text -> f (Maybe Text)) -> VmServer -> f VmServer
vmServer_vmManagerName = (VmServer -> Maybe Text)
-> (VmServer -> Maybe Text -> VmServer)
-> Lens VmServer VmServer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VmServer' {Maybe Text
vmManagerName :: Maybe Text
$sel:vmManagerName:VmServer' :: VmServer -> Maybe Text
vmManagerName} -> Maybe Text
vmManagerName) (\s :: VmServer
s@VmServer' {} Maybe Text
a -> VmServer
s {$sel:vmManagerName:VmServer' :: Maybe Text
vmManagerName = Maybe Text
a} :: VmServer)

-- | The type of VM management product.
vmServer_vmManagerType :: Lens.Lens' VmServer (Prelude.Maybe VmManagerType)
vmServer_vmManagerType :: (Maybe VmManagerType -> f (Maybe VmManagerType))
-> VmServer -> f VmServer
vmServer_vmManagerType = (VmServer -> Maybe VmManagerType)
-> (VmServer -> Maybe VmManagerType -> VmServer)
-> Lens
     VmServer VmServer (Maybe VmManagerType) (Maybe VmManagerType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VmServer' {Maybe VmManagerType
vmManagerType :: Maybe VmManagerType
$sel:vmManagerType:VmServer' :: VmServer -> Maybe VmManagerType
vmManagerType} -> Maybe VmManagerType
vmManagerType) (\s :: VmServer
s@VmServer' {} Maybe VmManagerType
a -> VmServer
s {$sel:vmManagerType:VmServer' :: Maybe VmManagerType
vmManagerType = Maybe VmManagerType
a} :: VmServer)

-- | The VM server location.
vmServer_vmServerAddress :: Lens.Lens' VmServer (Prelude.Maybe VmServerAddress)
vmServer_vmServerAddress :: (Maybe VmServerAddress -> f (Maybe VmServerAddress))
-> VmServer -> f VmServer
vmServer_vmServerAddress = (VmServer -> Maybe VmServerAddress)
-> (VmServer -> Maybe VmServerAddress -> VmServer)
-> Lens
     VmServer VmServer (Maybe VmServerAddress) (Maybe VmServerAddress)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VmServer' {Maybe VmServerAddress
vmServerAddress :: Maybe VmServerAddress
$sel:vmServerAddress:VmServer' :: VmServer -> Maybe VmServerAddress
vmServerAddress} -> Maybe VmServerAddress
vmServerAddress) (\s :: VmServer
s@VmServer' {} Maybe VmServerAddress
a -> VmServer
s {$sel:vmServerAddress:VmServer' :: Maybe VmServerAddress
vmServerAddress = Maybe VmServerAddress
a} :: VmServer)

-- | The name of the VM.
vmServer_vmName :: Lens.Lens' VmServer (Prelude.Maybe Prelude.Text)
vmServer_vmName :: (Maybe Text -> f (Maybe Text)) -> VmServer -> f VmServer
vmServer_vmName = (VmServer -> Maybe Text)
-> (VmServer -> Maybe Text -> VmServer)
-> Lens VmServer VmServer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VmServer' {Maybe Text
vmName :: Maybe Text
$sel:vmName:VmServer' :: VmServer -> Maybe Text
vmName} -> Maybe Text
vmName) (\s :: VmServer
s@VmServer' {} Maybe Text
a -> VmServer
s {$sel:vmName:VmServer' :: Maybe Text
vmName = Maybe Text
a} :: VmServer)

-- | The VM folder path in the vCenter Server virtual machine inventory tree.
vmServer_vmPath :: Lens.Lens' VmServer (Prelude.Maybe Prelude.Text)
vmServer_vmPath :: (Maybe Text -> f (Maybe Text)) -> VmServer -> f VmServer
vmServer_vmPath = (VmServer -> Maybe Text)
-> (VmServer -> Maybe Text -> VmServer)
-> Lens VmServer VmServer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VmServer' {Maybe Text
vmPath :: Maybe Text
$sel:vmPath:VmServer' :: VmServer -> Maybe Text
vmPath} -> Maybe Text
vmPath) (\s :: VmServer
s@VmServer' {} Maybe Text
a -> VmServer
s {$sel:vmPath:VmServer' :: Maybe Text
vmPath = Maybe Text
a} :: VmServer)

instance Core.FromJSON VmServer where
  parseJSON :: Value -> Parser VmServer
parseJSON =
    String -> (Object -> Parser VmServer) -> Value -> Parser VmServer
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VmServer"
      ( \Object
x ->
          Maybe Text
-> Maybe VmManagerType
-> Maybe VmServerAddress
-> Maybe Text
-> Maybe Text
-> VmServer
VmServer'
            (Maybe Text
 -> Maybe VmManagerType
 -> Maybe VmServerAddress
 -> Maybe Text
 -> Maybe Text
 -> VmServer)
-> Parser (Maybe Text)
-> Parser
     (Maybe VmManagerType
      -> Maybe VmServerAddress -> Maybe Text -> Maybe Text -> VmServer)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"vmManagerName")
            Parser
  (Maybe VmManagerType
   -> Maybe VmServerAddress -> Maybe Text -> Maybe Text -> VmServer)
-> Parser (Maybe VmManagerType)
-> Parser
     (Maybe VmServerAddress -> Maybe Text -> Maybe Text -> VmServer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VmManagerType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"vmManagerType")
            Parser
  (Maybe VmServerAddress -> Maybe Text -> Maybe Text -> VmServer)
-> Parser (Maybe VmServerAddress)
-> Parser (Maybe Text -> Maybe Text -> VmServer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VmServerAddress)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"vmServerAddress")
            Parser (Maybe Text -> Maybe Text -> VmServer)
-> Parser (Maybe Text) -> Parser (Maybe Text -> VmServer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"vmName")
            Parser (Maybe Text -> VmServer)
-> Parser (Maybe Text) -> Parser VmServer
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"vmPath")
      )

instance Prelude.Hashable VmServer

instance Prelude.NFData VmServer

instance Core.ToJSON VmServer where
  toJSON :: VmServer -> Value
toJSON VmServer' {Maybe Text
Maybe VmManagerType
Maybe VmServerAddress
vmPath :: Maybe Text
vmName :: Maybe Text
vmServerAddress :: Maybe VmServerAddress
vmManagerType :: Maybe VmManagerType
vmManagerName :: Maybe Text
$sel:vmPath:VmServer' :: VmServer -> Maybe Text
$sel:vmName:VmServer' :: VmServer -> Maybe Text
$sel:vmServerAddress:VmServer' :: VmServer -> Maybe VmServerAddress
$sel:vmManagerType:VmServer' :: VmServer -> Maybe VmManagerType
$sel:vmManagerName:VmServer' :: VmServer -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"vmManagerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
vmManagerName,
            (Text
"vmManagerType" Text -> VmManagerType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VmManagerType -> Pair) -> Maybe VmManagerType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VmManagerType
vmManagerType,
            (Text
"vmServerAddress" Text -> VmServerAddress -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (VmServerAddress -> Pair) -> Maybe VmServerAddress -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VmServerAddress
vmServerAddress,
            (Text
"vmName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
vmName,
            (Text
"vmPath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
vmPath
          ]
      )