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

import Amazonka.CognitoIdentityProvider.Types.ResourceServerScopeType
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A container for information about a resource server for a user pool.
--
-- /See:/ 'newResourceServerType' smart constructor.
data ResourceServerType = ResourceServerType'
  { -- | The identifier for the resource server.
    ResourceServerType -> Maybe Text
identifier :: Prelude.Maybe Prelude.Text,
    -- | The name of the resource server.
    ResourceServerType -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A list of scopes that are defined for the resource server.
    ResourceServerType -> Maybe [ResourceServerScopeType]
scopes :: Prelude.Maybe [ResourceServerScopeType],
    -- | The user pool ID for the user pool that hosts the resource server.
    ResourceServerType -> Maybe Text
userPoolId :: Prelude.Maybe Prelude.Text
  }
  deriving (ResourceServerType -> ResourceServerType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceServerType -> ResourceServerType -> Bool
$c/= :: ResourceServerType -> ResourceServerType -> Bool
== :: ResourceServerType -> ResourceServerType -> Bool
$c== :: ResourceServerType -> ResourceServerType -> Bool
Prelude.Eq, ReadPrec [ResourceServerType]
ReadPrec ResourceServerType
Int -> ReadS ResourceServerType
ReadS [ResourceServerType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceServerType]
$creadListPrec :: ReadPrec [ResourceServerType]
readPrec :: ReadPrec ResourceServerType
$creadPrec :: ReadPrec ResourceServerType
readList :: ReadS [ResourceServerType]
$creadList :: ReadS [ResourceServerType]
readsPrec :: Int -> ReadS ResourceServerType
$creadsPrec :: Int -> ReadS ResourceServerType
Prelude.Read, Int -> ResourceServerType -> ShowS
[ResourceServerType] -> ShowS
ResourceServerType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceServerType] -> ShowS
$cshowList :: [ResourceServerType] -> ShowS
show :: ResourceServerType -> String
$cshow :: ResourceServerType -> String
showsPrec :: Int -> ResourceServerType -> ShowS
$cshowsPrec :: Int -> ResourceServerType -> ShowS
Prelude.Show, forall x. Rep ResourceServerType x -> ResourceServerType
forall x. ResourceServerType -> Rep ResourceServerType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceServerType x -> ResourceServerType
$cfrom :: forall x. ResourceServerType -> Rep ResourceServerType x
Prelude.Generic)

-- |
-- Create a value of 'ResourceServerType' 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:
--
-- 'identifier', 'resourceServerType_identifier' - The identifier for the resource server.
--
-- 'name', 'resourceServerType_name' - The name of the resource server.
--
-- 'scopes', 'resourceServerType_scopes' - A list of scopes that are defined for the resource server.
--
-- 'userPoolId', 'resourceServerType_userPoolId' - The user pool ID for the user pool that hosts the resource server.
newResourceServerType ::
  ResourceServerType
newResourceServerType :: ResourceServerType
newResourceServerType =
  ResourceServerType'
    { $sel:identifier:ResourceServerType' :: Maybe Text
identifier = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ResourceServerType' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:scopes:ResourceServerType' :: Maybe [ResourceServerScopeType]
scopes = forall a. Maybe a
Prelude.Nothing,
      $sel:userPoolId:ResourceServerType' :: Maybe Text
userPoolId = forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier for the resource server.
resourceServerType_identifier :: Lens.Lens' ResourceServerType (Prelude.Maybe Prelude.Text)
resourceServerType_identifier :: Lens' ResourceServerType (Maybe Text)
resourceServerType_identifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceServerType' {Maybe Text
identifier :: Maybe Text
$sel:identifier:ResourceServerType' :: ResourceServerType -> Maybe Text
identifier} -> Maybe Text
identifier) (\s :: ResourceServerType
s@ResourceServerType' {} Maybe Text
a -> ResourceServerType
s {$sel:identifier:ResourceServerType' :: Maybe Text
identifier = Maybe Text
a} :: ResourceServerType)

