{-# 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.GroundStation.Types.Frequency
-- 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.GroundStation.Types.Frequency where

import qualified Amazonka.Core as Core
import Amazonka.GroundStation.Types.FrequencyUnits
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Object that describes the frequency.
--
-- /See:/ 'newFrequency' smart constructor.
data Frequency = Frequency'
  { -- | Frequency units.
    Frequency -> FrequencyUnits
units :: FrequencyUnits,
    -- | Frequency value. Valid values are between 2200 to 2300 MHz and 7750 to
    -- 8400 MHz for downlink and 2025 to 2120 MHz for uplink.
    Frequency -> Double
value :: Prelude.Double
  }
  deriving (Frequency -> Frequency -> Bool
(Frequency -> Frequency -> Bool)
-> (Frequency -> Frequency -> Bool) -> Eq Frequency
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Frequency -> Frequency -> Bool
$c/= :: Frequency -> Frequency -> Bool
== :: Frequency -> Frequency -> Bool
$c== :: Frequency -> Frequency -> Bool
Prelude.Eq, ReadPrec [Frequency]
ReadPrec Frequency
Int -> ReadS Frequency
ReadS [Frequency]
(Int -> ReadS Frequency)
-> ReadS [Frequency]
-> ReadPrec Frequency
-> ReadPrec [Frequency]
-> Read Frequency
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Frequency]
$creadListPrec :: ReadPrec [Frequency]
readPrec :: ReadPrec Frequency
$creadPrec :: ReadPrec Frequency
readList :: ReadS [Frequency]
$creadList :: ReadS [Frequency]
readsPrec :: Int -> ReadS Frequency
$creadsPrec :: Int -> ReadS Frequency
Prelude.Read, Int -> Frequency -> ShowS
[Frequency] -> ShowS
Frequency -> String
(Int -> Frequency -> ShowS)
-> (Frequency -> String)
-> ([Frequency] -> ShowS)
-> Show Frequency
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Frequency] -> ShowS
$cshowList :: [Frequency] -> ShowS
show :: Frequency -> String
$cshow :: Frequency -> String
showsPrec :: Int -> Frequency -> ShowS
$cshowsPrec :: Int -> Frequency -> ShowS
Prelude.Show, (forall x. Frequency -> Rep Frequency x)
-> (forall x. Rep Frequency x -> Frequency) -> Generic Frequency
forall x. Rep Frequency x -> Frequency
forall x. Frequency -> Rep Frequency x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Frequency x -> Frequency
$cfrom :: forall x. Frequency -> Rep Frequency x
Prelude.Generic)

-- |
-- Create a value of 'Frequency' 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:
--
-- 'units', 'frequency_units' - Frequency units.
--
-- 'value', 'frequency_value' - Frequency value. Valid values are between 2200 to 2300 MHz and 7750 to
-- 8400 MHz for downlink and 2025 to 2120 MHz for uplink.
newFrequency ::
  -- | 'units'
  FrequencyUnits ->
  -- | 'value'
  Prelude.Double ->
  Frequency
newFrequency :: FrequencyUnits -> Double -> Frequency
newFrequency FrequencyUnits
pUnits_ Double
pValue_ =
  Frequency' :: FrequencyUnits -> Double -> Frequency
Frequency' {$sel:units:Frequency' :: FrequencyUnits
units = FrequencyUnits
pUnits_, $sel:value:Frequency' :: Double
value = Double
pValue_}

-- | Frequency units.
frequency_units :: Lens.Lens' Frequency FrequencyUnits
frequency_units :: (FrequencyUnits -> f FrequencyUnits) -> Frequency -> f Frequency
frequency_units = (Frequency -> FrequencyUnits)
-> (Frequency -> FrequencyUnits -> Frequency)
-> Lens Frequency Frequency FrequencyUnits FrequencyUnits
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Frequency' {FrequencyUnits
units :: FrequencyUnits
$sel:units:Frequency' :: Frequency -> FrequencyUnits
units} -> FrequencyUnits
units) (\s :: Frequency
s@Frequency' {} FrequencyUnits
a -> Frequency
s {$sel:units:Frequency' :: FrequencyUnits
units = FrequencyUnits
a} :: Frequency)

-- | Frequency value. Valid values are between 2200 to 2300 MHz and 7750 to
-- 8400 MHz for downlink and 2025 to 2120 MHz for uplink.
frequency_value :: Lens.Lens' Frequency Prelude.Double
frequency_value :: (Double -> f Double) -> Frequency -> f Frequency
frequency_value = (Frequency -> Double)
-> (Frequency -> Double -> Frequency)
-> Lens Frequency Frequency Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Frequency' {Double
value :: Double
$sel:value:Frequency' :: Frequency -> Double
value} -> Double
value) (\s :: Frequency
s@Frequency' {} Double
a -> Frequency
s {$sel:value:Frequency' :: Double
value = Double
a} :: Frequency)

instance Core.FromJSON Frequency where
  parseJSON :: Value -> Parser Frequency
parseJSON =
    String -> (Object -> Parser Frequency) -> Value -> Parser Frequency
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Frequency"
      ( \Object
x ->
          FrequencyUnits -> Double -> Frequency
Frequency'
            (FrequencyUnits -> Double -> Frequency)
-> Parser FrequencyUnits -> Parser (Double -> Frequency)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser FrequencyUnits
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"units") Parser (Double -> Frequency) -> Parser Double -> Parser Frequency
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"value")
      )

instance Prelude.Hashable Frequency

instance Prelude.NFData Frequency

instance Core.ToJSON Frequency where
  toJSON :: Frequency -> Value
toJSON Frequency' {Double
FrequencyUnits
value :: Double
units :: FrequencyUnits
$sel:value:Frequency' :: Frequency -> Double
$sel:units:Frequency' :: Frequency -> FrequencyUnits
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"units" Text -> FrequencyUnits -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= FrequencyUnits
units),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"value" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
value)
          ]
      )