{-# 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.AppMesh.Types.SubjectAlternativeNameMatchers
-- 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.AppMesh.Types.SubjectAlternativeNameMatchers where

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

-- | An object that represents the methods by which a subject alternative
-- name on a peer Transport Layer Security (TLS) certificate can be
-- matched.
--
-- /See:/ 'newSubjectAlternativeNameMatchers' smart constructor.
data SubjectAlternativeNameMatchers = SubjectAlternativeNameMatchers'
  { -- | The values sent must match the specified values exactly.
    SubjectAlternativeNameMatchers -> [Text]
exact :: [Prelude.Text]
  }
  deriving (SubjectAlternativeNameMatchers
-> SubjectAlternativeNameMatchers -> Bool
(SubjectAlternativeNameMatchers
 -> SubjectAlternativeNameMatchers -> Bool)
-> (SubjectAlternativeNameMatchers
    -> SubjectAlternativeNameMatchers -> Bool)
-> Eq SubjectAlternativeNameMatchers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubjectAlternativeNameMatchers
-> SubjectAlternativeNameMatchers -> Bool
$c/= :: SubjectAlternativeNameMatchers
-> SubjectAlternativeNameMatchers -> Bool
== :: SubjectAlternativeNameMatchers
-> SubjectAlternativeNameMatchers -> Bool
$c== :: SubjectAlternativeNameMatchers
-> SubjectAlternativeNameMatchers -> Bool
Prelude.Eq, ReadPrec [SubjectAlternativeNameMatchers]
ReadPrec SubjectAlternativeNameMatchers
Int -> ReadS SubjectAlternativeNameMatchers
ReadS [SubjectAlternativeNameMatchers]
(Int -> ReadS SubjectAlternativeNameMatchers)
-> ReadS [SubjectAlternativeNameMatchers]
-> ReadPrec SubjectAlternativeNameMatchers
-> ReadPrec [SubjectAlternativeNameMatchers]
-> Read SubjectAlternativeNameMatchers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SubjectAlternativeNameMatchers]
$creadListPrec :: ReadPrec [SubjectAlternativeNameMatchers]
readPrec :: ReadPrec SubjectAlternativeNameMatchers
$creadPrec :: ReadPrec SubjectAlternativeNameMatchers
readList :: ReadS [SubjectAlternativeNameMatchers]
$creadList :: ReadS [SubjectAlternativeNameMatchers]
readsPrec :: Int -> ReadS SubjectAlternativeNameMatchers
$creadsPrec :: Int -> ReadS SubjectAlternativeNameMatchers
Prelude.Read, Int -> SubjectAlternativeNameMatchers -> ShowS
[SubjectAlternativeNameMatchers] -> ShowS
SubjectAlternativeNameMatchers -> String
(Int -> SubjectAlternativeNameMatchers -> ShowS)
-> (SubjectAlternativeNameMatchers -> String)
-> ([SubjectAlternativeNameMatchers] -> ShowS)
-> Show SubjectAlternativeNameMatchers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubjectAlternativeNameMatchers] -> ShowS
$cshowList :: [SubjectAlternativeNameMatchers] -> ShowS
show :: SubjectAlternativeNameMatchers -> String
$cshow :: SubjectAlternativeNameMatchers -> String
showsPrec :: Int -> SubjectAlternativeNameMatchers -> ShowS
$cshowsPrec :: Int -> SubjectAlternativeNameMatchers -> ShowS
Prelude.Show, (forall x.
 SubjectAlternativeNameMatchers
 -> Rep SubjectAlternativeNameMatchers x)
-> (forall x.
    Rep SubjectAlternativeNameMatchers x
    -> SubjectAlternativeNameMatchers)
-> Generic SubjectAlternativeNameMatchers
forall x.
Rep SubjectAlternativeNameMatchers x
-> SubjectAlternativeNameMatchers
forall x.
SubjectAlternativeNameMatchers
-> Rep SubjectAlternativeNameMatchers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SubjectAlternativeNameMatchers x
-> SubjectAlternativeNameMatchers
$cfrom :: forall x.
SubjectAlternativeNameMatchers
-> Rep SubjectAlternativeNameMatchers x
Prelude.Generic)

-- |
-- Create a value of 'SubjectAlternativeNameMatchers' 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:
--
-- 'exact', 'subjectAlternativeNameMatchers_exact' - The values sent must match the specified values exactly.
newSubjectAlternativeNameMatchers ::
  SubjectAlternativeNameMatchers
newSubjectAlternativeNameMatchers :: SubjectAlternativeNameMatchers
newSubjectAlternativeNameMatchers =
  SubjectAlternativeNameMatchers' :: [Text] -> SubjectAlternativeNameMatchers
SubjectAlternativeNameMatchers'
    { $sel:exact:SubjectAlternativeNameMatchers' :: [Text]
exact =
        [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The values sent must match the specified values exactly.
subjectAlternativeNameMatchers_exact :: Lens.Lens' SubjectAlternativeNameMatchers [Prelude.Text]
subjectAlternativeNameMatchers_exact :: ([Text] -> f [Text])
-> SubjectAlternativeNameMatchers
-> f SubjectAlternativeNameMatchers
subjectAlternativeNameMatchers_exact = (SubjectAlternativeNameMatchers -> [Text])
-> (SubjectAlternativeNameMatchers
    -> [Text] -> SubjectAlternativeNameMatchers)
-> Lens
     SubjectAlternativeNameMatchers
     SubjectAlternativeNameMatchers
     [Text]
     [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubjectAlternativeNameMatchers' {[Text]
exact :: [Text]
$sel:exact:SubjectAlternativeNameMatchers' :: SubjectAlternativeNameMatchers -> [Text]
exact} -> [Text]
exact) (\s :: SubjectAlternativeNameMatchers
s@SubjectAlternativeNameMatchers' {} [Text]
a -> SubjectAlternativeNameMatchers
s {$sel:exact:SubjectAlternativeNameMatchers' :: [Text]
exact = [Text]
a} :: SubjectAlternativeNameMatchers) (([Text] -> f [Text])
 -> SubjectAlternativeNameMatchers
 -> f SubjectAlternativeNameMatchers)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> SubjectAlternativeNameMatchers
-> f SubjectAlternativeNameMatchers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON SubjectAlternativeNameMatchers where
  parseJSON :: Value -> Parser SubjectAlternativeNameMatchers
parseJSON =
    String
-> (Object -> Parser SubjectAlternativeNameMatchers)
-> Value
-> Parser SubjectAlternativeNameMatchers
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SubjectAlternativeNameMatchers"
      ( \Object
x ->
          [Text] -> SubjectAlternativeNameMatchers
SubjectAlternativeNameMatchers'
            ([Text] -> SubjectAlternativeNameMatchers)
-> Parser [Text] -> Parser SubjectAlternativeNameMatchers
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
"exact" Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance
  Prelude.Hashable
    SubjectAlternativeNameMatchers

instance
  Prelude.NFData
    SubjectAlternativeNameMatchers

instance Core.ToJSON SubjectAlternativeNameMatchers where
  toJSON :: SubjectAlternativeNameMatchers -> Value
toJSON SubjectAlternativeNameMatchers' {[Text]
exact :: [Text]
$sel:exact:SubjectAlternativeNameMatchers' :: SubjectAlternativeNameMatchers -> [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"exact" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
exact)]
      )