-- | The name of the resource server.
resourceServerType_name :: Lens.Lens' ResourceServerType (Prelude.Maybe Prelude.Text)
resourceServerType_name :: Lens' ResourceServerType (Maybe Text)
resourceServerType_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceServerType' {Maybe Text
name :: Maybe Text
$sel:name:ResourceServerType' :: ResourceServerType -> Maybe Text
name} -> Maybe Text
name) (\s :: ResourceServerType
s@ResourceServerType' {} Maybe Text
a -> ResourceServerType
s {$sel:name:ResourceServerType' :: Maybe Text
name = Maybe Text
a} :: ResourceServerType)

-- | A list of scopes that are defined for the resource server.
resourceServerType_scopes :: Lens.Lens' ResourceServerType (Prelude.Maybe [ResourceServerScopeType])
resourceServerType_scopes :: Lens' ResourceServerType (Maybe [ResourceServerScopeType])
resourceServerType_scopes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceServerType' {Maybe [ResourceServerScopeType]
scopes :: Maybe [ResourceServerScopeType]
$sel:scopes:ResourceServerType' :: ResourceServerType -> Maybe [ResourceServerScopeType]
scopes} -> Maybe [ResourceServerScopeType]
scopes) (\s :: ResourceServerType
s@ResourceServerType' {} Maybe [ResourceServerScopeType]
a -> ResourceServerType
s {$sel:scopes:ResourceServerType' :: Maybe [ResourceServerScopeType]
scopes = Maybe [ResourceServerScopeType]
a} :: ResourceServerType) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The user pool ID for the user pool that hosts the resource server.
resourceServerType_userPoolId :: Lens.Lens' ResourceServerType (Prelude.Maybe Prelude.Text)
resourceServerType_userPoolId :: Lens' ResourceServerType (Maybe Text)
resourceServerType_userPoolId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceServerType' {Maybe Text
userPoolId :: Maybe Text
$sel:userPoolId:ResourceServerType' :: ResourceServerType -> Maybe Text
userPoolId} -> Maybe Text
userPoolId) (\s :: ResourceServerType
s@ResourceServerType' {} Maybe Text
a -> ResourceServerType
s {$sel:userPoolId:ResourceServerType' :: Maybe Text
userPoolId = Maybe Text
a} :: ResourceServerType)

instance Data.FromJSON ResourceServerType where
  parseJSON :: Value -> Parser ResourceServerType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceServerType"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe [ResourceServerScopeType]
-> Maybe Text
-> ResourceServerType
ResourceServerType'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Identifier")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Scopes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UserPoolId")
      )

instance Prelude.Hashable ResourceServerType where
  hashWithSalt :: Int -> ResourceServerType -> Int
hashWithSalt Int
_salt ResourceServerType' {Maybe [ResourceServerScopeType]
Maybe Text
userPoolId :: Maybe Text
scopes :: Maybe [ResourceServerScopeType]
name :: Maybe Text
identifier :: Maybe Text
$sel:userPoolId:ResourceServerType' :: ResourceServerType -> Maybe Text
$sel:scopes:ResourceServerType' :: ResourceServerType -> Maybe [ResourceServerScopeType]
$sel:name:ResourceServerType' :: ResourceServerType -> Maybe Text
$sel:identifier:ResourceServerType' :: ResourceServerType -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
identifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ResourceServerScopeType]
scopes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userPoolId

instance Prelude.NFData ResourceServerType where
  rnf :: ResourceServerType -> ()
rnf ResourceServerType' {Maybe [ResourceServerScopeType]
Maybe Text
userPoolId :: Maybe Text
scopes :: Maybe [ResourceServerScopeType]
name :: Maybe Text
identifier :: Maybe Text
$sel:userPoolId:ResourceServerType' :: ResourceServerType -> Maybe Text
$sel:scopes:ResourceServerType' :: ResourceServerType -> Maybe [ResourceServerScopeType]
$sel:name:ResourceServerType' :: ResourceServerType -> Maybe Text
$sel:identifier:ResourceServerType' :: ResourceServerType -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
identifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ResourceServerScopeType]
scopes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userPoolId