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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | Specifies the type of handshake action.
    --
    -- If you specify @ActionType@, you cannot also specify
    -- @ParentHandshakeId@.
    HandshakeFilter -> Maybe ActionType
actionType :: Prelude.Maybe ActionType
  }
  deriving (HandshakeFilter -> HandshakeFilter -> Bool
(HandshakeFilter -> HandshakeFilter -> Bool)
-> (HandshakeFilter -> HandshakeFilter -> Bool)
-> Eq HandshakeFilter
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]
(Int -> ReadS HandshakeFilter)
-> ReadS [HandshakeFilter]
-> ReadPrec HandshakeFilter
-> ReadPrec [HandshakeFilter]
-> Read 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
(Int -> HandshakeFilter -> ShowS)
-> (HandshakeFilter -> String)
-> ([HandshakeFilter] -> ShowS)
-> Show HandshakeFilter
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. HandshakeFilter -> Rep HandshakeFilter x)
-> (forall x. Rep HandshakeFilter x -> HandshakeFilter)
-> Generic HandshakeFilter
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:
--
-- '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.
--
-- 'actionType', 'handshakeFilter_actionType' - Specifies the type of handshake action.
--
-- If you specify @ActionType@, you cannot also specify
-- @ParentHandshakeId@.
newHandshakeFilter ::
  HandshakeFilter
newHandshakeFilter :: HandshakeFilter
newHandshakeFilter =
  HandshakeFilter' :: Maybe Text -> Maybe ActionType -> HandshakeFilter
HandshakeFilter'
    { $sel:parentHandshakeId:HandshakeFilter' :: Maybe Text
parentHandshakeId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:actionType:HandshakeFilter' :: Maybe ActionType
actionType = Maybe ActionType
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> HandshakeFilter -> f HandshakeFilter
handshakeFilter_parentHandshakeId = (HandshakeFilter -> Maybe Text)
-> (HandshakeFilter -> Maybe Text -> HandshakeFilter)
-> Lens HandshakeFilter HandshakeFilter (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe ActionType -> f (Maybe ActionType))
-> HandshakeFilter -> f HandshakeFilter
handshakeFilter_actionType = (HandshakeFilter -> Maybe ActionType)
-> (HandshakeFilter -> Maybe ActionType -> HandshakeFilter)
-> Lens
     HandshakeFilter
     HandshakeFilter
     (Maybe ActionType)
     (Maybe 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)

instance Prelude.Hashable HandshakeFilter

instance Prelude.NFData HandshakeFilter

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