{-# 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.CognitoIdentityProvider.Types.ResourceServerScopeType
-- 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.CognitoIdentityProvider.Types.ResourceServerScopeType where

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

-- | A resource server scope.
--
-- /See:/ 'newResourceServerScopeType' smart constructor.
data ResourceServerScopeType = ResourceServerScopeType'
  { -- | The name of the scope.
    ResourceServerScopeType -> Text
scopeName :: Prelude.Text,
    -- | A description of the scope.
    ResourceServerScopeType -> Text
scopeDescription :: Prelude.Text
  }
  deriving (ResourceServerScopeType -> ResourceServerScopeType -> Bool
(ResourceServerScopeType -> ResourceServerScopeType -> Bool)
-> (ResourceServerScopeType -> ResourceServerScopeType -> Bool)
-> Eq ResourceServerScopeType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceServerScopeType -> ResourceServerScopeType -> Bool
$c/= :: ResourceServerScopeType -> ResourceServerScopeType -> Bool
== :: ResourceServerScopeType -> ResourceServerScopeType -> Bool
$c== :: ResourceServerScopeType -> ResourceServerScopeType -> Bool
Prelude.Eq, ReadPrec [ResourceServerScopeType]
ReadPrec ResourceServerScopeType
Int -> ReadS ResourceServerScopeType
ReadS [ResourceServerScopeType]
(Int -> ReadS ResourceServerScopeType)
-> ReadS [ResourceServerScopeType]
-> ReadPrec ResourceServerScopeType
-> ReadPrec [ResourceServerScopeType]
-> Read ResourceServerScopeType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceServerScopeType]
$creadListPrec :: ReadPrec [ResourceServerScopeType]
readPrec :: ReadPrec ResourceServerScopeType
$creadPrec :: ReadPrec ResourceServerScopeType
readList :: ReadS [ResourceServerScopeType]
$creadList :: ReadS [ResourceServerScopeType]
readsPrec :: Int -> ReadS ResourceServerScopeType
$creadsPrec :: Int -> ReadS ResourceServerScopeType
Prelude.Read, Int -> ResourceServerScopeType -> ShowS
[ResourceServerScopeType] -> ShowS
ResourceServerScopeType -> String
(Int -> ResourceServerScopeType -> ShowS)
-> (ResourceServerScopeType -> String)
-> ([ResourceServerScopeType] -> ShowS)
-> Show ResourceServerScopeType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceServerScopeType] -> ShowS
$cshowList :: [ResourceServerScopeType] -> ShowS
show :: ResourceServerScopeType -> String
$cshow :: ResourceServerScopeType -> String
showsPrec :: Int -> ResourceServerScopeType -> ShowS
$cshowsPrec :: Int -> ResourceServerScopeType -> ShowS
Prelude.Show, (forall x.
 ResourceServerScopeType -> Rep ResourceServerScopeType x)
-> (forall x.
    Rep ResourceServerScopeType x -> ResourceServerScopeType)
-> Generic ResourceServerScopeType
forall x. Rep ResourceServerScopeType x -> ResourceServerScopeType
forall x. ResourceServerScopeType -> Rep ResourceServerScopeType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceServerScopeType x -> ResourceServerScopeType
$cfrom :: forall x. ResourceServerScopeType -> Rep ResourceServerScopeType x
Prelude.Generic)

-- |
-- Create a value of 'ResourceServerScopeType' 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:
--
-- 'scopeName', 'resourceServerScopeType_scopeName' - The name of the scope.
--
-- 'scopeDescription', 'resourceServerScopeType_scopeDescription' - A description of the scope.
newResourceServerScopeType ::
  -- | 'scopeName'
  Prelude.Text ->
  -- | 'scopeDescription'
  Prelude.Text ->
  ResourceServerScopeType
newResourceServerScopeType :: Text -> Text -> ResourceServerScopeType
newResourceServerScopeType
  Text
pScopeName_
  Text
pScopeDescription_ =
    ResourceServerScopeType' :: Text -> Text -> ResourceServerScopeType
ResourceServerScopeType'
      { $sel:scopeName:ResourceServerScopeType' :: Text
scopeName = Text
pScopeName_,
        $sel:scopeDescription:ResourceServerScopeType' :: Text
scopeDescription = Text
pScopeDescription_
      }

-- | The name of the scope.
resourceServerScopeType_scopeName :: Lens.Lens' ResourceServerScopeType Prelude.Text
resourceServerScopeType_scopeName :: (Text -> f Text)
-> ResourceServerScopeType -> f ResourceServerScopeType
resourceServerScopeType_scopeName = (ResourceServerScopeType -> Text)
-> (ResourceServerScopeType -> Text -> ResourceServerScopeType)
-> Lens ResourceServerScopeType ResourceServerScopeType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceServerScopeType' {Text
scopeName :: Text
$sel:scopeName:ResourceServerScopeType' :: ResourceServerScopeType -> Text
scopeName} -> Text
scopeName) (\s :: ResourceServerScopeType
s@ResourceServerScopeType' {} Text
a -> ResourceServerScopeType
s {$sel:scopeName:ResourceServerScopeType' :: Text
scopeName = Text
a} :: ResourceServerScopeType)

-- | A description of the scope.
resourceServerScopeType_scopeDescription :: Lens.Lens' ResourceServerScopeType Prelude.Text
resourceServerScopeType_scopeDescription :: (Text -> f Text)
-> ResourceServerScopeType -> f ResourceServerScopeType
resourceServerScopeType_scopeDescription = (ResourceServerScopeType -> Text)
-> (ResourceServerScopeType -> Text -> ResourceServerScopeType)
-> Lens ResourceServerScopeType ResourceServerScopeType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceServerScopeType' {Text
scopeDescription :: Text
$sel:scopeDescription:ResourceServerScopeType' :: ResourceServerScopeType -> Text
scopeDescription} -> Text
scopeDescription) (\s :: ResourceServerScopeType
s@ResourceServerScopeType' {} Text
a -> ResourceServerScopeType
s {$sel:scopeDescription:ResourceServerScopeType' :: Text
scopeDescription = Text
a} :: ResourceServerScopeType)

instance Core.FromJSON ResourceServerScopeType where
  parseJSON :: Value -> Parser ResourceServerScopeType
parseJSON =
    String
-> (Object -> Parser ResourceServerScopeType)
-> Value
-> Parser ResourceServerScopeType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceServerScopeType"
      ( \Object
x ->
          Text -> Text -> ResourceServerScopeType
ResourceServerScopeType'
            (Text -> Text -> ResourceServerScopeType)
-> Parser Text -> Parser (Text -> ResourceServerScopeType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ScopeName")
            Parser (Text -> ResourceServerScopeType)
-> Parser Text -> Parser ResourceServerScopeType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ScopeDescription")
      )

instance Prelude.Hashable ResourceServerScopeType

instance Prelude.NFData ResourceServerScopeType

instance Core.ToJSON ResourceServerScopeType where
  toJSON :: ResourceServerScopeType -> Value
toJSON ResourceServerScopeType' {Text
scopeDescription :: Text
scopeName :: Text
$sel:scopeDescription:ResourceServerScopeType' :: ResourceServerScopeType -> Text
$sel:scopeName:ResourceServerScopeType' :: ResourceServerScopeType -> 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
"ScopeName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
scopeName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ScopeDescription" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
scopeDescription)
          ]
      )