{-# 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.VolumeAttachment
-- 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.VolumeAttachment 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.VolumeAttachmentState
import qualified Amazonka.Prelude as Prelude

-- | Describes volume attachment details.
--
-- /See:/ 'newVolumeAttachment' smart constructor.
data VolumeAttachment = VolumeAttachment'
  { -- | The time stamp when the attachment initiated.
    VolumeAttachment -> Maybe ISO8601
attachTime :: Prelude.Maybe Data.ISO8601,
    -- | Indicates whether the EBS volume is deleted on instance termination.
    VolumeAttachment -> Maybe Bool
deleteOnTermination :: Prelude.Maybe Prelude.Bool,
    -- | The device name.
    VolumeAttachment -> Maybe Text
device :: Prelude.Maybe Prelude.Text,
    -- | The ID of the instance.
    VolumeAttachment -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | The attachment state of the volume.
    VolumeAttachment -> Maybe VolumeAttachmentState
state :: Prelude.Maybe VolumeAttachmentState,
    -- | The ID of the volume.
    VolumeAttachment -> Maybe Text
volumeId :: Prelude.Maybe Prelude.Text
  }
  deriving (VolumeAttachment -> VolumeAttachment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VolumeAttachment -> VolumeAttachment -> Bool
$c/= :: VolumeAttachment -> VolumeAttachment -> Bool
== :: VolumeAttachment -> VolumeAttachment -> Bool
$c== :: VolumeAttachment -> VolumeAttachment -> Bool
Prelude.Eq, ReadPrec [VolumeAttachment]
ReadPrec VolumeAttachment
Int -> ReadS VolumeAttachment
ReadS [VolumeAttachment]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VolumeAttachment]
$creadListPrec :: ReadPrec [VolumeAttachment]
readPrec :: ReadPrec VolumeAttachment
$creadPrec :: ReadPrec VolumeAttachment
readList :: ReadS [VolumeAttachment]
$creadList :: ReadS [VolumeAttachment]
readsPrec :: Int -> ReadS VolumeAttachment
$creadsPrec :: Int -> ReadS VolumeAttachment
Prelude.Read, Int -> VolumeAttachment -> ShowS
[VolumeAttachment] -> ShowS
VolumeAttachment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VolumeAttachment] -> ShowS
$cshowList :: [VolumeAttachment] -> ShowS
show :: VolumeAttachment -> String
$cshow :: VolumeAttachment -> String
showsPrec :: Int -> VolumeAttachment -> ShowS
$cshowsPrec :: Int -> VolumeAttachment -> ShowS
Prelude.Show, forall x. Rep VolumeAttachment x -> VolumeAttachment
forall x. VolumeAttachment -> Rep VolumeAttachment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VolumeAttachment x -> VolumeAttachment
$cfrom :: forall x. VolumeAttachment -> Rep VolumeAttachment x
Prelude.Generic)

-- |
-- Create a value of 'VolumeAttachment' 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', 'volumeAttachment_attachTime' - The time stamp when the attachment initiated.
--
-- 'deleteOnTermination', 'volumeAttachment_deleteOnTermination' - Indicates whether the EBS volume is deleted on instance termination.
--
-- 'device', 'volumeAttachment_device' - The device name.
--
-- 'instanceId', 'volumeAttachment_instanceId' - The ID of the instance.
--
-- 'state', 'volumeAttachment_state' - The attachment state of the volume.
--
-- 'volumeId', 'volumeAttachment_volumeId' - The ID of the volume.
newVolumeAttachment ::
  VolumeAttachment
newVolumeAttachment :: VolumeAttachment
newVolumeAttachment =
  VolumeAttachment'
    { $sel:attachTime:VolumeAttachment' :: Maybe ISO8601
attachTime = forall a. Maybe a
Prelude.Nothing,
      $sel:deleteOnTermination:VolumeAttachment' :: Maybe Bool
deleteOnTermination = forall a. Maybe a
Prelude.Nothing,
      $sel:device:VolumeAttachment' :: Maybe Text
device = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:VolumeAttachment' :: Maybe Text
instanceId = forall a. Maybe a
Prelude.Nothing,
      $sel:state:VolumeAttachment' :: Maybe VolumeAttachmentState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:volumeId:VolumeAttachment' :: Maybe Text
volumeId = forall a. Maybe a
Prelude.Nothing
    }

