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

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

-- | Describes a block storage disk mapping.
--
-- /See:/ 'newDiskMap' smart constructor.
data DiskMap = DiskMap'
  { -- | The new disk name (e.g., @my-new-disk@).
    DiskMap -> Maybe Text
newDiskName' :: Prelude.Maybe Prelude.Text,
    -- | The original disk path exposed to the instance (for example,
    -- @\/dev\/sdh@).
    DiskMap -> Maybe Text
originalDiskPath :: Prelude.Maybe Prelude.Text
  }
  deriving (DiskMap -> DiskMap -> Bool
(DiskMap -> DiskMap -> Bool)
-> (DiskMap -> DiskMap -> Bool) -> Eq DiskMap
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DiskMap -> DiskMap -> Bool
$c/= :: DiskMap -> DiskMap -> Bool
== :: DiskMap -> DiskMap -> Bool
$c== :: DiskMap -> DiskMap -> Bool
Prelude.Eq, ReadPrec [DiskMap]
ReadPrec DiskMap
Int -> ReadS DiskMap
ReadS [DiskMap]
(Int -> ReadS DiskMap)
-> ReadS [DiskMap]
-> ReadPrec DiskMap
-> ReadPrec [DiskMap]
-> Read DiskMap
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DiskMap]
$creadListPrec :: ReadPrec [DiskMap]
readPrec :: ReadPrec DiskMap
$creadPrec :: ReadPrec DiskMap
readList :: ReadS [DiskMap]
$creadList :: ReadS [DiskMap]
readsPrec :: Int -> ReadS DiskMap
$creadsPrec :: Int -> ReadS DiskMap
Prelude.Read, Int -> DiskMap -> ShowS
[DiskMap] -> ShowS
DiskMap -> String
(Int -> DiskMap -> ShowS)
-> (DiskMap -> String) -> ([DiskMap] -> ShowS) -> Show DiskMap
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DiskMap] -> ShowS
$cshowList :: [DiskMap] -> ShowS
show :: DiskMap -> String
$cshow :: DiskMap -> String
showsPrec :: Int -> DiskMap -> ShowS
$cshowsPrec :: Int -> DiskMap -> ShowS
Prelude.Show, (forall x. DiskMap -> Rep DiskMap x)
-> (forall x. Rep DiskMap x -> DiskMap) -> Generic DiskMap
forall x. Rep DiskMap x -> DiskMap
forall x. DiskMap -> Rep DiskMap x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DiskMap x -> DiskMap
$cfrom :: forall x. DiskMap -> Rep DiskMap x
Prelude.Generic)

-- |
-- Create a value of 'DiskMap' 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:
--
-- 'newDiskName'', 'diskMap_newDiskName' - The new disk name (e.g., @my-new-disk@).
--
-- 'originalDiskPath', 'diskMap_originalDiskPath' - The original disk path exposed to the instance (for example,
-- @\/dev\/sdh@).
newDiskMap ::
  DiskMap
newDiskMap :: DiskMap
newDiskMap =
  DiskMap' :: Maybe Text -> Maybe Text -> DiskMap
DiskMap'
    { $sel:newDiskName':DiskMap' :: Maybe Text
newDiskName' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:originalDiskPath:DiskMap' :: Maybe Text
originalDiskPath = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The new disk name (e.g., @my-new-disk@).
diskMap_newDiskName :: Lens.Lens' DiskMap (Prelude.Maybe Prelude.Text)
diskMap_newDiskName :: (Maybe Text -> f (Maybe Text)) -> DiskMap -> f DiskMap
diskMap_newDiskName = (DiskMap -> Maybe Text)
-> (DiskMap -> Maybe Text -> DiskMap)
-> Lens DiskMap DiskMap (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DiskMap' {Maybe Text
newDiskName' :: Maybe Text
$sel:newDiskName':DiskMap' :: DiskMap -> Maybe Text
newDiskName'} -> Maybe Text
newDiskName') (\s :: DiskMap
s@DiskMap' {} Maybe Text
a -> DiskMap
s {$sel:newDiskName':DiskMap' :: Maybe Text
newDiskName' = Maybe Text
a} :: DiskMap)

-- | The original disk path exposed to the instance (for example,
-- @\/dev\/sdh@).
diskMap_originalDiskPath :: Lens.Lens' DiskMap (Prelude.Maybe Prelude.Text)
diskMap_originalDiskPath :: (Maybe Text -> f (Maybe Text)) -> DiskMap -> f DiskMap
diskMap_originalDiskPath = (DiskMap -> Maybe Text)
-> (DiskMap -> Maybe Text -> DiskMap)
-> Lens DiskMap DiskMap (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DiskMap' {Maybe Text
originalDiskPath :: Maybe Text
$sel:originalDiskPath:DiskMap' :: DiskMap -> Maybe Text
originalDiskPath} -> Maybe Text
originalDiskPath) (\s :: DiskMap
s@DiskMap' {} Maybe Text
a -> DiskMap
s {$sel:originalDiskPath:DiskMap' :: Maybe Text
originalDiskPath = Maybe Text
a} :: DiskMap)

instance Prelude.Hashable DiskMap

instance Prelude.NFData DiskMap

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