{-# 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.SnowDeviceManagement.Types.InstanceBlockDeviceMapping
-- 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.SnowDeviceManagement.Types.InstanceBlockDeviceMapping where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SnowDeviceManagement.Types.EbsInstanceBlockDevice

-- | The description of a block device mapping.
--
-- /See:/ 'newInstanceBlockDeviceMapping' smart constructor.
data InstanceBlockDeviceMapping = InstanceBlockDeviceMapping'
  { -- | The parameters used to automatically set up Amazon Elastic Block Store
    -- (Amazon EBS) volumes when the instance is launched.
    InstanceBlockDeviceMapping -> Maybe EbsInstanceBlockDevice
ebs :: Prelude.Maybe EbsInstanceBlockDevice,
    -- | The block device name.
    InstanceBlockDeviceMapping -> Maybe Text
deviceName :: Prelude.Maybe Prelude.Text
  }
  deriving (InstanceBlockDeviceMapping -> InstanceBlockDeviceMapping -> Bool
(InstanceBlockDeviceMapping -> InstanceBlockDeviceMapping -> Bool)
-> (InstanceBlockDeviceMapping
    -> InstanceBlockDeviceMapping -> Bool)
-> Eq InstanceBlockDeviceMapping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceBlockDeviceMapping -> InstanceBlockDeviceMapping -> Bool
$c/= :: InstanceBlockDeviceMapping -> InstanceBlockDeviceMapping -> Bool
== :: InstanceBlockDeviceMapping -> InstanceBlockDeviceMapping -> Bool
$c== :: InstanceBlockDeviceMapping -> InstanceBlockDeviceMapping -> Bool
Prelude.Eq, ReadPrec [InstanceBlockDeviceMapping]
ReadPrec InstanceBlockDeviceMapping
Int -> ReadS InstanceBlockDeviceMapping
ReadS [InstanceBlockDeviceMapping]
(Int -> ReadS InstanceBlockDeviceMapping)
-> ReadS [InstanceBlockDeviceMapping]
-> ReadPrec InstanceBlockDeviceMapping
-> ReadPrec [InstanceBlockDeviceMapping]
-> Read InstanceBlockDeviceMapping
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceBlockDeviceMapping]
$creadListPrec :: ReadPrec [InstanceBlockDeviceMapping]
readPrec :: ReadPrec InstanceBlockDeviceMapping
$creadPrec :: ReadPrec InstanceBlockDeviceMapping
readList :: ReadS [InstanceBlockDeviceMapping]
$creadList :: ReadS [InstanceBlockDeviceMapping]
readsPrec :: Int -> ReadS InstanceBlockDeviceMapping
$creadsPrec :: Int -> ReadS InstanceBlockDeviceMapping
Prelude.Read, Int -> InstanceBlockDeviceMapping -> ShowS
[InstanceBlockDeviceMapping] -> ShowS
InstanceBlockDeviceMapping -> String
(Int -> InstanceBlockDeviceMapping -> ShowS)
-> (InstanceBlockDeviceMapping -> String)
-> ([InstanceBlockDeviceMapping] -> ShowS)
-> Show InstanceBlockDeviceMapping
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceBlockDeviceMapping] -> ShowS
$cshowList :: [InstanceBlockDeviceMapping] -> ShowS
show :: InstanceBlockDeviceMapping -> String
$cshow :: InstanceBlockDeviceMapping -> String
showsPrec :: Int -> InstanceBlockDeviceMapping -> ShowS
$cshowsPrec :: Int -> InstanceBlockDeviceMapping -> ShowS
Prelude.Show, (forall x.
 InstanceBlockDeviceMapping -> Rep InstanceBlockDeviceMapping x)
-> (forall x.
    Rep InstanceBlockDeviceMapping x -> InstanceBlockDeviceMapping)
-> Generic InstanceBlockDeviceMapping
forall x.
Rep InstanceBlockDeviceMapping x -> InstanceBlockDeviceMapping
forall x.
InstanceBlockDeviceMapping -> Rep InstanceBlockDeviceMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InstanceBlockDeviceMapping x -> InstanceBlockDeviceMapping
$cfrom :: forall x.
InstanceBlockDeviceMapping -> Rep InstanceBlockDeviceMapping x
Prelude.Generic)

