{-# 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.Transfer.Types.ProtocolDetails
-- 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.Transfer.Types.ProtocolDetails where

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

-- | The protocol settings that are configured for your server.
--
-- This type is only valid in the @UpdateServer@ API.
--
-- /See:/ 'newProtocolDetails' smart constructor.
data ProtocolDetails = ProtocolDetails'
  { -- | Indicates passive mode, for FTP and FTPS protocols. Enter a single
    -- dotted-quad IPv4 address, such as the external IP address of a firewall,
    -- router, or load balancer. For example:
    --
    -- @ aws transfer update-server --protocol-details PassiveIp=0.0.0.0 @
    --
    -- Replace @ 0.0.0.0 @ in the example above with the actual IP address you
    -- want to use.
    --
    -- If you change the @PassiveIp@ value, you must stop and then restart your
    -- Transfer server for the change to take effect. For details on using
    -- Passive IP (PASV) in a NAT environment, see
    -- <http://aws.amazon.com/blogs/storage/configuring-your-ftps-server-behind-a-firewall-or-nat-with-aws-transfer-family/ Configuring your FTPS server behind a firewall or NAT with Amazon Web Services Transfer Family>.
    ProtocolDetails -> Maybe Text
passiveIp :: Prelude.Maybe Prelude.Text
  }
  deriving (ProtocolDetails -> ProtocolDetails -> Bool
(ProtocolDetails -> ProtocolDetails -> Bool)
-> (ProtocolDetails -> ProtocolDetails -> Bool)
-> Eq ProtocolDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProtocolDetails -> ProtocolDetails -> Bool
$c/= :: ProtocolDetails -> ProtocolDetails -> Bool
== :: ProtocolDetails -> ProtocolDetails -> Bool
$c== :: ProtocolDetails -> ProtocolDetails -> Bool
Prelude.Eq, ReadPrec [ProtocolDetails]
ReadPrec ProtocolDetails
Int -> ReadS ProtocolDetails
ReadS [ProtocolDetails]
(Int -> ReadS ProtocolDetails)
-> ReadS [ProtocolDetails]
-> ReadPrec ProtocolDetails
-> ReadPrec [ProtocolDetails]
-> Read ProtocolDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProtocolDetails]
$creadListPrec :: ReadPrec [ProtocolDetails]
readPrec :: ReadPrec ProtocolDetails
$creadPrec :: ReadPrec ProtocolDetails
readList :: ReadS [ProtocolDetails]
$creadList :: ReadS [ProtocolDetails]
readsPrec :: Int -> ReadS ProtocolDetails
$creadsPrec :: Int -> ReadS ProtocolDetails
Prelude.Read, Int -> ProtocolDetails -> ShowS
[ProtocolDetails] -> ShowS
ProtocolDetails -> String
(Int -> ProtocolDetails -> ShowS)
-> (ProtocolDetails -> String)
-> ([ProtocolDetails] -> ShowS)
-> Show ProtocolDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProtocolDetails] -> ShowS
$cshowList :: [ProtocolDetails] -> ShowS
show :: ProtocolDetails -> String
$cshow :: ProtocolDetails -> String
showsPrec :: Int -> ProtocolDetails -> ShowS
$cshowsPrec :: Int -> ProtocolDetails -> ShowS
Prelude.Show, (forall x. ProtocolDetails -> Rep ProtocolDetails x)
-> (forall x. Rep ProtocolDetails x -> ProtocolDetails)
-> Generic ProtocolDetails
forall x. Rep ProtocolDetails x -> ProtocolDetails
forall x. ProtocolDetails -> Rep ProtocolDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProtocolDetails x -> ProtocolDetails
$cfrom :: forall x. ProtocolDetails -> Rep ProtocolDetails x
Prelude.Generic)

-- |
-- Create a value of 'ProtocolDetails' 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:
--
-- 'passiveIp', 'protocolDetails_passiveIp' - Indicates passive mode, for FTP and FTPS protocols. Enter a single
-- dotted-quad IPv4 address, such as the external IP address of a firewall,
-- router, or load balancer. For example:
--
-- @ aws transfer update-server --protocol-details PassiveIp=0.0.0.0 @
--
-- Replace @ 0.0.0.0 @ in the example above with the actual IP address you
-- want to use.
--
-- If you change the @PassiveIp@ value, you must stop and then restart your
-- Transfer server for the change to take effect. For details on using
-- Passive IP (PASV) in a NAT environment, see
-- <http://aws.amazon.com/blogs/storage/configuring-your-ftps-server-behind-a-firewall-or-nat-with-aws-transfer-family/ Configuring your FTPS server behind a firewall or NAT with Amazon Web Services Transfer Family>.
newProtocolDetails ::
  ProtocolDetails
newProtocolDetails :: ProtocolDetails
newProtocolDetails =
  ProtocolDetails' :: Maybe Text -> ProtocolDetails
ProtocolDetails' {$sel:passiveIp:ProtocolDetails' :: Maybe Text
passiveIp = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | Indicates passive mode, for FTP and FTPS protocols. Enter a single
-- dotted-quad IPv4 address, such as the external IP address of a firewall,
-- router, or load balancer. For example:
--
-- @ aws transfer update-server --protocol-details PassiveIp=0.0.0.0 @
--
-- Replace @ 0.0.0.0 @ in the example above with the actual IP address you
-- want to use.
--
-- If you change the @PassiveIp@ value, you must stop and then restart your
-- Transfer server for the change to take effect. For details on using
-- Passive IP (PASV) in a NAT environment, see
-- <http://aws.amazon.com/blogs/storage/configuring-your-ftps-server-behind-a-firewall-or-nat-with-aws-transfer-family/ Configuring your FTPS server behind a firewall or NAT with Amazon Web Services Transfer Family>.
protocolDetails_passiveIp :: Lens.Lens' ProtocolDetails (Prelude.Maybe Prelude.Text)
protocolDetails_passiveIp :: (Maybe Text -> f (Maybe Text))
-> ProtocolDetails -> f ProtocolDetails
protocolDetails_passiveIp = (ProtocolDetails -> Maybe Text)
-> (ProtocolDetails -> Maybe Text -> ProtocolDetails)
-> Lens ProtocolDetails ProtocolDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProtocolDetails' {Maybe Text
passiveIp :: Maybe Text
$sel:passiveIp:ProtocolDetails' :: ProtocolDetails -> Maybe Text
passiveIp} -> Maybe Text
passiveIp) (\s :: ProtocolDetails
s@ProtocolDetails' {} Maybe Text
a -> ProtocolDetails
s {$sel:passiveIp:ProtocolDetails' :: Maybe Text
passiveIp = Maybe Text
a} :: ProtocolDetails)

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

instance Prelude.Hashable ProtocolDetails

instance Prelude.NFData ProtocolDetails

instance Core.ToJSON ProtocolDetails where
  toJSON :: ProtocolDetails -> Value
toJSON ProtocolDetails' {Maybe Text
passiveIp :: Maybe Text
$sel:passiveIp:ProtocolDetails' :: ProtocolDetails -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"PassiveIp" 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
passiveIp]
      )