{-# 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.Organizations.Types.EnabledServicePrincipal
-- 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.Organizations.Types.EnabledServicePrincipal where

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 structure that contains details of a service principal that represents
-- an Amazon Web Services service that is enabled to integrate with
-- Organizations.
--
-- /See:/ 'newEnabledServicePrincipal' smart constructor.
data EnabledServicePrincipal = EnabledServicePrincipal'
  { -- | The date that the service principal was enabled for integration with
    -- Organizations.
    EnabledServicePrincipal -> Maybe POSIX
dateEnabled :: Prelude.Maybe Data.POSIX,
    -- | The name of the service principal. This is typically in the form of a
    -- URL, such as: @ @/@servicename@/@.amazonaws.com@.
    EnabledServicePrincipal -> Maybe Text
servicePrincipal :: Prelude.Maybe Prelude.Text
  }
  deriving (EnabledServicePrincipal -> EnabledServicePrincipal -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnabledServicePrincipal -> EnabledServicePrincipal -> Bool
$c/= :: EnabledServicePrincipal -> EnabledServicePrincipal -> Bool
== :: EnabledServicePrincipal -> EnabledServicePrincipal -> Bool
$c== :: EnabledServicePrincipal -> EnabledServicePrincipal -> Bool
Prelude.Eq, ReadPrec [EnabledServicePrincipal]
ReadPrec EnabledServicePrincipal
Int -> ReadS EnabledServicePrincipal
ReadS [EnabledServicePrincipal]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnabledServicePrincipal]
$creadListPrec :: ReadPrec [EnabledServicePrincipal]
readPrec :: ReadPrec EnabledServicePrincipal
$creadPrec :: ReadPrec EnabledServicePrincipal
readList :: ReadS [EnabledServicePrincipal]
$creadList :: ReadS [EnabledServicePrincipal]
readsPrec :: Int -> ReadS EnabledServicePrincipal
$creadsPrec :: Int -> ReadS EnabledServicePrincipal
Prelude.Read, Int -> EnabledServicePrincipal -> ShowS
[EnabledServicePrincipal] -> ShowS
EnabledServicePrincipal -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnabledServicePrincipal] -> ShowS
$cshowList :: [EnabledServicePrincipal] -> ShowS
show :: EnabledServicePrincipal -> String
$cshow :: EnabledServicePrincipal -> String
showsPrec :: Int -> EnabledServicePrincipal -> ShowS
$cshowsPrec :: Int -> EnabledServicePrincipal -> ShowS
Prelude.Show, forall x. Rep EnabledServicePrincipal x -> EnabledServicePrincipal
forall x. EnabledServicePrincipal -> Rep EnabledServicePrincipal x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnabledServicePrincipal x -> EnabledServicePrincipal
$cfrom :: forall x. EnabledServicePrincipal -> Rep EnabledServicePrincipal x
Prelude.Generic)

-- |
-- Create a value of 'EnabledServicePrincipal' 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:
--
-- 'dateEnabled', 'enabledServicePrincipal_dateEnabled' - The date that the service principal was enabled for integration with
-- Organizations.
--
-- 'servicePrincipal', 'enabledServicePrincipal_servicePrincipal' - The name of the service principal. This is typically in the form of a
-- URL, such as: @ @/@servicename@/@.amazonaws.com@.
newEnabledServicePrincipal ::
  EnabledServicePrincipal
newEnabledServicePrincipal :: EnabledServicePrincipal
newEnabledServicePrincipal =
  EnabledServicePrincipal'
    { $sel:dateEnabled:EnabledServicePrincipal' :: Maybe POSIX
dateEnabled =
        forall a. Maybe a
Prelude.Nothing,
      $sel:servicePrincipal:EnabledServicePrincipal' :: Maybe Text
servicePrincipal = forall a. Maybe a
Prelude.Nothing
    }

-- | The date that the service principal was enabled for integration with
-- Organizations.
enabledServicePrincipal_dateEnabled :: Lens.Lens' EnabledServicePrincipal (Prelude.Maybe Prelude.UTCTime)
enabledServicePrincipal_dateEnabled :: Lens' EnabledServicePrincipal (Maybe UTCTime)
enabledServicePrincipal_dateEnabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnabledServicePrincipal' {Maybe POSIX
dateEnabled :: Maybe POSIX
$sel:dateEnabled:EnabledServicePrincipal' :: EnabledServicePrincipal -> Maybe POSIX
dateEnabled} -> Maybe POSIX
dateEnabled) (\s :: EnabledServicePrincipal
s@EnabledServicePrincipal' {} Maybe POSIX
a -> EnabledServicePrincipal
s {$sel:dateEnabled:EnabledServicePrincipal' :: Maybe POSIX
dateEnabled = Maybe POSIX
a} :: EnabledServicePrincipal) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The name of the service principal. This is typically in the form of a
-- URL, such as: @ @/@servicename@/@.amazonaws.com@.
enabledServicePrincipal_servicePrincipal :: Lens.Lens' EnabledServicePrincipal (Prelude.Maybe Prelude.Text)
enabledServicePrincipal_servicePrincipal :: Lens' EnabledServicePrincipal (Maybe Text)
enabledServicePrincipal_servicePrincipal = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnabledServicePrincipal' {Maybe Text
servicePrincipal :: Maybe Text
$sel:servicePrincipal:EnabledServicePrincipal' :: EnabledServicePrincipal -> Maybe Text
servicePrincipal} -> Maybe Text
servicePrincipal) (\s :: EnabledServicePrincipal
s@EnabledServicePrincipal' {} Maybe Text
a -> EnabledServicePrincipal
s {$sel:servicePrincipal:EnabledServicePrincipal' :: Maybe Text
servicePrincipal = Maybe Text
a} :: EnabledServicePrincipal)

instance Data.FromJSON EnabledServicePrincipal where
  parseJSON :: Value -> Parser EnabledServicePrincipal
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EnabledServicePrincipal"
      ( \Object
x ->
          Maybe POSIX -> Maybe Text -> EnabledServicePrincipal
EnabledServicePrincipal'
            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
"DateEnabled")
            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
"ServicePrincipal")
      )

instance Prelude.Hashable EnabledServicePrincipal where
  hashWithSalt :: Int -> EnabledServicePrincipal -> Int
hashWithSalt Int
_salt EnabledServicePrincipal' {Maybe Text
Maybe POSIX
servicePrincipal :: Maybe Text
dateEnabled :: Maybe POSIX
$sel:servicePrincipal:EnabledServicePrincipal' :: EnabledServicePrincipal -> Maybe Text
$sel:dateEnabled:EnabledServicePrincipal' :: EnabledServicePrincipal -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
dateEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
servicePrincipal

instance Prelude.NFData EnabledServicePrincipal where
  rnf :: EnabledServicePrincipal -> ()
rnf EnabledServicePrincipal' {Maybe Text
Maybe POSIX
servicePrincipal :: Maybe Text
dateEnabled :: Maybe POSIX
$sel:servicePrincipal:EnabledServicePrincipal' :: EnabledServicePrincipal -> Maybe Text
$sel:dateEnabled:EnabledServicePrincipal' :: EnabledServicePrincipal -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
dateEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
servicePrincipal