-- |
-- Create a value of 'InstanceBlockDeviceMapping' 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:
--
-- 'ebs', 'instanceBlockDeviceMapping_ebs' - The parameters used to automatically set up Amazon Elastic Block Store
-- (Amazon EBS) volumes when the instance is launched.
--
-- 'deviceName', 'instanceBlockDeviceMapping_deviceName' - The block device name.
newInstanceBlockDeviceMapping ::
  InstanceBlockDeviceMapping
newInstanceBlockDeviceMapping :: InstanceBlockDeviceMapping
newInstanceBlockDeviceMapping =
  InstanceBlockDeviceMapping' :: Maybe EbsInstanceBlockDevice
-> Maybe Text -> InstanceBlockDeviceMapping
InstanceBlockDeviceMapping'
    { $sel:ebs:InstanceBlockDeviceMapping' :: Maybe EbsInstanceBlockDevice
ebs = Maybe EbsInstanceBlockDevice
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceName:InstanceBlockDeviceMapping' :: Maybe Text
deviceName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The parameters used to automatically set up Amazon Elastic Block Store
-- (Amazon EBS) volumes when the instance is launched.
instanceBlockDeviceMapping_ebs :: Lens.Lens' InstanceBlockDeviceMapping (Prelude.Maybe EbsInstanceBlockDevice)
instanceBlockDeviceMapping_ebs :: (Maybe EbsInstanceBlockDevice -> f (Maybe EbsInstanceBlockDevice))
-> InstanceBlockDeviceMapping -> f InstanceBlockDeviceMapping
instanceBlockDeviceMapping_ebs = (InstanceBlockDeviceMapping -> Maybe EbsInstanceBlockDevice)
-> (InstanceBlockDeviceMapping
    -> Maybe EbsInstanceBlockDevice -> InstanceBlockDeviceMapping)
-> Lens
     InstanceBlockDeviceMapping
     InstanceBlockDeviceMapping
     (Maybe EbsInstanceBlockDevice)
     (Maybe EbsInstanceBlockDevice)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceBlockDeviceMapping' {Maybe EbsInstanceBlockDevice
ebs :: Maybe EbsInstanceBlockDevice
$sel:ebs:InstanceBlockDeviceMapping' :: InstanceBlockDeviceMapping -> Maybe EbsInstanceBlockDevice
ebs} -> Maybe EbsInstanceBlockDevice
ebs) (\s :: InstanceBlockDeviceMapping
s@InstanceBlockDeviceMapping' {} Maybe EbsInstanceBlockDevice
a -> InstanceBlockDeviceMapping
s {$sel:ebs:InstanceBlockDeviceMapping' :: Maybe EbsInstanceBlockDevice
ebs = Maybe EbsInstanceBlockDevice
a} :: InstanceBlockDeviceMapping)

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

instance Core.FromJSON InstanceBlockDeviceMapping where
  parseJSON :: Value -> Parser InstanceBlockDeviceMapping
parseJSON =
    String
-> (Object -> Parser InstanceBlockDeviceMapping)
-> Value
-> Parser InstanceBlockDeviceMapping
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InstanceBlockDeviceMapping"
      ( \Object
x ->
          Maybe EbsInstanceBlockDevice
-> Maybe Text -> InstanceBlockDeviceMapping
InstanceBlockDeviceMapping'
            (Maybe EbsInstanceBlockDevice
 -> Maybe Text -> InstanceBlockDeviceMapping)
-> Parser (Maybe EbsInstanceBlockDevice)
-> Parser (Maybe Text -> InstanceBlockDeviceMapping)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EbsInstanceBlockDevice)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ebs")
            Parser (Maybe Text -> InstanceBlockDeviceMapping)
-> Parser (Maybe Text) -> Parser InstanceBlockDeviceMapping
forall (f :: * -> *) a b. Applicative f => 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")
      )

instance Prelude.Hashable InstanceBlockDeviceMapping

instance Prelude.NFData InstanceBlockDeviceMapping