{-# 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.StorageGateway.Types.EndpointNetworkConfiguration
-- 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.StorageGateway.Types.EndpointNetworkConfiguration where

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

-- | Specifies network configuration information for the gateway associated
-- with the Amazon FSx file system.
--
-- /See:/ 'newEndpointNetworkConfiguration' smart constructor.
data EndpointNetworkConfiguration = EndpointNetworkConfiguration'
  { -- | A list of gateway IP addresses on which the associated Amazon FSx file
    -- system is available.
    --
    -- If multiple file systems are associated with this gateway, this field is
    -- required.
    EndpointNetworkConfiguration -> Maybe [Text]
ipAddresses :: Prelude.Maybe [Prelude.Text]
  }
  deriving (EndpointNetworkConfiguration
-> EndpointNetworkConfiguration -> Bool
(EndpointNetworkConfiguration
 -> EndpointNetworkConfiguration -> Bool)
-> (EndpointNetworkConfiguration
    -> EndpointNetworkConfiguration -> Bool)
-> Eq EndpointNetworkConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EndpointNetworkConfiguration
-> EndpointNetworkConfiguration -> Bool
$c/= :: EndpointNetworkConfiguration
-> EndpointNetworkConfiguration -> Bool
== :: EndpointNetworkConfiguration
-> EndpointNetworkConfiguration -> Bool
$c== :: EndpointNetworkConfiguration
-> EndpointNetworkConfiguration -> Bool
Prelude.Eq, ReadPrec [EndpointNetworkConfiguration]
ReadPrec EndpointNetworkConfiguration
Int -> ReadS EndpointNetworkConfiguration
ReadS [EndpointNetworkConfiguration]
(Int -> ReadS EndpointNetworkConfiguration)
-> ReadS [EndpointNetworkConfiguration]
-> ReadPrec EndpointNetworkConfiguration
-> ReadPrec [EndpointNetworkConfiguration]
-> Read EndpointNetworkConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EndpointNetworkConfiguration]
$creadListPrec :: ReadPrec [EndpointNetworkConfiguration]
readPrec :: ReadPrec EndpointNetworkConfiguration
$creadPrec :: ReadPrec EndpointNetworkConfiguration
readList :: ReadS [EndpointNetworkConfiguration]
$creadList :: ReadS [EndpointNetworkConfiguration]
readsPrec :: Int -> ReadS EndpointNetworkConfiguration
$creadsPrec :: Int -> ReadS EndpointNetworkConfiguration
Prelude.Read, Int -> EndpointNetworkConfiguration -> ShowS
[EndpointNetworkConfiguration] -> ShowS
EndpointNetworkConfiguration -> String
(Int -> EndpointNetworkConfiguration -> ShowS)
-> (EndpointNetworkConfiguration -> String)
-> ([EndpointNetworkConfiguration] -> ShowS)
-> Show EndpointNetworkConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EndpointNetworkConfiguration] -> ShowS
$cshowList :: [EndpointNetworkConfiguration] -> ShowS
show :: EndpointNetworkConfiguration -> String
$cshow :: EndpointNetworkConfiguration -> String
showsPrec :: Int -> EndpointNetworkConfiguration -> ShowS
$cshowsPrec :: Int -> EndpointNetworkConfiguration -> ShowS
Prelude.Show, (forall x.
 EndpointNetworkConfiguration -> Rep EndpointNetworkConfiguration x)
-> (forall x.
    Rep EndpointNetworkConfiguration x -> EndpointNetworkConfiguration)
-> Generic EndpointNetworkConfiguration
forall x.
Rep EndpointNetworkConfiguration x -> EndpointNetworkConfiguration
forall x.
EndpointNetworkConfiguration -> Rep EndpointNetworkConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EndpointNetworkConfiguration x -> EndpointNetworkConfiguration
$cfrom :: forall x.
EndpointNetworkConfiguration -> Rep EndpointNetworkConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EndpointNetworkConfiguration' 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:
--
-- 'ipAddresses', 'endpointNetworkConfiguration_ipAddresses' - A list of gateway IP addresses on which the associated Amazon FSx file
-- system is available.
--
-- If multiple file systems are associated with this gateway, this field is
-- required.
newEndpointNetworkConfiguration ::
  EndpointNetworkConfiguration
newEndpointNetworkConfiguration :: EndpointNetworkConfiguration
newEndpointNetworkConfiguration =
  EndpointNetworkConfiguration' :: Maybe [Text] -> EndpointNetworkConfiguration
EndpointNetworkConfiguration'
    { $sel:ipAddresses:EndpointNetworkConfiguration' :: Maybe [Text]
ipAddresses =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of gateway IP addresses on which the associated Amazon FSx file
-- system is available.
--
-- If multiple file systems are associated with this gateway, this field is
-- required.
endpointNetworkConfiguration_ipAddresses :: Lens.Lens' EndpointNetworkConfiguration (Prelude.Maybe [Prelude.Text])
endpointNetworkConfiguration_ipAddresses :: (Maybe [Text] -> f (Maybe [Text]))
-> EndpointNetworkConfiguration -> f EndpointNetworkConfiguration
endpointNetworkConfiguration_ipAddresses = (EndpointNetworkConfiguration -> Maybe [Text])
-> (EndpointNetworkConfiguration
    -> Maybe [Text] -> EndpointNetworkConfiguration)
-> Lens
     EndpointNetworkConfiguration
     EndpointNetworkConfiguration
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointNetworkConfiguration' {Maybe [Text]
ipAddresses :: Maybe [Text]
$sel:ipAddresses:EndpointNetworkConfiguration' :: EndpointNetworkConfiguration -> Maybe [Text]
ipAddresses} -> Maybe [Text]
ipAddresses) (\s :: EndpointNetworkConfiguration
s@EndpointNetworkConfiguration' {} Maybe [Text]
a -> EndpointNetworkConfiguration
s {$sel:ipAddresses:EndpointNetworkConfiguration' :: Maybe [Text]
ipAddresses = Maybe [Text]
a} :: EndpointNetworkConfiguration) ((Maybe [Text] -> f (Maybe [Text]))
 -> EndpointNetworkConfiguration -> f EndpointNetworkConfiguration)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> EndpointNetworkConfiguration
-> f EndpointNetworkConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.Hashable
    EndpointNetworkConfiguration

instance Prelude.NFData EndpointNetworkConfiguration

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