{-# 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.IoTFleetWise.Types.CanDbcDefinition
-- 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.IoTFleetWise.Types.CanDbcDefinition 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

-- | Configurations used to create a decoder manifest.
--
-- /See:/ 'newCanDbcDefinition' smart constructor.
data CanDbcDefinition = CanDbcDefinition'
  { -- | Pairs every signal specified in your vehicle model with a signal
    -- decoder.
    CanDbcDefinition -> Maybe (HashMap Text Text)
signalsMap :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Contains information about a network interface.
    CanDbcDefinition -> Text
networkInterface :: Prelude.Text,
    -- | A list of DBC files. You can upload only one DBC file for each network
    -- interface and specify up to five (inclusive) files in the list.
    CanDbcDefinition -> NonEmpty Base64
canDbcFiles :: Prelude.NonEmpty Data.Base64
  }
  deriving (CanDbcDefinition -> CanDbcDefinition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CanDbcDefinition -> CanDbcDefinition -> Bool
$c/= :: CanDbcDefinition -> CanDbcDefinition -> Bool
== :: CanDbcDefinition -> CanDbcDefinition -> Bool
$c== :: CanDbcDefinition -> CanDbcDefinition -> Bool
Prelude.Eq, ReadPrec [CanDbcDefinition]
ReadPrec CanDbcDefinition
Int -> ReadS CanDbcDefinition
ReadS [CanDbcDefinition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CanDbcDefinition]
$creadListPrec :: ReadPrec [CanDbcDefinition]
readPrec :: ReadPrec CanDbcDefinition
$creadPrec :: ReadPrec CanDbcDefinition
readList :: ReadS [CanDbcDefinition]
$creadList :: ReadS [CanDbcDefinition]
readsPrec :: Int -> ReadS CanDbcDefinition
$creadsPrec :: Int -> ReadS CanDbcDefinition
Prelude.Read, Int -> CanDbcDefinition -> ShowS
[CanDbcDefinition] -> ShowS
CanDbcDefinition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CanDbcDefinition] -> ShowS
$cshowList :: [CanDbcDefinition] -> ShowS
show :: CanDbcDefinition -> String
$cshow :: CanDbcDefinition -> String
showsPrec :: Int -> CanDbcDefinition -> ShowS
$cshowsPrec :: Int -> CanDbcDefinition -> ShowS
Prelude.Show, forall x. Rep CanDbcDefinition x -> CanDbcDefinition
forall x. CanDbcDefinition -> Rep CanDbcDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CanDbcDefinition x -> CanDbcDefinition
$cfrom :: forall x. CanDbcDefinition -> Rep CanDbcDefinition x
Prelude.Generic)

-- |
-- Create a value of 'CanDbcDefinition' 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:
--
-- 'signalsMap', 'canDbcDefinition_signalsMap' - Pairs every signal specified in your vehicle model with a signal
-- decoder.
--
-- 'networkInterface', 'canDbcDefinition_networkInterface' - Contains information about a network interface.
--
-- 'canDbcFiles', 'canDbcDefinition_canDbcFiles' - A list of DBC files. You can upload only one DBC file for each network
-- interface and specify up to five (inclusive) files in the list.
newCanDbcDefinition ::
  -- | 'networkInterface'
  Prelude.Text ->
  -- | 'canDbcFiles'
  Prelude.NonEmpty Prelude.ByteString ->
  CanDbcDefinition
newCanDbcDefinition :: Text -> NonEmpty ByteString -> CanDbcDefinition
newCanDbcDefinition Text
pNetworkInterface_ NonEmpty ByteString
pCanDbcFiles_ =
  CanDbcDefinition'
    { $sel:signalsMap:CanDbcDefinition' :: Maybe (HashMap Text Text)
signalsMap = forall a. Maybe a
Prelude.Nothing,
      $sel:networkInterface:CanDbcDefinition' :: Text
networkInterface = Text
pNetworkInterface_,
      $sel:canDbcFiles:CanDbcDefinition' :: NonEmpty Base64
canDbcFiles = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty ByteString
pCanDbcFiles_
    }

