{-# 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 #-}
module Amazonka.IoT.Types.FileLocation where
import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.S3Location
import Amazonka.IoT.Types.Stream
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data FileLocation = FileLocation'
{
FileLocation -> Maybe Stream
stream :: Prelude.Maybe Stream,
FileLocation -> Maybe S3Location
s3Location :: Prelude.Maybe S3Location
}
deriving (FileLocation -> FileLocation -> Bool
(FileLocation -> FileLocation -> Bool)
-> (FileLocation -> FileLocation -> Bool) -> Eq FileLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileLocation -> FileLocation -> Bool
$c/= :: FileLocation -> FileLocation -> Bool
== :: FileLocation -> FileLocation -> Bool
$c== :: FileLocation -> FileLocation -> Bool
Prelude.Eq, ReadPrec [FileLocation]
ReadPrec FileLocation
Int -> ReadS FileLocation
ReadS [FileLocation]
(Int -> ReadS FileLocation)
-> ReadS [FileLocation]
-> ReadPrec FileLocation
-> ReadPrec [FileLocation]
-> Read FileLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FileLocation]
$creadListPrec :: ReadPrec [FileLocation]
readPrec :: ReadPrec FileLocation
$creadPrec :: ReadPrec FileLocation
readList :: ReadS [FileLocation]
$creadList :: ReadS [FileLocation]
readsPrec :: Int -> ReadS FileLocation
$creadsPrec :: Int -> ReadS FileLocation
Prelude.Read, Int -> FileLocation -> ShowS
[FileLocation] -> ShowS
FileLocation -> String
(Int -> FileLocation -> ShowS)
-> (FileLocation -> String)
-> ([FileLocation] -> ShowS)
-> Show FileLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileLocation] -> ShowS
$cshowList :: [FileLocation] -> ShowS
show :: FileLocation -> String
$cshow :: FileLocation -> String
showsPrec :: Int -> FileLocation -> ShowS
$cshowsPrec :: Int -> FileLocation -> ShowS
Prelude.Show, (forall x. FileLocation -> Rep FileLocation x)
-> (forall x. Rep FileLocation x -> FileLocation)
-> Generic FileLocation
forall x. Rep FileLocation x -> FileLocation
forall x. FileLocation -> Rep FileLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FileLocation x -> FileLocation
$cfrom :: forall x. FileLocation -> Rep FileLocation x
Prelude.Generic)
newFileLocation ::
FileLocation
newFileLocation :: FileLocation
newFileLocation =
FileLocation' :: Maybe Stream -> Maybe S3Location -> FileLocation
FileLocation'
{ $sel:stream:FileLocation' :: Maybe Stream
stream = Maybe Stream
forall a. Maybe a
Prelude.Nothing,
$sel:s3Location:FileLocation' :: Maybe S3Location
s3Location = Maybe S3Location
forall a. Maybe a
Prelude.Nothing
}
fileLocation_stream :: Lens.Lens' FileLocation (Prelude.Maybe Stream)
fileLocation_stream :: (Maybe Stream -> f (Maybe Stream))
-> FileLocation -> f FileLocation
fileLocation_stream = (FileLocation -> Maybe Stream)
-> (FileLocation -> Maybe Stream -> FileLocation)
-> Lens FileLocation FileLocation (Maybe Stream) (Maybe Stream)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileLocation' {Maybe Stream
stream :: Maybe Stream
$sel:stream:FileLocation' :: FileLocation -> Maybe Stream
stream} -> Maybe Stream
stream) (\s :: FileLocation
s@FileLocation' {} Maybe Stream
a -> FileLocation
s {$sel:stream:FileLocation' :: Maybe Stream
stream = Maybe Stream
a} :: FileLocation)
fileLocation_s3Location :: Lens.Lens' FileLocation (Prelude.Maybe S3Location)
fileLocation_s3Location :: (Maybe S3Location -> f (Maybe S3Location))
-> FileLocation -> f FileLocation
fileLocation_s3Location = (FileLocation -> Maybe S3Location)
-> (FileLocation -> Maybe S3Location -> FileLocation)
-> Lens
FileLocation FileLocation (Maybe S3Location) (Maybe S3Location)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileLocation' {Maybe S3Location
s3Location :: Maybe S3Location
$sel:s3Location:FileLocation' :: FileLocation -> Maybe S3Location
s3Location} -> Maybe S3Location
s3Location) (\s :: FileLocation
s@FileLocation' {} Maybe S3Location
a -> FileLocation
s {$sel:s3Location:FileLocation' :: Maybe S3Location
s3Location = Maybe S3Location
a} :: FileLocation)
instance Core.FromJSON FileLocation where
parseJSON :: Value -> Parser FileLocation
parseJSON =
String
-> (Object -> Parser FileLocation) -> Value -> Parser FileLocation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"FileLocation"
( \Object
x ->
Maybe Stream -> Maybe S3Location -> FileLocation
FileLocation'
(Maybe Stream -> Maybe S3Location -> FileLocation)
-> Parser (Maybe Stream)
-> Parser (Maybe S3Location -> FileLocation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Stream)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"stream")
Parser (Maybe S3Location -> FileLocation)
-> Parser (Maybe S3Location) -> Parser FileLocation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe S3Location)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"s3Location")
)
instance Prelude.Hashable FileLocation
instance Prelude.NFData FileLocation
instance Core.ToJSON FileLocation where
toJSON :: FileLocation -> Value
toJSON FileLocation' {Maybe S3Location
Maybe Stream
s3Location :: Maybe S3Location
stream :: Maybe Stream
$sel:s3Location:FileLocation' :: FileLocation -> Maybe S3Location
$sel:stream:FileLocation' :: FileLocation -> Maybe Stream
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"stream" Text -> Stream -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Stream -> Pair) -> Maybe Stream -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Stream
stream,
(Text
"s3Location" Text -> S3Location -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (S3Location -> Pair) -> Maybe S3Location -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3Location
s3Location
]
)