{-# 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.IoTSiteWise.Types.ImageFile
-- 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.IoTSiteWise.Types.ImageFile where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTSiteWise.Types.ImageFileType
import qualified Amazonka.Prelude as Prelude

-- | Contains an image file.
--
-- /See:/ 'newImageFile' smart constructor.
data ImageFile = ImageFile'
  { -- | The image file contents, represented as a base64-encoded string. The
    -- file size must be less than 1 MB.
    ImageFile -> Base64
data' :: Data.Base64,
    -- | The file type of the image.
    ImageFile -> ImageFileType
type' :: ImageFileType
  }
  deriving (ImageFile -> ImageFile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageFile -> ImageFile -> Bool
$c/= :: ImageFile -> ImageFile -> Bool
== :: ImageFile -> ImageFile -> Bool
$c== :: ImageFile -> ImageFile -> Bool
Prelude.Eq, ReadPrec [ImageFile]
ReadPrec ImageFile
Int -> ReadS ImageFile
ReadS [ImageFile]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImageFile]
$creadListPrec :: ReadPrec [ImageFile]
readPrec :: ReadPrec ImageFile
$creadPrec :: ReadPrec ImageFile
readList :: ReadS [ImageFile]
$creadList :: ReadS [ImageFile]
readsPrec :: Int -> ReadS ImageFile
$creadsPrec :: Int -> ReadS ImageFile
Prelude.Read, Int -> ImageFile -> ShowS
[ImageFile] -> ShowS
ImageFile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageFile] -> ShowS
$cshowList :: [ImageFile] -> ShowS
show :: ImageFile -> String
$cshow :: ImageFile -> String
showsPrec :: Int -> ImageFile -> ShowS
$cshowsPrec :: Int -> ImageFile -> ShowS
Prelude.Show, forall x. Rep ImageFile x -> ImageFile
forall x. ImageFile -> Rep ImageFile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImageFile x -> ImageFile
$cfrom :: forall x. ImageFile -> Rep ImageFile x
Prelude.Generic)

-- |
-- Create a value of 'ImageFile' 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:
--
-- 'data'', 'imageFile_data' - The image file contents, represented as a base64-encoded string. The
-- file size must be less than 1 MB.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'type'', 'imageFile_type' - The file type of the image.
newImageFile ::
  -- | 'data''
  Prelude.ByteString ->
  -- | 'type''
  ImageFileType ->
  ImageFile
newImageFile :: ByteString -> ImageFileType -> ImageFile
newImageFile ByteString
pData_ ImageFileType
pType_ =
  ImageFile'
    { $sel:data':ImageFile' :: Base64
data' = Iso' Base64 ByteString
Data._Base64 forall t b. AReview t b -> b -> t
Lens.# ByteString
pData_,
      $sel:type':ImageFile' :: ImageFileType
type' = ImageFileType
pType_
    }

-- | The image file contents, represented as a base64-encoded string. The
-- file size must be less than 1 MB.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
imageFile_data :: Lens.Lens' ImageFile Prelude.ByteString
imageFile_data :: Lens' ImageFile ByteString
imageFile_data = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageFile' {Base64
data' :: Base64
$sel:data':ImageFile' :: ImageFile -> Base64
data'} -> Base64
data') (\s :: ImageFile
s@ImageFile' {} Base64
a -> ImageFile
s {$sel:data':ImageFile' :: Base64
data' = Base64
a} :: ImageFile) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64

-- | The file type of the image.
imageFile_type :: Lens.Lens' ImageFile ImageFileType
imageFile_type :: Lens' ImageFile ImageFileType
imageFile_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageFile' {ImageFileType
type' :: ImageFileType
$sel:type':ImageFile' :: ImageFile -> ImageFileType
type'} -> ImageFileType
type') (\s :: ImageFile
s@ImageFile' {} ImageFileType
a -> ImageFile
s {$sel:type':ImageFile' :: ImageFileType
type' = ImageFileType
a} :: ImageFile)

instance Prelude.Hashable ImageFile where
  hashWithSalt :: Int -> ImageFile -> Int
hashWithSalt Int
_salt ImageFile' {Base64
ImageFileType
type' :: ImageFileType
data' :: Base64
$sel:type':ImageFile' :: ImageFile -> ImageFileType
$sel:data':ImageFile' :: ImageFile -> Base64
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Base64
data'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ImageFileType
type'

instance Prelude.NFData ImageFile where
  rnf :: ImageFile -> ()
rnf ImageFile' {Base64
ImageFileType
type' :: ImageFileType
data' :: Base64
$sel:type':ImageFile' :: ImageFile -> ImageFileType
$sel:data':ImageFile' :: ImageFile -> Base64
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Base64
data' seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ImageFileType
type'

instance Data.ToJSON ImageFile where
  toJSON :: ImageFile -> Value
toJSON ImageFile' {Base64
ImageFileType
type' :: ImageFileType
data' :: Base64
$sel:type':ImageFile' :: ImageFile -> ImageFileType
$sel:data':ImageFile' :: ImageFile -> Base64
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"data" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Base64
data'),
            forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ImageFileType
type')
          ]
      )