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

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

-- | A list of Amazon Resource Names (ARNs) of agents to use for a Network
-- File System (NFS) location.
--
-- /See:/ 'newOnPremConfig' smart constructor.
data OnPremConfig = OnPremConfig'
  { -- | ARNs of the agents to use for an NFS location.
    OnPremConfig -> NonEmpty Text
agentArns :: Prelude.NonEmpty Prelude.Text
  }
  deriving (OnPremConfig -> OnPremConfig -> Bool
(OnPremConfig -> OnPremConfig -> Bool)
-> (OnPremConfig -> OnPremConfig -> Bool) -> Eq OnPremConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OnPremConfig -> OnPremConfig -> Bool
$c/= :: OnPremConfig -> OnPremConfig -> Bool
== :: OnPremConfig -> OnPremConfig -> Bool
$c== :: OnPremConfig -> OnPremConfig -> Bool
Prelude.Eq, ReadPrec [OnPremConfig]
ReadPrec OnPremConfig
Int -> ReadS OnPremConfig
ReadS [OnPremConfig]
(Int -> ReadS OnPremConfig)
-> ReadS [OnPremConfig]
-> ReadPrec OnPremConfig
-> ReadPrec [OnPremConfig]
-> Read OnPremConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OnPremConfig]
$creadListPrec :: ReadPrec [OnPremConfig]
readPrec :: ReadPrec OnPremConfig
$creadPrec :: ReadPrec OnPremConfig
readList :: ReadS [OnPremConfig]
$creadList :: ReadS [OnPremConfig]
readsPrec :: Int -> ReadS OnPremConfig
$creadsPrec :: Int -> ReadS OnPremConfig
Prelude.Read, Int -> OnPremConfig -> ShowS
[OnPremConfig] -> ShowS
OnPremConfig -> String
(Int -> OnPremConfig -> ShowS)
-> (OnPremConfig -> String)
-> ([OnPremConfig] -> ShowS)
-> Show OnPremConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OnPremConfig] -> ShowS
$cshowList :: [OnPremConfig] -> ShowS
show :: OnPremConfig -> String
$cshow :: OnPremConfig -> String
showsPrec :: Int -> OnPremConfig -> ShowS
$cshowsPrec :: Int -> OnPremConfig -> ShowS
Prelude.Show, (forall x. OnPremConfig -> Rep OnPremConfig x)
-> (forall x. Rep OnPremConfig x -> OnPremConfig)
-> Generic OnPremConfig
forall x. Rep OnPremConfig x -> OnPremConfig
forall x. OnPremConfig -> Rep OnPremConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OnPremConfig x -> OnPremConfig
$cfrom :: forall x. OnPremConfig -> Rep OnPremConfig x
Prelude.Generic)

-- |
-- Create a value of 'OnPremConfig' 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:
--
-- 'agentArns', 'onPremConfig_agentArns' - ARNs of the agents to use for an NFS location.
newOnPremConfig ::
  -- | 'agentArns'
  Prelude.NonEmpty Prelude.Text ->
  OnPremConfig
newOnPremConfig :: NonEmpty Text -> OnPremConfig
newOnPremConfig NonEmpty Text
pAgentArns_ =
  OnPremConfig' :: NonEmpty Text -> OnPremConfig
OnPremConfig'
    { $sel:agentArns:OnPremConfig' :: NonEmpty Text
agentArns =
        Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pAgentArns_
    }

-- | ARNs of the agents to use for an NFS location.
onPremConfig_agentArns :: Lens.Lens' OnPremConfig (Prelude.NonEmpty Prelude.Text)
onPremConfig_agentArns :: (NonEmpty Text -> f (NonEmpty Text))
-> OnPremConfig -> f OnPremConfig
onPremConfig_agentArns = (OnPremConfig -> NonEmpty Text)
-> (OnPremConfig -> NonEmpty Text -> OnPremConfig)
-> Lens OnPremConfig OnPremConfig (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OnPremConfig' {NonEmpty Text
agentArns :: NonEmpty Text
$sel:agentArns:OnPremConfig' :: OnPremConfig -> NonEmpty Text
agentArns} -> NonEmpty Text
agentArns) (\s :: OnPremConfig
s@OnPremConfig' {} NonEmpty Text
a -> OnPremConfig
s {$sel:agentArns:OnPremConfig' :: NonEmpty Text
agentArns = NonEmpty Text
a} :: OnPremConfig) ((NonEmpty Text -> f (NonEmpty Text))
 -> OnPremConfig -> f OnPremConfig)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> OnPremConfig
-> f OnPremConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable OnPremConfig

instance Prelude.NFData OnPremConfig

instance Core.ToJSON OnPremConfig where
  toJSON :: OnPremConfig -> Value
toJSON OnPremConfig' {NonEmpty Text
agentArns :: NonEmpty Text
$sel:agentArns:OnPremConfig' :: OnPremConfig -> NonEmpty Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AgentArns" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
agentArns)]
      )