{-# 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.Lightsail.Types.InstanceNetworking
-- 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.Lightsail.Types.InstanceNetworking where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types.InstancePortInfo
import Amazonka.Lightsail.Types.MonthlyTransfer
import qualified Amazonka.Prelude as Prelude

-- | Describes monthly data transfer rates and port information for an
-- instance.
--
-- /See:/ 'newInstanceNetworking' smart constructor.
data InstanceNetworking = InstanceNetworking'
  { -- | The amount of data in GB allocated for monthly data transfers.
    InstanceNetworking -> Maybe MonthlyTransfer
monthlyTransfer :: Prelude.Maybe MonthlyTransfer,
    -- | An array of key-value pairs containing information about the ports on
    -- the instance.
    InstanceNetworking -> Maybe [InstancePortInfo]
ports :: Prelude.Maybe [InstancePortInfo]
  }
  deriving (InstanceNetworking -> InstanceNetworking -> Bool
(InstanceNetworking -> InstanceNetworking -> Bool)
-> (InstanceNetworking -> InstanceNetworking -> Bool)
-> Eq InstanceNetworking
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceNetworking -> InstanceNetworking -> Bool
$c/= :: InstanceNetworking -> InstanceNetworking -> Bool
== :: InstanceNetworking -> InstanceNetworking -> Bool
$c== :: InstanceNetworking -> InstanceNetworking -> Bool
Prelude.Eq, ReadPrec [InstanceNetworking]
ReadPrec InstanceNetworking
Int -> ReadS InstanceNetworking
ReadS [InstanceNetworking]
(Int -> ReadS InstanceNetworking)
-> ReadS [InstanceNetworking]
-> ReadPrec InstanceNetworking
-> ReadPrec [InstanceNetworking]
-> Read InstanceNetworking
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceNetworking]
$creadListPrec :: ReadPrec [InstanceNetworking]
readPrec :: ReadPrec InstanceNetworking
$creadPrec :: ReadPrec InstanceNetworking
readList :: ReadS [InstanceNetworking]
$creadList :: ReadS [InstanceNetworking]
readsPrec :: Int -> ReadS InstanceNetworking
$creadsPrec :: Int -> ReadS InstanceNetworking
Prelude.Read, Int -> InstanceNetworking -> ShowS
[InstanceNetworking] -> ShowS
InstanceNetworking -> String
(Int -> InstanceNetworking -> ShowS)
-> (InstanceNetworking -> String)
-> ([InstanceNetworking] -> ShowS)
-> Show InstanceNetworking
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceNetworking] -> ShowS
$cshowList :: [InstanceNetworking] -> ShowS
show :: InstanceNetworking -> String
$cshow :: InstanceNetworking -> String
showsPrec :: Int -> InstanceNetworking -> ShowS
$cshowsPrec :: Int -> InstanceNetworking -> ShowS
Prelude.Show, (forall x. InstanceNetworking -> Rep InstanceNetworking x)
-> (forall x. Rep InstanceNetworking x -> InstanceNetworking)
-> Generic InstanceNetworking
forall x. Rep InstanceNetworking x -> InstanceNetworking
forall x. InstanceNetworking -> Rep InstanceNetworking x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceNetworking x -> InstanceNetworking
$cfrom :: forall x. InstanceNetworking -> Rep InstanceNetworking x
Prelude.Generic)

-- |
-- Create a value of 'InstanceNetworking' 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:
--
-- 'monthlyTransfer', 'instanceNetworking_monthlyTransfer' - The amount of data in GB allocated for monthly data transfers.
--
-- 'ports', 'instanceNetworking_ports' - An array of key-value pairs containing information about the ports on
-- the instance.
newInstanceNetworking ::
  InstanceNetworking
newInstanceNetworking :: InstanceNetworking
newInstanceNetworking =
  InstanceNetworking' :: Maybe MonthlyTransfer
-> Maybe [InstancePortInfo] -> InstanceNetworking
InstanceNetworking'
    { $sel:monthlyTransfer:InstanceNetworking' :: Maybe MonthlyTransfer
monthlyTransfer =
        Maybe MonthlyTransfer
forall a. Maybe a
Prelude.Nothing,
      $sel:ports:InstanceNetworking' :: Maybe [InstancePortInfo]
ports = Maybe [InstancePortInfo]
forall a. Maybe a
Prelude.Nothing
    }

