{-# 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.Glue.Types.UserDefinedFunctionInput
-- 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.Glue.Types.UserDefinedFunctionInput where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.PrincipalType
import Amazonka.Glue.Types.ResourceUri
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A structure used to create or update a user-defined function.
--
-- /See:/ 'newUserDefinedFunctionInput' smart constructor.
data UserDefinedFunctionInput = UserDefinedFunctionInput'
  { -- | The owner of the function.
    UserDefinedFunctionInput -> Maybe Text
ownerName :: Prelude.Maybe Prelude.Text,
    -- | The resource URIs for the function.
    UserDefinedFunctionInput -> Maybe [ResourceUri]
resourceUris :: Prelude.Maybe [ResourceUri],
    -- | The name of the function.
    UserDefinedFunctionInput -> Maybe Text
functionName :: Prelude.Maybe Prelude.Text,
    -- | The owner type.
    UserDefinedFunctionInput -> Maybe PrincipalType
ownerType :: Prelude.Maybe PrincipalType,
    -- | The Java class that contains the function code.
    UserDefinedFunctionInput -> Maybe Text
className :: Prelude.Maybe Prelude.Text
  }
  deriving (UserDefinedFunctionInput -> UserDefinedFunctionInput -> Bool
(UserDefinedFunctionInput -> UserDefinedFunctionInput -> Bool)
-> (UserDefinedFunctionInput -> UserDefinedFunctionInput -> Bool)
-> Eq UserDefinedFunctionInput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserDefinedFunctionInput -> UserDefinedFunctionInput -> Bool
$c/= :: UserDefinedFunctionInput -> UserDefinedFunctionInput -> Bool
== :: UserDefinedFunctionInput -> UserDefinedFunctionInput -> Bool
$c== :: UserDefinedFunctionInput -> UserDefinedFunctionInput -> Bool
Prelude.Eq, ReadPrec [UserDefinedFunctionInput]
ReadPrec UserDefinedFunctionInput
Int -> ReadS UserDefinedFunctionInput
ReadS [UserDefinedFunctionInput]
(Int -> ReadS UserDefinedFunctionInput)
-> ReadS [UserDefinedFunctionInput]
-> ReadPrec UserDefinedFunctionInput
-> ReadPrec [UserDefinedFunctionInput]
-> Read UserDefinedFunctionInput
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserDefinedFunctionInput]
$creadListPrec :: ReadPrec [UserDefinedFunctionInput]
readPrec :: ReadPrec UserDefinedFunctionInput
$creadPrec :: ReadPrec UserDefinedFunctionInput
readList :: ReadS [UserDefinedFunctionInput]
$creadList :: ReadS [UserDefinedFunctionInput]
readsPrec :: Int -> ReadS UserDefinedFunctionInput
$creadsPrec :: Int -> ReadS UserDefinedFunctionInput
Prelude.Read, Int -> UserDefinedFunctionInput -> ShowS
[UserDefinedFunctionInput] -> ShowS
UserDefinedFunctionInput -> String
(Int -> UserDefinedFunctionInput -> ShowS)
-> (UserDefinedFunctionInput -> String)
-> ([UserDefinedFunctionInput] -> ShowS)
-> Show UserDefinedFunctionInput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserDefinedFunctionInput] -> ShowS
$cshowList :: [UserDefinedFunctionInput] -> ShowS
show :: UserDefinedFunctionInput -> String
$cshow :: UserDefinedFunctionInput -> String
showsPrec :: Int -> UserDefinedFunctionInput -> ShowS
$cshowsPrec :: Int -> UserDefinedFunctionInput -> ShowS
Prelude.Show, (forall x.
 UserDefinedFunctionInput -> Rep UserDefinedFunctionInput x)
-> (forall x.
    Rep UserDefinedFunctionInput x -> UserDefinedFunctionInput)
-> Generic UserDefinedFunctionInput
forall x.
Rep UserDefinedFunctionInput x -> UserDefinedFunctionInput
forall x.
UserDefinedFunctionInput -> Rep UserDefinedFunctionInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UserDefinedFunctionInput x -> UserDefinedFunctionInput
$cfrom :: forall x.
UserDefinedFunctionInput -> Rep UserDefinedFunctionInput x
Prelude.Generic)

-- |
-- Create a value of 'UserDefinedFunctionInput' 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:
--
-- 'ownerName', 'userDefinedFunctionInput_ownerName' - The owner of the function.
--
-- 'resourceUris', 'userDefinedFunctionInput_resourceUris' - The resource URIs for the function.
--
-- 'functionName', 'userDefinedFunctionInput_functionName' - The name of the function.
--
-- 'ownerType', 'userDefinedFunctionInput_ownerType' - The owner type.
--
-- 'className', 'userDefinedFunctionInput_className' - The Java class that contains the function code.
newUserDefinedFunctionInput ::
  UserDefinedFunctionInput
