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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ImageLocation -> ImageLocation -> Bool)
-> (ImageLocation -> ImageLocation -> Bool) -> Eq ImageLocation
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]
(Int -> ReadS ImageLocation)
-> ReadS [ImageLocation]
-> ReadPrec ImageLocation
-> ReadPrec [ImageLocation]
-> Read 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
(Int -> ImageLocation -> ShowS)
-> (ImageLocation -> String)
-> ([ImageLocation] -> ShowS)
-> Show ImageLocation
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. ImageLocation -> Rep ImageLocation x)
-> (forall x. Rep ImageLocation x -> ImageLocation)
-> Generic ImageLocation
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' :: Text -> Text -> ImageLocation
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 :: (Text -> f Text) -> ImageLocation -> f ImageLocation
imageLocation_id = (ImageLocation -> Text)
-> (ImageLocation -> Text -> ImageLocation)
-> Lens ImageLocation ImageLocation Text Text
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 :: (Text -> f Text) -> ImageLocation -> f ImageLocation
imageLocation_url = (ImageLocation -> Text)
-> (ImageLocation -> Text -> ImageLocation)
-> Lens ImageLocation ImageLocation Text Text
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 Core.FromJSON ImageLocation where
  parseJSON :: Value -> Parser ImageLocation
parseJSON =
    String
-> (Object -> Parser ImageLocation)
-> Value
-> Parser ImageLocation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ImageLocation"
      ( \Object
x ->
          Text -> Text -> ImageLocation
ImageLocation'
            (Text -> Text -> ImageLocation)
-> Parser Text -> Parser (Text -> ImageLocation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"id") Parser (Text -> ImageLocation)
-> Parser Text -> Parser ImageLocation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"url")
      )

instance Prelude.Hashable ImageLocation

instance Prelude.NFData ImageLocation