{-# 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.FMS.Types.AwsEc2InstanceViolation
-- 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.FMS.Types.AwsEc2InstanceViolation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FMS.Types.AwsEc2NetworkInterfaceViolation
import qualified Amazonka.Prelude as Prelude

-- | Violation detail for an EC2 instance resource.
--
-- /See:/ 'newAwsEc2InstanceViolation' smart constructor.
data AwsEc2InstanceViolation = AwsEc2InstanceViolation'
  { -- | Violation detail for network interfaces associated with the EC2
    -- instance.
    AwsEc2InstanceViolation -> Maybe [AwsEc2NetworkInterfaceViolation]
awsEc2NetworkInterfaceViolations :: Prelude.Maybe [AwsEc2NetworkInterfaceViolation],
    -- | The resource ID of the EC2 instance.
    AwsEc2InstanceViolation -> Maybe Text
violationTarget :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsEc2InstanceViolation -> AwsEc2InstanceViolation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsEc2InstanceViolation -> AwsEc2InstanceViolation -> Bool
$c/= :: AwsEc2InstanceViolation -> AwsEc2InstanceViolation -> Bool
== :: AwsEc2InstanceViolation -> AwsEc2InstanceViolation -> Bool
$c== :: AwsEc2InstanceViolation -> AwsEc2InstanceViolation -> Bool
Prelude.Eq, ReadPrec [AwsEc2InstanceViolation]
ReadPrec AwsEc2InstanceViolation
Int -> ReadS AwsEc2InstanceViolation
ReadS [AwsEc2InstanceViolation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsEc2InstanceViolation]
$creadListPrec :: ReadPrec [AwsEc2InstanceViolation]
readPrec :: ReadPrec AwsEc2InstanceViolation
$creadPrec :: ReadPrec AwsEc2InstanceViolation
readList :: ReadS [AwsEc2InstanceViolation]
$creadList :: ReadS [AwsEc2InstanceViolation]
readsPrec :: Int -> ReadS AwsEc2InstanceViolation
$creadsPrec :: Int -> ReadS AwsEc2InstanceViolation
Prelude.Read, Int -> AwsEc2InstanceViolation -> ShowS
[AwsEc2InstanceViolation] -> ShowS
AwsEc2InstanceViolation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsEc2InstanceViolation] -> ShowS
$cshowList :: [AwsEc2InstanceViolation] -> ShowS
show :: AwsEc2InstanceViolation -> String
$cshow :: AwsEc2InstanceViolation -> String
showsPrec :: Int -> AwsEc2InstanceViolation -> ShowS
$cshowsPrec :: Int -> AwsEc2InstanceViolation -> ShowS
Prelude.Show, forall x. Rep AwsEc2InstanceViolation x -> AwsEc2InstanceViolation
forall x. AwsEc2InstanceViolation -> Rep AwsEc2InstanceViolation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsEc2InstanceViolation x -> AwsEc2InstanceViolation
$cfrom :: forall x. AwsEc2InstanceViolation -> Rep AwsEc2InstanceViolation x
Prelude.Generic)

-- |
-- Create a value of 'AwsEc2InstanceViolation' 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:
--
-- 'awsEc2NetworkInterfaceViolations', 'awsEc2InstanceViolation_awsEc2NetworkInterfaceViolations' - Violation detail for network interfaces associated with the EC2
-- instance.
--
-- 'violationTarget', 'awsEc2InstanceViolation_violationTarget' - The resource ID of the EC2 instance.
newAwsEc2InstanceViolation ::
  AwsEc2InstanceViolation
newAwsEc2InstanceViolation :: AwsEc2InstanceViolation
newAwsEc2InstanceViolation =
  AwsEc2InstanceViolation'
    { $sel:awsEc2NetworkInterfaceViolations:AwsEc2InstanceViolation' :: Maybe [AwsEc2NetworkInterfaceViolation]
awsEc2NetworkInterfaceViolations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:violationTarget:AwsEc2InstanceViolation' :: Maybe Text
violationTarget = forall a. Maybe a
Prelude.Nothing
    }

-- | Violation detail for network interfaces associated with the EC2
-- instance.
awsEc2InstanceViolation_awsEc2NetworkInterfaceViolations :: Lens.Lens' AwsEc2InstanceViolation (Prelude.Maybe [AwsEc2NetworkInterfaceViolation])
awsEc2InstanceViolation_awsEc2NetworkInterfaceViolations :: Lens'
  AwsEc2InstanceViolation (Maybe [AwsEc2NetworkInterfaceViolation])
