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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.ImageFile
import qualified Amazonka.Lens as Lens
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'
  { -- | The ID of an existing image. Specify this parameter to keep an existing
    -- image.
    Image -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    Image -> Maybe ImageFile
file :: Prelude.Maybe ImageFile
  }
  deriving (Image -> Image -> Bool
(Image -> Image -> Bool) -> (Image -> Image -> Bool) -> Eq Image
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]
(Int -> ReadS Image)
-> ReadS [Image]
-> ReadPrec Image
-> ReadPrec [Image]
-> Read 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
(Int -> Image -> ShowS)
-> (Image -> String) -> ([Image] -> ShowS) -> Show Image
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. Image -> Rep Image x)
-> (forall x. Rep Image x -> Image) -> Generic Image
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:
--
-- 'id', 'image_id' - The ID of an existing image. Specify this parameter to keep an existing
-- image.
--
-- 'file', 'image_file' - Undocumented member.
newImage ::
  Image
newImage :: Image
newImage =
  Image' :: Maybe Text -> Maybe ImageFile -> Image
Image'
    { $sel:id:Image' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:file:Image' :: Maybe ImageFile
file = Maybe ImageFile
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> Image -> f Image
image_id = (Image -> Maybe Text)
-> (Image -> Maybe Text -> Image)
-> Lens Image Image (Maybe Text) (Maybe Text)
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)

-- | Undocumented member.
image_file :: Lens.Lens' Image (Prelude.Maybe ImageFile)
image_file :: (Maybe ImageFile -> f (Maybe ImageFile)) -> Image -> f Image
image_file = (Image -> Maybe ImageFile)
-> (Image -> Maybe ImageFile -> Image)
-> Lens Image Image (Maybe ImageFile) (Maybe ImageFile)
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)

instance Prelude.Hashable Image

instance Prelude.NFData Image

instance Core.ToJSON Image where
  toJSON :: Image -> Value
toJSON Image' {Maybe Text
Maybe ImageFile
file :: Maybe ImageFile
id :: Maybe Text
$sel:file:Image' :: Image -> Maybe ImageFile
$sel:id:Image' :: Image -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"id" 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
id,
            (Text
"file" Text -> ImageFile -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ImageFile -> Pair) -> Maybe ImageFile -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ImageFile
file
          ]
      )