{-# 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.SecurityHub.Types.AwsEc2VolumeAttachment
-- 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.SecurityHub.Types.AwsEc2VolumeAttachment where

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

-- | An attachment to an Amazon EC2 volume.
--
-- /See:/ 'newAwsEc2VolumeAttachment' smart constructor.
data AwsEc2VolumeAttachment = AwsEc2VolumeAttachment'
  { -- | The identifier of the EC2 instance.
    AwsEc2VolumeAttachment -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | The attachment state of the volume.
    AwsEc2VolumeAttachment -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | Whether the EBS volume is deleted when the EC2 instance is terminated.
    AwsEc2VolumeAttachment -> Maybe Bool
deleteOnTermination :: Prelude.Maybe Prelude.Bool,
    -- | The datetime when the attachment initiated.
    AwsEc2VolumeAttachment -> Maybe Text
attachTime :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsEc2VolumeAttachment -> AwsEc2VolumeAttachment -> Bool
(AwsEc2VolumeAttachment -> AwsEc2VolumeAttachment -> Bool)
-> (AwsEc2VolumeAttachment -> AwsEc2VolumeAttachment -> Bool)
-> Eq AwsEc2VolumeAttachment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsEc2VolumeAttachment -> AwsEc2VolumeAttachment -> Bool
$c/= :: AwsEc2VolumeAttachment -> AwsEc2VolumeAttachment -> Bool
== :: AwsEc2VolumeAttachment -> AwsEc2VolumeAttachment -> Bool
$c== :: AwsEc2VolumeAttachment -> AwsEc2VolumeAttachment -> Bool
Prelude.Eq, ReadPrec [AwsEc2VolumeAttachment]
ReadPrec AwsEc2VolumeAttachment
Int -> ReadS AwsEc2VolumeAttachment
ReadS [AwsEc2VolumeAttachment]
(Int -> ReadS AwsEc2VolumeAttachment)
-> ReadS [AwsEc2VolumeAttachment]
-> ReadPrec AwsEc2VolumeAttachment
-> ReadPrec [AwsEc2VolumeAttachment]
-> Read AwsEc2VolumeAttachment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsEc2VolumeAttachment]
$creadListPrec :: ReadPrec [AwsEc2VolumeAttachment]
readPrec :: ReadPrec AwsEc2VolumeAttachment
$creadPrec :: ReadPrec AwsEc2VolumeAttachment
readList :: ReadS [AwsEc2VolumeAttachment]
$creadList :: ReadS [AwsEc2VolumeAttachment]
readsPrec :: Int -> ReadS AwsEc2VolumeAttachment
$creadsPrec :: Int -> ReadS AwsEc2VolumeAttachment
Prelude.Read, Int -> AwsEc2VolumeAttachment -> ShowS
[AwsEc2VolumeAttachment] -> ShowS
AwsEc2VolumeAttachment -> String
(Int -> AwsEc2VolumeAttachment -> ShowS)
-> (AwsEc2VolumeAttachment -> String)
-> ([AwsEc2VolumeAttachment] -> ShowS)
-> Show AwsEc2VolumeAttachment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsEc2VolumeAttachment] -> ShowS
$cshowList :: [AwsEc2VolumeAttachment] -> ShowS
show :: AwsEc2VolumeAttachment -> String
$cshow :: AwsEc2VolumeAttachment -> String
showsPrec :: Int -> AwsEc2VolumeAttachment -> ShowS
$cshowsPrec :: Int -> AwsEc2VolumeAttachment -> ShowS
Prelude.Show, (forall x. AwsEc2VolumeAttachment -> Rep AwsEc2VolumeAttachment x)
-> (forall x.
    Rep AwsEc2VolumeAttachment x -> AwsEc2VolumeAttachment)
-> Generic AwsEc2VolumeAttachment
forall x. Rep AwsEc2VolumeAttachment x -> AwsEc2VolumeAttachment
forall x. AwsEc2VolumeAttachment -> Rep AwsEc2VolumeAttachment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsEc2VolumeAttachment x -> AwsEc2VolumeAttachment
$cfrom :: forall x. AwsEc2VolumeAttachment -> Rep AwsEc2VolumeAttachment x
Prelude.Generic)

