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

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

-- | Defines the real-time status of a Snow device\'s data transfer while the
-- device is at AWS. This data is only available while a job has a
-- @JobState@ value of @InProgress@, for both import and export jobs.
--
-- /See:/ 'newDataTransfer' smart constructor.
data DataTransfer = DataTransfer'
  { -- | The total number of objects for a transfer between a Snow device and
    -- Amazon S3. This value is set to 0 (zero) until all the keys that will be
    -- transferred have been listed.
    DataTransfer -> Maybe Integer
totalObjects :: Prelude.Maybe Prelude.Integer,
    -- | The total bytes of data for a transfer between a Snow device and Amazon
    -- S3. This value is set to 0 (zero) until all the keys that will be
    -- transferred have been listed.
    DataTransfer -> Maybe Integer
totalBytes :: Prelude.Maybe Prelude.Integer,
    -- | The number of objects transferred between a Snow device and Amazon S3.
    DataTransfer -> Maybe Integer
objectsTransferred :: Prelude.Maybe Prelude.Integer,
    -- | The number of bytes transferred between a Snow device and Amazon S3.
    DataTransfer -> Maybe Integer
bytesTransferred :: Prelude.Maybe Prelude.Integer
  }
  deriving (DataTransfer -> DataTransfer -> Bool
(DataTransfer -> DataTransfer -> Bool)
-> (DataTransfer -> DataTransfer -> Bool) -> Eq DataTransfer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataTransfer -> DataTransfer -> Bool
$c/= :: DataTransfer -> DataTransfer -> Bool
== :: DataTransfer -> DataTransfer -> Bool
$c== :: DataTransfer -> DataTransfer -> Bool
Prelude.Eq, ReadPrec [DataTransfer]
ReadPrec DataTransfer
Int -> ReadS DataTransfer
ReadS [DataTransfer]
(Int -> ReadS DataTransfer)
-> ReadS [DataTransfer]
-> ReadPrec DataTransfer
-> ReadPrec [DataTransfer]
-> Read DataTransfer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataTransfer]
$creadListPrec :: ReadPrec [DataTransfer]
readPrec :: ReadPrec DataTransfer
$creadPrec :: ReadPrec DataTransfer
readList :: ReadS [DataTransfer]
$creadList :: ReadS [DataTransfer]
readsPrec :: Int -> ReadS DataTransfer
$creadsPrec :: Int -> ReadS DataTransfer
Prelude.Read, Int -> DataTransfer -> ShowS
[DataTransfer] -> ShowS
DataTransfer -> String
(Int -> DataTransfer -> ShowS)
-> (DataTransfer -> String)
-> ([DataTransfer] -> ShowS)
-> Show DataTransfer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataTransfer] -> ShowS
$cshowList :: [DataTransfer] -> ShowS
show :: DataTransfer -> String
$cshow :: DataTransfer -> String
showsPrec :: Int -> DataTransfer -> ShowS
$cshowsPrec :: Int -> DataTransfer -> ShowS
Prelude.Show, (forall x. DataTransfer -> Rep DataTransfer x)
-> (forall x. Rep DataTransfer x -> DataTransfer)
-> Generic DataTransfer
forall x. Rep DataTransfer x -> DataTransfer
forall x. DataTransfer -> Rep DataTransfer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataTransfer x -> DataTransfer
$cfrom :: forall x. DataTransfer -> Rep DataTransfer x
Prelude.Generic)

-- |
-- Create a value of 'DataTransfer' 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:
--
-- 'totalObjects', 'dataTransfer_totalObjects' - The total number of objects for a transfer between a Snow device and
-- Amazon S3. This value is set to 0 (zero) until all the keys that will be
-- transferred have been listed.
--
-- 'totalBytes', 'dataTransfer_totalBytes' - The total bytes of data for a transfer between a Snow device and Amazon
-- S3. This value is set to 0 (zero) until all the keys that will be
-- transferred have been listed.
--
-- 'objectsTransferred', 'dataTransfer_objectsTransferred' - The number of objects transferred between a Snow device and Amazon S3.
--
-- 'bytesTransferred', 'dataTransfer_bytesTransferred' - The number of bytes transferred between a Snow device and Amazon S3.
newDataTransfer ::
  DataTransfer
newDataTransfer :: DataTransfer
newDataTransfer =
  DataTransfer' :: Maybe Integer
-> Maybe Integer -> Maybe Integer -> Maybe Integer -> DataTransfer
DataTransfer'
    { $sel:totalObjects:DataTransfer' :: Maybe Integer
totalObjects = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:totalBytes:DataTransfer' :: Maybe Integer
totalBytes = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:objectsTransferred:DataTransfer' :: Maybe Integer
objectsTransferred = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:bytesTransferred:DataTransfer' :: Maybe Integer
bytesTransferred = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The total number of objects for a transfer between a Snow device and
-- Amazon S3. This value is set to 0 (zero) until all the keys that will be
-- transferred have been listed.
dataTransfer_totalObjects :: Lens.Lens' DataTransfer (Prelude.Maybe Prelude.Integer)
dataTransfer_totalObjects :: (Maybe Integer -> f (Maybe Integer))
-> DataTransfer -> f DataTransfer
dataTransfer_totalObjects = (DataTransfer -> Maybe Integer)
-> (DataTransfer -> Maybe Integer -> DataTransfer)
-> Lens DataTransfer DataTransfer (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataTransfer' {Maybe Integer
totalObjects :: Maybe Integer
$sel:totalObjects:DataTransfer' :: DataTransfer -> Maybe Integer
totalObjects} -> Maybe Integer
totalObjects) (\s :: DataTransfer
s@DataTransfer' {} Maybe Integer
a -> DataTransfer
s {$sel:totalObjects:DataTransfer' :: Maybe Integer
totalObjects = Maybe Integer
a} :: DataTransfer)

