{-# 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.AwsEc2SecurityGroupIpv6Range
-- 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.AwsEc2SecurityGroupIpv6Range where

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

-- | A range of IPv6 addresses.
--
-- /See:/ 'newAwsEc2SecurityGroupIpv6Range' smart constructor.
data AwsEc2SecurityGroupIpv6Range = AwsEc2SecurityGroupIpv6Range'
  { -- | The IPv6 CIDR range. You can specify either a CIDR range or a source
    -- security group, but not both. To specify a single IPv6 address, use the
    -- \/128 prefix length.
    AwsEc2SecurityGroupIpv6Range -> Maybe Text
cidrIpv6 :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsEc2SecurityGroupIpv6Range
-> AwsEc2SecurityGroupIpv6Range -> Bool
(AwsEc2SecurityGroupIpv6Range
 -> AwsEc2SecurityGroupIpv6Range -> Bool)
-> (AwsEc2SecurityGroupIpv6Range
    -> AwsEc2SecurityGroupIpv6Range -> Bool)
-> Eq AwsEc2SecurityGroupIpv6Range
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsEc2SecurityGroupIpv6Range
-> AwsEc2SecurityGroupIpv6Range -> Bool
$c/= :: AwsEc2SecurityGroupIpv6Range
-> AwsEc2SecurityGroupIpv6Range -> Bool
== :: AwsEc2SecurityGroupIpv6Range
-> AwsEc2SecurityGroupIpv6Range -> Bool
$c== :: AwsEc2SecurityGroupIpv6Range
-> AwsEc2SecurityGroupIpv6Range -> Bool
Prelude.Eq, ReadPrec [AwsEc2SecurityGroupIpv6Range]
ReadPrec AwsEc2SecurityGroupIpv6Range
Int -> ReadS AwsEc2SecurityGroupIpv6Range
ReadS [AwsEc2SecurityGroupIpv6Range]
(Int -> ReadS AwsEc2SecurityGroupIpv6Range)
-> ReadS [AwsEc2SecurityGroupIpv6Range]
-> ReadPrec AwsEc2SecurityGroupIpv6Range
-> ReadPrec [AwsEc2SecurityGroupIpv6Range]
-> Read AwsEc2SecurityGroupIpv6Range
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsEc2SecurityGroupIpv6Range]
$creadListPrec :: ReadPrec [AwsEc2SecurityGroupIpv6Range]
readPrec :: ReadPrec AwsEc2SecurityGroupIpv6Range
$creadPrec :: ReadPrec AwsEc2SecurityGroupIpv6Range
readList :: ReadS [AwsEc2SecurityGroupIpv6Range]
$creadList :: ReadS [AwsEc2SecurityGroupIpv6Range]
readsPrec :: Int -> ReadS AwsEc2SecurityGroupIpv6Range
$creadsPrec :: Int -> ReadS AwsEc2SecurityGroupIpv6Range
Prelude.Read, Int -> AwsEc2SecurityGroupIpv6Range -> ShowS
[AwsEc2SecurityGroupIpv6Range] -> ShowS
AwsEc2SecurityGroupIpv6Range -> String
(Int -> AwsEc2SecurityGroupIpv6Range -> ShowS)
-> (AwsEc2SecurityGroupIpv6Range -> String)
-> ([AwsEc2SecurityGroupIpv6Range] -> ShowS)
-> Show AwsEc2SecurityGroupIpv6Range
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsEc2SecurityGroupIpv6Range] -> ShowS
$cshowList :: [AwsEc2SecurityGroupIpv6Range] -> ShowS
show :: AwsEc2SecurityGroupIpv6Range -> String
$cshow :: AwsEc2SecurityGroupIpv6Range -> String
showsPrec :: Int -> AwsEc2SecurityGroupIpv6Range -> ShowS
$cshowsPrec :: Int -> AwsEc2SecurityGroupIpv6Range -> ShowS
Prelude.Show, (forall x.
 AwsEc2SecurityGroupIpv6Range -> Rep AwsEc2SecurityGroupIpv6Range x)
-> (forall x.
    Rep AwsEc2SecurityGroupIpv6Range x -> AwsEc2SecurityGroupIpv6Range)
