{-# 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.Support.Types.AttachmentDetails
-- 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.Support.Types.AttachmentDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The file name and ID of an attachment to a case communication. You can
-- use the ID to retrieve the attachment with the DescribeAttachment
-- operation.
--
-- /See:/ 'newAttachmentDetails' smart constructor.
data AttachmentDetails = AttachmentDetails'
  { -- | The ID of the attachment.
    AttachmentDetails -> Maybe Text
attachmentId :: Prelude.Maybe Prelude.Text,
    -- | The file name of the attachment.
    AttachmentDetails -> Maybe Text
fileName :: Prelude.Maybe Prelude.Text
  }
  deriving (AttachmentDetails -> AttachmentDetails -> Bool
(AttachmentDetails -> AttachmentDetails -> Bool)
-> (AttachmentDetails -> AttachmentDetails -> Bool)
-> Eq AttachmentDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachmentDetails -> AttachmentDetails -> Bool
$c/= :: AttachmentDetails -> AttachmentDetails -> Bool
== :: AttachmentDetails -> AttachmentDetails -> Bool
$c== :: AttachmentDetails -> AttachmentDetails -> Bool
Prelude.Eq, ReadPrec [AttachmentDetails]
ReadPrec AttachmentDetails
Int -> ReadS AttachmentDetails
ReadS [AttachmentDetails]
(Int -> ReadS AttachmentDetails)
-> ReadS [AttachmentDetails]
-> ReadPrec AttachmentDetails
-> ReadPrec [AttachmentDetails]
-> Read AttachmentDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachmentDetails]
$creadListPrec :: ReadPrec [AttachmentDetails]
readPrec :: ReadPrec AttachmentDetails
$creadPrec :: ReadPrec AttachmentDetails
readList :: ReadS [AttachmentDetails]
$creadList :: ReadS [AttachmentDetails]
readsPrec :: Int -> ReadS AttachmentDetails
$creadsPrec :: Int -> ReadS AttachmentDetails
Prelude.Read, Int -> AttachmentDetails -> ShowS
[AttachmentDetails] -> ShowS
AttachmentDetails -> String
(Int -> AttachmentDetails -> ShowS)
-> (AttachmentDetails -> String)
-> ([AttachmentDetails] -> ShowS)
-> Show AttachmentDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachmentDetails] -> ShowS
$cshowList :: [AttachmentDetails] -> ShowS
show :: AttachmentDetails -> String
$cshow :: AttachmentDetails -> String
showsPrec :: Int -> AttachmentDetails -> ShowS
$cshowsPrec :: Int -> AttachmentDetails -> ShowS
Prelude.Show, (forall x. AttachmentDetails -> Rep AttachmentDetails x)
-> (forall x. Rep AttachmentDetails x -> AttachmentDetails)
-> Generic AttachmentDetails
forall x. Rep AttachmentDetails x -> AttachmentDetails
forall x. AttachmentDetails -> Rep AttachmentDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttachmentDetails x -> AttachmentDetails
$cfrom :: forall x. AttachmentDetails -> Rep AttachmentDetails x
Prelude.Generic)

-- |
-- Create a value of 'AttachmentDetails' 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:
--
-- 'attachmentId', 'attachmentDetails_attachmentId' - The ID of the attachment.
--
-- 'fileName', 'attachmentDetails_fileName' - The file name of the attachment.
newAttachmentDetails ::
  AttachmentDetails
newAttachmentDetails :: AttachmentDetails
newAttachmentDetails =
  AttachmentDetails' :: Maybe Text -> Maybe Text -> AttachmentDetails
AttachmentDetails'
    { $sel:attachmentId:AttachmentDetails' :: Maybe Text
attachmentId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fileName:AttachmentDetails' :: Maybe Text
fileName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the attachment.
attachmentDetails_attachmentId :: Lens.Lens' AttachmentDetails (Prelude.Maybe Prelude.Text)
attachmentDetails_attachmentId :: (Maybe Text -> f (Maybe Text))
-> AttachmentDetails -> f AttachmentDetails
attachmentDetails_attachmentId = (AttachmentDetails -> Maybe Text)
-> (AttachmentDetails -> Maybe Text -> AttachmentDetails)
-> Lens
     AttachmentDetails AttachmentDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachmentDetails' {Maybe Text
attachmentId :: Maybe Text
$sel:attachmentId:AttachmentDetails' :: AttachmentDetails -> Maybe Text
attachmentId} -> Maybe Text
attachmentId) (\s :: AttachmentDetails
s@AttachmentDetails' {} Maybe Text
a -> AttachmentDetails
s {$sel:attachmentId:AttachmentDetails' :: Maybe Text
attachmentId = Maybe Text
a} :: AttachmentDetails)

-- | The file name of the attachment.
attachmentDetails_fileName :: Lens.Lens' AttachmentDetails (Prelude.Maybe Prelude.Text)
attachmentDetails_fileName :: (Maybe Text -> f (Maybe Text))
-> AttachmentDetails -> f AttachmentDetails
attachmentDetails_fileName = (AttachmentDetails -> Maybe Text)
-> (AttachmentDetails -> Maybe Text -> AttachmentDetails)
-> Lens
     AttachmentDetails AttachmentDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachmentDetails' {Maybe Text
fileName :: Maybe Text
$sel:fileName:AttachmentDetails' :: AttachmentDetails -> Maybe Text
fileName} -> Maybe Text
fileName) (\s :: AttachmentDetails
s@AttachmentDetails' {} Maybe Text
a -> AttachmentDetails
s {$sel:fileName:AttachmentDetails' :: Maybe Text
fileName = Maybe Text
a} :: AttachmentDetails)

instance Core.FromJSON AttachmentDetails where
  parseJSON :: Value -> Parser AttachmentDetails
parseJSON =
    String
-> (Object -> Parser AttachmentDetails)
-> Value
-> Parser AttachmentDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AttachmentDetails"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> AttachmentDetails
AttachmentDetails'
            (Maybe Text -> Maybe Text -> AttachmentDetails)
-> Parser (Maybe Text) -> Parser (Maybe Text -> AttachmentDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attachmentId")
            Parser (Maybe Text -> AttachmentDetails)
-> Parser (Maybe Text) -> Parser AttachmentDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"fileName")
      )

instance Prelude.Hashable AttachmentDetails

instance Prelude.NFData AttachmentDetails