awsEc2InstanceViolation_awsEc2NetworkInterfaceViolations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2InstanceViolation' {Maybe [AwsEc2NetworkInterfaceViolation]
awsEc2NetworkInterfaceViolations :: Maybe [AwsEc2NetworkInterfaceViolation]
$sel:awsEc2NetworkInterfaceViolations:AwsEc2InstanceViolation' :: AwsEc2InstanceViolation -> Maybe [AwsEc2NetworkInterfaceViolation]
awsEc2NetworkInterfaceViolations} -> Maybe [AwsEc2NetworkInterfaceViolation]
awsEc2NetworkInterfaceViolations) (\s :: AwsEc2InstanceViolation
s@AwsEc2InstanceViolation' {} Maybe [AwsEc2NetworkInterfaceViolation]
a -> AwsEc2InstanceViolation
s {$sel:awsEc2NetworkInterfaceViolations:AwsEc2InstanceViolation' :: Maybe [AwsEc2NetworkInterfaceViolation]
awsEc2NetworkInterfaceViolations = Maybe [AwsEc2NetworkInterfaceViolation]
a} :: AwsEc2InstanceViolation) 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

-- | The resource ID of the EC2 instance.
awsEc2InstanceViolation_violationTarget :: Lens.Lens' AwsEc2InstanceViolation (Prelude.Maybe Prelude.Text)
awsEc2InstanceViolation_violationTarget :: Lens' AwsEc2InstanceViolation (Maybe Text)
awsEc2InstanceViolation_violationTarget = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2InstanceViolation' {Maybe Text
violationTarget :: Maybe Text
$sel:violationTarget:AwsEc2InstanceViolation' :: AwsEc2InstanceViolation -> Maybe Text
violationTarget} -> Maybe Text
violationTarget) (\s :: AwsEc2InstanceViolation
s@AwsEc2InstanceViolation' {} Maybe Text
a -> AwsEc2InstanceViolation
s {$sel:violationTarget:AwsEc2InstanceViolation' :: Maybe Text
violationTarget = Maybe Text
a} :: AwsEc2InstanceViolation)

instance Data.FromJSON AwsEc2InstanceViolation where
  parseJSON :: Value -> Parser AwsEc2InstanceViolation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AwsEc2InstanceViolation"
      ( \Object
x ->
          Maybe [AwsEc2NetworkInterfaceViolation]
-> Maybe Text -> AwsEc2InstanceViolation
AwsEc2InstanceViolation'
            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
"AwsEc2NetworkInterfaceViolations"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"ViolationTarget")
      )

instance Prelude.Hashable AwsEc2InstanceViolation where
  hashWithSalt :: Int -> AwsEc2InstanceViolation -> Int
hashWithSalt Int
_salt AwsEc2InstanceViolation' {Maybe [AwsEc2NetworkInterfaceViolation]
Maybe Text
violationTarget :: Maybe Text
awsEc2NetworkInterfaceViolations :: Maybe [AwsEc2NetworkInterfaceViolation]
$sel:violationTarget:AwsEc2InstanceViolation' :: AwsEc2InstanceViolation -> Maybe Text
$sel:awsEc2NetworkInterfaceViolations:AwsEc2InstanceViolation' :: AwsEc2InstanceViolation -> Maybe [AwsEc2NetworkInterfaceViolation]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AwsEc2NetworkInterfaceViolation]
awsEc2NetworkInterfaceViolations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
violationTarget

instance Prelude.NFData AwsEc2InstanceViolation where
  rnf :: AwsEc2InstanceViolation -> ()
rnf AwsEc2InstanceViolation' {Maybe [AwsEc2NetworkInterfaceViolation]
Maybe Text
violationTarget :: Maybe Text
awsEc2NetworkInterfaceViolations :: Maybe [AwsEc2NetworkInterfaceViolation]
$sel:violationTarget:AwsEc2InstanceViolation' :: AwsEc2InstanceViolation -> Maybe Text
$sel:awsEc2NetworkInterfaceViolations:AwsEc2InstanceViolation' :: AwsEc2InstanceViolation -> Maybe [AwsEc2NetworkInterfaceViolation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AwsEc2NetworkInterfaceViolation]
awsEc2NetworkInterfaceViolations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
violationTarget