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

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

-- | Describes a parameter used to set up an Amazon Elastic Block Store
-- (Amazon EBS) volume in a block device mapping.
--
-- /See:/ 'newEbsInstanceBlockDevice' smart constructor.
data EbsInstanceBlockDevice = EbsInstanceBlockDevice'
  { -- | A value that indicates whether the volume is deleted on instance
    -- termination.
    EbsInstanceBlockDevice -> Maybe Bool
deleteOnTermination :: Prelude.Maybe Prelude.Bool,
    -- | The attachment state.
    EbsInstanceBlockDevice -> Maybe AttachmentStatus
status :: Prelude.Maybe AttachmentStatus,
    -- | The ID of the Amazon EBS volume.
    EbsInstanceBlockDevice -> Maybe Text
volumeId :: Prelude.Maybe Prelude.Text,
    -- | When the attachment was initiated.
    EbsInstanceBlockDevice -> Maybe POSIX
attachTime :: Prelude.Maybe Core.POSIX
  }
  deriving (EbsInstanceBlockDevice -> EbsInstanceBlockDevice -> Bool
(EbsInstanceBlockDevice -> EbsInstanceBlockDevice -> Bool)
-> (EbsInstanceBlockDevice -> EbsInstanceBlockDevice -> Bool)
-> Eq EbsInstanceBlockDevice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EbsInstanceBlockDevice -> EbsInstanceBlockDevice -> Bool
$c/= :: EbsInstanceBlockDevice -> EbsInstanceBlockDevice -> Bool
== :: EbsInstanceBlockDevice -> EbsInstanceBlockDevice -> Bool
$c== :: EbsInstanceBlockDevice -> EbsInstanceBlockDevice -> Bool
Prelude.Eq, ReadPrec [EbsInstanceBlockDevice]
ReadPrec EbsInstanceBlockDevice
Int -> ReadS EbsInstanceBlockDevice
ReadS [EbsInstanceBlockDevice]
(Int -> ReadS EbsInstanceBlockDevice)
-> ReadS [EbsInstanceBlockDevice]
-> ReadPrec EbsInstanceBlockDevice
-> ReadPrec [EbsInstanceBlockDevice]
-> Read EbsInstanceBlockDevice
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EbsInstanceBlockDevice]
$creadListPrec :: ReadPrec [EbsInstanceBlockDevice]
readPrec :: ReadPrec EbsInstanceBlockDevice
$creadPrec :: ReadPrec EbsInstanceBlockDevice
readList :: ReadS [EbsInstanceBlockDevice]
$creadList :: ReadS [EbsInstanceBlockDevice]
readsPrec :: Int -> ReadS EbsInstanceBlockDevice
$creadsPrec :: Int -> ReadS EbsInstanceBlockDevice
Prelude.Read, Int -> EbsInstanceBlockDevice -> ShowS
[EbsInstanceBlockDevice] -> ShowS
EbsInstanceBlockDevice -> String
(Int -> EbsInstanceBlockDevice -> ShowS)
-> (EbsInstanceBlockDevice -> String)
-> ([EbsInstanceBlockDevice] -> ShowS)
-> Show EbsInstanceBlockDevice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EbsInstanceBlockDevice] -> ShowS
$cshowList :: [EbsInstanceBlockDevice] -> ShowS
show :: EbsInstanceBlockDevice -> String
$cshow :: EbsInstanceBlockDevice -> String
showsPrec :: Int -> EbsInstanceBlockDevice -> ShowS
$cshowsPrec :: Int -> EbsInstanceBlockDevice -> ShowS
Prelude.Show, (forall x. EbsInstanceBlockDevice -> Rep EbsInstanceBlockDevice x)
-> (forall x.
    Rep EbsInstanceBlockDevice x -> EbsInstanceBlockDevice)
-> Generic EbsInstanceBlockDevice
forall x. Rep EbsInstanceBlockDevice x -> EbsInstanceBlockDevice
forall x. EbsInstanceBlockDevice -> Rep EbsInstanceBlockDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EbsInstanceBlockDevice x -> EbsInstanceBlockDevice
$cfrom :: forall x. EbsInstanceBlockDevice -> Rep EbsInstanceBlockDevice x
Prelude.Generic)

-- |
-- Create a value of 'EbsInstanceBlockDevice' 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:
--
-- 'deleteOnTermination', 'ebsInstanceBlockDevice_deleteOnTermination' - A value that indicates whether the volume is deleted on instance
-- termination.
--
-- 'status', 'ebsInstanceBlockDevice_status' - The attachment state.
--
-- 'volumeId', 'ebsInstanceBlockDevice_volumeId' - The ID of the Amazon EBS volume.
--
-- 'attachTime', 'ebsInstanceBlockDevice_attachTime' - When the attachment was initiated.
newEbsInstanceBlockDevice ::
  EbsInstanceBlockDevice
newEbsInstanceBlockDevice :: EbsInstanceBlockDevice
newEbsInstanceBlockDevice =
  EbsInstanceBlockDevice' :: Maybe Bool
