{-# 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.Grafana.Types.AuthenticationDescription
-- 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.Grafana.Types.AuthenticationDescription where

import qualified Amazonka.Core as Core
import Amazonka.Grafana.Types.AuthenticationProviderTypes
import Amazonka.Grafana.Types.AwsSsoAuthentication
import Amazonka.Grafana.Types.SamlAuthentication
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A structure containing information about the user authentication methods
-- used by the workspace.
--
-- /See:/ 'newAuthenticationDescription' smart constructor.
data AuthenticationDescription = AuthenticationDescription'
  { -- | A structure containing information about how this workspace works with
    -- Amazon Web Services SSO.
    AuthenticationDescription -> Maybe AwsSsoAuthentication
awsSso :: Prelude.Maybe AwsSsoAuthentication,
    -- | A structure containing information about how this workspace works with
    -- SAML, including what attributes within the assertion are to be mapped to
    -- user information in the workspace.
    AuthenticationDescription -> Maybe SamlAuthentication
saml :: Prelude.Maybe SamlAuthentication,
    -- | Specifies whether this workspace uses Amazon Web Services SSO, SAML, or
    -- both methods to authenticate users to use the Grafana console in the
    -- Amazon Managed Grafana workspace.
    AuthenticationDescription -> [AuthenticationProviderTypes]
providers :: [AuthenticationProviderTypes]
  }
  deriving (AuthenticationDescription -> AuthenticationDescription -> Bool
(AuthenticationDescription -> AuthenticationDescription -> Bool)
-> (AuthenticationDescription -> AuthenticationDescription -> Bool)
-> Eq AuthenticationDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AuthenticationDescription -> AuthenticationDescription -> Bool
$c/= :: AuthenticationDescription -> AuthenticationDescription -> Bool
== :: AuthenticationDescription -> AuthenticationDescription -> Bool
$c== :: AuthenticationDescription -> AuthenticationDescription -> Bool
Prelude.Eq, ReadPrec [AuthenticationDescription]
ReadPrec AuthenticationDescription
Int -> ReadS AuthenticationDescription
ReadS [AuthenticationDescription]
(Int -> ReadS AuthenticationDescription)
-> ReadS [AuthenticationDescription]
-> ReadPrec AuthenticationDescription
-> ReadPrec [AuthenticationDescription]
-> Read AuthenticationDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AuthenticationDescription]
$creadListPrec :: ReadPrec [AuthenticationDescription]
readPrec :: ReadPrec AuthenticationDescription
$creadPrec :: ReadPrec AuthenticationDescription
readList :: ReadS [AuthenticationDescription]
$creadList :: ReadS [AuthenticationDescription]
readsPrec :: Int -> ReadS AuthenticationDescription
$creadsPrec :: Int -> ReadS AuthenticationDescription
Prelude.Read, Int -> AuthenticationDescription -> ShowS
[AuthenticationDescription] -> ShowS
AuthenticationDescription -> String
(Int -> AuthenticationDescription -> ShowS)
-> (AuthenticationDescription -> String)
-> ([AuthenticationDescription] -> ShowS)
-> Show AuthenticationDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuthenticationDescription] -> ShowS
$cshowList :: [AuthenticationDescription] -> ShowS
show :: AuthenticationDescription -> String
$cshow :: AuthenticationDescription -> String
showsPrec :: Int -> AuthenticationDescription -> ShowS
$cshowsPrec :: Int -> AuthenticationDescription -> ShowS
Prelude.Show, (forall x.
 AuthenticationDescription -> Rep AuthenticationDescription x)
-> (forall x.
    Rep AuthenticationDescription x -> AuthenticationDescription)
-> Generic AuthenticationDescription
forall x.
Rep AuthenticationDescription x -> AuthenticationDescription
forall x.
AuthenticationDescription -> Rep AuthenticationDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AuthenticationDescription x -> AuthenticationDescription
$cfrom :: forall x.
AuthenticationDescription -> Rep AuthenticationDescription x
Prelude.Generic)

