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

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

-- | A structure that contains details of a service principal that represents
-- an AWS service that is enabled to integrate with AWS Organizations.
--
-- /See:/ 'newEnabledServicePrincipal' smart constructor.
data EnabledServicePrincipal = EnabledServicePrincipal'
  { -- | 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,
    -- | The date that the service principal was enabled for integration with AWS
    -- Organizations.
    EnabledServicePrincipal -> Maybe POSIX
dateEnabled :: Prelude.Maybe Core.POSIX
  }
  deriving (EnabledServicePrincipal -> EnabledServicePrincipal -> Bool
(EnabledServicePrincipal -> EnabledServicePrincipal -> Bool)
-> (EnabledServicePrincipal -> EnabledServicePrincipal -> Bool)
-> Eq EnabledServicePrincipal
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]
(Int -> ReadS EnabledServicePrincipal)
-> ReadS [EnabledServicePrincipal]
-> ReadPrec EnabledServicePrincipal
-> ReadPrec [EnabledServicePrincipal]
-> Read 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
(Int -> EnabledServicePrincipal -> ShowS)
-> (EnabledServicePrincipal -> String)
-> ([EnabledServicePrincipal] -> ShowS)
-> Show EnabledServicePrincipal
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.
 EnabledServicePrincipal -> Rep EnabledServicePrincipal x)
-> (forall x.
    Rep EnabledServicePrincipal x -> EnabledServicePrincipal)
-> Generic EnabledServicePrincipal
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:
--
-- 'servicePrincipal', 'enabledServicePrincipal_servicePrincipal' - The name of the service principal. This is typically in the form of a
-- URL, such as: @ servicename.amazonaws.com@.
--
-- 'dateEnabled', 'enabledServicePrincipal_dateEnabled' - The date that the service principal was enabled for integration with AWS
-- Organizations.
newEnabledServicePrincipal ::
  EnabledServicePrincipal
newEnabledServicePrincipal :: EnabledServicePrincipal
newEnabledServicePrincipal =
  EnabledServicePrincipal' :: Maybe Text -> Maybe POSIX -> EnabledServicePrincipal
EnabledServicePrincipal'
    { $sel:servicePrincipal:EnabledServicePrincipal' :: Maybe Text
servicePrincipal =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dateEnabled:EnabledServicePrincipal' :: Maybe POSIX
dateEnabled = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> EnabledServicePrincipal -> f EnabledServicePrincipal
enabledServicePrincipal_servicePrincipal = (EnabledServicePrincipal -> Maybe Text)
-> (EnabledServicePrincipal
    -> Maybe Text -> EnabledServicePrincipal)
-> Lens
     EnabledServicePrincipal
     EnabledServicePrincipal
     (Maybe Text)
     (Maybe Text)
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)

-- | The date that the service principal was enabled for integration with AWS
-- Organizations.
enabledServicePrincipal_dateEnabled :: Lens.Lens' EnabledServicePrincipal (Prelude.Maybe Prelude.UTCTime)
enabledServicePrincipal_dateEnabled :: (Maybe UTCTime -> f (Maybe UTCTime))
-> EnabledServicePrincipal -> f EnabledServicePrincipal
enabledServicePrincipal_dateEnabled = (EnabledServicePrincipal -> Maybe POSIX)
-> (EnabledServicePrincipal
    -> Maybe POSIX -> EnabledServicePrincipal)
-> Lens
     EnabledServicePrincipal
     EnabledServicePrincipal
     (Maybe POSIX)
     (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> EnabledServicePrincipal -> f EnabledServicePrincipal)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> EnabledServicePrincipal
-> f EnabledServicePrincipal
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Prelude.Hashable EnabledServicePrincipal

instance Prelude.NFData EnabledServicePrincipal