{-# 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.FileCacheNFSConfiguration
-- 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.FileCacheNFSConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FSx.Types.NfsVersion
import qualified Amazonka.Prelude as Prelude

-- | The configuration for an NFS data repository association (DRA) created
-- during the creation of the Amazon File Cache resource.
--
-- /See:/ 'newFileCacheNFSConfiguration' smart constructor.
data FileCacheNFSConfiguration = FileCacheNFSConfiguration'
  { -- | A list of up to 2 IP addresses of DNS servers used to resolve the NFS
    -- file system domain name. The provided IP addresses can either be the IP
    -- addresses of a DNS forwarder or resolver that the customer manages and
    -- runs inside the customer VPC, or the IP addresses of the on-premises DNS
    -- servers.
    FileCacheNFSConfiguration -> Maybe [Text]
dnsIps :: Prelude.Maybe [Prelude.Text],
    -- | The version of the NFS (Network File System) protocol of the NFS data
    -- repository. The only supported value is @NFS3@, which indicates that the
    -- data repository must support the NFSv3 protocol.
    FileCacheNFSConfiguration -> NfsVersion
version :: NfsVersion
  }
  deriving (FileCacheNFSConfiguration -> FileCacheNFSConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileCacheNFSConfiguration -> FileCacheNFSConfiguration -> Bool
$c/= :: FileCacheNFSConfiguration -> FileCacheNFSConfiguration -> Bool
== :: FileCacheNFSConfiguration -> FileCacheNFSConfiguration -> Bool
$c== :: FileCacheNFSConfiguration -> FileCacheNFSConfiguration -> Bool
Prelude.Eq, ReadPrec [FileCacheNFSConfiguration]
ReadPrec FileCacheNFSConfiguration
Int -> ReadS FileCacheNFSConfiguration
ReadS [FileCacheNFSConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FileCacheNFSConfiguration]
$creadListPrec :: ReadPrec [FileCacheNFSConfiguration]
readPrec :: ReadPrec FileCacheNFSConfiguration
$creadPrec :: ReadPrec FileCacheNFSConfiguration
readList :: ReadS [FileCacheNFSConfiguration]
$creadList :: ReadS [FileCacheNFSConfiguration]
readsPrec :: Int -> ReadS FileCacheNFSConfiguration
$creadsPrec :: Int -> ReadS FileCacheNFSConfiguration
Prelude.Read, Int -> FileCacheNFSConfiguration -> ShowS
[FileCacheNFSConfiguration] -> ShowS
FileCacheNFSConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileCacheNFSConfiguration] -> ShowS
$cshowList :: [FileCacheNFSConfiguration] -> ShowS
show :: FileCacheNFSConfiguration -> String
$cshow :: FileCacheNFSConfiguration -> String
showsPrec :: Int -> FileCacheNFSConfiguration -> ShowS
$cshowsPrec :: Int -> FileCacheNFSConfiguration -> ShowS
Prelude.Show, forall x.
Rep FileCacheNFSConfiguration x -> FileCacheNFSConfiguration
forall x.
FileCacheNFSConfiguration -> Rep FileCacheNFSConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FileCacheNFSConfiguration x -> FileCacheNFSConfiguration
$cfrom :: forall x.
FileCacheNFSConfiguration -> Rep FileCacheNFSConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'FileCacheNFSConfiguration' 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:
--
-- 'dnsIps', 'fileCacheNFSConfiguration_dnsIps' - A list of up to 2 IP addresses of DNS servers used to resolve the NFS
-- file system domain name. The provided IP addresses can either be the IP
-- addresses of a DNS forwarder or resolver that the customer manages and
-- runs inside the customer VPC, or the IP addresses of the on-premises DNS
-- servers.
--
-- 'version', 'fileCacheNFSConfiguration_version' - The version of the NFS (Network File System) protocol of the NFS data
-- repository. The only supported value is @NFS3@, which indicates that the
-- data repository must support the NFSv3 protocol.
newFileCacheNFSConfiguration ::
  -- | 'version'
  NfsVersion ->
  FileCacheNFSConfiguration
newFileCacheNFSConfiguration :: NfsVersion -> FileCacheNFSConfiguration
newFileCacheNFSConfiguration NfsVersion
pVersion_ =
  FileCacheNFSConfiguration'
    { $sel:dnsIps:FileCacheNFSConfiguration' :: Maybe [Text]
dnsIps =
        forall a. Maybe a
Prelude.Nothing,
      $sel:version:FileCacheNFSConfiguration' :: NfsVersion
version = NfsVersion
pVersion_
    }

-- | A list of up to 2 IP addresses of DNS servers used to resolve the NFS
-- file system domain name. The provided IP addresses can either be the IP
-- addresses of a DNS forwarder or resolver that the customer manages and
-- runs inside the customer VPC, or the IP addresses of the on-premises DNS
-- servers.
fileCacheNFSConfiguration_dnsIps :: Lens.Lens' FileCacheNFSConfiguration (Prelude.Maybe [Prelude.Text])
fileCacheNFSConfiguration_dnsIps :: Lens' FileCacheNFSConfiguration (Maybe [Text])
fileCacheNFSConfiguration_dnsIps = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileCacheNFSConfiguration' {Maybe [Text]
dnsIps :: Maybe [Text]
$sel:dnsIps:FileCacheNFSConfiguration' :: FileCacheNFSConfiguration -> Maybe [Text]
dnsIps} -> Maybe [Text]
dnsIps) (\s :: FileCacheNFSConfiguration
s@FileCacheNFSConfiguration' {} Maybe [Text]
a -> FileCacheNFSConfiguration
s {$sel:dnsIps:FileCacheNFSConfiguration' :: Maybe [Text]
dnsIps = Maybe [Text]
a} :: FileCacheNFSConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The version of the NFS (Network File System) protocol of the NFS data
-- repository. The only supported value is @NFS3@, which indicates that the
-- data repository must support the NFSv3 protocol.
fileCacheNFSConfiguration_version :: Lens.Lens' FileCacheNFSConfiguration NfsVersion
fileCacheNFSConfiguration_version :: Lens' FileCacheNFSConfiguration NfsVersion
fileCacheNFSConfiguration_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileCacheNFSConfiguration' {NfsVersion
version :: NfsVersion
$sel:version:FileCacheNFSConfiguration' :: FileCacheNFSConfiguration -> NfsVersion
version} -> NfsVersion
version) (\s :: FileCacheNFSConfiguration
s@FileCacheNFSConfiguration' {} NfsVersion
a -> FileCacheNFSConfiguration
s {$sel:version:FileCacheNFSConfiguration' :: NfsVersion
version = NfsVersion
a} :: FileCacheNFSConfiguration)

instance Prelude.Hashable FileCacheNFSConfiguration where
  hashWithSalt :: Int -> FileCacheNFSConfiguration -> Int
hashWithSalt Int
_salt FileCacheNFSConfiguration' {Maybe [Text]
NfsVersion
version :: NfsVersion
dnsIps :: Maybe [Text]
$sel:version:FileCacheNFSConfiguration' :: FileCacheNFSConfiguration -> NfsVersion
$sel:dnsIps:FileCacheNFSConfiguration' :: FileCacheNFSConfiguration -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
dnsIps
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NfsVersion
version

instance Prelude.NFData FileCacheNFSConfiguration where
  rnf :: FileCacheNFSConfiguration -> ()
rnf FileCacheNFSConfiguration' {Maybe [Text]
NfsVersion
version :: NfsVersion
dnsIps :: Maybe [Text]
$sel:version:FileCacheNFSConfiguration' :: FileCacheNFSConfiguration -> NfsVersion
$sel:dnsIps:FileCacheNFSConfiguration' :: FileCacheNFSConfiguration -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
dnsIps
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NfsVersion
version

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