{-# 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.Lightsail.Types.AttachedDisk
-- 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.Lightsail.Types.AttachedDisk where

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

-- | Describes a block storage disk that is attached to an instance, and is
-- included in an automatic snapshot.
--
-- /See:/ 'newAttachedDisk' smart constructor.
data AttachedDisk = AttachedDisk'
  { -- | The path of the disk (e.g., @\/dev\/xvdf@).
    AttachedDisk -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | The size of the disk in GB.
    AttachedDisk -> Maybe Int
sizeInGb :: Prelude.Maybe Prelude.Int
  }
  deriving (AttachedDisk -> AttachedDisk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachedDisk -> AttachedDisk -> Bool
$c/= :: AttachedDisk -> AttachedDisk -> Bool
== :: AttachedDisk -> AttachedDisk -> Bool
$c== :: AttachedDisk -> AttachedDisk -> Bool
Prelude.Eq, ReadPrec [AttachedDisk]
ReadPrec AttachedDisk
Int -> ReadS AttachedDisk
ReadS [AttachedDisk]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachedDisk]
$creadListPrec :: ReadPrec [AttachedDisk]
readPrec :: ReadPrec AttachedDisk
$creadPrec :: ReadPrec AttachedDisk
readList :: ReadS [AttachedDisk]
$creadList :: ReadS [AttachedDisk]
readsPrec :: Int -> ReadS AttachedDisk
$creadsPrec :: Int -> ReadS AttachedDisk
Prelude.Read, Int -> AttachedDisk -> ShowS
[AttachedDisk] -> ShowS
AttachedDisk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachedDisk] -> ShowS
$cshowList :: [AttachedDisk] -> ShowS
show :: AttachedDisk -> String
$cshow :: AttachedDisk -> String
showsPrec :: Int -> AttachedDisk -> ShowS
$cshowsPrec :: Int -> AttachedDisk -> ShowS
Prelude.Show, forall x. Rep AttachedDisk x -> AttachedDisk
forall x. AttachedDisk -> Rep AttachedDisk x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttachedDisk x -> AttachedDisk
$cfrom :: forall x. AttachedDisk -> Rep AttachedDisk x
Prelude.Generic)

-- |
-- Create a value of 'AttachedDisk' 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:
--
-- 'path', 'attachedDisk_path' - The path of the disk (e.g., @\/dev\/xvdf@).
--
-- 'sizeInGb', 'attachedDisk_sizeInGb' - The size of the disk in GB.
newAttachedDisk ::
  AttachedDisk
newAttachedDisk :: AttachedDisk
newAttachedDisk =
  AttachedDisk'
    { $sel:path:AttachedDisk' :: Maybe Text
path = forall a. Maybe a
Prelude.Nothing,
      $sel:sizeInGb:AttachedDisk' :: Maybe Int
sizeInGb = forall a. Maybe a
Prelude.Nothing
    }

-- | The path of the disk (e.g., @\/dev\/xvdf@).
attachedDisk_path :: Lens.Lens' AttachedDisk (Prelude.Maybe Prelude.Text)
attachedDisk_path :: Lens' AttachedDisk (Maybe Text)
attachedDisk_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachedDisk' {Maybe Text
path :: Maybe Text
$sel:path:AttachedDisk' :: AttachedDisk -> Maybe Text
path} -> Maybe Text
path) (\s :: AttachedDisk
s@AttachedDisk' {} Maybe Text
a -> AttachedDisk
s {$sel:path:AttachedDisk' :: Maybe Text
path = Maybe Text
a} :: AttachedDisk)

-- | The size of the disk in GB.
attachedDisk_sizeInGb :: Lens.Lens' AttachedDisk (Prelude.Maybe Prelude.Int)
attachedDisk_sizeInGb :: Lens' AttachedDisk (Maybe Int)
attachedDisk_sizeInGb = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachedDisk' {Maybe Int
sizeInGb :: Maybe Int
$sel:sizeInGb:AttachedDisk' :: AttachedDisk -> Maybe Int
sizeInGb} -> Maybe Int
sizeInGb) (\s :: AttachedDisk
s@AttachedDisk' {} Maybe Int
a -> AttachedDisk
s {$sel:sizeInGb:AttachedDisk' :: Maybe Int
sizeInGb = Maybe Int
a} :: AttachedDisk)

instance Data.FromJSON AttachedDisk where
  parseJSON :: Value -> Parser AttachedDisk
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AttachedDisk"
      ( \Object
x ->
          Maybe Text -> Maybe Int -> AttachedDisk
AttachedDisk'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"path")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"sizeInGb")
      )

instance Prelude.Hashable AttachedDisk where
  hashWithSalt :: Int -> AttachedDisk -> Int
hashWithSalt Int
_salt AttachedDisk' {Maybe Int
Maybe Text
sizeInGb :: Maybe Int
path :: Maybe Text
$sel:sizeInGb:AttachedDisk' :: AttachedDisk -> Maybe Int
$sel:path:AttachedDisk' :: AttachedDisk -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
path
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
sizeInGb

instance Prelude.NFData AttachedDisk where
  rnf :: AttachedDisk -> ()
rnf AttachedDisk' {Maybe Int
Maybe Text
sizeInGb :: Maybe Int
path :: Maybe Text
$sel:sizeInGb:AttachedDisk' :: AttachedDisk -> Maybe Int
$sel:path:AttachedDisk' :: AttachedDisk -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
path seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
sizeInGb