newUserDefinedFunctionInput :: UserDefinedFunctionInput
newUserDefinedFunctionInput =
  UserDefinedFunctionInput' :: Maybe Text
-> Maybe [ResourceUri]
-> Maybe Text
-> Maybe PrincipalType
-> Maybe Text
-> UserDefinedFunctionInput
UserDefinedFunctionInput'
    { $sel:ownerName:UserDefinedFunctionInput' :: Maybe Text
ownerName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceUris:UserDefinedFunctionInput' :: Maybe [ResourceUri]
resourceUris = Maybe [ResourceUri]
forall a. Maybe a
Prelude.Nothing,
      $sel:functionName:UserDefinedFunctionInput' :: Maybe Text
functionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ownerType:UserDefinedFunctionInput' :: Maybe PrincipalType
ownerType = Maybe PrincipalType
forall a. Maybe a
Prelude.Nothing,
      $sel:className:UserDefinedFunctionInput' :: Maybe Text
className = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The owner of the function.
userDefinedFunctionInput_ownerName :: Lens.Lens' UserDefinedFunctionInput (Prelude.Maybe Prelude.Text)
userDefinedFunctionInput_ownerName :: (Maybe Text -> f (Maybe Text))
-> UserDefinedFunctionInput -> f UserDefinedFunctionInput
userDefinedFunctionInput_ownerName = (UserDefinedFunctionInput -> Maybe Text)
-> (UserDefinedFunctionInput
    -> Maybe Text -> UserDefinedFunctionInput)
-> Lens
     UserDefinedFunctionInput
     UserDefinedFunctionInput
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserDefinedFunctionInput' {Maybe Text
ownerName :: Maybe Text
$sel:ownerName:UserDefinedFunctionInput' :: UserDefinedFunctionInput -> Maybe Text
ownerName} -> Maybe Text
ownerName) (\s :: UserDefinedFunctionInput
s@UserDefinedFunctionInput' {} Maybe Text
a -> UserDefinedFunctionInput
s {$sel:ownerName:UserDefinedFunctionInput' :: Maybe Text
ownerName = Maybe Text
a} :: UserDefinedFunctionInput)

-- | The resource URIs for the function.
userDefinedFunctionInput_resourceUris :: Lens.Lens' UserDefinedFunctionInput (Prelude.Maybe [ResourceUri])
userDefinedFunctionInput_resourceUris :: (Maybe [ResourceUri] -> f (Maybe [ResourceUri]))
-> UserDefinedFunctionInput -> f UserDefinedFunctionInput
userDefinedFunctionInput_resourceUris = (UserDefinedFunctionInput -> Maybe [ResourceUri])
-> (UserDefinedFunctionInput
    -> Maybe [ResourceUri] -> UserDefinedFunctionInput)
-> Lens
     UserDefinedFunctionInput
     UserDefinedFunctionInput
     (Maybe [ResourceUri])
     (Maybe [ResourceUri])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserDefinedFunctionInput' {Maybe [ResourceUri]
resourceUris :: Maybe [ResourceUri]
$sel:resourceUris:UserDefinedFunctionInput' :: UserDefinedFunctionInput -> Maybe [ResourceUri]
resourceUris} -> Maybe [ResourceUri]
resourceUris) (\s :: UserDefinedFunctionInput
s@UserDefinedFunctionInput' {} Maybe [ResourceUri]
a -> UserDefinedFunctionInput
s {$sel:resourceUris:UserDefinedFunctionInput' :: Maybe [ResourceUri]
resourceUris = Maybe [ResourceUri]
a} :: UserDefinedFunctionInput) ((Maybe [ResourceUri] -> f (Maybe [ResourceUri]))
 -> UserDefinedFunctionInput -> f UserDefinedFunctionInput)
-> ((Maybe [ResourceUri] -> f (Maybe [ResourceUri]))
    -> Maybe [ResourceUri] -> f (Maybe [ResourceUri]))
-> (Maybe [ResourceUri] -> f (Maybe [ResourceUri]))
-> UserDefinedFunctionInput
-> f UserDefinedFunctionInput
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ResourceUri] [ResourceUri] [ResourceUri] [ResourceUri]
-> Iso
     (Maybe [ResourceUri])
     (Maybe [ResourceUri])
     (Maybe [ResourceUri])
     (Maybe [ResourceUri])
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 [ResourceUri] [ResourceUri] [ResourceUri] [ResourceUri]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the function.
userDefinedFunctionInput_functionName :: Lens.Lens' UserDefinedFunctionInput (Prelude.Maybe Prelude.Text)
userDefinedFunctionInput_functionName :: (Maybe Text -> f (Maybe Text))
-> UserDefinedFunctionInput -> f UserDefinedFunctionInput
userDefinedFunctionInput_functionName = (UserDefinedFunctionInput -> Maybe Text)
-> (UserDefinedFunctionInput
    -> Maybe Text -> UserDefinedFunctionInput)
