{-# 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.Inspector2.Types.Ec2Metadata
-- 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.Inspector2.Types.Ec2Metadata where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector2.Types.Ec2Platform
import qualified Amazonka.Prelude as Prelude

-- | Meta data details of an Amazon EC2 instance.
--
-- /See:/ 'newEc2Metadata' smart constructor.
data Ec2Metadata = Ec2Metadata'
  { -- | The ID of the Amazon Machine Image (AMI) used to launch the instance.
    Ec2Metadata -> Maybe Text
amiId :: Prelude.Maybe Prelude.Text,
    -- | The platform of the instance.
    Ec2Metadata -> Maybe Ec2Platform
platform :: Prelude.Maybe Ec2Platform,
    -- | The tags attached to the instance.
    Ec2Metadata -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (Ec2Metadata -> Ec2Metadata -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ec2Metadata -> Ec2Metadata -> Bool
$c/= :: Ec2Metadata -> Ec2Metadata -> Bool
== :: Ec2Metadata -> Ec2Metadata -> Bool
$c== :: Ec2Metadata -> Ec2Metadata -> Bool
Prelude.Eq, ReadPrec [Ec2Metadata]
ReadPrec Ec2Metadata
Int -> ReadS Ec2Metadata
ReadS [Ec2Metadata]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Ec2Metadata]
$creadListPrec :: ReadPrec [Ec2Metadata]
readPrec :: ReadPrec Ec2Metadata
$creadPrec :: ReadPrec Ec2Metadata
readList :: ReadS [Ec2Metadata]
$creadList :: ReadS [Ec2Metadata]
readsPrec :: Int -> ReadS Ec2Metadata
$creadsPrec :: Int -> ReadS Ec2Metadata
Prelude.Read, Int -> Ec2Metadata -> ShowS
[Ec2Metadata] -> ShowS
Ec2Metadata -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Ec2Metadata] -> ShowS
$cshowList :: [Ec2Metadata] -> ShowS
show :: Ec2Metadata -> String
$cshow :: Ec2Metadata -> String
showsPrec :: Int -> Ec2Metadata -> ShowS
$cshowsPrec :: Int -> Ec2Metadata -> ShowS
Prelude.Show, forall x. Rep Ec2Metadata x -> Ec2Metadata
forall x. Ec2Metadata -> Rep Ec2Metadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Ec2Metadata x -> Ec2Metadata
$cfrom :: forall x. Ec2Metadata -> Rep Ec2Metadata x
Prelude.Generic)

-- |
-- Create a value of 'Ec2Metadata' 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:
--
-- 'amiId', 'ec2Metadata_amiId' - The ID of the Amazon Machine Image (AMI) used to launch the instance.
--
-- 'platform', 'ec2Metadata_platform' - The platform of the instance.
--
-- 'tags', 'ec2Metadata_tags' - The tags attached to the instance.
newEc2Metadata ::
  Ec2Metadata
newEc2Metadata :: Ec2Metadata
newEc2Metadata =
  Ec2Metadata'
    { $sel:amiId:Ec2Metadata' :: Maybe Text
amiId = forall a. Maybe a
Prelude.Nothing,
      $sel:platform:Ec2Metadata' :: Maybe Ec2Platform
platform = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:Ec2Metadata' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the Amazon Machine Image (AMI) used to launch the instance.
ec2Metadata_amiId :: Lens.Lens' Ec2Metadata (Prelude.Maybe Prelude.Text)
ec2Metadata_amiId :: Lens' Ec2Metadata (Maybe Text)
ec2Metadata_amiId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ec2Metadata' {Maybe Text
amiId :: Maybe Text
$sel:amiId:Ec2Metadata' :: Ec2Metadata -> Maybe Text
amiId} -> Maybe Text
amiId) (\s :: Ec2Metadata
s@Ec2Metadata' {} Maybe Text
a -> Ec2Metadata
s {$sel:amiId:Ec2Metadata' :: Maybe Text
amiId = Maybe Text
a} :: Ec2Metadata)

-- | The platform of the instance.
ec2Metadata_platform :: Lens.Lens' Ec2Metadata (Prelude.Maybe Ec2Platform)
ec2Metadata_platform :: Lens' Ec2Metadata (Maybe Ec2Platform)
ec2Metadata_platform = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ec2Metadata' {Maybe Ec2Platform
platform :: Maybe Ec2Platform
$sel:platform:Ec2Metadata' :: Ec2Metadata -> Maybe Ec2Platform
platform} -> Maybe Ec2Platform
platform) (\s :: Ec2Metadata
s@Ec2Metadata' {} Maybe Ec2Platform
a -> Ec2Metadata
s {$sel:platform:Ec2Metadata' :: Maybe Ec2Platform
platform = Maybe Ec2Platform
a} :: Ec2Metadata)

-- | The tags attached to the instance.
ec2Metadata_tags :: Lens.Lens' Ec2Metadata (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
ec2Metadata_tags :: Lens' Ec2Metadata (Maybe (HashMap Text Text))
ec2Metadata_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ec2Metadata' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:Ec2Metadata' :: Ec2Metadata -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: Ec2Metadata
s@Ec2Metadata' {} Maybe (HashMap Text Text)
a -> Ec2Metadata
s {$sel:tags:Ec2Metadata' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: Ec2Metadata) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON Ec2Metadata where
  parseJSON :: Value -> Parser Ec2Metadata
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Ec2Metadata"
      ( \Object
x ->
          Maybe Text
-> Maybe Ec2Platform -> Maybe (HashMap Text Text) -> Ec2Metadata
Ec2Metadata'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"amiId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"platform")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"tags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Ec2Metadata where
  hashWithSalt :: Int -> Ec2Metadata -> Int
hashWithSalt Int
_salt Ec2Metadata' {Maybe Text
Maybe (HashMap Text Text)
Maybe Ec2Platform
tags :: Maybe (HashMap Text Text)
platform :: Maybe Ec2Platform
amiId :: Maybe Text
$sel:tags:Ec2Metadata' :: Ec2Metadata -> Maybe (HashMap Text Text)
$sel:platform:Ec2Metadata' :: Ec2Metadata -> Maybe Ec2Platform
$sel:amiId:Ec2Metadata' :: Ec2Metadata -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
amiId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Ec2Platform
platform
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags

instance Prelude.NFData Ec2Metadata where
  rnf :: Ec2Metadata -> ()
rnf Ec2Metadata' {Maybe Text
Maybe (HashMap Text Text)
Maybe Ec2Platform
tags :: Maybe (HashMap Text Text)
platform :: Maybe Ec2Platform
amiId :: Maybe Text
$sel:tags:Ec2Metadata' :: Ec2Metadata -> Maybe (HashMap Text Text)
$sel:platform:Ec2Metadata' :: Ec2Metadata -> Maybe Ec2Platform
$sel:amiId:Ec2Metadata' :: Ec2Metadata -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
amiId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Ec2Platform
platform
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags