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

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

-- | Object that represents EIRP.
--
-- /See:/ 'newEirp' smart constructor.
data Eirp = Eirp'
  { -- | Units of an EIRP.
    Eirp -> EirpUnits
units :: EirpUnits,
    -- | Value of an EIRP. Valid values are between 20.0 to 50.0 dBW.
    Eirp -> Double
value :: Prelude.Double
  }
  deriving (Eirp -> Eirp -> Bool
(Eirp -> Eirp -> Bool) -> (Eirp -> Eirp -> Bool) -> Eq Eirp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Eirp -> Eirp -> Bool
$c/= :: Eirp -> Eirp -> Bool
== :: Eirp -> Eirp -> Bool
$c== :: Eirp -> Eirp -> Bool
Prelude.Eq, ReadPrec [Eirp]
ReadPrec Eirp
Int -> ReadS Eirp
ReadS [Eirp]
(Int -> ReadS Eirp)
-> ReadS [Eirp] -> ReadPrec Eirp -> ReadPrec [Eirp] -> Read Eirp
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Eirp]
$creadListPrec :: ReadPrec [Eirp]
readPrec :: ReadPrec Eirp
$creadPrec :: ReadPrec Eirp
readList :: ReadS [Eirp]
$creadList :: ReadS [Eirp]
readsPrec :: Int -> ReadS Eirp
$creadsPrec :: Int -> ReadS Eirp
Prelude.Read, Int -> Eirp -> ShowS
[Eirp] -> ShowS
Eirp -> String
(Int -> Eirp -> ShowS)
-> (Eirp -> String) -> ([Eirp] -> ShowS) -> Show Eirp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Eirp] -> ShowS
$cshowList :: [Eirp] -> ShowS
show :: Eirp -> String
$cshow :: Eirp -> String
showsPrec :: Int -> Eirp -> ShowS
$cshowsPrec :: Int -> Eirp -> ShowS
Prelude.Show, (forall x. Eirp -> Rep Eirp x)
-> (forall x. Rep Eirp x -> Eirp) -> Generic Eirp
forall x. Rep Eirp x -> Eirp
forall x. Eirp -> Rep Eirp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Eirp x -> Eirp
$cfrom :: forall x. Eirp -> Rep Eirp x
Prelude.Generic)

-- |
-- Create a value of 'Eirp' 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', 'eirp_units' - Units of an EIRP.
--
-- 'value', 'eirp_value' - Value of an EIRP. Valid values are between 20.0 to 50.0 dBW.
newEirp ::
  -- | 'units'
  EirpUnits ->
  -- | 'value'
  Prelude.Double ->
  Eirp
newEirp :: EirpUnits -> Double -> Eirp
newEirp EirpUnits
pUnits_ Double
pValue_ =
  Eirp' :: EirpUnits -> Double -> Eirp
Eirp' {$sel:units:Eirp' :: EirpUnits
units = EirpUnits
pUnits_, $sel:value:Eirp' :: Double
value = Double
pValue_}

-- | Units of an EIRP.
eirp_units :: Lens.Lens' Eirp EirpUnits
eirp_units :: (EirpUnits -> f EirpUnits) -> Eirp -> f Eirp
eirp_units = (Eirp -> EirpUnits)
-> (Eirp -> EirpUnits -> Eirp)
-> Lens Eirp Eirp EirpUnits EirpUnits
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Eirp' {EirpUnits
units :: EirpUnits
$sel:units:Eirp' :: Eirp -> EirpUnits
units} -> EirpUnits
units) (\s :: Eirp
s@Eirp' {} EirpUnits
a -> Eirp
s {$sel:units:Eirp' :: EirpUnits
units = EirpUnits
a} :: Eirp)

-- | Value of an EIRP. Valid values are between 20.0 to 50.0 dBW.
eirp_value :: Lens.Lens' Eirp Prelude.Double
eirp_value :: (Double -> f Double) -> Eirp -> f Eirp
eirp_value = (Eirp -> Double)
-> (Eirp -> Double -> Eirp) -> Lens Eirp Eirp Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Eirp' {Double
value :: Double
$sel:value:Eirp' :: Eirp -> Double
value} -> Double
value) (\s :: Eirp
s@Eirp' {} Double
a -> Eirp
s {$sel:value:Eirp' :: Double
value = Double
a} :: Eirp)

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

instance Prelude.NFData Eirp

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