{-# 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.DataSync.Types.NfsMountOptions
-- 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.DataSync.Types.NfsMountOptions where

import qualified Amazonka.Core as Core
import Amazonka.DataSync.Types.NfsVersion
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the mount options that are available for DataSync to access
-- an NFS location.
--
-- /See:/ 'newNfsMountOptions' smart constructor.
data NfsMountOptions = NfsMountOptions'
  { -- | The specific NFS version that you want DataSync to use to mount your NFS
    -- share. If the server refuses to use the version specified, the sync will
    -- fail. If you don\'t specify a version, DataSync defaults to @AUTOMATIC@.
    -- That is, DataSync automatically selects a version based on negotiation
    -- with the NFS server.
    --
    -- You can specify the following NFS versions:
    --
    -- -   __<https://tools.ietf.org/html/rfc1813 NFSv3>__ - stateless protocol
    --     version that allows for asynchronous writes on the server.
    --
    -- -   __<https://tools.ietf.org/html/rfc3530 NFSv4.0>__ - stateful,
    --     firewall-friendly protocol version that supports delegations and
    --     pseudo filesystems.
    --
    -- -   __<https://tools.ietf.org/html/rfc5661 NFSv4.1>__ - stateful
    --     protocol version that supports sessions, directory delegations, and
    --     parallel data processing. Version 4.1 also includes all features
    --     available in version 4.0.
    NfsMountOptions -> Maybe NfsVersion
version :: Prelude.Maybe NfsVersion
  }
  deriving (NfsMountOptions -> NfsMountOptions -> Bool
(NfsMountOptions -> NfsMountOptions -> Bool)
-> (NfsMountOptions -> NfsMountOptions -> Bool)
-> Eq NfsMountOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NfsMountOptions -> NfsMountOptions -> Bool
$c/= :: NfsMountOptions -> NfsMountOptions -> Bool
== :: NfsMountOptions -> NfsMountOptions -> Bool
$c== :: NfsMountOptions -> NfsMountOptions -> Bool
Prelude.Eq, ReadPrec [NfsMountOptions]
ReadPrec NfsMountOptions
Int -> ReadS NfsMountOptions
ReadS [NfsMountOptions]
(Int -> ReadS NfsMountOptions)
-> ReadS [NfsMountOptions]
-> ReadPrec NfsMountOptions
-> ReadPrec [NfsMountOptions]
-> Read NfsMountOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NfsMountOptions]
$creadListPrec :: ReadPrec [NfsMountOptions]
readPrec :: ReadPrec NfsMountOptions
$creadPrec :: ReadPrec NfsMountOptions
readList :: ReadS [NfsMountOptions]
$creadList :: ReadS [NfsMountOptions]
readsPrec :: Int -> ReadS NfsMountOptions
$creadsPrec :: Int -> ReadS NfsMountOptions
Prelude.Read, Int -> NfsMountOptions -> ShowS
[NfsMountOptions] -> ShowS
NfsMountOptions -> String
(Int -> NfsMountOptions -> ShowS)
-> (NfsMountOptions -> String)
-> ([NfsMountOptions] -> ShowS)
-> Show NfsMountOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NfsMountOptions] -> ShowS
$cshowList :: [NfsMountOptions] -> ShowS
show :: NfsMountOptions -> String
$cshow :: NfsMountOptions -> String
showsPrec :: Int -> NfsMountOptions -> ShowS
$cshowsPrec :: Int -> NfsMountOptions -> ShowS
Prelude.Show, (forall x. NfsMountOptions -> Rep NfsMountOptions x)
-> (forall x. Rep NfsMountOptions x -> NfsMountOptions)
-> Generic NfsMountOptions
forall x. Rep NfsMountOptions x -> NfsMountOptions
forall x. NfsMountOptions -> Rep NfsMountOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NfsMountOptions x -> NfsMountOptions
$cfrom :: forall x. NfsMountOptions -> Rep NfsMountOptions x
Prelude.Generic)

-- |
-- Create a value of 'NfsMountOptions' 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:
--
-- 'version', 'nfsMountOptions_version' - The specific NFS version that you want DataSync to use to mount your NFS
-- share. If the server refuses to use the version specified, the sync will
-- fail. If you don\'t specify a version, DataSync defaults to @AUTOMATIC@.
-- That is, DataSync automatically selects a version based on negotiation
-- with the NFS server.
--
-- You can specify the following NFS versions:
--
-- -   __<https://tools.ietf.org/html/rfc1813 NFSv3>__ - stateless protocol
--     version that allows for asynchronous writes on the server.
--
-- -   __<https://tools.ietf.org/html/rfc3530 NFSv4.0>__ - stateful,
--     firewall-friendly protocol version that supports delegations and
--     pseudo filesystems.
--
-- -   __<https://tools.ietf.org/html/rfc5661 NFSv4.1>__ - stateful
--     protocol version that supports sessions, directory delegations, and
--     parallel data processing. Version 4.1 also includes all features
--     available in version 4.0.
newNfsMountOptions ::
  NfsMountOptions
newNfsMountOptions :: NfsMountOptions
newNfsMountOptions =
  NfsMountOptions' :: Maybe NfsVersion -> NfsMountOptions
NfsMountOptions' {$sel:version:NfsMountOptions' :: Maybe NfsVersion
version = Maybe NfsVersion
forall a. Maybe a
Prelude.Nothing}

-- | The specific NFS version that you want DataSync to use to mount your NFS
-- share. If the server refuses to use the version specified, the sync will
-- fail. If you don\'t specify a version, DataSync defaults to @AUTOMATIC@.
-- That is, DataSync automatically selects a version based on negotiation
-- with the NFS server.
--
-- You can specify the following NFS versions:
--
-- -   __<https://tools.ietf.org/html/rfc1813 NFSv3>__ - stateless protocol
--     version that allows for asynchronous writes on the server.
--
-- -   __<https://tools.ietf.org/html/rfc3530 NFSv4.0>__ - stateful,
--     firewall-friendly protocol version that supports delegations and
--     pseudo filesystems.
--
-- -   __<https://tools.ietf.org/html/rfc5661 NFSv4.1>__ - stateful
--     protocol version that supports sessions, directory delegations, and
--     parallel data processing. Version 4.1 also includes all features
--     available in version 4.0.
nfsMountOptions_version :: Lens.Lens' NfsMountOptions (Prelude.Maybe NfsVersion)
nfsMountOptions_version :: (Maybe NfsVersion -> f (Maybe NfsVersion))
-> NfsMountOptions -> f NfsMountOptions
nfsMountOptions_version = (NfsMountOptions -> Maybe NfsVersion)
-> (NfsMountOptions -> Maybe NfsVersion -> NfsMountOptions)
-> Lens
     NfsMountOptions
     NfsMountOptions
     (Maybe NfsVersion)
     (Maybe NfsVersion)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NfsMountOptions' {Maybe NfsVersion
version :: Maybe NfsVersion
$sel:version:NfsMountOptions' :: NfsMountOptions -> Maybe NfsVersion
version} -> Maybe NfsVersion
version) (\s :: NfsMountOptions
s@NfsMountOptions' {} Maybe NfsVersion
a -> NfsMountOptions
s {$sel:version:NfsMountOptions' :: Maybe NfsVersion
version = Maybe NfsVersion
a} :: NfsMountOptions)

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

instance Prelude.Hashable NfsMountOptions

instance Prelude.NFData NfsMountOptions

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