{-# 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.MGN.Types.Disk
-- 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.MGN.Types.Disk where

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

-- | The disk identifier.
--
-- /See:/ 'newDisk' smart constructor.
data Disk = Disk'
  { -- | The disk or device name.
    Disk -> Maybe Text
deviceName :: Prelude.Maybe Prelude.Text,
    -- | The amount of storage on the disk in bytes.
    Disk -> Maybe Natural
bytes :: Prelude.Maybe Prelude.Natural
  }
  deriving (Disk -> Disk -> Bool
(Disk -> Disk -> Bool) -> (Disk -> Disk -> Bool) -> Eq Disk
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Disk -> Disk -> Bool
$c/= :: Disk -> Disk -> Bool
== :: Disk -> Disk -> Bool
$c== :: Disk -> Disk -> Bool
Prelude.Eq, ReadPrec [Disk]
ReadPrec Disk
Int -> ReadS Disk
ReadS [Disk]
(Int -> ReadS Disk)
-> ReadS [Disk] -> ReadPrec Disk -> ReadPrec [Disk] -> Read Disk
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Disk]
$creadListPrec :: ReadPrec [Disk]
readPrec :: ReadPrec Disk
$creadPrec :: ReadPrec Disk
readList :: ReadS [Disk]
$creadList :: ReadS [Disk]
readsPrec :: Int -> ReadS Disk
$creadsPrec :: Int -> ReadS Disk
Prelude.Read, Int -> Disk -> ShowS
[Disk] -> ShowS
Disk -> String
(Int -> Disk -> ShowS)
-> (Disk -> String) -> ([Disk] -> ShowS) -> Show Disk
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Disk] -> ShowS
$cshowList :: [Disk] -> ShowS
show :: Disk -> String
$cshow :: Disk -> String
showsPrec :: Int -> Disk -> ShowS
$cshowsPrec :: Int -> Disk -> ShowS
Prelude.Show, (forall x. Disk -> Rep Disk x)
-> (forall x. Rep Disk x -> Disk) -> Generic Disk
forall x. Rep Disk x -> Disk
forall x. Disk -> Rep Disk x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Disk x -> Disk
$cfrom :: forall x. Disk -> Rep Disk x
Prelude.Generic)

-- |
-- Create a value of 'Disk' 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:
--
-- 'deviceName', 'disk_deviceName' - The disk or device name.
--
-- 'bytes', 'disk_bytes' - The amount of storage on the disk in bytes.
newDisk ::
  Disk
newDisk :: Disk
newDisk =
  Disk' :: Maybe Text -> Maybe Natural -> Disk
Disk'
    { $sel:deviceName:Disk' :: Maybe Text
deviceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bytes:Disk' :: Maybe Natural
bytes = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The disk or device name.
disk_deviceName :: Lens.Lens' Disk (Prelude.Maybe Prelude.Text)
disk_deviceName :: (Maybe Text -> f (Maybe Text)) -> Disk -> f Disk
disk_deviceName = (Disk -> Maybe Text)
-> (Disk -> Maybe Text -> Disk)
-> Lens Disk Disk (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Disk' {Maybe Text
deviceName :: Maybe Text
$sel:deviceName:Disk' :: Disk -> Maybe Text
deviceName} -> Maybe Text
deviceName) (\s :: Disk
s@Disk' {} Maybe Text
a -> Disk
s {$sel:deviceName:Disk' :: Maybe Text
deviceName = Maybe Text
a} :: Disk)

-- | The amount of storage on the disk in bytes.
disk_bytes :: Lens.Lens' Disk (Prelude.Maybe Prelude.Natural)
disk_bytes :: (Maybe Natural -> f (Maybe Natural)) -> Disk -> f Disk
disk_bytes = (Disk -> Maybe Natural)
-> (Disk -> Maybe Natural -> Disk)
-> Lens Disk Disk (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Disk' {Maybe Natural
bytes :: Maybe Natural
$sel:bytes:Disk' :: Disk -> Maybe Natural
bytes} -> Maybe Natural
bytes) (\s :: Disk
s@Disk' {} Maybe Natural
a -> Disk
s {$sel:bytes:Disk' :: Maybe Natural
bytes = Maybe Natural
a} :: Disk)

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

instance Prelude.Hashable Disk

instance Prelude.NFData Disk