{-# 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.Server
-- 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.Server where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SMS.Types.ServerType
import Amazonka.SMS.Types.VmServer

-- | Represents a server.
--
-- /See:/ 'newServer' smart constructor.
data Server = Server'
  { -- | The type of server.
    Server -> Maybe ServerType
serverType :: Prelude.Maybe ServerType,
    -- | The ID of the server.
    Server -> Maybe Text
serverId :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether the replication job is deleted or failed.
    Server -> Maybe Bool
replicationJobTerminated :: Prelude.Maybe Prelude.Bool,
    -- | Information about the VM server.
    Server -> Maybe VmServer
vmServer :: Prelude.Maybe VmServer,
    -- | The ID of the replication job.
    Server -> Maybe Text
replicationJobId :: Prelude.Maybe Prelude.Text
  }
  deriving (Server -> Server -> Bool
(Server -> Server -> Bool)
-> (Server -> Server -> Bool) -> Eq Server
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Server -> Server -> Bool
$c/= :: Server -> Server -> Bool
== :: Server -> Server -> Bool
$c== :: Server -> Server -> Bool
Prelude.Eq, ReadPrec [Server]
ReadPrec Server
Int -> ReadS Server
ReadS [Server]
(Int -> ReadS Server)
-> ReadS [Server]
-> ReadPrec Server
-> ReadPrec [Server]
-> Read Server
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Server]
$creadListPrec :: ReadPrec [Server]
readPrec :: ReadPrec Server
$creadPrec :: ReadPrec Server
readList :: ReadS [Server]
$creadList :: ReadS [Server]
readsPrec :: Int -> ReadS Server
$creadsPrec :: Int -> ReadS Server
Prelude.Read, Int -> Server -> ShowS
[Server] -> ShowS
Server -> String
(Int -> Server -> ShowS)
-> (Server -> String) -> ([Server] -> ShowS) -> Show Server
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Server] -> ShowS
$cshowList :: [Server] -> ShowS
show :: Server -> String
$cshow :: Server -> String
showsPrec :: Int -> Server -> ShowS
$cshowsPrec :: Int -> Server -> ShowS
Prelude.Show, (forall x. Server -> Rep Server x)
-> (forall x. Rep Server x -> Server) -> Generic Server
forall x. Rep Server x -> Server
forall x. Server -> Rep Server x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Server x -> Server
$cfrom :: forall x. Server -> Rep Server x
Prelude.Generic)

-- |
-- Create a value of 'Server' 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:
--
-- 'serverType', 'server_serverType' - The type of server.
--
-- 'serverId', 'server_serverId' - The ID of the server.
--
-- 'replicationJobTerminated', 'server_replicationJobTerminated' - Indicates whether the replication job is deleted or failed.
--
-- 'vmServer', 'server_vmServer' - Information about the VM server.
--
-- 'replicationJobId', 'server_replicationJobId' - The ID of the replication job.
newServer ::
  Server
newServer :: Server
newServer =
  Server' :: Maybe ServerType
-> Maybe Text
-> Maybe Bool
-> Maybe VmServer
-> Maybe Text
-> Server
Server'
    { $sel:serverType:Server' :: Maybe ServerType
serverType = Maybe ServerType
forall a. Maybe a
Prelude.Nothing,
      $sel:serverId:Server' :: Maybe Text
serverId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:replicationJobTerminated:Server' :: Maybe Bool
replicationJobTerminated = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:vmServer:Server' :: Maybe VmServer
vmServer = Maybe VmServer
forall a. Maybe a
Prelude.Nothing,
      $sel:replicationJobId:Server' :: Maybe Text
replicationJobId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of server.
server_serverType :: Lens.Lens' Server (Prelude.Maybe ServerType)
server_serverType :: (Maybe ServerType -> f (Maybe ServerType)) -> Server -> f Server
server_serverType = (Server -> Maybe ServerType)
-> (Server -> Maybe ServerType -> Server)
-> Lens Server Server (Maybe ServerType) (Maybe ServerType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Server' {Maybe ServerType
serverType :: Maybe ServerType
$sel:serverType:Server' :: Server -> Maybe ServerType
serverType} -> Maybe ServerType
serverType) (\s :: Server
s@Server' {} Maybe ServerType
a -> Server
s {$sel:serverType:Server' :: Maybe ServerType
serverType = Maybe ServerType
a} :: Server)

-- | The ID of the server.
server_serverId :: Lens.Lens' Server (Prelude.Maybe Prelude.Text)
server_serverId :: (Maybe Text -> f (Maybe Text)) -> Server -> f Server
server_serverId = (Server -> Maybe Text)
-> (Server -> Maybe Text -> Server)
-> Lens Server Server (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Server' {Maybe Text
serverId :: Maybe Text
$sel:serverId:Server' :: Server -> Maybe Text
serverId} -> Maybe Text
serverId) (\s :: Server
s@Server' {} Maybe Text
a -> Server
s {$sel:serverId:Server' :: Maybe Text
serverId = Maybe Text
a} :: Server)

