{-# 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.Panorama.Types.NtpPayload
-- 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.Panorama.Types.NtpPayload 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

-- | Network time protocol (NTP) server settings. Use this option to connect
-- to local NTP servers instead of @pool.ntp.org@.
--
-- /See:/ 'newNtpPayload' smart constructor.
data NtpPayload = NtpPayload'
  { -- | NTP servers to use, in order of preference.
    NtpPayload -> [Text]
ntpServers :: [Prelude.Text]
  }
  deriving (NtpPayload -> NtpPayload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NtpPayload -> NtpPayload -> Bool
$c/= :: NtpPayload -> NtpPayload -> Bool
== :: NtpPayload -> NtpPayload -> Bool
$c== :: NtpPayload -> NtpPayload -> Bool
Prelude.Eq, ReadPrec [NtpPayload]
ReadPrec NtpPayload
Int -> ReadS NtpPayload
ReadS [NtpPayload]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NtpPayload]
$creadListPrec :: ReadPrec [NtpPayload]
readPrec :: ReadPrec NtpPayload
$creadPrec :: ReadPrec NtpPayload
readList :: ReadS [NtpPayload]
$creadList :: ReadS [NtpPayload]
readsPrec :: Int -> ReadS NtpPayload
$creadsPrec :: Int -> ReadS NtpPayload
Prelude.Read, Int -> NtpPayload -> ShowS
[NtpPayload] -> ShowS
NtpPayload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NtpPayload] -> ShowS
$cshowList :: [NtpPayload] -> ShowS
show :: NtpPayload -> String
$cshow :: NtpPayload -> String
showsPrec :: Int -> NtpPayload -> ShowS
$cshowsPrec :: Int -> NtpPayload -> ShowS
Prelude.Show, forall x. Rep NtpPayload x -> NtpPayload
forall x. NtpPayload -> Rep NtpPayload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NtpPayload x -> NtpPayload
$cfrom :: forall x. NtpPayload -> Rep NtpPayload x
Prelude.Generic)

-- |
-- Create a value of 'NtpPayload' 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:
--
-- 'ntpServers', 'ntpPayload_ntpServers' - NTP servers to use, in order of preference.
newNtpPayload ::
  NtpPayload
newNtpPayload :: NtpPayload
newNtpPayload =
  NtpPayload' {$sel:ntpServers:NtpPayload' :: [Text]
ntpServers = forall a. Monoid a => a
Prelude.mempty}

-- | NTP servers to use, in order of preference.
ntpPayload_ntpServers :: Lens.Lens' NtpPayload [Prelude.Text]
ntpPayload_ntpServers :: Lens' NtpPayload [Text]
ntpPayload_ntpServers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NtpPayload' {[Text]
ntpServers :: [Text]
$sel:ntpServers:NtpPayload' :: NtpPayload -> [Text]
ntpServers} -> [Text]
ntpServers) (\s :: NtpPayload
s@NtpPayload' {} [Text]
a -> NtpPayload
s {$sel:ntpServers:NtpPayload' :: [Text]
ntpServers = [Text]
a} :: NtpPayload) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON NtpPayload where
  parseJSON :: Value -> Parser NtpPayload
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NtpPayload"
      ( \Object
x ->
          [Text] -> NtpPayload
NtpPayload'
            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
"NtpServers" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable NtpPayload where
  hashWithSalt :: Int -> NtpPayload -> Int
hashWithSalt Int
_salt NtpPayload' {[Text]
ntpServers :: [Text]
$sel:ntpServers:NtpPayload' :: NtpPayload -> [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
ntpServers

instance Prelude.NFData NtpPayload where
  rnf :: NtpPayload -> ()
rnf NtpPayload' {[Text]
ntpServers :: [Text]
$sel:ntpServers:NtpPayload' :: NtpPayload -> [Text]
..} = forall a. NFData a => a -> ()
Prelude.rnf [Text]
ntpServers

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