-> Maybe AttachmentStatus
-> Maybe Text
-> Maybe POSIX
-> EbsInstanceBlockDevice
EbsInstanceBlockDevice'
    { $sel:deleteOnTermination:EbsInstanceBlockDevice' :: Maybe Bool
deleteOnTermination =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:status:EbsInstanceBlockDevice' :: Maybe AttachmentStatus
status = Maybe AttachmentStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:volumeId:EbsInstanceBlockDevice' :: Maybe Text
volumeId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attachTime:EbsInstanceBlockDevice' :: Maybe POSIX
attachTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | A value that indicates whether the volume is deleted on instance
-- termination.
ebsInstanceBlockDevice_deleteOnTermination :: Lens.Lens' EbsInstanceBlockDevice (Prelude.Maybe Prelude.Bool)
ebsInstanceBlockDevice_deleteOnTermination :: (Maybe Bool -> f (Maybe Bool))
-> EbsInstanceBlockDevice -> f EbsInstanceBlockDevice
ebsInstanceBlockDevice_deleteOnTermination = (EbsInstanceBlockDevice -> Maybe Bool)
-> (EbsInstanceBlockDevice -> Maybe Bool -> EbsInstanceBlockDevice)
-> Lens
     EbsInstanceBlockDevice
     EbsInstanceBlockDevice
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EbsInstanceBlockDevice' {Maybe Bool
deleteOnTermination :: Maybe Bool
$sel:deleteOnTermination:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe Bool
deleteOnTermination} -> Maybe Bool
deleteOnTermination) (\s :: EbsInstanceBlockDevice
s@EbsInstanceBlockDevice' {} Maybe Bool
a -> EbsInstanceBlockDevice
s {$sel:deleteOnTermination:EbsInstanceBlockDevice' :: Maybe Bool
deleteOnTermination = Maybe Bool
a} :: EbsInstanceBlockDevice)

-- | The attachment state.
ebsInstanceBlockDevice_status :: Lens.Lens' EbsInstanceBlockDevice (Prelude.Maybe AttachmentStatus)
ebsInstanceBlockDevice_status :: (Maybe AttachmentStatus -> f (Maybe AttachmentStatus))
-> EbsInstanceBlockDevice -> f EbsInstanceBlockDevice
ebsInstanceBlockDevice_status = (EbsInstanceBlockDevice -> Maybe AttachmentStatus)
-> (EbsInstanceBlockDevice
    -> Maybe AttachmentStatus -> EbsInstanceBlockDevice)
-> Lens
     EbsInstanceBlockDevice
     EbsInstanceBlockDevice
     (Maybe AttachmentStatus)
     (Maybe AttachmentStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EbsInstanceBlockDevice' {Maybe AttachmentStatus
status :: Maybe AttachmentStatus
$sel:status:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe AttachmentStatus
status} -> Maybe AttachmentStatus
status) (\s :: EbsInstanceBlockDevice
s@EbsInstanceBlockDevice' {} Maybe AttachmentStatus
a -> EbsInstanceBlockDevice
s {$sel:status:EbsInstanceBlockDevice' :: Maybe AttachmentStatus
status = Maybe AttachmentStatus
a} :: EbsInstanceBlockDevice)

-- | The ID of the Amazon EBS volume.
ebsInstanceBlockDevice_volumeId :: Lens.Lens' EbsInstanceBlockDevice (Prelude.Maybe Prelude.Text)
ebsInstanceBlockDevice_volumeId :: (Maybe Text -> f (Maybe Text))
-> EbsInstanceBlockDevice -> f EbsInstanceBlockDevice
ebsInstanceBlockDevice_volumeId = (EbsInstanceBlockDevice -> Maybe Text)
-> (EbsInstanceBlockDevice -> Maybe Text -> EbsInstanceBlockDevice)
-> Lens
     EbsInstanceBlockDevice
     EbsInstanceBlockDevice
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EbsInstanceBlockDevice' {Maybe Text
volumeId :: Maybe Text
$sel:volumeId:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe Text
volumeId} -> Maybe Text
volumeId) (\s :: EbsInstanceBlockDevice
s@EbsInstanceBlockDevice' {} Maybe Text
a -> EbsInstanceBlockDevice
s {$sel:volumeId:EbsInstanceBlockDevice' :: Maybe Text
volumeId = Maybe Text
a} :: EbsInstanceBlockDevice)

-- | When the attachment was initiated.
ebsInstanceBlockDevice_attachTime :: Lens.Lens' EbsInstanceBlockDevice (Prelude.Maybe Prelude.UTCTime)
ebsInstanceBlockDevice_attachTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> EbsInstanceBlockDevice -> f EbsInstanceBlockDevice
ebsInstanceBlockDevice_attachTime = (EbsInstanceBlockDevice -> Maybe POSIX)
-> (EbsInstanceBlockDevice
    -> Maybe POSIX -> EbsInstanceBlockDevice)
-> Lens
     EbsInstanceBlockDevice
     EbsInstanceBlockDevice
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EbsInstanceBlockDevice' {Maybe POSIX
attachTime :: Maybe POSIX
$sel:attachTime:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe POSIX
attachTime} -> Maybe POSIX
attachTime) (\s :: EbsInstanceBlockDevice
s@EbsInstanceBlockDevice' {} Maybe POSIX
a -> EbsInstanceBlockDevice
s {$sel:attachTime:EbsInstanceBlockDevice' :: Maybe POSIX
attachTime = Maybe POSIX
a} :: EbsInstanceBlockDevice) ((Maybe POSIX -> f (Maybe POSIX))
 -> EbsInstanceBlockDevice -> f EbsInstanceBlockDevice)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> EbsInstanceBlockDevice
-> f EbsInstanceBlockDevice
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Prelude.Hashable EbsInstanceBlockDevice

instance Prelude.NFData EbsInstanceBlockDevice