-- | Pairs every signal specified in your vehicle model with a signal
-- decoder.
canDbcDefinition_signalsMap :: Lens.Lens' CanDbcDefinition (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
canDbcDefinition_signalsMap :: Lens' CanDbcDefinition (Maybe (HashMap Text Text))
canDbcDefinition_signalsMap = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanDbcDefinition' {Maybe (HashMap Text Text)
signalsMap :: Maybe (HashMap Text Text)
$sel:signalsMap:CanDbcDefinition' :: CanDbcDefinition -> Maybe (HashMap Text Text)
signalsMap} -> Maybe (HashMap Text Text)
signalsMap) (\s :: CanDbcDefinition
s@CanDbcDefinition' {} Maybe (HashMap Text Text)
a -> CanDbcDefinition
s {$sel:signalsMap:CanDbcDefinition' :: Maybe (HashMap Text Text)
signalsMap = Maybe (HashMap Text Text)
a} :: CanDbcDefinition) 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

-- | Contains information about a network interface.
canDbcDefinition_networkInterface :: Lens.Lens' CanDbcDefinition Prelude.Text
canDbcDefinition_networkInterface :: Lens' CanDbcDefinition Text
canDbcDefinition_networkInterface = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanDbcDefinition' {Text
networkInterface :: Text
$sel:networkInterface:CanDbcDefinition' :: CanDbcDefinition -> Text
networkInterface} -> Text
networkInterface) (\s :: CanDbcDefinition
s@CanDbcDefinition' {} Text
a -> CanDbcDefinition
s {$sel:networkInterface:CanDbcDefinition' :: Text
networkInterface = Text
a} :: CanDbcDefinition)

-- | A list of DBC files. You can upload only one DBC file for each network
-- interface and specify up to five (inclusive) files in the list.
canDbcDefinition_canDbcFiles :: Lens.Lens' CanDbcDefinition (Prelude.NonEmpty Prelude.ByteString)
canDbcDefinition_canDbcFiles :: Lens' CanDbcDefinition (NonEmpty ByteString)
canDbcDefinition_canDbcFiles = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanDbcDefinition' {NonEmpty Base64
canDbcFiles :: NonEmpty Base64
$sel:canDbcFiles:CanDbcDefinition' :: CanDbcDefinition -> NonEmpty Base64
canDbcFiles} -> NonEmpty Base64
canDbcFiles) (\s :: CanDbcDefinition
s@CanDbcDefinition' {} NonEmpty Base64
a -> CanDbcDefinition
s {$sel:canDbcFiles:CanDbcDefinition' :: NonEmpty Base64
canDbcFiles = NonEmpty Base64
a} :: CanDbcDefinition) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable CanDbcDefinition where
  hashWithSalt :: Int -> CanDbcDefinition -> Int
hashWithSalt Int
_salt CanDbcDefinition' {Maybe (HashMap Text Text)
NonEmpty Base64
Text
canDbcFiles :: NonEmpty Base64
networkInterface :: Text
signalsMap :: Maybe (HashMap Text Text)
$sel:canDbcFiles:CanDbcDefinition' :: CanDbcDefinition -> NonEmpty Base64
$sel:networkInterface:CanDbcDefinition' :: CanDbcDefinition -> Text
$sel:signalsMap:CanDbcDefinition' :: CanDbcDefinition -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
signalsMap
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
networkInterface
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Base64
canDbcFiles

instance Prelude.NFData CanDbcDefinition where
  rnf :: CanDbcDefinition -> ()
rnf CanDbcDefinition' {Maybe (HashMap Text Text)
NonEmpty Base64
Text
canDbcFiles :: NonEmpty Base64
networkInterface :: Text
signalsMap :: Maybe (HashMap Text Text)
$sel:canDbcFiles:CanDbcDefinition' :: CanDbcDefinition -> NonEmpty Base64
$sel:networkInterface:CanDbcDefinition' :: CanDbcDefinition -> Text
$sel:signalsMap:CanDbcDefinition' :: CanDbcDefinition -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
signalsMap
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
networkInterface
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Base64
canDbcFiles

instance Data.ToJSON CanDbcDefinition where
  toJSON :: CanDbcDefinition -> Value
toJSON CanDbcDefinition' {Maybe (HashMap Text Text)
NonEmpty Base64
Text
canDbcFiles :: NonEmpty Base64
networkInterface :: Text
signalsMap :: Maybe (HashMap Text Text)
$sel:canDbcFiles:CanDbcDefinition' :: CanDbcDefinition -> NonEmpty Base64
$sel:networkInterface:CanDbcDefinition' :: CanDbcDefinition -> Text
$sel:signalsMap:CanDbcDefinition' :: CanDbcDefinition -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"signalsMap" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
signalsMap,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"networkInterface" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
networkInterface),
            forall a. a -> Maybe a
Prelude.Just (Key
"canDbcFiles" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Base64
canDbcFiles)
          ]
      )