{-# 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.NetworkManager.Types.Bandwidth
-- 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.NetworkManager.Types.Bandwidth where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes bandwidth information.
--
-- /See:/ 'newBandwidth' smart constructor.
data Bandwidth = Bandwidth'
  { -- | Download speed in Mbps.
    Bandwidth -> Maybe Int
downloadSpeed :: Prelude.Maybe Prelude.Int,
    -- | Upload speed in Mbps.
    Bandwidth -> Maybe Int
uploadSpeed :: Prelude.Maybe Prelude.Int
  }
  deriving (Bandwidth -> Bandwidth -> Bool
(Bandwidth -> Bandwidth -> Bool)
-> (Bandwidth -> Bandwidth -> Bool) -> Eq Bandwidth
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Bandwidth -> Bandwidth -> Bool
$c/= :: Bandwidth -> Bandwidth -> Bool
== :: Bandwidth -> Bandwidth -> Bool
$c== :: Bandwidth -> Bandwidth -> Bool
Prelude.Eq, ReadPrec [Bandwidth]
ReadPrec Bandwidth
Int -> ReadS Bandwidth
ReadS [Bandwidth]
(Int -> ReadS Bandwidth)
-> ReadS [Bandwidth]
-> ReadPrec Bandwidth
-> ReadPrec [Bandwidth]
-> Read Bandwidth
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Bandwidth]
$creadListPrec :: ReadPrec [Bandwidth]
readPrec :: ReadPrec Bandwidth
$creadPrec :: ReadPrec Bandwidth
readList :: ReadS [Bandwidth]
$creadList :: ReadS [Bandwidth]
readsPrec :: Int -> ReadS Bandwidth
$creadsPrec :: Int -> ReadS Bandwidth
Prelude.Read, Int -> Bandwidth -> ShowS
[Bandwidth] -> ShowS
Bandwidth -> String
(Int -> Bandwidth -> ShowS)
-> (Bandwidth -> String)
-> ([Bandwidth] -> ShowS)
-> Show Bandwidth
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Bandwidth] -> ShowS
$cshowList :: [Bandwidth] -> ShowS
show :: Bandwidth -> String
$cshow :: Bandwidth -> String
showsPrec :: Int -> Bandwidth -> ShowS
$cshowsPrec :: Int -> Bandwidth -> ShowS
Prelude.Show, (forall x. Bandwidth -> Rep Bandwidth x)
-> (forall x. Rep Bandwidth x -> Bandwidth) -> Generic Bandwidth
forall x. Rep Bandwidth x -> Bandwidth
forall x. Bandwidth -> Rep Bandwidth x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Bandwidth x -> Bandwidth
$cfrom :: forall x. Bandwidth -> Rep Bandwidth x
Prelude.Generic)

-- |
-- Create a value of 'Bandwidth' 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:
--
-- 'downloadSpeed', 'bandwidth_downloadSpeed' - Download speed in Mbps.
--
-- 'uploadSpeed', 'bandwidth_uploadSpeed' - Upload speed in Mbps.
newBandwidth ::
  Bandwidth
newBandwidth :: Bandwidth
newBandwidth =
  Bandwidth' :: Maybe Int -> Maybe Int -> Bandwidth
Bandwidth'
    { $sel:downloadSpeed:Bandwidth' :: Maybe Int
downloadSpeed = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:uploadSpeed:Bandwidth' :: Maybe Int
uploadSpeed = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Download speed in Mbps.
bandwidth_downloadSpeed :: Lens.Lens' Bandwidth (Prelude.Maybe Prelude.Int)
bandwidth_downloadSpeed :: (Maybe Int -> f (Maybe Int)) -> Bandwidth -> f Bandwidth
bandwidth_downloadSpeed = (Bandwidth -> Maybe Int)
-> (Bandwidth -> Maybe Int -> Bandwidth)
-> Lens Bandwidth Bandwidth (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Bandwidth' {Maybe Int
downloadSpeed :: Maybe Int
$sel:downloadSpeed:Bandwidth' :: Bandwidth -> Maybe Int
downloadSpeed} -> Maybe Int
downloadSpeed) (\s :: Bandwidth
s@Bandwidth' {} Maybe Int
a -> Bandwidth
s {$sel:downloadSpeed:Bandwidth' :: Maybe Int
downloadSpeed = Maybe Int
a} :: Bandwidth)

-- | Upload speed in Mbps.
bandwidth_uploadSpeed :: Lens.Lens' Bandwidth (Prelude.Maybe Prelude.Int)
bandwidth_uploadSpeed :: (Maybe Int -> f (Maybe Int)) -> Bandwidth -> f Bandwidth
bandwidth_uploadSpeed = (Bandwidth -> Maybe Int)
-> (Bandwidth -> Maybe Int -> Bandwidth)
-> Lens Bandwidth Bandwidth (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Bandwidth' {Maybe Int
uploadSpeed :: Maybe Int
$sel:uploadSpeed:Bandwidth' :: Bandwidth -> Maybe Int
uploadSpeed} -> Maybe Int
uploadSpeed) (\s :: Bandwidth
s@Bandwidth' {} Maybe Int
a -> Bandwidth
s {$sel:uploadSpeed:Bandwidth' :: Maybe Int
uploadSpeed = Maybe Int
a} :: Bandwidth)

instance Core.FromJSON Bandwidth where
  parseJSON :: Value -> Parser Bandwidth
parseJSON =
    String -> (Object -> Parser Bandwidth) -> Value -> Parser Bandwidth
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Bandwidth"
      ( \Object
x ->
          Maybe Int -> Maybe Int -> Bandwidth
Bandwidth'
            (Maybe Int -> Maybe Int -> Bandwidth)
-> Parser (Maybe Int) -> Parser (Maybe Int -> Bandwidth)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DownloadSpeed")
            Parser (Maybe Int -> Bandwidth)
-> Parser (Maybe Int) -> Parser Bandwidth
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UploadSpeed")
      )

instance Prelude.Hashable Bandwidth

instance Prelude.NFData Bandwidth

instance Core.ToJSON Bandwidth where
  toJSON :: Bandwidth -> Value
toJSON Bandwidth' {Maybe Int
uploadSpeed :: Maybe Int
downloadSpeed :: Maybe Int
$sel:uploadSpeed:Bandwidth' :: Bandwidth -> Maybe Int
$sel:downloadSpeed:Bandwidth' :: Bandwidth -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DownloadSpeed" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
downloadSpeed,
            (Text
"UploadSpeed" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
uploadSpeed
          ]
      )