{-# 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.Snowball.Types.TargetOnDeviceService
-- 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.Snowball.Types.TargetOnDeviceService where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Snowball.Types.DeviceServiceName
import Amazonka.Snowball.Types.TransferOption

-- | An object that represents the service or services on the Snow Family
-- device that your transferred data will be exported from or imported
-- into. AWS Snow Family supports Amazon S3 and NFS (Network File System).
--
-- /See:/ 'newTargetOnDeviceService' smart constructor.
data TargetOnDeviceService = TargetOnDeviceService'
  { -- | Specifies whether the data is being imported or exported. You can import
    -- or export the data, or use it locally on the device.
    TargetOnDeviceService -> Maybe TransferOption
transferOption :: Prelude.Maybe TransferOption,
    -- | Specifies the name of the service on the Snow Family device that your
    -- transferred data will be exported from or imported into.
    TargetOnDeviceService -> Maybe DeviceServiceName
serviceName :: Prelude.Maybe DeviceServiceName
  }
  deriving (TargetOnDeviceService -> TargetOnDeviceService -> Bool
(TargetOnDeviceService -> TargetOnDeviceService -> Bool)
-> (TargetOnDeviceService -> TargetOnDeviceService -> Bool)
-> Eq TargetOnDeviceService
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetOnDeviceService -> TargetOnDeviceService -> Bool
$c/= :: TargetOnDeviceService -> TargetOnDeviceService -> Bool
== :: TargetOnDeviceService -> TargetOnDeviceService -> Bool
$c== :: TargetOnDeviceService -> TargetOnDeviceService -> Bool
Prelude.Eq, ReadPrec [TargetOnDeviceService]
ReadPrec TargetOnDeviceService
Int -> ReadS TargetOnDeviceService
ReadS [TargetOnDeviceService]
(Int -> ReadS TargetOnDeviceService)
-> ReadS [TargetOnDeviceService]
-> ReadPrec TargetOnDeviceService
-> ReadPrec [TargetOnDeviceService]
-> Read TargetOnDeviceService
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetOnDeviceService]
$creadListPrec :: ReadPrec [TargetOnDeviceService]
readPrec :: ReadPrec TargetOnDeviceService
$creadPrec :: ReadPrec TargetOnDeviceService
readList :: ReadS [TargetOnDeviceService]
$creadList :: ReadS [TargetOnDeviceService]
readsPrec :: Int -> ReadS TargetOnDeviceService
$creadsPrec :: Int -> ReadS TargetOnDeviceService
Prelude.Read, Int -> TargetOnDeviceService -> ShowS
[TargetOnDeviceService] -> ShowS
TargetOnDeviceService -> String
(Int -> TargetOnDeviceService -> ShowS)
-> (TargetOnDeviceService -> String)
-> ([TargetOnDeviceService] -> ShowS)
-> Show TargetOnDeviceService
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetOnDeviceService] -> ShowS
$cshowList :: [TargetOnDeviceService] -> ShowS
show :: TargetOnDeviceService -> String
$cshow :: TargetOnDeviceService -> String
showsPrec :: Int -> TargetOnDeviceService -> ShowS
$cshowsPrec :: Int -> TargetOnDeviceService -> ShowS
Prelude.Show, (forall x. TargetOnDeviceService -> Rep TargetOnDeviceService x)
-> (forall x. Rep TargetOnDeviceService x -> TargetOnDeviceService)
-> Generic TargetOnDeviceService
forall x. Rep TargetOnDeviceService x -> TargetOnDeviceService
forall x. TargetOnDeviceService -> Rep TargetOnDeviceService x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TargetOnDeviceService x -> TargetOnDeviceService
$cfrom :: forall x. TargetOnDeviceService -> Rep TargetOnDeviceService x
Prelude.Generic)

-- |
-- Create a value of 'TargetOnDeviceService' 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:
--
-- 'transferOption', 'targetOnDeviceService_transferOption' - Specifies whether the data is being imported or exported. You can import
-- or export the data, or use it locally on the device.
--
-- 'serviceName', 'targetOnDeviceService_serviceName' - Specifies the name of the service on the Snow Family device that your
-- transferred data will be exported from or imported into.
newTargetOnDeviceService ::
  TargetOnDeviceService
