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

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

-- | Object that describes the frequency bandwidth.
--
-- /See:/ 'newFrequencyBandwidth' smart constructor.
data FrequencyBandwidth = FrequencyBandwidth'
  { -- | Frequency bandwidth units.
    FrequencyBandwidth -> BandwidthUnits
units :: BandwidthUnits,
    -- | Frequency bandwidth value. AWS Ground Station currently has the
    -- following bandwidth limitations:
    --
    -- -   For @AntennaDownlinkDemodDecodeconfig@, valid values are between 125
    --     kHz to 650 MHz.
    --
    -- -   For @AntennaDownlinkconfig@, valid values are between 10 kHz to 54
    --     MHz.
    --
    -- -   For @AntennaUplinkConfig@, valid values are between 10 kHz to 54
    --     MHz.
    FrequencyBandwidth -> Double
value :: Prelude.Double
  }
  deriving (FrequencyBandwidth -> FrequencyBandwidth -> Bool
(FrequencyBandwidth -> FrequencyBandwidth -> Bool)
-> (FrequencyBandwidth -> FrequencyBandwidth -> Bool)
-> Eq FrequencyBandwidth
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FrequencyBandwidth -> FrequencyBandwidth -> Bool
$c/= :: FrequencyBandwidth -> FrequencyBandwidth -> Bool
== :: FrequencyBandwidth -> FrequencyBandwidth -> Bool
$c== :: FrequencyBandwidth -> FrequencyBandwidth -> Bool
Prelude.Eq, ReadPrec [FrequencyBandwidth]
ReadPrec FrequencyBandwidth
Int -> ReadS FrequencyBandwidth
ReadS [FrequencyBandwidth]
(Int -> ReadS FrequencyBandwidth)
-> ReadS [FrequencyBandwidth]
-> ReadPrec FrequencyBandwidth
-> ReadPrec [FrequencyBandwidth]
-> Read FrequencyBandwidth
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FrequencyBandwidth]
$creadListPrec :: ReadPrec [FrequencyBandwidth]
readPrec :: ReadPrec FrequencyBandwidth
$creadPrec :: ReadPrec FrequencyBandwidth
readList :: ReadS [FrequencyBandwidth]
$creadList :: ReadS [FrequencyBandwidth]
readsPrec :: Int -> ReadS FrequencyBandwidth
$creadsPrec :: Int -> ReadS FrequencyBandwidth
Prelude.Read, Int -> FrequencyBandwidth -> ShowS
[FrequencyBandwidth] -> ShowS
FrequencyBandwidth -> String
(Int -> FrequencyBandwidth -> ShowS)
-> (FrequencyBandwidth -> String)
-> ([FrequencyBandwidth] -> ShowS)
-> Show FrequencyBandwidth
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FrequencyBandwidth] -> ShowS
$cshowList :: [FrequencyBandwidth] -> ShowS
show :: FrequencyBandwidth -> String
$cshow :: FrequencyBandwidth -> String
showsPrec :: Int -> FrequencyBandwidth -> ShowS
$cshowsPrec :: Int -> FrequencyBandwidth -> ShowS
Prelude.Show, (forall x. FrequencyBandwidth -> Rep FrequencyBandwidth x)
-> (forall x. Rep FrequencyBandwidth x -> FrequencyBandwidth)
-> Generic FrequencyBandwidth
forall x. Rep FrequencyBandwidth x -> FrequencyBandwidth
forall x. FrequencyBandwidth -> Rep FrequencyBandwidth x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FrequencyBandwidth x -> FrequencyBandwidth
$cfrom :: forall x. FrequencyBandwidth -> Rep FrequencyBandwidth x
Prelude.Generic)

-- |
-- Create a value of 'FrequencyBandwidth' 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', 'frequencyBandwidth_units' - Frequency bandwidth units.
--
-- 'value', 'frequencyBandwidth_value' - Frequency bandwidth value. AWS Ground Station currently has the
-- following bandwidth limitations:
--
-- -   For @AntennaDownlinkDemodDecodeconfig@, valid values are between 125
--     kHz to 650 MHz.
--
-- -   For @AntennaDownlinkconfig@, valid values are between 10 kHz to 54
--     MHz.
--
-- -   For @AntennaUplinkConfig@, valid values are between 10 kHz to 54
--     MHz.
newFrequencyBandwidth ::
  -- | 'units'
  BandwidthUnits ->
  -- | 'value'
  Prelude.Double ->
  FrequencyBandwidth
newFrequencyBandwidth :: BandwidthUnits -> Double -> FrequencyBandwidth
newFrequencyBandwidth BandwidthUnits
pUnits_ Double
pValue_ =
  FrequencyBandwidth' :: BandwidthUnits -> Double -> FrequencyBandwidth
FrequencyBandwidth'
    { $sel:units:FrequencyBandwidth' :: BandwidthUnits
units = BandwidthUnits
pUnits_,
      $sel:value:FrequencyBandwidth' :: Double
value = Double
pValue_
    }

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

-- | Frequency bandwidth value. AWS Ground Station currently has the
-- following bandwidth limitations:
--
-- -   For @AntennaDownlinkDemodDecodeconfig@, valid values are between 125
--     kHz to 650 MHz.
--
-- -   For @AntennaDownlinkconfig@, valid values are between 10 kHz to 54
--     MHz.
--
-- -   For @AntennaUplinkConfig@, valid values are between 10 kHz to 54
--     MHz.
frequencyBandwidth_value :: Lens.Lens' FrequencyBandwidth Prelude.Double
frequencyBandwidth_value :: (Double -> f Double) -> FrequencyBandwidth -> f FrequencyBandwidth
frequencyBandwidth_value = (FrequencyBandwidth -> Double)
-> (FrequencyBandwidth -> Double -> FrequencyBandwidth)
-> Lens FrequencyBandwidth FrequencyBandwidth Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FrequencyBandwidth' {Double
value :: Double
$sel:value:FrequencyBandwidth' :: FrequencyBandwidth -> Double
value} -> Double
value) (\s :: FrequencyBandwidth
s@FrequencyBandwidth' {} Double
a -> FrequencyBandwidth
s {$sel:value:FrequencyBandwidth' :: Double
value = Double
a} :: FrequencyBandwidth)

instance Core.FromJSON FrequencyBandwidth where
  parseJSON :: Value -> Parser FrequencyBandwidth
parseJSON =
    String
-> (Object -> Parser FrequencyBandwidth)
-> Value
-> Parser FrequencyBandwidth
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FrequencyBandwidth"
      ( \Object
x ->
          BandwidthUnits -> Double -> FrequencyBandwidth
FrequencyBandwidth'
            (BandwidthUnits -> Double -> FrequencyBandwidth)
-> Parser BandwidthUnits -> Parser (Double -> FrequencyBandwidth)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser BandwidthUnits
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"units") Parser (Double -> FrequencyBandwidth)
-> Parser Double -> Parser FrequencyBandwidth
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 FrequencyBandwidth

instance Prelude.NFData FrequencyBandwidth

instance Core.ToJSON FrequencyBandwidth where
  toJSON :: FrequencyBandwidth -> Value
toJSON FrequencyBandwidth' {Double
BandwidthUnits
value :: Double
units :: BandwidthUnits
$sel:value:FrequencyBandwidth' :: FrequencyBandwidth -> Double
$sel:units:FrequencyBandwidth' :: FrequencyBandwidth -> BandwidthUnits
..} =
    [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 -> BandwidthUnits -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= BandwidthUnits
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)
          ]
      )