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

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

-- | Violation detail for an EC2 instance resource.
--
-- /See:/ 'newAwsEc2InstanceViolation' smart constructor.
data AwsEc2InstanceViolation = AwsEc2InstanceViolation'
  { -- | The resource ID of the EC2 instance.
    AwsEc2InstanceViolation -> Maybe Text
violationTarget :: Prelude.Maybe Prelude.Text,
    -- | Violation detail for network interfaces associated with the EC2
    -- instance.
    AwsEc2InstanceViolation -> Maybe [AwsEc2NetworkInterfaceViolation]
awsEc2NetworkInterfaceViolations :: Prelude.Maybe [AwsEc2NetworkInterfaceViolation]
  }
  deriving (AwsEc2InstanceViolation -> AwsEc2InstanceViolation -> Bool
(AwsEc2InstanceViolation -> AwsEc2InstanceViolation -> Bool)
-> (AwsEc2InstanceViolation -> AwsEc2InstanceViolation -> Bool)
-> Eq AwsEc2InstanceViolation
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]
(Int -> ReadS AwsEc2InstanceViolation)
-> ReadS [AwsEc2InstanceViolation]
-> ReadPrec AwsEc2InstanceViolation
-> ReadPrec [AwsEc2InstanceViolation]
-> Read 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
(Int -> AwsEc2InstanceViolation -> ShowS)
-> (AwsEc2InstanceViolation -> String)
-> ([AwsEc2InstanceViolation] -> ShowS)
-> Show AwsEc2InstanceViolation
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.
 AwsEc2InstanceViolation -> Rep AwsEc2InstanceViolation x)
-> (forall x.
    Rep AwsEc2InstanceViolation x -> AwsEc2InstanceViolation)
-> Generic AwsEc2InstanceViolation
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:
--
-- 'violationTarget', 'awsEc2InstanceViolation_violationTarget' - The resource ID of the EC2 instance.
--
-- 'awsEc2NetworkInterfaceViolations', 'awsEc2InstanceViolation_awsEc2NetworkInterfaceViolations' - Violation detail for network interfaces associated with the EC2
-- instance.
newAwsEc2InstanceViolation ::
  AwsEc2InstanceViolation
newAwsEc2InstanceViolation :: AwsEc2InstanceViolation
newAwsEc2InstanceViolation =
  AwsEc2InstanceViolation' :: Maybe Text
-> Maybe [AwsEc2NetworkInterfaceViolation]
-> AwsEc2InstanceViolation
AwsEc2InstanceViolation'
    { $sel:violationTarget:AwsEc2InstanceViolation' :: Maybe Text
violationTarget =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:awsEc2NetworkInterfaceViolations:AwsEc2InstanceViolation' :: Maybe [AwsEc2NetworkInterfaceViolation]
awsEc2NetworkInterfaceViolations = Maybe [AwsEc2NetworkInterfaceViolation]
forall a. Maybe a
Prelude.Nothing
    }

-- | The resource ID of the EC2 instance.
awsEc2InstanceViolation_violationTarget :: Lens.Lens' AwsEc2InstanceViolation (Prelude.Maybe Prelude.Text)
awsEc2InstanceViolation_violationTarget :: (Maybe Text -> f (Maybe Text))
-> AwsEc2InstanceViolation -> f AwsEc2InstanceViolation
awsEc2InstanceViolation_violationTarget = (AwsEc2InstanceViolation -> Maybe Text)
-> (AwsEc2InstanceViolation
    -> Maybe Text -> AwsEc2InstanceViolation)
-> Lens
     AwsEc2InstanceViolation
     AwsEc2InstanceViolation
     (Maybe Text)
     (Maybe Text)
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)

-- | Violation detail for network interfaces associated with the EC2
-- instance.
awsEc2InstanceViolation_awsEc2NetworkInterfaceViolations :: Lens.Lens' AwsEc2InstanceViolation (Prelude.Maybe [AwsEc2NetworkInterfaceViolation])
awsEc2InstanceViolation_awsEc2NetworkInterfaceViolations :: (Maybe [AwsEc2NetworkInterfaceViolation]
 -> f (Maybe [AwsEc2NetworkInterfaceViolation]))
-> AwsEc2InstanceViolation -> f AwsEc2InstanceViolation
awsEc2InstanceViolation_awsEc2NetworkInterfaceViolations = (AwsEc2InstanceViolation
 -> Maybe [AwsEc2NetworkInterfaceViolation])
-> (AwsEc2InstanceViolation
    -> Maybe [AwsEc2NetworkInterfaceViolation]
    -> AwsEc2InstanceViolation)
-> Lens
     AwsEc2InstanceViolation
     AwsEc2InstanceViolation
     (Maybe [AwsEc2NetworkInterfaceViolation])
     (Maybe [AwsEc2NetworkInterfaceViolation])
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) ((Maybe [AwsEc2NetworkInterfaceViolation]
  -> f (Maybe [AwsEc2NetworkInterfaceViolation]))
 -> AwsEc2InstanceViolation -> f AwsEc2InstanceViolation)
-> ((Maybe [AwsEc2NetworkInterfaceViolation]
     -> f (Maybe [AwsEc2NetworkInterfaceViolation]))
    -> Maybe [AwsEc2NetworkInterfaceViolation]
    -> f (Maybe [AwsEc2NetworkInterfaceViolation]))
-> (Maybe [AwsEc2NetworkInterfaceViolation]
    -> f (Maybe [AwsEc2NetworkInterfaceViolation]))
-> AwsEc2InstanceViolation
-> f AwsEc2InstanceViolation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AwsEc2NetworkInterfaceViolation]
  [AwsEc2NetworkInterfaceViolation]
  [AwsEc2NetworkInterfaceViolation]
  [AwsEc2NetworkInterfaceViolation]
-> Iso
     (Maybe [AwsEc2NetworkInterfaceViolation])
     (Maybe [AwsEc2NetworkInterfaceViolation])
     (Maybe [AwsEc2NetworkInterfaceViolation])
     (Maybe [AwsEc2NetworkInterfaceViolation])
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 AnIso
  [AwsEc2NetworkInterfaceViolation]
  [AwsEc2NetworkInterfaceViolation]
  [AwsEc2NetworkInterfaceViolation]
  [AwsEc2NetworkInterfaceViolation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable AwsEc2InstanceViolation

instance Prelude.NFData AwsEc2InstanceViolation