{-# 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.EC2.Types.Ipv6Range
-- 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.EC2.Types.Ipv6Range where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import qualified Amazonka.Prelude as Prelude

-- | [EC2-VPC only] Describes an IPv6 range.
--
-- /See:/ 'newIpv6Range' smart constructor.
data Ipv6Range = Ipv6Range'
  { -- | The IPv6 CIDR range. You can either specify a CIDR range or a source
    -- security group, not both. To specify a single IPv6 address, use the
    -- \/128 prefix length.
    Ipv6Range -> Maybe Text
cidrIpv6 :: Prelude.Maybe Prelude.Text,
    -- | A description for the security group rule that references this IPv6
    -- address range.
    --
    -- Constraints: Up to 255 characters in length. Allowed characters are a-z,
    -- A-Z, 0-9, spaces, and ._-:\/()#,\@[]+=&;{}!$*
    Ipv6Range -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (Ipv6Range -> Ipv6Range -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ipv6Range -> Ipv6Range -> Bool
$c/= :: Ipv6Range -> Ipv6Range -> Bool
== :: Ipv6Range -> Ipv6Range -> Bool
$c== :: Ipv6Range -> Ipv6Range -> Bool
Prelude.Eq, ReadPrec [Ipv6Range]
ReadPrec Ipv6Range
Int -> ReadS Ipv6Range
ReadS [Ipv6Range]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Ipv6Range]
$creadListPrec :: ReadPrec [Ipv6Range]
readPrec :: ReadPrec Ipv6Range
$creadPrec :: ReadPrec Ipv6Range
readList :: ReadS [Ipv6Range]
$creadList :: ReadS [Ipv6Range]
readsPrec :: Int -> ReadS Ipv6Range
$creadsPrec :: Int -> ReadS Ipv6Range
Prelude.Read, Int -> Ipv6Range -> ShowS
[Ipv6Range] -> ShowS
Ipv6Range -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Ipv6Range] -> ShowS
$cshowList :: [Ipv6Range] -> ShowS
show :: Ipv6Range -> String
$cshow :: Ipv6Range -> String
showsPrec :: Int -> Ipv6Range -> ShowS
$cshowsPrec :: Int -> Ipv6Range -> ShowS
Prelude.Show, forall x. Rep Ipv6Range x -> Ipv6Range
forall x. Ipv6Range -> Rep Ipv6Range x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Ipv6Range x -> Ipv6Range
$cfrom :: forall x. Ipv6Range -> Rep Ipv6Range x
Prelude.Generic)

-- |
-- Create a value of 'Ipv6Range' 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', 'ipv6Range_cidrIpv6' - The IPv6 CIDR range. You can either specify a CIDR range or a source
-- security group, not both. To specify a single IPv6 address, use the
-- \/128 prefix length.
--
-- 'description', 'ipv6Range_description' - A description for the security group rule that references this IPv6
-- address range.
--
-- Constraints: Up to 255 characters in length. Allowed characters are a-z,
-- A-Z, 0-9, spaces, and ._-:\/()#,\@[]+=&;{}!$*
newIpv6Range ::
  Ipv6Range
newIpv6Range :: Ipv6Range
newIpv6Range =
  Ipv6Range'
    { $sel:cidrIpv6:Ipv6Range' :: Maybe Text
cidrIpv6 = forall a. Maybe a
Prelude.Nothing,
      $sel:description:Ipv6Range' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing
    }

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

-- | A description for the security group rule that references this IPv6
-- address range.
--
-- Constraints: Up to 255 characters in length. Allowed characters are a-z,
-- A-Z, 0-9, spaces, and ._-:\/()#,\@[]+=&;{}!$*
ipv6Range_description :: Lens.Lens' Ipv6Range (Prelude.Maybe Prelude.Text)
ipv6Range_description :: Lens' Ipv6Range (Maybe Text)
ipv6Range_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ipv6Range' {Maybe Text
description :: Maybe Text
$sel:description:Ipv6Range' :: Ipv6Range -> Maybe Text
description} -> Maybe Text
description) (\s :: Ipv6Range
s@Ipv6Range' {} Maybe Text
a -> Ipv6Range
s {$sel:description:Ipv6Range' :: Maybe Text
description = Maybe Text
a} :: Ipv6Range)

instance Data.FromXML Ipv6Range where
  parseXML :: [Node] -> Either String Ipv6Range
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Ipv6Range
Ipv6Range'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"cidrIpv6")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"description")

instance Prelude.Hashable Ipv6Range where
  hashWithSalt :: Int -> Ipv6Range -> Int
hashWithSalt Int
_salt Ipv6Range' {Maybe Text
description :: Maybe Text
cidrIpv6 :: Maybe Text
$sel:description:Ipv6Range' :: Ipv6Range -> Maybe Text
$sel:cidrIpv6:Ipv6Range' :: Ipv6Range -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
cidrIpv6
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description

instance Prelude.NFData Ipv6Range where
  rnf :: Ipv6Range -> ()
rnf Ipv6Range' {Maybe Text
description :: Maybe Text
cidrIpv6 :: Maybe Text
$sel:description:Ipv6Range' :: Ipv6Range -> Maybe Text
$sel:cidrIpv6:Ipv6Range' :: Ipv6Range -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
cidrIpv6
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description

instance Data.ToQuery Ipv6Range where
  toQuery :: Ipv6Range -> QueryString
toQuery Ipv6Range' {Maybe Text
description :: Maybe Text
cidrIpv6 :: Maybe Text
$sel:description:Ipv6Range' :: Ipv6Range -> Maybe Text
$sel:cidrIpv6:Ipv6Range' :: Ipv6Range -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"CidrIpv6" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
cidrIpv6,
        ByteString
"Description" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
description
      ]