{-# 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.APIGateway.Types.MethodSnapshot
-- 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.APIGateway.Types.MethodSnapshot where

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

-- | Represents a summary of a Method resource, given a particular date and
-- time.
--
-- /See:/ 'newMethodSnapshot' smart constructor.
data MethodSnapshot = MethodSnapshot'
  { -- | The method\'s authorization type. Valid values are @NONE@ for open
    -- access, @AWS_IAM@ for using AWS IAM permissions, @CUSTOM@ for using a
    -- custom authorizer, or @COGNITO_USER_POOLS@ for using a Cognito user
    -- pool.
    MethodSnapshot -> Maybe Text
authorizationType :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether the method requires a valid ApiKey.
    MethodSnapshot -> Maybe Bool
apiKeyRequired :: Prelude.Maybe Prelude.Bool
  }
  deriving (MethodSnapshot -> MethodSnapshot -> Bool
(MethodSnapshot -> MethodSnapshot -> Bool)
-> (MethodSnapshot -> MethodSnapshot -> Bool) -> Eq MethodSnapshot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MethodSnapshot -> MethodSnapshot -> Bool
$c/= :: MethodSnapshot -> MethodSnapshot -> Bool
== :: MethodSnapshot -> MethodSnapshot -> Bool
$c== :: MethodSnapshot -> MethodSnapshot -> Bool
Prelude.Eq, ReadPrec [MethodSnapshot]
ReadPrec MethodSnapshot
Int -> ReadS MethodSnapshot
ReadS [MethodSnapshot]
(Int -> ReadS MethodSnapshot)
-> ReadS [MethodSnapshot]
-> ReadPrec MethodSnapshot
-> ReadPrec [MethodSnapshot]
-> Read MethodSnapshot
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MethodSnapshot]
$creadListPrec :: ReadPrec [MethodSnapshot]
readPrec :: ReadPrec MethodSnapshot
$creadPrec :: ReadPrec MethodSnapshot
readList :: ReadS [MethodSnapshot]
$creadList :: ReadS [MethodSnapshot]
readsPrec :: Int -> ReadS MethodSnapshot
$creadsPrec :: Int -> ReadS MethodSnapshot
Prelude.Read, Int -> MethodSnapshot -> ShowS
[MethodSnapshot] -> ShowS
MethodSnapshot -> String
(Int -> MethodSnapshot -> ShowS)
-> (MethodSnapshot -> String)
-> ([MethodSnapshot] -> ShowS)
-> Show MethodSnapshot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MethodSnapshot] -> ShowS
$cshowList :: [MethodSnapshot] -> ShowS
show :: MethodSnapshot -> String
$cshow :: MethodSnapshot -> String
showsPrec :: Int -> MethodSnapshot -> ShowS
$cshowsPrec :: Int -> MethodSnapshot -> ShowS
Prelude.Show, (forall x. MethodSnapshot -> Rep MethodSnapshot x)
-> (forall x. Rep MethodSnapshot x -> MethodSnapshot)
-> Generic MethodSnapshot
forall x. Rep MethodSnapshot x -> MethodSnapshot
forall x. MethodSnapshot -> Rep MethodSnapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MethodSnapshot x -> MethodSnapshot
$cfrom :: forall x. MethodSnapshot -> Rep MethodSnapshot x
Prelude.Generic)

-- |
-- Create a value of 'MethodSnapshot' 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:
--
-- 'authorizationType', 'methodSnapshot_authorizationType' - The method\'s authorization type. Valid values are @NONE@ for open
-- access, @AWS_IAM@ for using AWS IAM permissions, @CUSTOM@ for using a
-- custom authorizer, or @COGNITO_USER_POOLS@ for using a Cognito user
-- pool.
--
-- 'apiKeyRequired', 'methodSnapshot_apiKeyRequired' - Specifies whether the method requires a valid ApiKey.
newMethodSnapshot ::
  MethodSnapshot
newMethodSnapshot :: MethodSnapshot
newMethodSnapshot =
  MethodSnapshot' :: Maybe Text -> Maybe Bool -> MethodSnapshot
MethodSnapshot'
    { $sel:authorizationType:MethodSnapshot' :: Maybe Text
authorizationType =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:apiKeyRequired:MethodSnapshot' :: Maybe Bool
apiKeyRequired = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The method\'s authorization type. Valid values are @NONE@ for open
-- access, @AWS_IAM@ for using AWS IAM permissions, @CUSTOM@ for using a
-- custom authorizer, or @COGNITO_USER_POOLS@ for using a Cognito user
-- pool.
methodSnapshot_authorizationType :: Lens.Lens' MethodSnapshot (Prelude.Maybe Prelude.Text)
methodSnapshot_authorizationType :: (Maybe Text -> f (Maybe Text))
-> MethodSnapshot -> f MethodSnapshot
methodSnapshot_authorizationType = (MethodSnapshot -> Maybe Text)
-> (MethodSnapshot -> Maybe Text -> MethodSnapshot)
-> Lens MethodSnapshot MethodSnapshot (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MethodSnapshot' {Maybe Text
authorizationType :: Maybe Text
$sel:authorizationType:MethodSnapshot' :: MethodSnapshot -> Maybe Text
authorizationType} -> Maybe Text
authorizationType) (\s :: MethodSnapshot
s@MethodSnapshot' {} Maybe Text
a -> MethodSnapshot
s {$sel:authorizationType:MethodSnapshot' :: Maybe Text
authorizationType = Maybe Text
a} :: MethodSnapshot)

-- | Specifies whether the method requires a valid ApiKey.
methodSnapshot_apiKeyRequired :: Lens.Lens' MethodSnapshot (Prelude.Maybe Prelude.Bool)
methodSnapshot_apiKeyRequired :: (Maybe Bool -> f (Maybe Bool))
-> MethodSnapshot -> f MethodSnapshot
methodSnapshot_apiKeyRequired = (MethodSnapshot -> Maybe Bool)
-> (MethodSnapshot -> Maybe Bool -> MethodSnapshot)
-> Lens MethodSnapshot MethodSnapshot (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MethodSnapshot' {Maybe Bool
apiKeyRequired :: Maybe Bool
$sel:apiKeyRequired:MethodSnapshot' :: MethodSnapshot -> Maybe Bool
apiKeyRequired} -> Maybe Bool
apiKeyRequired) (\s :: MethodSnapshot
s@MethodSnapshot' {} Maybe Bool
a -> MethodSnapshot
s {$sel:apiKeyRequired:MethodSnapshot' :: Maybe Bool
apiKeyRequired = Maybe Bool
a} :: MethodSnapshot)

instance Core.FromJSON MethodSnapshot where
  parseJSON :: Value -> Parser MethodSnapshot
parseJSON =
    String
-> (Object -> Parser MethodSnapshot)
-> Value
-> Parser MethodSnapshot
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MethodSnapshot"
      ( \Object
x ->
          Maybe Text -> Maybe Bool -> MethodSnapshot
MethodSnapshot'
            (Maybe Text -> Maybe Bool -> MethodSnapshot)
-> Parser (Maybe Text) -> Parser (Maybe Bool -> MethodSnapshot)
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
"authorizationType")
            Parser (Maybe Bool -> MethodSnapshot)
-> Parser (Maybe Bool) -> Parser MethodSnapshot
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"apiKeyRequired")
      )

instance Prelude.Hashable MethodSnapshot

instance Prelude.NFData MethodSnapshot