{-# 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.Support.Types.Attachment 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
data Attachment = Attachment'
{
Attachment -> Maybe Base64
data' :: Prelude.Maybe Data.Base64,
Attachment -> Maybe Text
fileName :: Prelude.Maybe Prelude.Text
}
deriving (Attachment -> Attachment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Attachment -> Attachment -> Bool
$c/= :: Attachment -> Attachment -> Bool
== :: Attachment -> Attachment -> Bool
$c== :: Attachment -> Attachment -> Bool
Prelude.Eq, ReadPrec [Attachment]
ReadPrec Attachment
Int -> ReadS Attachment
ReadS [Attachment]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Attachment]
$creadListPrec :: ReadPrec [Attachment]
readPrec :: ReadPrec Attachment
$creadPrec :: ReadPrec Attachment
readList :: ReadS [Attachment]
$creadList :: ReadS [Attachment]
readsPrec :: Int -> ReadS Attachment
$creadsPrec :: Int -> ReadS Attachment
Prelude.Read, Int -> Attachment -> ShowS
[Attachment] -> ShowS
Attachment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Attachment] -> ShowS
$cshowList :: [Attachment] -> ShowS
show :: Attachment -> String
$cshow :: Attachment -> String
showsPrec :: Int -> Attachment -> ShowS
$cshowsPrec :: Int -> Attachment -> ShowS
Prelude.Show, forall x. Rep Attachment x -> Attachment
forall x. Attachment -> Rep Attachment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Attachment x -> Attachment
$cfrom :: forall x. Attachment -> Rep Attachment x
Prelude.Generic)
newAttachment ::
Attachment
newAttachment :: Attachment
newAttachment =
Attachment'
{ $sel:data':Attachment' :: Maybe Base64
data' = forall a. Maybe a
Prelude.Nothing,
$sel:fileName:Attachment' :: Maybe Text
fileName = forall a. Maybe a
Prelude.Nothing
}
attachment_data :: Lens.Lens' Attachment (Prelude.Maybe Prelude.ByteString)
attachment_data :: Lens' Attachment (Maybe ByteString)
attachment_data = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attachment' {Maybe Base64
data' :: Maybe Base64
$sel:data':Attachment' :: Attachment -> Maybe Base64
data'} -> Maybe Base64
data') (\s :: Attachment
s@Attachment' {} Maybe Base64
a -> Attachment
s {$sel:data':Attachment' :: Maybe Base64
data' = Maybe Base64
a} :: Attachment) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping Iso' Base64 ByteString
Data._Base64
attachment_fileName :: Lens.Lens' Attachment (Prelude.Maybe Prelude.Text)
attachment_fileName :: Lens' Attachment (Maybe Text)
attachment_fileName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attachment' {Maybe Text
fileName :: Maybe Text
$sel:fileName:Attachment' :: Attachment -> Maybe Text
fileName} -> Maybe Text
fileName) (\s :: Attachment
s@Attachment' {} Maybe Text
a -> Attachment
s {$sel:fileName:Attachment' :: Maybe Text
fileName = Maybe Text
a} :: Attachment)
instance Data.FromJSON Attachment where
parseJSON :: Value -> Parser Attachment
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"Attachment"
( \Object
x ->
Maybe Base64 -> Maybe Text -> Attachment
Attachment'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"data")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"fileName")
)
instance Prelude.Hashable Attachment where
hashWithSalt :: Int -> Attachment -> Int
hashWithSalt Int
_salt Attachment' {Maybe Text
Maybe Base64
fileName :: Maybe Text
data' :: Maybe Base64
$sel:fileName:Attachment' :: Attachment -> Maybe Text
$sel:data':Attachment' :: Attachment -> Maybe Base64
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Base64
data'
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
fileName
instance Prelude.NFData Attachment where
rnf :: Attachment -> ()
rnf Attachment' {Maybe Text
Maybe Base64
fileName :: Maybe Text
data' :: Maybe Base64
$sel:fileName:Attachment' :: Attachment -> Maybe Text
$sel:data':Attachment' :: Attachment -> Maybe Base64
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Base64
data'
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fileName
instance Data.ToJSON Attachment where
toJSON :: Attachment -> Value
toJSON Attachment' {Maybe Text
Maybe Base64
fileName :: Maybe Text
data' :: Maybe Base64
$sel:fileName:Attachment' :: Attachment -> Maybe Text
$sel:data':Attachment' :: Attachment -> Maybe Base64
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"data" 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 Base64
data',
(Key
"fileName" 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
fileName
]
)