newTargetOnDeviceService :: TargetOnDeviceService
newTargetOnDeviceService =
  TargetOnDeviceService' :: Maybe TransferOption
-> Maybe DeviceServiceName -> TargetOnDeviceService
TargetOnDeviceService'
    { $sel:transferOption:TargetOnDeviceService' :: Maybe TransferOption
transferOption =
        Maybe TransferOption
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceName:TargetOnDeviceService' :: Maybe DeviceServiceName
serviceName = Maybe DeviceServiceName
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether the data is being imported or exported. You can import
-- or export the data, or use it locally on the device.
targetOnDeviceService_transferOption :: Lens.Lens' TargetOnDeviceService (Prelude.Maybe TransferOption)
targetOnDeviceService_transferOption :: (Maybe TransferOption -> f (Maybe TransferOption))
-> TargetOnDeviceService -> f TargetOnDeviceService
targetOnDeviceService_transferOption = (TargetOnDeviceService -> Maybe TransferOption)
-> (TargetOnDeviceService
    -> Maybe TransferOption -> TargetOnDeviceService)
-> Lens
     TargetOnDeviceService
     TargetOnDeviceService
     (Maybe TransferOption)
     (Maybe TransferOption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetOnDeviceService' {Maybe TransferOption
transferOption :: Maybe TransferOption
$sel:transferOption:TargetOnDeviceService' :: TargetOnDeviceService -> Maybe TransferOption
transferOption} -> Maybe TransferOption
transferOption) (\s :: TargetOnDeviceService
s@TargetOnDeviceService' {} Maybe TransferOption
a -> TargetOnDeviceService
s {$sel:transferOption:TargetOnDeviceService' :: Maybe TransferOption
transferOption = Maybe TransferOption
a} :: TargetOnDeviceService)

-- | Specifies the name of the service on the Snow Family device that your
-- transferred data will be exported from or imported into.
targetOnDeviceService_serviceName :: Lens.Lens' TargetOnDeviceService (Prelude.Maybe DeviceServiceName)
targetOnDeviceService_serviceName :: (Maybe DeviceServiceName -> f (Maybe DeviceServiceName))
-> TargetOnDeviceService -> f TargetOnDeviceService
targetOnDeviceService_serviceName = (TargetOnDeviceService -> Maybe DeviceServiceName)
-> (TargetOnDeviceService
    -> Maybe DeviceServiceName -> TargetOnDeviceService)
-> Lens
     TargetOnDeviceService
     TargetOnDeviceService
     (Maybe DeviceServiceName)
     (Maybe DeviceServiceName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetOnDeviceService' {Maybe DeviceServiceName
serviceName :: Maybe DeviceServiceName
$sel:serviceName:TargetOnDeviceService' :: TargetOnDeviceService -> Maybe DeviceServiceName
serviceName} -> Maybe DeviceServiceName
serviceName) (\s :: TargetOnDeviceService
s@TargetOnDeviceService' {} Maybe DeviceServiceName
a -> TargetOnDeviceService
s {$sel:serviceName:TargetOnDeviceService' :: Maybe DeviceServiceName
serviceName = Maybe DeviceServiceName
a} :: TargetOnDeviceService)

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

instance Prelude.Hashable TargetOnDeviceService

instance Prelude.NFData TargetOnDeviceService

instance Core.ToJSON TargetOnDeviceService where
  toJSON :: TargetOnDeviceService -> Value
toJSON TargetOnDeviceService' {Maybe DeviceServiceName
Maybe TransferOption
serviceName :: Maybe DeviceServiceName
transferOption :: Maybe TransferOption
$sel:serviceName:TargetOnDeviceService' :: TargetOnDeviceService -> Maybe DeviceServiceName
$sel:transferOption:TargetOnDeviceService' :: TargetOnDeviceService -> Maybe TransferOption
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TransferOption" Text -> TransferOption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TransferOption -> Pair) -> Maybe TransferOption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TransferOption
transferOption,
            (Text
"ServiceName" Text -> DeviceServiceName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DeviceServiceName -> Pair)
-> Maybe DeviceServiceName -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeviceServiceName
serviceName
          ]
      )