-- |
-- Create a value of 'AwsEc2VolumeAttachment' 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:
--
-- 'instanceId', 'awsEc2VolumeAttachment_instanceId' - The identifier of the EC2 instance.
--
-- 'status', 'awsEc2VolumeAttachment_status' - The attachment state of the volume.
--
-- 'deleteOnTermination', 'awsEc2VolumeAttachment_deleteOnTermination' - Whether the EBS volume is deleted when the EC2 instance is terminated.
--
-- 'attachTime', 'awsEc2VolumeAttachment_attachTime' - The datetime when the attachment initiated.
newAwsEc2VolumeAttachment ::
  AwsEc2VolumeAttachment
newAwsEc2VolumeAttachment :: AwsEc2VolumeAttachment
newAwsEc2VolumeAttachment =
  AwsEc2VolumeAttachment' :: Maybe Text
-> Maybe Text -> Maybe Bool -> Maybe Text -> AwsEc2VolumeAttachment
AwsEc2VolumeAttachment'
    { $sel:instanceId:AwsEc2VolumeAttachment' :: Maybe Text
instanceId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:status:AwsEc2VolumeAttachment' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deleteOnTermination:AwsEc2VolumeAttachment' :: Maybe Bool
deleteOnTermination = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:attachTime:AwsEc2VolumeAttachment' :: Maybe Text
attachTime = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the EC2 instance.
awsEc2VolumeAttachment_instanceId :: Lens.Lens' AwsEc2VolumeAttachment (Prelude.Maybe Prelude.Text)
awsEc2VolumeAttachment_instanceId :: (Maybe Text -> f (Maybe Text))
-> AwsEc2VolumeAttachment -> f AwsEc2VolumeAttachment
awsEc2VolumeAttachment_instanceId = (AwsEc2VolumeAttachment -> Maybe Text)
-> (AwsEc2VolumeAttachment -> Maybe Text -> AwsEc2VolumeAttachment)
-> Lens
     AwsEc2VolumeAttachment
     AwsEc2VolumeAttachment
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2VolumeAttachment' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:AwsEc2VolumeAttachment' :: AwsEc2VolumeAttachment -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: AwsEc2VolumeAttachment
s@AwsEc2VolumeAttachment' {} Maybe Text
a -> AwsEc2VolumeAttachment
s {$sel:instanceId:AwsEc2VolumeAttachment' :: Maybe Text
instanceId = Maybe Text
a} :: AwsEc2VolumeAttachment)

-- | The attachment state of the volume.
awsEc2VolumeAttachment_status :: Lens.Lens' AwsEc2VolumeAttachment (Prelude.Maybe Prelude.Text)
awsEc2VolumeAttachment_status :: (Maybe Text -> f (Maybe Text))
-> AwsEc2VolumeAttachment -> f AwsEc2VolumeAttachment
awsEc2VolumeAttachment_status = (AwsEc2VolumeAttachment -> Maybe Text)
-> (AwsEc2VolumeAttachment -> Maybe Text -> AwsEc2VolumeAttachment)
-> Lens
     AwsEc2VolumeAttachment
     AwsEc2VolumeAttachment
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2VolumeAttachment' {Maybe Text
status :: Maybe Text
$sel:status:AwsEc2VolumeAttachment' :: AwsEc2VolumeAttachment -> Maybe Text
status} -> Maybe Text
status) (\s :: AwsEc2VolumeAttachment
s@AwsEc2VolumeAttachment' {} Maybe Text
a -> AwsEc2VolumeAttachment
s {$sel:status:AwsEc2VolumeAttachment' :: Maybe Text
status = Maybe Text
a} :: AwsEc2VolumeAttachment)

-- | Whether the EBS volume is deleted when the EC2 instance is terminated.
awsEc2VolumeAttachment_deleteOnTermination :: Lens.Lens' AwsEc2VolumeAttachment (Prelude.Maybe Prelude.Bool)
awsEc2VolumeAttachment_deleteOnTermination :: (Maybe Bool -> f (Maybe Bool))
-> AwsEc2VolumeAttachment -> f AwsEc2VolumeAttachment
awsEc2VolumeAttachment_deleteOnTermination = (AwsEc2VolumeAttachment -> Maybe Bool)
-> (AwsEc2VolumeAttachment -> Maybe Bool -> AwsEc2VolumeAttachment)
-> Lens
     AwsEc2VolumeAttachment
     AwsEc2VolumeAttachment
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2VolumeAttachment' {Maybe Bool
deleteOnTermination :: Maybe Bool
$sel:deleteOnTermination:AwsEc2VolumeAttachment' :: AwsEc2VolumeAttachment -> Maybe Bool
deleteOnTermination} -> Maybe Bool
deleteOnTermination) (\s :: AwsEc2VolumeAttachment
s@AwsEc2VolumeAttachment' {} Maybe Bool
a -> AwsEc2VolumeAttachment
s {$sel:deleteOnTermination:AwsEc2VolumeAttachment' :: Maybe Bool
deleteOnTermination = Maybe Bool
a} :: AwsEc2VolumeAttachment)