-- | The total bytes of data for a transfer between a Snow device and Amazon
-- S3. This value is set to 0 (zero) until all the keys that will be
-- transferred have been listed.
dataTransfer_totalBytes :: Lens.Lens' DataTransfer (Prelude.Maybe Prelude.Integer)
dataTransfer_totalBytes :: (Maybe Integer -> f (Maybe Integer))
-> DataTransfer -> f DataTransfer
dataTransfer_totalBytes = (DataTransfer -> Maybe Integer)
-> (DataTransfer -> Maybe Integer -> DataTransfer)
-> Lens DataTransfer DataTransfer (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataTransfer' {Maybe Integer
totalBytes :: Maybe Integer
$sel:totalBytes:DataTransfer' :: DataTransfer -> Maybe Integer
totalBytes} -> Maybe Integer
totalBytes) (\s :: DataTransfer
s@DataTransfer' {} Maybe Integer
a -> DataTransfer
s {$sel:totalBytes:DataTransfer' :: Maybe Integer
totalBytes = Maybe Integer
a} :: DataTransfer)

-- | The number of objects transferred between a Snow device and Amazon S3.
dataTransfer_objectsTransferred :: Lens.Lens' DataTransfer (Prelude.Maybe Prelude.Integer)
dataTransfer_objectsTransferred :: (Maybe Integer -> f (Maybe Integer))
-> DataTransfer -> f DataTransfer
dataTransfer_objectsTransferred = (DataTransfer -> Maybe Integer)
-> (DataTransfer -> Maybe Integer -> DataTransfer)
-> Lens DataTransfer DataTransfer (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataTransfer' {Maybe Integer
objectsTransferred :: Maybe Integer
$sel:objectsTransferred:DataTransfer' :: DataTransfer -> Maybe Integer
objectsTransferred} -> Maybe Integer
objectsTransferred) (\s :: DataTransfer
s@DataTransfer' {} Maybe Integer
a -> DataTransfer
s {$sel:objectsTransferred:DataTransfer' :: Maybe Integer
objectsTransferred = Maybe Integer
a} :: DataTransfer)

-- | The number of bytes transferred between a Snow device and Amazon S3.
dataTransfer_bytesTransferred :: Lens.Lens' DataTransfer (Prelude.Maybe Prelude.Integer)
dataTransfer_bytesTransferred :: (Maybe Integer -> f (Maybe Integer))
-> DataTransfer -> f DataTransfer
dataTransfer_bytesTransferred = (DataTransfer -> Maybe Integer)
-> (DataTransfer -> Maybe Integer -> DataTransfer)
-> Lens DataTransfer DataTransfer (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataTransfer' {Maybe Integer
bytesTransferred :: Maybe Integer
$sel:bytesTransferred:DataTransfer' :: DataTransfer -> Maybe Integer
bytesTransferred} -> Maybe Integer
bytesTransferred) (\s :: DataTransfer
s@DataTransfer' {} Maybe Integer
a -> DataTransfer
s {$sel:bytesTransferred:DataTransfer' :: Maybe Integer
bytesTransferred = Maybe Integer
a} :: DataTransfer)

instance Core.FromJSON DataTransfer where
  parseJSON :: Value -> Parser DataTransfer
parseJSON =
    String
-> (Object -> Parser DataTransfer) -> Value -> Parser DataTransfer
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DataTransfer"
      ( \Object
x ->
          Maybe Integer
-> Maybe Integer -> Maybe Integer -> Maybe Integer -> DataTransfer
DataTransfer'
            (Maybe Integer
 -> Maybe Integer -> Maybe Integer -> Maybe Integer -> DataTransfer)
-> Parser (Maybe Integer)
-> Parser
     (Maybe Integer -> Maybe Integer -> Maybe Integer -> DataTransfer)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TotalObjects")
            Parser
  (Maybe Integer -> Maybe Integer -> Maybe Integer -> DataTransfer)
-> Parser (Maybe Integer)
-> Parser (Maybe Integer -> Maybe Integer -> DataTransfer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TotalBytes")
            Parser (Maybe Integer -> Maybe Integer -> DataTransfer)
-> Parser (Maybe Integer) -> Parser (Maybe Integer -> DataTransfer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ObjectsTransferred")
            Parser (Maybe Integer -> DataTransfer)
-> Parser (Maybe Integer) -> Parser DataTransfer
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BytesTransferred")
      )

instance Prelude.Hashable DataTransfer

instance Prelude.NFData DataTransfer