-> Generic AwsEc2SecurityGroupIpv6Range
forall x.
Rep AwsEc2SecurityGroupIpv6Range x -> AwsEc2SecurityGroupIpv6Range
forall x.
AwsEc2SecurityGroupIpv6Range -> Rep AwsEc2SecurityGroupIpv6Range x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsEc2SecurityGroupIpv6Range x -> AwsEc2SecurityGroupIpv6Range
$cfrom :: forall x.
AwsEc2SecurityGroupIpv6Range -> Rep AwsEc2SecurityGroupIpv6Range x
Prelude.Generic)

-- |
-- Create a value of 'AwsEc2SecurityGroupIpv6Range' 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:
--
-- 'cidrIpv6', 'awsEc2SecurityGroupIpv6Range_cidrIpv6' - The IPv6 CIDR range. You can specify either a CIDR range or a source
-- security group, but not both. To specify a single IPv6 address, use the
-- \/128 prefix length.
newAwsEc2SecurityGroupIpv6Range ::
  AwsEc2SecurityGroupIpv6Range
newAwsEc2SecurityGroupIpv6Range :: AwsEc2SecurityGroupIpv6Range
newAwsEc2SecurityGroupIpv6Range =
  AwsEc2SecurityGroupIpv6Range' :: Maybe Text -> AwsEc2SecurityGroupIpv6Range
AwsEc2SecurityGroupIpv6Range'
    { $sel:cidrIpv6:AwsEc2SecurityGroupIpv6Range' :: Maybe Text
cidrIpv6 =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The IPv6 CIDR range. You can specify either a CIDR range or a source
-- security group, but not both. To specify a single IPv6 address, use the
-- \/128 prefix length.
awsEc2SecurityGroupIpv6Range_cidrIpv6 :: Lens.Lens' AwsEc2SecurityGroupIpv6Range (Prelude.Maybe Prelude.Text)
awsEc2SecurityGroupIpv6Range_cidrIpv6 :: (Maybe Text -> f (Maybe Text))
-> AwsEc2SecurityGroupIpv6Range -> f AwsEc2SecurityGroupIpv6Range
awsEc2SecurityGroupIpv6Range_cidrIpv6 = (AwsEc2SecurityGroupIpv6Range -> Maybe Text)
-> (AwsEc2SecurityGroupIpv6Range
    -> Maybe Text -> AwsEc2SecurityGroupIpv6Range)
-> Lens
     AwsEc2SecurityGroupIpv6Range
     AwsEc2SecurityGroupIpv6Range
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2SecurityGroupIpv6Range' {Maybe Text
cidrIpv6 :: Maybe Text
$sel:cidrIpv6:AwsEc2SecurityGroupIpv6Range' :: AwsEc2SecurityGroupIpv6Range -> Maybe Text
cidrIpv6} -> Maybe Text
cidrIpv6) (\s :: AwsEc2SecurityGroupIpv6Range
s@AwsEc2SecurityGroupIpv6Range' {} Maybe Text
a -> AwsEc2SecurityGroupIpv6Range
s {$sel:cidrIpv6:AwsEc2SecurityGroupIpv6Range' :: Maybe Text
cidrIpv6 = Maybe Text
a} :: AwsEc2SecurityGroupIpv6Range)

instance Core.FromJSON AwsEc2SecurityGroupIpv6Range where
  parseJSON :: Value -> Parser AwsEc2SecurityGroupIpv6Range
parseJSON =
    String
-> (Object -> Parser AwsEc2SecurityGroupIpv6Range)
-> Value
-> Parser AwsEc2SecurityGroupIpv6Range
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsEc2SecurityGroupIpv6Range"
      ( \Object
x ->
          Maybe Text -> AwsEc2SecurityGroupIpv6Range
AwsEc2SecurityGroupIpv6Range'
            (Maybe Text -> AwsEc2SecurityGroupIpv6Range)
-> Parser (Maybe Text) -> Parser AwsEc2SecurityGroupIpv6Range
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
"CidrIpv6")
      )

instance
  Prelude.Hashable
    AwsEc2SecurityGroupIpv6Range

instance Prelude.NFData AwsEc2SecurityGroupIpv6Range

instance Core.ToJSON AwsEc2SecurityGroupIpv6Range where
  toJSON :: AwsEc2SecurityGroupIpv6Range -> Value
toJSON AwsEc2SecurityGroupIpv6Range' {Maybe Text
cidrIpv6 :: Maybe Text
$sel:cidrIpv6:AwsEc2SecurityGroupIpv6Range' :: AwsEc2SecurityGroupIpv6Range -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"CidrIpv6" 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
cidrIpv6]
      )