{-# 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.Organizations.Types.HandshakeFilter
-- 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.Organizations.Types.HandshakeFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Organizations.Types.ActionType
import qualified Amazonka.Prelude as Prelude

-- | Specifies the criteria that are used to select the handshakes for the
-- operation.
--
-- /See:/ 'newHandshakeFilter' smart constructor.
data HandshakeFilter = HandshakeFilter'
  { -- | Specifies the type of handshake action.
    --
    -- If you specify @ActionType@, you cannot also specify
    -- @ParentHandshakeId@.
    HandshakeFilter -> Maybe ActionType
actionType :: Prelude.Maybe ActionType,
    -- | Specifies the parent handshake. Only used for handshake types that are a
    -- child of another type.
    --
    -- If you specify @ParentHandshakeId@, you cannot also specify
    -- @ActionType@.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for handshake ID
    -- string requires \"h-\" followed by from 8 to 32 lowercase letters or
    -- digits.
    HandshakeFilter -> Maybe Text
parentHandshakeId :: Prelude.Maybe Prelude.Text
  }
  deriving (HandshakeFilter -> HandshakeFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HandshakeFilter -> HandshakeFilter -> Bool
$c/= :: HandshakeFilter -> HandshakeFilter -> Bool
== :: HandshakeFilter -> HandshakeFilter -> Bool
$c== :: HandshakeFilter -> HandshakeFilter -> Bool
Prelude.Eq, ReadPrec [HandshakeFilter]
ReadPrec HandshakeFilter
Int -> ReadS HandshakeFilter
ReadS [HandshakeFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HandshakeFilter]
$creadListPrec :: ReadPrec [HandshakeFilter]
readPrec :: ReadPrec HandshakeFilter
$creadPrec :: ReadPrec HandshakeFilter
readList :: ReadS [HandshakeFilter]
$creadList :: ReadS [HandshakeFilter]
readsPrec :: Int -> ReadS HandshakeFilter
$creadsPrec :: Int -> ReadS HandshakeFilter
Prelude.Read, Int -> HandshakeFilter -> ShowS
[HandshakeFilter] -> ShowS
HandshakeFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HandshakeFilter] -> ShowS
$cshowList :: [HandshakeFilter] -> ShowS
show :: HandshakeFilter -> String
$cshow :: HandshakeFilter -> String
showsPrec :: Int -> HandshakeFilter -> ShowS
$cshowsPrec :: Int -> HandshakeFilter -> ShowS
Prelude.Show, forall x. Rep HandshakeFilter x -> HandshakeFilter
forall x. HandshakeFilter -> Rep HandshakeFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HandshakeFilter x -> HandshakeFilter
$cfrom :: forall x. HandshakeFilter -> Rep HandshakeFilter x
Prelude.Generic)

-- |
-- Create a value of 'HandshakeFilter' 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:
--
-- 'actionType', 'handshakeFilter_actionType' - Specifies the type of handshake action.
--
-- If you specify @ActionType@, you cannot also specify
-- @ParentHandshakeId@.
--
-- 'parentHandshakeId', 'handshakeFilter_parentHandshakeId' - Specifies the parent handshake. Only used for handshake types that are a
-- child of another type.
--
-- If you specify @ParentHandshakeId@, you cannot also specify
-- @ActionType@.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for handshake ID
-- string requires \"h-\" followed by from 8 to 32 lowercase letters or
-- digits.
newHandshakeFilter ::
  HandshakeFilter
newHandshakeFilter :: HandshakeFilter
newHandshakeFilter =
  HandshakeFilter'
    { $sel:actionType:HandshakeFilter' :: Maybe ActionType
actionType = forall a. Maybe a
Prelude.Nothing,
      $sel:parentHandshakeId:HandshakeFilter' :: Maybe Text
parentHandshakeId = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the type of handshake action.
--
-- If you specify @ActionType@, you cannot also specify
-- @ParentHandshakeId@.
handshakeFilter_actionType :: Lens.Lens' HandshakeFilter (Prelude.Maybe ActionType)
handshakeFilter_actionType :: Lens' HandshakeFilter (Maybe ActionType)
handshakeFilter_actionType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HandshakeFilter' {Maybe ActionType
actionType :: Maybe ActionType
$sel:actionType:HandshakeFilter' :: HandshakeFilter -> Maybe ActionType
actionType} -> Maybe ActionType
actionType) (\s :: HandshakeFilter
s@HandshakeFilter' {} Maybe ActionType
a -> HandshakeFilter
s {$sel:actionType:HandshakeFilter' :: Maybe ActionType
actionType = Maybe ActionType
a} :: HandshakeFilter)

-- | Specifies the parent handshake. Only used for handshake types that are a
-- child of another type.
--
-- If you specify @ParentHandshakeId@, you cannot also specify
-- @ActionType@.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for handshake ID
-- string requires \"h-\" followed by from 8 to 32 lowercase letters or
-- digits.
handshakeFilter_parentHandshakeId :: Lens.Lens' HandshakeFilter (Prelude.Maybe Prelude.Text)
handshakeFilter_parentHandshakeId :: Lens' HandshakeFilter (Maybe Text)
handshakeFilter_parentHandshakeId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HandshakeFilter' {Maybe Text
parentHandshakeId :: Maybe Text
$sel:parentHandshakeId:HandshakeFilter' :: HandshakeFilter -> Maybe Text
parentHandshakeId} -> Maybe Text
parentHandshakeId) (\s :: HandshakeFilter
s@HandshakeFilter' {} Maybe Text
a -> HandshakeFilter
s {$sel:parentHandshakeId:HandshakeFilter' :: Maybe Text
parentHandshakeId = Maybe Text
a} :: HandshakeFilter)

instance Prelude.Hashable HandshakeFilter where
  hashWithSalt :: Int -> HandshakeFilter -> Int
hashWithSalt Int
_salt HandshakeFilter' {Maybe Text
Maybe ActionType
parentHandshakeId :: Maybe Text
actionType :: Maybe ActionType
$sel:parentHandshakeId:HandshakeFilter' :: HandshakeFilter -> Maybe Text
$sel:actionType:HandshakeFilter' :: HandshakeFilter -> Maybe ActionType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ActionType
actionType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parentHandshakeId

instance Prelude.NFData HandshakeFilter where
  rnf :: HandshakeFilter -> ()
rnf HandshakeFilter' {Maybe Text
Maybe ActionType
parentHandshakeId :: Maybe Text
actionType :: Maybe ActionType
$sel:parentHandshakeId:HandshakeFilter' :: HandshakeFilter -> Maybe Text
$sel:actionType:HandshakeFilter' :: HandshakeFilter -> Maybe ActionType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ActionType
actionType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
parentHandshakeId

instance Data.ToJSON HandshakeFilter where
  toJSON :: HandshakeFilter -> Value
toJSON HandshakeFilter' {Maybe Text
Maybe ActionType
parentHandshakeId :: Maybe Text
actionType :: Maybe ActionType
$sel:parentHandshakeId:HandshakeFilter' :: HandshakeFilter -> Maybe Text
$sel:actionType:HandshakeFilter' :: HandshakeFilter -> Maybe ActionType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ActionType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ActionType
actionType,
            (Key
"ParentHandshakeId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
parentHandshakeId
          ]
      )