{-# 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.ImageLocation
-- 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.ImageLocation 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

-- | Contains an image that is uploaded to IoT SiteWise and available at a
-- URL.
--
-- /See:/ 'newImageLocation' smart constructor.
data ImageLocation = ImageLocation'
  { -- | The ID of the image.
    ImageLocation -> Text
id :: Prelude.Text,
    -- | The URL where the image is available. The URL is valid for 15 minutes so
    -- that you can view and download the image
    ImageLocation -> Text
url :: Prelude.Text
  }
  deriving (ImageLocation -> ImageLocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageLocation -> ImageLocation -> Bool
$c/= :: ImageLocation -> ImageLocation -> Bool
== :: ImageLocation -> ImageLocation -> Bool
$c== :: ImageLocation -> ImageLocation -> Bool
Prelude.Eq, ReadPrec [ImageLocation]
ReadPrec ImageLocation
Int -> ReadS ImageLocation
ReadS [ImageLocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImageLocation]
$creadListPrec :: ReadPrec [ImageLocation]
readPrec :: ReadPrec ImageLocation
$creadPrec :: ReadPrec ImageLocation
readList :: ReadS [ImageLocation]
$creadList :: ReadS [ImageLocation]
readsPrec :: Int -> ReadS ImageLocation
$creadsPrec :: Int -> ReadS ImageLocation
Prelude.Read, Int -> ImageLocation -> ShowS
[ImageLocation] -> ShowS
ImageLocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageLocation] -> ShowS
$cshowList :: [ImageLocation] -> ShowS
show :: ImageLocation -> String
$cshow :: ImageLocation -> String
showsPrec :: Int -> ImageLocation -> ShowS
$cshowsPrec :: Int -> ImageLocation -> ShowS
Prelude.Show, forall x. Rep ImageLocation x -> ImageLocation
forall x. ImageLocation -> Rep ImageLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImageLocation x -> ImageLocation
$cfrom :: forall x. ImageLocation -> Rep ImageLocation x
Prelude.Generic)

-- |
-- Create a value of 'ImageLocation' 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', 'imageLocation_id' - The ID of the image.
--
-- 'url', 'imageLocation_url' - The URL where the image is available. The URL is valid for 15 minutes so
-- that you can view and download the image
newImageLocation ::
  -- | 'id'
  Prelude.Text ->
  -- | 'url'
  Prelude.Text ->
  ImageLocation
newImageLocation :: Text -> Text -> ImageLocation
newImageLocation Text
pId_ Text
pUrl_ =
  ImageLocation' {$sel:id:ImageLocation' :: Text
id = Text
pId_, $sel:url:ImageLocation' :: Text
url = Text
pUrl_}

-- | The ID of the image.
imageLocation_id :: Lens.Lens' ImageLocation Prelude.Text
imageLocation_id :: Lens' ImageLocation Text
imageLocation_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageLocation' {Text
id :: Text
$sel:id:ImageLocation' :: ImageLocation -> Text
id} -> Text
id) (\s :: ImageLocation
s@ImageLocation' {} Text
a -> ImageLocation
s {$sel:id:ImageLocation' :: Text
id = Text
a} :: ImageLocation)

-- | The URL where the image is available. The URL is valid for 15 minutes so
-- that you can view and download the image
imageLocation_url :: Lens.Lens' ImageLocation Prelude.Text
imageLocation_url :: Lens' ImageLocation Text
imageLocation_url = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageLocation' {Text
url :: Text
$sel:url:ImageLocation' :: ImageLocation -> Text
url} -> Text
url) (\s :: ImageLocation
s@ImageLocation' {} Text
a -> ImageLocation
s {$sel:url:ImageLocation' :: Text
url = Text
a} :: ImageLocation)

instance Data.FromJSON ImageLocation where
  parseJSON :: Value -> Parser ImageLocation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ImageLocation"
      ( \Object
x ->
          Text -> Text -> ImageLocation
ImageLocation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"id")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"url")
      )

instance Prelude.Hashable ImageLocation where
  hashWithSalt :: Int -> ImageLocation -> Int
hashWithSalt Int
_salt ImageLocation' {Text
url :: Text
id :: Text
$sel:url:ImageLocation' :: ImageLocation -> Text
$sel:id:ImageLocation' :: ImageLocation -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
url

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