-> Lens
     UserDefinedFunctionInput
     UserDefinedFunctionInput
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserDefinedFunctionInput' {Maybe Text
functionName :: Maybe Text
$sel:functionName:UserDefinedFunctionInput' :: UserDefinedFunctionInput -> Maybe Text
functionName} -> Maybe Text
functionName) (\s :: UserDefinedFunctionInput
s@UserDefinedFunctionInput' {} Maybe Text
a -> UserDefinedFunctionInput
s {$sel:functionName:UserDefinedFunctionInput' :: Maybe Text
functionName = Maybe Text
a} :: UserDefinedFunctionInput)

-- | The owner type.
userDefinedFunctionInput_ownerType :: Lens.Lens' UserDefinedFunctionInput (Prelude.Maybe PrincipalType)
userDefinedFunctionInput_ownerType :: (Maybe PrincipalType -> f (Maybe PrincipalType))
-> UserDefinedFunctionInput -> f UserDefinedFunctionInput
userDefinedFunctionInput_ownerType = (UserDefinedFunctionInput -> Maybe PrincipalType)
-> (UserDefinedFunctionInput
    -> Maybe PrincipalType -> UserDefinedFunctionInput)
-> Lens
     UserDefinedFunctionInput
     UserDefinedFunctionInput
     (Maybe PrincipalType)
     (Maybe PrincipalType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserDefinedFunctionInput' {Maybe PrincipalType
ownerType :: Maybe PrincipalType
$sel:ownerType:UserDefinedFunctionInput' :: UserDefinedFunctionInput -> Maybe PrincipalType
ownerType} -> Maybe PrincipalType
ownerType) (\s :: UserDefinedFunctionInput
s@UserDefinedFunctionInput' {} Maybe PrincipalType
a -> UserDefinedFunctionInput
s {$sel:ownerType:UserDefinedFunctionInput' :: Maybe PrincipalType
ownerType = Maybe PrincipalType
a} :: UserDefinedFunctionInput)

-- | The Java class that contains the function code.
userDefinedFunctionInput_className :: Lens.Lens' UserDefinedFunctionInput (Prelude.Maybe Prelude.Text)
userDefinedFunctionInput_className :: (Maybe Text -> f (Maybe Text))
-> UserDefinedFunctionInput -> f UserDefinedFunctionInput
userDefinedFunctionInput_className = (UserDefinedFunctionInput -> Maybe Text)
-> (UserDefinedFunctionInput
    -> Maybe Text -> UserDefinedFunctionInput)
-> Lens
     UserDefinedFunctionInput
     UserDefinedFunctionInput
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserDefinedFunctionInput' {Maybe Text
className :: Maybe Text
$sel:className:UserDefinedFunctionInput' :: UserDefinedFunctionInput -> Maybe Text
className} -> Maybe Text
className) (\s :: UserDefinedFunctionInput
s@UserDefinedFunctionInput' {} Maybe Text
a -> UserDefinedFunctionInput
s {$sel:className:UserDefinedFunctionInput' :: Maybe Text
className = Maybe Text
a} :: UserDefinedFunctionInput)

instance Prelude.Hashable UserDefinedFunctionInput

instance Prelude.NFData UserDefinedFunctionInput

instance Core.ToJSON UserDefinedFunctionInput where
  toJSON :: UserDefinedFunctionInput -> Value
toJSON UserDefinedFunctionInput' {Maybe [ResourceUri]
Maybe Text
Maybe PrincipalType
className :: Maybe Text
ownerType :: Maybe PrincipalType
functionName :: Maybe Text
resourceUris :: Maybe [ResourceUri]
ownerName :: Maybe Text
$sel:className:UserDefinedFunctionInput' :: UserDefinedFunctionInput -> Maybe Text
$sel:ownerType:UserDefinedFunctionInput' :: UserDefinedFunctionInput -> Maybe PrincipalType
$sel:functionName:UserDefinedFunctionInput' :: UserDefinedFunctionInput -> Maybe Text
$sel:resourceUris:UserDefinedFunctionInput' :: UserDefinedFunctionInput -> Maybe [ResourceUri]
$sel:ownerName:UserDefinedFunctionInput' :: UserDefinedFunctionInput -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OwnerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ownerName,
            (Text
"ResourceUris" Text -> [ResourceUri] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([ResourceUri] -> Pair) -> Maybe [ResourceUri] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ResourceUri]
resourceUris,
            (Text
"FunctionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
functionName,
            (Text
"OwnerType" Text -> PrincipalType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (PrincipalType -> Pair) -> Maybe PrincipalType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PrincipalType
ownerType,
            (Text
"ClassName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
className
          ]
      )