-- | Indicates whether the replication job is deleted or failed.
server_replicationJobTerminated :: Lens.Lens' Server (Prelude.Maybe Prelude.Bool)
server_replicationJobTerminated :: (Maybe Bool -> f (Maybe Bool)) -> Server -> f Server
server_replicationJobTerminated = (Server -> Maybe Bool)
-> (Server -> Maybe Bool -> Server)
-> Lens Server Server (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Server' {Maybe Bool
replicationJobTerminated :: Maybe Bool
$sel:replicationJobTerminated:Server' :: Server -> Maybe Bool
replicationJobTerminated} -> Maybe Bool
replicationJobTerminated) (\s :: Server
s@Server' {} Maybe Bool
a -> Server
s {$sel:replicationJobTerminated:Server' :: Maybe Bool
replicationJobTerminated = Maybe Bool
a} :: Server)

-- | Information about the VM server.
server_vmServer :: Lens.Lens' Server (Prelude.Maybe VmServer)
server_vmServer :: (Maybe VmServer -> f (Maybe VmServer)) -> Server -> f Server
server_vmServer = (Server -> Maybe VmServer)
-> (Server -> Maybe VmServer -> Server)
-> Lens Server Server (Maybe VmServer) (Maybe VmServer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Server' {Maybe VmServer
vmServer :: Maybe VmServer
$sel:vmServer:Server' :: Server -> Maybe VmServer
vmServer} -> Maybe VmServer
vmServer) (\s :: Server
s@Server' {} Maybe VmServer
a -> Server
s {$sel:vmServer:Server' :: Maybe VmServer
vmServer = Maybe VmServer
a} :: Server)

-- | The ID of the replication job.
server_replicationJobId :: Lens.Lens' Server (Prelude.Maybe Prelude.Text)
server_replicationJobId :: (Maybe Text -> f (Maybe Text)) -> Server -> f Server
server_replicationJobId = (Server -> Maybe Text)
-> (Server -> Maybe Text -> Server)
-> Lens Server Server (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Server' {Maybe Text
replicationJobId :: Maybe Text
$sel:replicationJobId:Server' :: Server -> Maybe Text
replicationJobId} -> Maybe Text
replicationJobId) (\s :: Server
s@Server' {} Maybe Text
a -> Server
s {$sel:replicationJobId:Server' :: Maybe Text
replicationJobId = Maybe Text
a} :: Server)

instance Core.FromJSON Server where
  parseJSON :: Value -> Parser Server
parseJSON =
    String -> (Object -> Parser Server) -> Value -> Parser Server
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Server"
      ( \Object
x ->
          Maybe ServerType
-> Maybe Text
-> Maybe Bool
-> Maybe VmServer
-> Maybe Text
-> Server
Server'
            (Maybe ServerType
 -> Maybe Text
 -> Maybe Bool
 -> Maybe VmServer
 -> Maybe Text
 -> Server)
-> Parser (Maybe ServerType)
-> Parser
     (Maybe Text
      -> Maybe Bool -> Maybe VmServer -> Maybe Text -> Server)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ServerType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"serverType")
            Parser
  (Maybe Text
   -> Maybe Bool -> Maybe VmServer -> Maybe Text -> Server)
-> Parser (Maybe Text)
-> Parser (Maybe Bool -> Maybe VmServer -> Maybe Text -> Server)
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
"serverId")
            Parser (Maybe Bool -> Maybe VmServer -> Maybe Text -> Server)
-> Parser (Maybe Bool)
-> Parser (Maybe VmServer -> Maybe Text -> Server)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"replicationJobTerminated")
            Parser (Maybe VmServer -> Maybe Text -> Server)
-> Parser (Maybe VmServer) -> Parser (Maybe Text -> Server)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VmServer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"vmServer")
            Parser (Maybe Text -> Server)
-> Parser (Maybe Text) -> Parser Server
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
"replicationJobId")
      )

instance Prelude.Hashable Server

instance Prelude.NFData Server

instance Core.ToJSON Server where
  toJSON :: Server -> Value
toJSON Server' {Maybe Bool
Maybe Text
Maybe ServerType
Maybe VmServer
replicationJobId :: Maybe Text
vmServer :: Maybe VmServer
replicationJobTerminated :: Maybe Bool
serverId :: Maybe Text
serverType :: Maybe ServerType
$sel:replicationJobId:Server' :: Server -> Maybe Text
$sel:vmServer:Server' :: Server -> Maybe VmServer
$sel:replicationJobTerminated:Server' :: Server -> Maybe Bool
$sel:serverId:Server' :: Server -> Maybe Text
$sel:serverType:Server' :: Server -> Maybe ServerType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"serverType" Text -> ServerType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ServerType -> Pair) -> Maybe ServerType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ServerType
serverType,
            (Text
"serverId" 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
serverId,
            (Text
"replicationJobTerminated" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
replicationJobTerminated,
            (Text
"vmServer" Text -> VmServer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VmServer -> Pair) -> Maybe VmServer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VmServer
vmServer,
            (Text
"replicationJobId" 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
replicationJobId
          ]
      )