-- | The amount of data in GB allocated for monthly data transfers.
instanceNetworking_monthlyTransfer :: Lens.Lens' InstanceNetworking (Prelude.Maybe MonthlyTransfer)
instanceNetworking_monthlyTransfer :: (Maybe MonthlyTransfer -> f (Maybe MonthlyTransfer))
-> InstanceNetworking -> f InstanceNetworking
instanceNetworking_monthlyTransfer = (InstanceNetworking -> Maybe MonthlyTransfer)
-> (InstanceNetworking
    -> Maybe MonthlyTransfer -> InstanceNetworking)
-> Lens
     InstanceNetworking
     InstanceNetworking
     (Maybe MonthlyTransfer)
     (Maybe MonthlyTransfer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceNetworking' {Maybe MonthlyTransfer
monthlyTransfer :: Maybe MonthlyTransfer
$sel:monthlyTransfer:InstanceNetworking' :: InstanceNetworking -> Maybe MonthlyTransfer
monthlyTransfer} -> Maybe MonthlyTransfer
monthlyTransfer) (\s :: InstanceNetworking
s@InstanceNetworking' {} Maybe MonthlyTransfer
a -> InstanceNetworking
s {$sel:monthlyTransfer:InstanceNetworking' :: Maybe MonthlyTransfer
monthlyTransfer = Maybe MonthlyTransfer
a} :: InstanceNetworking)

-- | An array of key-value pairs containing information about the ports on
-- the instance.
instanceNetworking_ports :: Lens.Lens' InstanceNetworking (Prelude.Maybe [InstancePortInfo])
instanceNetworking_ports :: (Maybe [InstancePortInfo] -> f (Maybe [InstancePortInfo]))
-> InstanceNetworking -> f InstanceNetworking
instanceNetworking_ports = (InstanceNetworking -> Maybe [InstancePortInfo])
-> (InstanceNetworking
    -> Maybe [InstancePortInfo] -> InstanceNetworking)
-> Lens
     InstanceNetworking
     InstanceNetworking
     (Maybe [InstancePortInfo])
     (Maybe [InstancePortInfo])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceNetworking' {Maybe [InstancePortInfo]
ports :: Maybe [InstancePortInfo]
$sel:ports:InstanceNetworking' :: InstanceNetworking -> Maybe [InstancePortInfo]
ports} -> Maybe [InstancePortInfo]
ports) (\s :: InstanceNetworking
s@InstanceNetworking' {} Maybe [InstancePortInfo]
a -> InstanceNetworking
s {$sel:ports:InstanceNetworking' :: Maybe [InstancePortInfo]
ports = Maybe [InstancePortInfo]
a} :: InstanceNetworking) ((Maybe [InstancePortInfo] -> f (Maybe [InstancePortInfo]))
 -> InstanceNetworking -> f InstanceNetworking)
-> ((Maybe [InstancePortInfo] -> f (Maybe [InstancePortInfo]))
    -> Maybe [InstancePortInfo] -> f (Maybe [InstancePortInfo]))
-> (Maybe [InstancePortInfo] -> f (Maybe [InstancePortInfo]))
-> InstanceNetworking
-> f InstanceNetworking
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [InstancePortInfo]
  [InstancePortInfo]
  [InstancePortInfo]
  [InstancePortInfo]
-> Iso
     (Maybe [InstancePortInfo])
     (Maybe [InstancePortInfo])
     (Maybe [InstancePortInfo])
     (Maybe [InstancePortInfo])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [InstancePortInfo]
  [InstancePortInfo]
  [InstancePortInfo]
  [InstancePortInfo]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON InstanceNetworking where
  parseJSON :: Value -> Parser InstanceNetworking
parseJSON =
    String
-> (Object -> Parser InstanceNetworking)
-> Value
-> Parser InstanceNetworking
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InstanceNetworking"
      ( \Object
x ->
          Maybe MonthlyTransfer
-> Maybe [InstancePortInfo] -> InstanceNetworking
InstanceNetworking'
            (Maybe MonthlyTransfer
 -> Maybe [InstancePortInfo] -> InstanceNetworking)
-> Parser (Maybe MonthlyTransfer)
-> Parser (Maybe [InstancePortInfo] -> InstanceNetworking)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe MonthlyTransfer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"monthlyTransfer")
            Parser (Maybe [InstancePortInfo] -> InstanceNetworking)
-> Parser (Maybe [InstancePortInfo]) -> Parser InstanceNetworking
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [InstancePortInfo]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ports" Parser (Maybe (Maybe [InstancePortInfo]))
-> Maybe [InstancePortInfo] -> Parser (Maybe [InstancePortInfo])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [InstancePortInfo]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable InstanceNetworking

instance Prelude.NFData InstanceNetworking