{-# 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.IotTwinMaker.Types.FunctionResponse
-- 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.IotTwinMaker.Types.FunctionResponse where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IotTwinMaker.Types.DataConnector
import Amazonka.IotTwinMaker.Types.Scope
import qualified Amazonka.Prelude as Prelude

-- | The function response.
--
-- /See:/ 'newFunctionResponse' smart constructor.
data FunctionResponse = FunctionResponse'
  { -- | The data connector.
    FunctionResponse -> Maybe DataConnector
implementedBy :: Prelude.Maybe DataConnector,
    -- | Indicates whether this function is inherited.
    FunctionResponse -> Maybe Bool
isInherited :: Prelude.Maybe Prelude.Bool,
    -- | The required properties of the function.
    FunctionResponse -> Maybe [Text]
requiredProperties :: Prelude.Maybe [Prelude.Text],
    -- | The scope of the function.
    FunctionResponse -> Maybe Scope
scope :: Prelude.Maybe Scope
  }
  deriving (FunctionResponse -> FunctionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FunctionResponse -> FunctionResponse -> Bool
$c/= :: FunctionResponse -> FunctionResponse -> Bool
== :: FunctionResponse -> FunctionResponse -> Bool
$c== :: FunctionResponse -> FunctionResponse -> Bool
Prelude.Eq, ReadPrec [FunctionResponse]
ReadPrec FunctionResponse
Int -> ReadS FunctionResponse
ReadS [FunctionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FunctionResponse]
$creadListPrec :: ReadPrec [FunctionResponse]
readPrec :: ReadPrec FunctionResponse
$creadPrec :: ReadPrec FunctionResponse
readList :: ReadS [FunctionResponse]
$creadList :: ReadS [FunctionResponse]
readsPrec :: Int -> ReadS FunctionResponse
$creadsPrec :: Int -> ReadS FunctionResponse
Prelude.Read, Int -> FunctionResponse -> ShowS
[FunctionResponse] -> ShowS
FunctionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionResponse] -> ShowS
$cshowList :: [FunctionResponse] -> ShowS
show :: FunctionResponse -> String
$cshow :: FunctionResponse -> String
showsPrec :: Int -> FunctionResponse -> ShowS
$cshowsPrec :: Int -> FunctionResponse -> ShowS
Prelude.Show, forall x. Rep FunctionResponse x -> FunctionResponse
forall x. FunctionResponse -> Rep FunctionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FunctionResponse x -> FunctionResponse
$cfrom :: forall x. FunctionResponse -> Rep FunctionResponse x
Prelude.Generic)

-- |
-- Create a value of 'FunctionResponse' 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:
--
-- 'implementedBy', 'functionResponse_implementedBy' - The data connector.
--
-- 'isInherited', 'functionResponse_isInherited' - Indicates whether this function is inherited.
--
-- 'requiredProperties', 'functionResponse_requiredProperties' - The required properties of the function.
--
-- 'scope', 'functionResponse_scope' - The scope of the function.
newFunctionResponse ::
  FunctionResponse
newFunctionResponse :: FunctionResponse
newFunctionResponse =
  FunctionResponse'
    { $sel:implementedBy:FunctionResponse' :: Maybe DataConnector
implementedBy = forall a. Maybe a
Prelude.Nothing,
      $sel:isInherited:FunctionResponse' :: Maybe Bool
isInherited = forall a. Maybe a
Prelude.Nothing,
      $sel:requiredProperties:FunctionResponse' :: Maybe [Text]
requiredProperties = forall a. Maybe a
Prelude.Nothing,
      $sel:scope:FunctionResponse' :: Maybe Scope
scope = forall a. Maybe a
Prelude.Nothing
    }

-- | The data connector.
functionResponse_implementedBy :: Lens.Lens' FunctionResponse (Prelude.Maybe DataConnector)
functionResponse_implementedBy :: Lens' FunctionResponse (Maybe DataConnector)
functionResponse_implementedBy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionResponse' {Maybe DataConnector
implementedBy :: Maybe DataConnector
$sel:implementedBy:FunctionResponse' :: FunctionResponse -> Maybe DataConnector
implementedBy} -> Maybe DataConnector
implementedBy) (\s :: FunctionResponse
s@FunctionResponse' {} Maybe DataConnector
a -> FunctionResponse
s {$sel:implementedBy:FunctionResponse' :: Maybe DataConnector
implementedBy = Maybe DataConnector
a} :: FunctionResponse)

