{-# 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.VmServerAddress
-- 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.SMS.Types.VmServerAddress 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

-- | Represents a VM server location.
--
-- /See:/ 'newVmServerAddress' smart constructor.
data VmServerAddress = VmServerAddress'
  { -- | The ID of the VM.
    VmServerAddress -> Maybe Text
vmId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the VM manager.
    VmServerAddress -> Maybe Text
vmManagerId :: Prelude.Maybe Prelude.Text
  }
  deriving (VmServerAddress -> VmServerAddress -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VmServerAddress -> VmServerAddress -> Bool
$c/= :: VmServerAddress -> VmServerAddress -> Bool
== :: VmServerAddress -> VmServerAddress -> Bool
$c== :: VmServerAddress -> VmServerAddress -> Bool
Prelude.Eq, ReadPrec [VmServerAddress]
ReadPrec VmServerAddress
Int -> ReadS VmServerAddress
ReadS [VmServerAddress]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VmServerAddress]
$creadListPrec :: ReadPrec [VmServerAddress]
readPrec :: ReadPrec VmServerAddress
$creadPrec :: ReadPrec VmServerAddress
readList :: ReadS [VmServerAddress]
$creadList :: ReadS [VmServerAddress]
readsPrec :: Int -> ReadS VmServerAddress
$creadsPrec :: Int -> ReadS VmServerAddress
Prelude.Read, Int -> VmServerAddress -> ShowS
[VmServerAddress] -> ShowS
VmServerAddress -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VmServerAddress] -> ShowS
$cshowList :: [VmServerAddress] -> ShowS
show :: VmServerAddress -> String
$cshow :: VmServerAddress -> String
showsPrec :: Int -> VmServerAddress -> ShowS
$cshowsPrec :: Int -> VmServerAddress -> ShowS
Prelude.Show, forall x. Rep VmServerAddress x -> VmServerAddress
forall x. VmServerAddress -> Rep VmServerAddress x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VmServerAddress x -> VmServerAddress
$cfrom :: forall x. VmServerAddress -> Rep VmServerAddress x
Prelude.Generic)

-- |
-- Create a value of 'VmServerAddress' 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:
--
-- 'vmId', 'vmServerAddress_vmId' - The ID of the VM.
--
-- 'vmManagerId', 'vmServerAddress_vmManagerId' - The ID of the VM manager.
newVmServerAddress ::
  VmServerAddress
newVmServerAddress :: VmServerAddress
newVmServerAddress =
  VmServerAddress'
    { $sel:vmId:VmServerAddress' :: Maybe Text
vmId = forall a. Maybe a
Prelude.Nothing,
      $sel:vmManagerId:VmServerAddress' :: Maybe Text
vmManagerId = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the VM.
vmServerAddress_vmId :: Lens.Lens' VmServerAddress (Prelude.Maybe Prelude.Text)
vmServerAddress_vmId :: Lens' VmServerAddress (Maybe Text)
vmServerAddress_vmId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VmServerAddress' {Maybe Text
vmId :: Maybe Text
$sel:vmId:VmServerAddress' :: VmServerAddress -> Maybe Text
vmId} -> Maybe Text
vmId) (\s :: VmServerAddress
s@VmServerAddress' {} Maybe Text
a -> VmServerAddress
s {$sel:vmId:VmServerAddress' :: Maybe Text
vmId = Maybe Text
a} :: VmServerAddress)

-- | The ID of the VM manager.
vmServerAddress_vmManagerId :: Lens.Lens' VmServerAddress (Prelude.Maybe Prelude.Text)
vmServerAddress_vmManagerId :: Lens' VmServerAddress (Maybe Text)
vmServerAddress_vmManagerId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VmServerAddress' {Maybe Text
vmManagerId :: Maybe Text
$sel:vmManagerId:VmServerAddress' :: VmServerAddress -> Maybe Text
vmManagerId} -> Maybe Text
vmManagerId) (\s :: VmServerAddress
s@VmServerAddress' {} Maybe Text
a -> VmServerAddress
s {$sel:vmManagerId:VmServerAddress' :: Maybe Text
vmManagerId = Maybe Text
a} :: VmServerAddress)

instance Data.FromJSON VmServerAddress where
  parseJSON :: Value -> Parser VmServerAddress
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VmServerAddress"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> VmServerAddress
VmServerAddress'
            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
"vmId")
            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
"vmManagerId")
      )

instance Prelude.Hashable VmServerAddress where
  hashWithSalt :: Int -> VmServerAddress -> Int
hashWithSalt Int
_salt VmServerAddress' {Maybe Text
vmManagerId :: Maybe Text
vmId :: Maybe Text
$sel:vmManagerId:VmServerAddress' :: VmServerAddress -> Maybe Text
$sel:vmId:VmServerAddress' :: VmServerAddress -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vmId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vmManagerId

instance Prelude.NFData VmServerAddress where
  rnf :: VmServerAddress -> ()
rnf VmServerAddress' {Maybe Text
vmManagerId :: Maybe Text
vmId :: Maybe Text
$sel:vmManagerId:VmServerAddress' :: VmServerAddress -> Maybe Text
$sel:vmId:VmServerAddress' :: VmServerAddress -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vmId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vmManagerId

instance Data.ToJSON VmServerAddress where
  toJSON :: VmServerAddress -> Value
toJSON VmServerAddress' {Maybe Text
vmManagerId :: Maybe Text
vmId :: Maybe Text
$sel:vmManagerId:VmServerAddress' :: VmServerAddress -> Maybe Text
$sel:vmId:VmServerAddress' :: VmServerAddress -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"vmId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
vmId,
            (Key
"vmManagerId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
vmManagerId
          ]
      )