{-# 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.FSx.Types.OpenZFSClientConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.FSx.Types.OpenZFSClientConfiguration where

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

-- | Specifies who can mount an OpenZFS file system and the options available
-- while mounting the file system.
--
-- /See:/ 'newOpenZFSClientConfiguration' smart constructor.
data OpenZFSClientConfiguration = OpenZFSClientConfiguration'
  { -- | A value that specifies who can mount the file system. You can provide a
    -- wildcard character (@*@), an IP address (@0.0.0.0@), or a CIDR address
    -- (@192.0.2.0\/24@). By default, Amazon FSx uses the wildcard character
    -- when specifying the client.
    OpenZFSClientConfiguration -> Text
clients :: Prelude.Text,
    -- | The options to use when mounting the file system. For a list of options
    -- that you can use with Network File System (NFS), see the
    -- <https://linux.die.net/man/5/exports exports(5) - Linux man page>. When
    -- choosing your options, consider the following:
    --
    -- -   @crossmnt@ is used by default. If you don\'t specify @crossmnt@ when
    --     changing the client configuration, you won\'t be able to see or
    --     access snapshots in your file system\'s snapshot directory.
    --
    -- -   @sync@ is used by default. If you instead specify @async@, the
    --     system acknowledges writes before writing to disk. If the system
    --     crashes before the writes are finished, you lose the unwritten data.
    OpenZFSClientConfiguration -> NonEmpty Text
options :: Prelude.NonEmpty Prelude.Text
  }
  deriving (OpenZFSClientConfiguration -> OpenZFSClientConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OpenZFSClientConfiguration -> OpenZFSClientConfiguration -> Bool
$c/= :: OpenZFSClientConfiguration -> OpenZFSClientConfiguration -> Bool
== :: OpenZFSClientConfiguration -> OpenZFSClientConfiguration -> Bool
$c== :: OpenZFSClientConfiguration -> OpenZFSClientConfiguration -> Bool
Prelude.Eq, ReadPrec [OpenZFSClientConfiguration]
ReadPrec OpenZFSClientConfiguration
Int -> ReadS OpenZFSClientConfiguration
ReadS [OpenZFSClientConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OpenZFSClientConfiguration]
$creadListPrec :: ReadPrec [OpenZFSClientConfiguration]
readPrec :: ReadPrec OpenZFSClientConfiguration
$creadPrec :: ReadPrec OpenZFSClientConfiguration
readList :: ReadS [OpenZFSClientConfiguration]
$creadList :: ReadS [OpenZFSClientConfiguration]
readsPrec :: Int -> ReadS OpenZFSClientConfiguration
$creadsPrec :: Int -> ReadS OpenZFSClientConfiguration
Prelude.Read, Int -> OpenZFSClientConfiguration -> ShowS
[OpenZFSClientConfiguration] -> ShowS
OpenZFSClientConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpenZFSClientConfiguration] -> ShowS
$cshowList :: [OpenZFSClientConfiguration] -> ShowS
show :: OpenZFSClientConfiguration -> String
$cshow :: OpenZFSClientConfiguration -> String
showsPrec :: Int -> OpenZFSClientConfiguration -> ShowS
$cshowsPrec :: Int -> OpenZFSClientConfiguration -> ShowS
Prelude.Show, forall x.
Rep OpenZFSClientConfiguration x -> OpenZFSClientConfiguration
forall x.
OpenZFSClientConfiguration -> Rep OpenZFSClientConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep OpenZFSClientConfiguration x -> OpenZFSClientConfiguration
$cfrom :: forall x.
OpenZFSClientConfiguration -> Rep OpenZFSClientConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'OpenZFSClientConfiguration' 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:
--
-- 'clients', 'openZFSClientConfiguration_clients' - A value that specifies who can mount the file system. You can provide a
-- wildcard character (@*@), an IP address (@0.0.0.0@), or a CIDR address
-- (@192.0.2.0\/24@). By default, Amazon FSx uses the wildcard character
-- when specifying the client.
--
-- 'options', 'openZFSClientConfiguration_options' - The options to use when mounting the file system. For a list of options
-- that you can use with Network File System (NFS), see the
-- <https://linux.die.net/man/5/exports exports(5) - Linux man page>. When
-- choosing your options, consider the following:
--
-- -   @crossmnt@ is used by default. If you don\'t specify @crossmnt@ when
--     changing the client configuration, you won\'t be able to see or
--     access snapshots in your file system\'s snapshot directory.
--
-- -   @sync@ is used by default. If you instead specify @async@, the
--     system acknowledges writes before writing to disk. If the system
--     crashes before the writes are finished, you lose the unwritten data.
newOpenZFSClientConfiguration ::
  -- | 'clients'
  Prelude.Text ->
  -- | 'options'
  Prelude.NonEmpty Prelude.Text ->
  OpenZFSClientConfiguration
newOpenZFSClientConfiguration :: Text -> NonEmpty Text -> OpenZFSClientConfiguration
newOpenZFSClientConfiguration Text
pClients_ NonEmpty Text
pOptions_ =
  OpenZFSClientConfiguration'
    { $sel:clients:OpenZFSClientConfiguration' :: Text
clients = Text
pClients_,
      $sel:options:OpenZFSClientConfiguration' :: NonEmpty Text
options = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pOptions_
    }

-- | A value that specifies who can mount the file system. You can provide a
-- wildcard character (@*@), an IP address (@0.0.0.0@), or a CIDR address
-- (@192.0.2.0\/24@). By default, Amazon FSx uses the wildcard character
-- when specifying the client.
openZFSClientConfiguration_clients :: Lens.Lens' OpenZFSClientConfiguration Prelude.Text
openZFSClientConfiguration_clients :: Lens' OpenZFSClientConfiguration Text
openZFSClientConfiguration_clients = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpenZFSClientConfiguration' {Text
clients :: Text
$sel:clients:OpenZFSClientConfiguration' :: OpenZFSClientConfiguration -> Text
clients} -> Text
clients) (\s :: OpenZFSClientConfiguration
s@OpenZFSClientConfiguration' {} Text
a -> OpenZFSClientConfiguration
s {$sel:clients:OpenZFSClientConfiguration' :: Text
clients = Text
a} :: OpenZFSClientConfiguration)