-- | Indicates whether this function is inherited.
functionResponse_isInherited :: Lens.Lens' FunctionResponse (Prelude.Maybe Prelude.Bool)
functionResponse_isInherited :: Lens' FunctionResponse (Maybe Bool)
functionResponse_isInherited = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionResponse' {Maybe Bool
isInherited :: Maybe Bool
$sel:isInherited:FunctionResponse' :: FunctionResponse -> Maybe Bool
isInherited} -> Maybe Bool
isInherited) (\s :: FunctionResponse
s@FunctionResponse' {} Maybe Bool
a -> FunctionResponse
s {$sel:isInherited:FunctionResponse' :: Maybe Bool
isInherited = Maybe Bool
a} :: FunctionResponse)

-- | The required properties of the function.
functionResponse_requiredProperties :: Lens.Lens' FunctionResponse (Prelude.Maybe [Prelude.Text])
functionResponse_requiredProperties :: Lens' FunctionResponse (Maybe [Text])
functionResponse_requiredProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionResponse' {Maybe [Text]
requiredProperties :: Maybe [Text]
$sel:requiredProperties:FunctionResponse' :: FunctionResponse -> Maybe [Text]
requiredProperties} -> Maybe [Text]
requiredProperties) (\s :: FunctionResponse
s@FunctionResponse' {} Maybe [Text]
a -> FunctionResponse
s {$sel:requiredProperties:FunctionResponse' :: Maybe [Text]
requiredProperties = Maybe [Text]
a} :: FunctionResponse) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The scope of the function.
functionResponse_scope :: Lens.Lens' FunctionResponse (Prelude.Maybe Scope)
functionResponse_scope :: Lens' FunctionResponse (Maybe Scope)
functionResponse_scope = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionResponse' {Maybe Scope
scope :: Maybe Scope
$sel:scope:FunctionResponse' :: FunctionResponse -> Maybe Scope
scope} -> Maybe Scope
scope) (\s :: FunctionResponse
s@FunctionResponse' {} Maybe Scope
a -> FunctionResponse
s {$sel:scope:FunctionResponse' :: Maybe Scope
scope = Maybe Scope
a} :: FunctionResponse)

instance Data.FromJSON FunctionResponse where
  parseJSON :: Value -> Parser FunctionResponse
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FunctionResponse"
      ( \Object
x ->
          Maybe DataConnector
-> Maybe Bool -> Maybe [Text] -> Maybe Scope -> FunctionResponse
FunctionResponse'
            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
"implementedBy")
            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
"isInherited")
            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
"requiredProperties"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"scope")
      )

instance Prelude.Hashable FunctionResponse where
  hashWithSalt :: Int -> FunctionResponse -> Int
hashWithSalt Int
_salt FunctionResponse' {Maybe Bool
Maybe [Text]
Maybe DataConnector
Maybe Scope
scope :: Maybe Scope
requiredProperties :: Maybe [Text]
isInherited :: Maybe Bool
implementedBy :: Maybe DataConnector
$sel:scope:FunctionResponse' :: FunctionResponse -> Maybe Scope
$sel:requiredProperties:FunctionResponse' :: FunctionResponse -> Maybe [Text]
$sel:isInherited:FunctionResponse' :: FunctionResponse -> Maybe Bool
$sel:implementedBy:FunctionResponse' :: FunctionResponse -> Maybe DataConnector
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DataConnector
implementedBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isInherited
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
requiredProperties
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Scope
scope

instance Prelude.NFData FunctionResponse where
  rnf :: FunctionResponse -> ()
rnf FunctionResponse' {Maybe Bool
Maybe [Text]
Maybe DataConnector
Maybe Scope
scope :: Maybe Scope
requiredProperties :: Maybe [Text]
isInherited :: Maybe Bool
implementedBy :: Maybe DataConnector
$sel:scope:FunctionResponse' :: FunctionResponse -> Maybe Scope
$sel:requiredProperties:FunctionResponse' :: FunctionResponse -> Maybe [Text]
$sel:isInherited:FunctionResponse' :: FunctionResponse -> Maybe Bool
$sel:implementedBy:FunctionResponse' :: FunctionResponse -> Maybe DataConnector
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DataConnector
implementedBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isInherited
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
requiredProperties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Scope
scope