-- |
-- Create a value of 'AuthenticationDescription' 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:
--
-- 'awsSso', 'authenticationDescription_awsSso' - A structure containing information about how this workspace works with
-- Amazon Web Services SSO.
--
-- 'saml', 'authenticationDescription_saml' - A structure containing information about how this workspace works with
-- SAML, including what attributes within the assertion are to be mapped to
-- user information in the workspace.
--
-- 'providers', 'authenticationDescription_providers' - Specifies whether this workspace uses Amazon Web Services SSO, SAML, or
-- both methods to authenticate users to use the Grafana console in the
-- Amazon Managed Grafana workspace.
newAuthenticationDescription ::
  AuthenticationDescription
newAuthenticationDescription :: AuthenticationDescription
newAuthenticationDescription =
  AuthenticationDescription' :: Maybe AwsSsoAuthentication
-> Maybe SamlAuthentication
-> [AuthenticationProviderTypes]
-> AuthenticationDescription
AuthenticationDescription'
    { $sel:awsSso:AuthenticationDescription' :: Maybe AwsSsoAuthentication
awsSso =
        Maybe AwsSsoAuthentication
forall a. Maybe a
Prelude.Nothing,
      $sel:saml:AuthenticationDescription' :: Maybe SamlAuthentication
saml = Maybe SamlAuthentication
forall a. Maybe a
Prelude.Nothing,
      $sel:providers:AuthenticationDescription' :: [AuthenticationProviderTypes]
providers = [AuthenticationProviderTypes]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A structure containing information about how this workspace works with
-- Amazon Web Services SSO.
authenticationDescription_awsSso :: Lens.Lens' AuthenticationDescription (Prelude.Maybe AwsSsoAuthentication)
authenticationDescription_awsSso :: (Maybe AwsSsoAuthentication -> f (Maybe AwsSsoAuthentication))
-> AuthenticationDescription -> f AuthenticationDescription
authenticationDescription_awsSso = (AuthenticationDescription -> Maybe AwsSsoAuthentication)
-> (AuthenticationDescription
    -> Maybe AwsSsoAuthentication -> AuthenticationDescription)
-> Lens
     AuthenticationDescription
     AuthenticationDescription
     (Maybe AwsSsoAuthentication)
     (Maybe AwsSsoAuthentication)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationDescription' {Maybe AwsSsoAuthentication
awsSso :: Maybe AwsSsoAuthentication
$sel:awsSso:AuthenticationDescription' :: AuthenticationDescription -> Maybe AwsSsoAuthentication
awsSso} -> Maybe AwsSsoAuthentication
awsSso) (\s :: AuthenticationDescription
s@AuthenticationDescription' {} Maybe AwsSsoAuthentication
a -> AuthenticationDescription
s {$sel:awsSso:AuthenticationDescription' :: Maybe AwsSsoAuthentication
awsSso = Maybe AwsSsoAuthentication
a} :: AuthenticationDescription)

-- | A structure containing information about how this workspace works with
-- SAML, including what attributes within the assertion are to be mapped to
-- user information in the workspace.
authenticationDescription_saml :: Lens.Lens' AuthenticationDescription (Prelude.Maybe SamlAuthentication)
authenticationDescription_saml :: (Maybe SamlAuthentication -> f (Maybe SamlAuthentication))
-> AuthenticationDescription -> f AuthenticationDescription
authenticationDescription_saml = (AuthenticationDescription -> Maybe SamlAuthentication)
-> (AuthenticationDescription
    -> Maybe SamlAuthentication -> AuthenticationDescription)
-> Lens
     AuthenticationDescription
     AuthenticationDescription
     (Maybe SamlAuthentication)
     (Maybe SamlAuthentication)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationDescription' {Maybe SamlAuthentication
