{-# 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.IcmpTypeCode
-- 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.IcmpTypeCode 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

-- | Describes the ICMP type and code.
--
-- /See:/ 'newIcmpTypeCode' smart constructor.
data IcmpTypeCode = IcmpTypeCode'
  { -- | The ICMP code. A value of -1 means all codes for the specified ICMP
    -- type.
    IcmpTypeCode -> Maybe Int
code :: Prelude.Maybe Prelude.Int,
    -- | The ICMP type. A value of -1 means all types.
    IcmpTypeCode -> Maybe Int
type' :: Prelude.Maybe Prelude.Int
  }
  deriving (IcmpTypeCode -> IcmpTypeCode -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IcmpTypeCode -> IcmpTypeCode -> Bool
$c/= :: IcmpTypeCode -> IcmpTypeCode -> Bool
== :: IcmpTypeCode -> IcmpTypeCode -> Bool
$c== :: IcmpTypeCode -> IcmpTypeCode -> Bool
Prelude.Eq, ReadPrec [IcmpTypeCode]
ReadPrec IcmpTypeCode
Int -> ReadS IcmpTypeCode
ReadS [IcmpTypeCode]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IcmpTypeCode]
$creadListPrec :: ReadPrec [IcmpTypeCode]
readPrec :: ReadPrec IcmpTypeCode
$creadPrec :: ReadPrec IcmpTypeCode
readList :: ReadS [IcmpTypeCode]
$creadList :: ReadS [IcmpTypeCode]
readsPrec :: Int -> ReadS IcmpTypeCode
$creadsPrec :: Int -> ReadS IcmpTypeCode
Prelude.Read, Int -> IcmpTypeCode -> ShowS
[IcmpTypeCode] -> ShowS
IcmpTypeCode -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IcmpTypeCode] -> ShowS
$cshowList :: [IcmpTypeCode] -> ShowS
show :: IcmpTypeCode -> String
$cshow :: IcmpTypeCode -> String
showsPrec :: Int -> IcmpTypeCode -> ShowS
$cshowsPrec :: Int -> IcmpTypeCode -> ShowS
Prelude.Show, forall x. Rep IcmpTypeCode x -> IcmpTypeCode
forall x. IcmpTypeCode -> Rep IcmpTypeCode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IcmpTypeCode x -> IcmpTypeCode
$cfrom :: forall x. IcmpTypeCode -> Rep IcmpTypeCode x
Prelude.Generic)

-- |
-- Create a value of 'IcmpTypeCode' 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:
--
-- 'code', 'icmpTypeCode_code' - The ICMP code. A value of -1 means all codes for the specified ICMP
-- type.
--
-- 'type'', 'icmpTypeCode_type' - The ICMP type. A value of -1 means all types.
newIcmpTypeCode ::
  IcmpTypeCode
newIcmpTypeCode :: IcmpTypeCode
newIcmpTypeCode =
  IcmpTypeCode'
    { $sel:code:IcmpTypeCode' :: Maybe Int
code = forall a. Maybe a
Prelude.Nothing,
      $sel:type':IcmpTypeCode' :: Maybe Int
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The ICMP code. A value of -1 means all codes for the specified ICMP
-- type.
icmpTypeCode_code :: Lens.Lens' IcmpTypeCode (Prelude.Maybe Prelude.Int)
icmpTypeCode_code :: Lens' IcmpTypeCode (Maybe Int)
icmpTypeCode_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IcmpTypeCode' {Maybe Int
code :: Maybe Int
$sel:code:IcmpTypeCode' :: IcmpTypeCode -> Maybe Int
code} -> Maybe Int
code) (\s :: IcmpTypeCode
s@IcmpTypeCode' {} Maybe Int
a -> IcmpTypeCode
s {$sel:code:IcmpTypeCode' :: Maybe Int
code = Maybe Int
a} :: IcmpTypeCode)

-- | The ICMP type. A value of -1 means all types.
icmpTypeCode_type :: Lens.Lens' IcmpTypeCode (Prelude.Maybe Prelude.Int)
icmpTypeCode_type :: Lens' IcmpTypeCode (Maybe Int)
icmpTypeCode_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IcmpTypeCode' {Maybe Int
type' :: Maybe Int
$sel:type':IcmpTypeCode' :: IcmpTypeCode -> Maybe Int
type'} -> Maybe Int
type') (\s :: IcmpTypeCode
s@IcmpTypeCode' {} Maybe Int
a -> IcmpTypeCode
s {$sel:type':IcmpTypeCode' :: Maybe Int
type' = Maybe Int
a} :: IcmpTypeCode)

instance Data.FromXML IcmpTypeCode where
  parseXML :: [Node] -> Either String IcmpTypeCode
parseXML [Node]
x =
    Maybe Int -> Maybe Int -> IcmpTypeCode
IcmpTypeCode'
      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
"code")
      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
"type")

instance Prelude.Hashable IcmpTypeCode where
  hashWithSalt :: Int -> IcmpTypeCode -> Int
hashWithSalt Int
_salt IcmpTypeCode' {Maybe Int
type' :: Maybe Int
code :: Maybe Int
$sel:type':IcmpTypeCode' :: IcmpTypeCode -> Maybe Int
$sel:code:IcmpTypeCode' :: IcmpTypeCode -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
type'

instance Prelude.NFData IcmpTypeCode where
  rnf :: IcmpTypeCode -> ()
rnf IcmpTypeCode' {Maybe Int
type' :: Maybe Int
code :: Maybe Int
$sel:type':IcmpTypeCode' :: IcmpTypeCode -> Maybe Int
$sel:code:IcmpTypeCode' :: IcmpTypeCode -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
code seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
type'

instance Data.ToQuery IcmpTypeCode where
  toQuery :: IcmpTypeCode -> QueryString
toQuery IcmpTypeCode' {Maybe Int
type' :: Maybe Int
code :: Maybe Int
$sel:type':IcmpTypeCode' :: IcmpTypeCode -> Maybe Int
$sel:code:IcmpTypeCode' :: IcmpTypeCode -> Maybe Int
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"Code" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
code, ByteString
"Type" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
type']