-- | The options to use when mounting the file system. For a list of options
-- that you can use with Network File System (NFS), see the
-- <https://linux.die.net/man/5/exports exports(5) - Linux man page>. When
-- choosing your options, consider the following:
--
-- -   @crossmnt@ is used by default. If you don\'t specify @crossmnt@ when
--     changing the client configuration, you won\'t be able to see or
--     access snapshots in your file system\'s snapshot directory.
--
-- -   @sync@ is used by default. If you instead specify @async@, the
--     system acknowledges writes before writing to disk. If the system
--     crashes before the writes are finished, you lose the unwritten data.
openZFSClientConfiguration_options :: Lens.Lens' OpenZFSClientConfiguration (Prelude.NonEmpty Prelude.Text)
openZFSClientConfiguration_options :: Lens' OpenZFSClientConfiguration (NonEmpty Text)
openZFSClientConfiguration_options = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpenZFSClientConfiguration' {NonEmpty Text
options :: NonEmpty Text
$sel:options:OpenZFSClientConfiguration' :: OpenZFSClientConfiguration -> NonEmpty Text
options} -> NonEmpty Text
options) (\s :: OpenZFSClientConfiguration
s@OpenZFSClientConfiguration' {} NonEmpty Text
a -> OpenZFSClientConfiguration
s {$sel:options:OpenZFSClientConfiguration' :: NonEmpty Text
options = NonEmpty Text
a} :: OpenZFSClientConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON OpenZFSClientConfiguration where
  parseJSON :: Value -> Parser OpenZFSClientConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OpenZFSClientConfiguration"
      ( \Object
x ->
          Text -> NonEmpty Text -> OpenZFSClientConfiguration
OpenZFSClientConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Clients")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Options")
      )

instance Prelude.Hashable OpenZFSClientConfiguration where
  hashWithSalt :: Int -> OpenZFSClientConfiguration -> Int
hashWithSalt Int
_salt OpenZFSClientConfiguration' {NonEmpty Text
Text
options :: NonEmpty Text
clients :: Text
$sel:options:OpenZFSClientConfiguration' :: OpenZFSClientConfiguration -> NonEmpty Text
$sel:clients:OpenZFSClientConfiguration' :: OpenZFSClientConfiguration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clients
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
options

instance Prelude.NFData OpenZFSClientConfiguration where
  rnf :: OpenZFSClientConfiguration -> ()
rnf OpenZFSClientConfiguration' {NonEmpty Text
Text
options :: NonEmpty Text
clients :: Text
$sel:options:OpenZFSClientConfiguration' :: OpenZFSClientConfiguration -> NonEmpty Text
$sel:clients:OpenZFSClientConfiguration' :: OpenZFSClientConfiguration -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
clients
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
options

instance Data.ToJSON OpenZFSClientConfiguration where
  toJSON :: OpenZFSClientConfiguration -> Value
toJSON OpenZFSClientConfiguration' {NonEmpty Text
Text
options :: NonEmpty Text
clients :: Text
$sel:options:OpenZFSClientConfiguration' :: OpenZFSClientConfiguration -> NonEmpty Text
$sel:clients:OpenZFSClientConfiguration' :: OpenZFSClientConfiguration -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Clients" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
clients),
            forall a. a -> Maybe a
Prelude.Just (Key
"Options" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
options)
          ]
      )