-- | The time stamp when the attachment initiated.
volumeAttachment_attachTime :: Lens.Lens' VolumeAttachment (Prelude.Maybe Prelude.UTCTime)
volumeAttachment_attachTime :: Lens' VolumeAttachment (Maybe UTCTime)
volumeAttachment_attachTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VolumeAttachment' {Maybe ISO8601
attachTime :: Maybe ISO8601
$sel:attachTime:VolumeAttachment' :: VolumeAttachment -> Maybe ISO8601
attachTime} -> Maybe ISO8601
attachTime) (\s :: VolumeAttachment
s@VolumeAttachment' {} Maybe ISO8601
a -> VolumeAttachment
s {$sel:attachTime:VolumeAttachment' :: Maybe ISO8601
attachTime = Maybe ISO8601
a} :: VolumeAttachment) 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 EBS volume is deleted on instance termination.
volumeAttachment_deleteOnTermination :: Lens.Lens' VolumeAttachment (Prelude.Maybe Prelude.Bool)
volumeAttachment_deleteOnTermination :: Lens' VolumeAttachment (Maybe Bool)
volumeAttachment_deleteOnTermination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VolumeAttachment' {Maybe Bool
deleteOnTermination :: Maybe Bool
$sel:deleteOnTermination:VolumeAttachment' :: VolumeAttachment -> Maybe Bool
deleteOnTermination} -> Maybe Bool
deleteOnTermination) (\s :: VolumeAttachment
s@VolumeAttachment' {} Maybe Bool
a -> VolumeAttachment
s {$sel:deleteOnTermination:VolumeAttachment' :: Maybe Bool
deleteOnTermination = Maybe Bool
a} :: VolumeAttachment)

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

-- | The ID of the instance.
volumeAttachment_instanceId :: Lens.Lens' VolumeAttachment (Prelude.Maybe Prelude.Text)
volumeAttachment_instanceId :: Lens' VolumeAttachment (Maybe Text)
volumeAttachment_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VolumeAttachment' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:VolumeAttachment' :: VolumeAttachment -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: VolumeAttachment
s@VolumeAttachment' {} Maybe Text
a -> VolumeAttachment
s {$sel:instanceId:VolumeAttachment' :: Maybe Text
instanceId = Maybe Text
a} :: VolumeAttachment)

-- | The attachment state of the volume.
volumeAttachment_state :: Lens.Lens' VolumeAttachment (Prelude.Maybe VolumeAttachmentState)
volumeAttachment_state :: Lens' VolumeAttachment (Maybe VolumeAttachmentState)
volumeAttachment_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VolumeAttachment' {Maybe VolumeAttachmentState
state :: Maybe VolumeAttachmentState
$sel:state:VolumeAttachment' :: VolumeAttachment -> Maybe VolumeAttachmentState
state} -> Maybe VolumeAttachmentState
state) (\s :: VolumeAttachment
s@VolumeAttachment' {} Maybe VolumeAttachmentState
a -> VolumeAttachment
s {$sel:state:VolumeAttachment' :: Maybe VolumeAttachmentState
state = Maybe VolumeAttachmentState
a} :: VolumeAttachment)

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

instance Data.FromXML VolumeAttachment where
  parseXML :: [Node] -> Either String VolumeAttachment
parseXML [Node]
x =
    Maybe ISO8601
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe VolumeAttachmentState
-> Maybe Text
-> VolumeAttachment
VolumeAttachment'
      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
"device")
      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
"instanceId")
      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 VolumeAttachment where
  hashWithSalt :: Int -> VolumeAttachment -> Int
hashWithSalt Int
_salt VolumeAttachment' {Maybe Bool
Maybe Text
Maybe ISO8601
Maybe VolumeAttachmentState
volumeId :: Maybe Text
state :: Maybe VolumeAttachmentState
instanceId :: Maybe Text
device :: Maybe Text
deleteOnTermination :: Maybe Bool
attachTime :: Maybe ISO8601
$sel:volumeId:VolumeAttachment' :: VolumeAttachment -> Maybe Text
$sel:state:VolumeAttachment' :: VolumeAttachment -> Maybe VolumeAttachmentState
$sel:instanceId:VolumeAttachment' :: VolumeAttachment -> Maybe Text
$sel:device:VolumeAttachment' :: VolumeAttachment -> Maybe Text
$sel:deleteOnTermination:VolumeAttachment' :: VolumeAttachment -> Maybe Bool
$sel:attachTime:VolumeAttachment' :: VolumeAttachment -> 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 Text
device
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VolumeAttachmentState
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
volumeId

instance Prelude.NFData VolumeAttachment where
  rnf :: VolumeAttachment -> ()
rnf VolumeAttachment' {Maybe Bool
Maybe Text
Maybe ISO8601
Maybe VolumeAttachmentState
volumeId :: Maybe Text
state :: Maybe VolumeAttachmentState
instanceId :: Maybe Text
device :: Maybe Text
deleteOnTermination :: Maybe Bool
attachTime :: Maybe ISO8601
$sel:volumeId:VolumeAttachment' :: VolumeAttachment -> Maybe Text
$sel:state:VolumeAttachment' :: VolumeAttachment -> Maybe VolumeAttachmentState
$sel:instanceId:VolumeAttachment' :: VolumeAttachment -> Maybe Text
$sel:device:VolumeAttachment' :: VolumeAttachment -> Maybe Text
$sel:deleteOnTermination:VolumeAttachment' :: VolumeAttachment -> Maybe Bool
$sel:attachTime:VolumeAttachment' :: VolumeAttachment -> 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 Text
device
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VolumeAttachmentState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
volumeId