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

import Amazonka.CognitoIdentityProvider.Types.ResourceServerScopeType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 user pool ID for the user pool that hosts the resource server.
    ResourceServerType -> Maybe Text
userPoolId :: Prelude.Maybe Prelude.Text,
    -- | The identifier for the resource server.
    ResourceServerType -> Maybe Text
identifier :: Prelude.Maybe Prelude.Text,
    -- | A list of scopes that are defined for the resource server.
    ResourceServerType -> Maybe [ResourceServerScopeType]
scopes :: Prelude.Maybe [ResourceServerScopeType],
    -- | The name of the resource server.
    ResourceServerType -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (ResourceServerType -> ResourceServerType -> Bool
(ResourceServerType -> ResourceServerType -> Bool)
-> (ResourceServerType -> ResourceServerType -> Bool)
-> Eq ResourceServerType
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]
(Int -> ReadS ResourceServerType)
-> ReadS [ResourceServerType]
-> ReadPrec ResourceServerType
-> ReadPrec [ResourceServerType]
-> Read 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
(Int -> ResourceServerType -> ShowS)
-> (ResourceServerType -> String)
-> ([ResourceServerType] -> ShowS)
-> Show ResourceServerType
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. ResourceServerType -> Rep ResourceServerType x)
-> (forall x. Rep ResourceServerType x -> ResourceServerType)
-> Generic ResourceServerType
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:
--
-- 'userPoolId', 'resourceServerType_userPoolId' - The user pool ID for the user pool that hosts the resource server.
--
-- 'identifier', 'resourceServerType_identifier' - The identifier for the resource server.
--
-- 'scopes', 'resourceServerType_scopes' - A list of scopes that are defined for the resource server.
--
-- 'name', 'resourceServerType_name' - The name of the resource server.
newResourceServerType ::
  ResourceServerType
newResourceServerType :: ResourceServerType
newResourceServerType =
  ResourceServerType' :: Maybe Text
-> Maybe Text
-> Maybe [ResourceServerScopeType]
-> Maybe Text
-> ResourceServerType
ResourceServerType'
    { $sel:userPoolId:ResourceServerType' :: Maybe Text
userPoolId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:identifier:ResourceServerType' :: Maybe Text
identifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:scopes:ResourceServerType' :: Maybe [ResourceServerScopeType]
scopes = Maybe [ResourceServerScopeType]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ResourceServerType' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The user pool ID for the user pool that hosts the resource server.
resourceServerType_userPoolId :: Lens.Lens' ResourceServerType (Prelude.Maybe Prelude.Text)
resourceServerType_userPoolId :: (Maybe Text -> f (Maybe Text))
-> ResourceServerType -> f ResourceServerType
resourceServerType_userPoolId = (ResourceServerType -> Maybe Text)
-> (ResourceServerType -> Maybe Text -> ResourceServerType)
-> Lens
     ResourceServerType ResourceServerType (Maybe Text) (Maybe Text)
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)

-- | The identifier for the resource server.
resourceServerType_identifier :: Lens.Lens' ResourceServerType (Prelude.Maybe Prelude.Text)
resourceServerType_identifier :: (Maybe Text -> f (Maybe Text))
-> ResourceServerType -> f ResourceServerType
resourceServerType_identifier = (ResourceServerType -> Maybe Text)
-> (ResourceServerType -> Maybe Text -> ResourceServerType)
-> Lens
     ResourceServerType ResourceServerType (Maybe Text) (Maybe Text)
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)

-- | A list of scopes that are defined for the resource server.
resourceServerType_scopes :: Lens.Lens' ResourceServerType (Prelude.Maybe [ResourceServerScopeType])
resourceServerType_scopes :: (Maybe [ResourceServerScopeType]
 -> f (Maybe [ResourceServerScopeType]))
-> ResourceServerType -> f ResourceServerType
resourceServerType_scopes = (ResourceServerType -> Maybe [ResourceServerScopeType])
-> (ResourceServerType
    -> Maybe [ResourceServerScopeType] -> ResourceServerType)
-> Lens
     ResourceServerType
     ResourceServerType
     (Maybe [ResourceServerScopeType])
     (Maybe [ResourceServerScopeType])
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) ((Maybe [ResourceServerScopeType]
  -> f (Maybe [ResourceServerScopeType]))
 -> ResourceServerType -> f ResourceServerType)
-> ((Maybe [ResourceServerScopeType]
     -> f (Maybe [ResourceServerScopeType]))
    -> Maybe [ResourceServerScopeType]
    -> f (Maybe [ResourceServerScopeType]))
-> (Maybe [ResourceServerScopeType]
    -> f (Maybe [ResourceServerScopeType]))
-> ResourceServerType
-> f ResourceServerType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ResourceServerScopeType]
  [ResourceServerScopeType]
  [ResourceServerScopeType]
  [ResourceServerScopeType]
-> Iso
     (Maybe [ResourceServerScopeType])
     (Maybe [ResourceServerScopeType])
     (Maybe [ResourceServerScopeType])
     (Maybe [ResourceServerScopeType])
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 AnIso
  [ResourceServerScopeType]
  [ResourceServerScopeType]
  [ResourceServerScopeType]
  [ResourceServerScopeType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the resource server.
resourceServerType_name :: Lens.Lens' ResourceServerType (Prelude.Maybe Prelude.Text)
resourceServerType_name :: (Maybe Text -> f (Maybe Text))
-> ResourceServerType -> f ResourceServerType
resourceServerType_name = (ResourceServerType -> Maybe Text)
-> (ResourceServerType -> Maybe Text -> ResourceServerType)
-> Lens
     ResourceServerType ResourceServerType (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable ResourceServerType

instance Prelude.NFData ResourceServerType