saml :: Maybe SamlAuthentication
$sel:saml:AuthenticationDescription' :: AuthenticationDescription -> Maybe SamlAuthentication
saml} -> Maybe SamlAuthentication
saml) (\s :: AuthenticationDescription
s@AuthenticationDescription' {} Maybe SamlAuthentication
a -> AuthenticationDescription
s {$sel:saml:AuthenticationDescription' :: Maybe SamlAuthentication
saml = Maybe SamlAuthentication
a} :: AuthenticationDescription)

-- | Specifies whether this workspace uses Amazon Web Services SSO, SAML, or
-- both methods to authenticate users to use the Grafana console in the
-- Amazon Managed Grafana workspace.
authenticationDescription_providers :: Lens.Lens' AuthenticationDescription [AuthenticationProviderTypes]
authenticationDescription_providers :: ([AuthenticationProviderTypes] -> f [AuthenticationProviderTypes])
-> AuthenticationDescription -> f AuthenticationDescription
authenticationDescription_providers = (AuthenticationDescription -> [AuthenticationProviderTypes])
-> (AuthenticationDescription
    -> [AuthenticationProviderTypes] -> AuthenticationDescription)
-> Lens
     AuthenticationDescription
     AuthenticationDescription
     [AuthenticationProviderTypes]
     [AuthenticationProviderTypes]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationDescription' {[AuthenticationProviderTypes]
providers :: [AuthenticationProviderTypes]
$sel:providers:AuthenticationDescription' :: AuthenticationDescription -> [AuthenticationProviderTypes]
providers} -> [AuthenticationProviderTypes]
providers) (\s :: AuthenticationDescription
s@AuthenticationDescription' {} [AuthenticationProviderTypes]
a -> AuthenticationDescription
s {$sel:providers:AuthenticationDescription' :: [AuthenticationProviderTypes]
providers = [AuthenticationProviderTypes]
a} :: AuthenticationDescription) (([AuthenticationProviderTypes] -> f [AuthenticationProviderTypes])
 -> AuthenticationDescription -> f AuthenticationDescription)
-> (([AuthenticationProviderTypes]
     -> f [AuthenticationProviderTypes])
    -> [AuthenticationProviderTypes]
    -> f [AuthenticationProviderTypes])
-> ([AuthenticationProviderTypes]
    -> f [AuthenticationProviderTypes])
-> AuthenticationDescription
-> f AuthenticationDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AuthenticationProviderTypes] -> f [AuthenticationProviderTypes])
-> [AuthenticationProviderTypes] -> f [AuthenticationProviderTypes]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AuthenticationDescription where
  parseJSON :: Value -> Parser AuthenticationDescription
parseJSON =
    String
-> (Object -> Parser AuthenticationDescription)
-> Value
-> Parser AuthenticationDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AuthenticationDescription"
      ( \Object
x ->
          Maybe AwsSsoAuthentication
-> Maybe SamlAuthentication
-> [AuthenticationProviderTypes]
-> AuthenticationDescription
AuthenticationDescription'
            (Maybe AwsSsoAuthentication
 -> Maybe SamlAuthentication
 -> [AuthenticationProviderTypes]
 -> AuthenticationDescription)
-> Parser (Maybe AwsSsoAuthentication)
-> Parser
     (Maybe SamlAuthentication
      -> [AuthenticationProviderTypes] -> AuthenticationDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AwsSsoAuthentication)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"awsSso")
            Parser
  (Maybe SamlAuthentication
   -> [AuthenticationProviderTypes] -> AuthenticationDescription)
-> Parser (Maybe SamlAuthentication)
-> Parser
     ([AuthenticationProviderTypes] -> AuthenticationDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SamlAuthentication)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"saml")
            Parser ([AuthenticationProviderTypes] -> AuthenticationDescription)
-> Parser [AuthenticationProviderTypes]
-> Parser AuthenticationDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [AuthenticationProviderTypes])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"providers" Parser (Maybe [AuthenticationProviderTypes])
-> [AuthenticationProviderTypes]
-> Parser [AuthenticationProviderTypes]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [AuthenticationProviderTypes]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AuthenticationDescription

instance Prelude.NFData AuthenticationDescription