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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(AttachedDisk -> AttachedDisk -> Bool)
-> (AttachedDisk -> AttachedDisk -> Bool) -> Eq AttachedDisk
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]
(Int -> ReadS AttachedDisk)
-> ReadS [AttachedDisk]
-> ReadPrec AttachedDisk
-> ReadPrec [AttachedDisk]
-> Read 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
(Int -> AttachedDisk -> ShowS)
-> (AttachedDisk -> String)
-> ([AttachedDisk] -> ShowS)
-> Show AttachedDisk
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. AttachedDisk -> Rep AttachedDisk x)
-> (forall x. Rep AttachedDisk x -> AttachedDisk)
-> Generic AttachedDisk
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' :: Maybe Text -> Maybe Int -> AttachedDisk
AttachedDisk'
    { $sel:path:AttachedDisk' :: Maybe Text
path = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sizeInGb:AttachedDisk' :: Maybe Int
sizeInGb = Maybe Int
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 :: (Maybe Text -> f (Maybe Text)) -> AttachedDisk -> f AttachedDisk
attachedDisk_path = (AttachedDisk -> Maybe Text)
-> (AttachedDisk -> Maybe Text -> AttachedDisk)
-> Lens AttachedDisk AttachedDisk (Maybe Text) (Maybe Text)
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 :: (Maybe Int -> f (Maybe Int)) -> AttachedDisk -> f AttachedDisk
attachedDisk_sizeInGb = (AttachedDisk -> Maybe Int)
-> (AttachedDisk -> Maybe Int -> AttachedDisk)
-> Lens AttachedDisk AttachedDisk (Maybe Int) (Maybe Int)
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 Core.FromJSON AttachedDisk where
  parseJSON :: Value -> Parser AttachedDisk
parseJSON =
    String
-> (Object -> Parser AttachedDisk) -> Value -> Parser AttachedDisk
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AttachedDisk"
      ( \Object
x ->
          Maybe Text -> Maybe Int -> AttachedDisk
AttachedDisk'
            (Maybe Text -> Maybe Int -> AttachedDisk)
-> Parser (Maybe Text) -> Parser (Maybe Int -> AttachedDisk)
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
"path")
            Parser (Maybe Int -> AttachedDisk)
-> Parser (Maybe Int) -> Parser AttachedDisk
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sizeInGb")
      )

instance Prelude.Hashable AttachedDisk

instance Prelude.NFData AttachedDisk