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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.AttachmentStatus
import qualified Amazonka.Prelude as Prelude

-- | Describes a parameter used to set up an EBS volume in a block device
-- mapping.
--
-- /See:/ 'newEbsInstanceBlockDevice' smart constructor.
data EbsInstanceBlockDevice = EbsInstanceBlockDevice'
  { -- | The time stamp when the attachment initiated.
    EbsInstanceBlockDevice -> Maybe ISO8601
attachTime :: Prelude.Maybe Data.ISO8601,
    -- | 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 EBS volume.
    EbsInstanceBlockDevice -> Maybe Text
volumeId :: Prelude.Maybe Prelude.Text
  }
  deriving (EbsInstanceBlockDevice -> EbsInstanceBlockDevice -> Bool
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]
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
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. 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:
--
-- 'attachTime', 'ebsInstanceBlockDevice_attachTime' - The time stamp when the attachment initiated.
--
-- 'deleteOnTermination', 'ebsInstanceBlockDevice_deleteOnTermination' - Indicates whether the volume is deleted on instance termination.
--
-- 'status', 'ebsInstanceBlockDevice_status' - The attachment state.
--
-- 'volumeId', 'ebsInstanceBlockDevice_volumeId' - The ID of the EBS volume.
newEbsInstanceBlockDevice ::
  EbsInstanceBlockDevice
newEbsInstanceBlockDevice :: EbsInstanceBlockDevice
newEbsInstanceBlockDevice =
  EbsInstanceBlockDevice'
    { $sel:attachTime:EbsInstanceBlockDevice' :: Maybe ISO8601
attachTime =
        forall a. Maybe a
Prelude.Nothing,
      $sel:deleteOnTermination:EbsInstanceBlockDevice' :: Maybe Bool
deleteOnTermination = forall a. Maybe a
Prelude.Nothing,
      $sel:status:EbsInstanceBlockDevice' :: Maybe AttachmentStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:volumeId:EbsInstanceBlockDevice' :: Maybe Text
volumeId = forall a. Maybe a
Prelude.Nothing
    }

-- | The time stamp when the attachment initiated.
ebsInstanceBlockDevice_attachTime :: Lens.Lens' EbsInstanceBlockDevice (Prelude.Maybe Prelude.UTCTime)
ebsInstanceBlockDevice_attachTime :: Lens' EbsInstanceBlockDevice (Maybe UTCTime)
ebsInstanceBlockDevice_attachTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EbsInstanceBlockDevice' {Maybe ISO8601
attachTime :: Maybe ISO8601
$sel:attachTime:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe ISO8601
attachTime} -> Maybe ISO8601
attachTime) (\s :: EbsInstanceBlockDevice
s@EbsInstanceBlockDevice' {} Maybe ISO8601
a -> EbsInstanceBlockDevice
s {$sel:attachTime:EbsInstanceBlockDevice' :: Maybe ISO8601
attachTime = Maybe ISO8601
a} :: EbsInstanceBlockDevice) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Indicates whether the volume is deleted on instance termination.
ebsInstanceBlockDevice_deleteOnTermination :: Lens.Lens' EbsInstanceBlockDevice (Prelude.Maybe Prelude.Bool)
ebsInstanceBlockDevice_deleteOnTermination :: Lens' EbsInstanceBlockDevice (Maybe Bool)
ebsInstanceBlockDevice_deleteOnTermination = 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 :: Lens' EbsInstanceBlockDevice (Maybe AttachmentStatus)
ebsInstanceBlockDevice_status = 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 EBS volume.
ebsInstanceBlockDevice_volumeId :: Lens.Lens' EbsInstanceBlockDevice (Prelude.Maybe Prelude.Text)
ebsInstanceBlockDevice_volumeId :: Lens' EbsInstanceBlockDevice (Maybe Text)
ebsInstanceBlockDevice_volumeId = 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)

instance Data.FromXML EbsInstanceBlockDevice where
  parseXML :: [Node] -> Either String EbsInstanceBlockDevice
parseXML [Node]
x =
    Maybe ISO8601
-> Maybe Bool
-> Maybe AttachmentStatus
-> Maybe Text
-> EbsInstanceBlockDevice
EbsInstanceBlockDevice'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"attachTime")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"deleteOnTermination")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"status")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"volumeId")

instance Prelude.Hashable EbsInstanceBlockDevice where
  hashWithSalt :: Int -> EbsInstanceBlockDevice -> Int
hashWithSalt Int
_salt EbsInstanceBlockDevice' {Maybe Bool
Maybe Text
Maybe ISO8601
Maybe AttachmentStatus
volumeId :: Maybe Text
status :: Maybe AttachmentStatus
deleteOnTermination :: Maybe Bool
attachTime :: Maybe ISO8601
$sel:volumeId:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe Text
$sel:status:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe AttachmentStatus
$sel:deleteOnTermination:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe Bool
$sel:attachTime:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
attachTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
deleteOnTermination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttachmentStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
volumeId

instance Prelude.NFData EbsInstanceBlockDevice where
  rnf :: EbsInstanceBlockDevice -> ()
rnf EbsInstanceBlockDevice' {Maybe Bool
Maybe Text
Maybe ISO8601
Maybe AttachmentStatus
volumeId :: Maybe Text
status :: Maybe AttachmentStatus
deleteOnTermination :: Maybe Bool
attachTime :: Maybe ISO8601
$sel:volumeId:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe Text
$sel:status:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe AttachmentStatus
$sel:deleteOnTermination:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe Bool
$sel:attachTime:EbsInstanceBlockDevice' :: EbsInstanceBlockDevice -> Maybe ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
attachTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
deleteOnTermination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AttachmentStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
volumeId