-- | The datetime when the attachment initiated.
awsEc2VolumeAttachment_attachTime :: Lens.Lens' AwsEc2VolumeAttachment (Prelude.Maybe Prelude.Text)
awsEc2VolumeAttachment_attachTime :: (Maybe Text -> f (Maybe Text))
-> AwsEc2VolumeAttachment -> f AwsEc2VolumeAttachment
awsEc2VolumeAttachment_attachTime = (AwsEc2VolumeAttachment -> Maybe Text)
-> (AwsEc2VolumeAttachment -> Maybe Text -> AwsEc2VolumeAttachment)
-> Lens
     AwsEc2VolumeAttachment
     AwsEc2VolumeAttachment
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2VolumeAttachment' {Maybe Text
attachTime :: Maybe Text
$sel:attachTime:AwsEc2VolumeAttachment' :: AwsEc2VolumeAttachment -> Maybe Text
attachTime} -> Maybe Text
attachTime) (\s :: AwsEc2VolumeAttachment
s@AwsEc2VolumeAttachment' {} Maybe Text
a -> AwsEc2VolumeAttachment
s {$sel:attachTime:AwsEc2VolumeAttachment' :: Maybe Text
attachTime = Maybe Text
a} :: AwsEc2VolumeAttachment)

instance Core.FromJSON AwsEc2VolumeAttachment where
  parseJSON :: Value -> Parser AwsEc2VolumeAttachment
parseJSON =
    String
-> (Object -> Parser AwsEc2VolumeAttachment)
-> Value
-> Parser AwsEc2VolumeAttachment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsEc2VolumeAttachment"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Bool -> Maybe Text -> AwsEc2VolumeAttachment
AwsEc2VolumeAttachment'
            (Maybe Text
 -> Maybe Text
 -> Maybe Bool
 -> Maybe Text
 -> AwsEc2VolumeAttachment)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Bool -> Maybe Text -> AwsEc2VolumeAttachment)
forall (f :: * -> *) a b. Functor 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
"InstanceId")
            Parser
  (Maybe Text -> Maybe Bool -> Maybe Text -> AwsEc2VolumeAttachment)
-> Parser (Maybe Text)
-> Parser (Maybe Bool -> Maybe Text -> AwsEc2VolumeAttachment)
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
"Status")
            Parser (Maybe Bool -> Maybe Text -> AwsEc2VolumeAttachment)
-> Parser (Maybe Bool)
-> Parser (Maybe Text -> AwsEc2VolumeAttachment)
forall (f :: * -> *) a b. Applicative f => 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 Text -> AwsEc2VolumeAttachment)
-> Parser (Maybe Text) -> Parser AwsEc2VolumeAttachment
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
"AttachTime")
      )

instance Prelude.Hashable AwsEc2VolumeAttachment

instance Prelude.NFData AwsEc2VolumeAttachment

instance Core.ToJSON AwsEc2VolumeAttachment where
  toJSON :: AwsEc2VolumeAttachment -> Value
toJSON AwsEc2VolumeAttachment' {Maybe Bool
Maybe Text
attachTime :: Maybe Text
deleteOnTermination :: Maybe Bool
status :: Maybe Text
instanceId :: Maybe Text
$sel:attachTime:AwsEc2VolumeAttachment' :: AwsEc2VolumeAttachment -> Maybe Text
$sel:deleteOnTermination:AwsEc2VolumeAttachment' :: AwsEc2VolumeAttachment -> Maybe Bool
$sel:status:AwsEc2VolumeAttachment' :: AwsEc2VolumeAttachment -> Maybe Text
$sel:instanceId:AwsEc2VolumeAttachment' :: AwsEc2VolumeAttachment -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"InstanceId" 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
instanceId,
            (Text
"Status" 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
status,
            (Text
"DeleteOnTermination" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
deleteOnTermination,
            (Text
"AttachTime" 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
attachTime
          ]
      )