{-# 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.Image
-- 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.Image 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.ImageFile
import qualified Amazonka.Prelude as Prelude

-- | Contains an image that is one of the following:
--
-- -   An image file. Choose this option to upload a new image.
--
-- -   The ID of an existing image. Choose this option to keep an existing
--     image.
--
-- /See:/ 'newImage' smart constructor.
data Image = Image'
  { Image -> Maybe ImageFile
file :: Prelude.Maybe ImageFile,
    -- | The ID of an existing image. Specify this parameter to keep an existing
    -- image.
    Image -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (Image -> Image -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Image -> Image -> Bool
$c/= :: Image -> Image -> Bool
== :: Image -> Image -> Bool
$c== :: Image -> Image -> Bool
Prelude.Eq, ReadPrec [Image]
ReadPrec Image
Int -> ReadS Image
ReadS [Image]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Image]
$creadListPrec :: ReadPrec [Image]
readPrec :: ReadPrec Image
$creadPrec :: ReadPrec Image
readList :: ReadS [Image]
$creadList :: ReadS [Image]
readsPrec :: Int -> ReadS Image
$creadsPrec :: Int -> ReadS Image
Prelude.Read, Int -> Image -> ShowS
[Image] -> ShowS
Image -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Image] -> ShowS
$cshowList :: [Image] -> ShowS
show :: Image -> String
$cshow :: Image -> String
showsPrec :: Int -> Image -> ShowS
$cshowsPrec :: Int -> Image -> ShowS
Prelude.Show, forall x. Rep Image x -> Image
forall x. Image -> Rep Image x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Image x -> Image
$cfrom :: forall x. Image -> Rep Image x
Prelude.Generic)

-- |
-- Create a value of 'Image' 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:
--
-- 'file', 'image_file' - Undocumented member.
--
-- 'id', 'image_id' - The ID of an existing image. Specify this parameter to keep an existing
-- image.
newImage ::
  Image
newImage :: Image
newImage =
  Image'
    { $sel:file:Image' :: Maybe ImageFile
file = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Image' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
image_file :: Lens.Lens' Image (Prelude.Maybe ImageFile)
image_file :: Lens' Image (Maybe ImageFile)
image_file = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Image' {Maybe ImageFile
file :: Maybe ImageFile
$sel:file:Image' :: Image -> Maybe ImageFile
file} -> Maybe ImageFile
file) (\s :: Image
s@Image' {} Maybe ImageFile
a -> Image
s {$sel:file:Image' :: Maybe ImageFile
file = Maybe ImageFile
a} :: Image)

-- | The ID of an existing image. Specify this parameter to keep an existing
-- image.
image_id :: Lens.Lens' Image (Prelude.Maybe Prelude.Text)
image_id :: Lens' Image (Maybe Text)
image_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Image' {Maybe Text
id :: Maybe Text
$sel:id:Image' :: Image -> Maybe Text
id} -> Maybe Text
id) (\s :: Image
s@Image' {} Maybe Text
a -> Image
s {$sel:id:Image' :: Maybe Text
id = Maybe Text
a} :: Image)

instance Prelude.Hashable Image where
  hashWithSalt :: Int -> Image -> Int
hashWithSalt Int
_salt Image' {Maybe Text
Maybe ImageFile
id :: Maybe Text
file :: Maybe ImageFile
$sel:id:Image' :: Image -> Maybe Text
$sel:file:Image' :: Image -> Maybe ImageFile
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ImageFile
file
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id

instance Prelude.NFData Image where
  rnf :: Image -> ()
rnf Image' {Maybe Text
Maybe ImageFile
id :: Maybe Text
file :: Maybe ImageFile
$sel:id:Image' :: Image -> Maybe Text
$sel:file:Image' :: Image -> Maybe ImageFile
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ImageFile
file seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id

instance Data.ToJSON Image where
  toJSON :: Image -> Value
toJSON Image' {Maybe Text
Maybe ImageFile
id :: Maybe Text
file :: Maybe ImageFile
$sel:id:Image' :: Image -> Maybe Text
$sel:file:Image' :: Image -> Maybe ImageFile
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"file" 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 ImageFile
file,
            (Key
"id" 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 Text
id
          ]
      )