{-# 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.ConnectParticipant.Types.UploadMetadata
-- 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.ConnectParticipant.Types.UploadMetadata where

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

-- | Fields to be used while uploading the attachment.
--
-- /See:/ 'newUploadMetadata' smart constructor.
data UploadMetadata = UploadMetadata'
  { -- | The expiration time of the URL in ISO timestamp. It\'s specified in ISO
    -- 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For example,
    -- 2019-11-08T02:41:28.172Z.
    UploadMetadata -> Maybe Text
urlExpiry :: Prelude.Maybe Prelude.Text,
    -- | The headers to be provided while uploading the file to the URL.
    UploadMetadata -> Maybe (HashMap Text Text)
headersToInclude :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The pre-signed URL using which file would be downloaded from Amazon S3
    -- by the API caller.
    UploadMetadata -> Maybe Text
url :: Prelude.Maybe Prelude.Text
  }
  deriving (UploadMetadata -> UploadMetadata -> Bool
(UploadMetadata -> UploadMetadata -> Bool)
-> (UploadMetadata -> UploadMetadata -> Bool) -> Eq UploadMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UploadMetadata -> UploadMetadata -> Bool
$c/= :: UploadMetadata -> UploadMetadata -> Bool
== :: UploadMetadata -> UploadMetadata -> Bool
$c== :: UploadMetadata -> UploadMetadata -> Bool
Prelude.Eq, ReadPrec [UploadMetadata]
ReadPrec UploadMetadata
Int -> ReadS UploadMetadata
ReadS [UploadMetadata]
(Int -> ReadS UploadMetadata)
-> ReadS [UploadMetadata]
-> ReadPrec UploadMetadata
-> ReadPrec [UploadMetadata]
-> Read UploadMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UploadMetadata]
$creadListPrec :: ReadPrec [UploadMetadata]
readPrec :: ReadPrec UploadMetadata
$creadPrec :: ReadPrec UploadMetadata
readList :: ReadS [UploadMetadata]
$creadList :: ReadS [UploadMetadata]
readsPrec :: Int -> ReadS UploadMetadata
$creadsPrec :: Int -> ReadS UploadMetadata
Prelude.Read, Int -> UploadMetadata -> ShowS
[UploadMetadata] -> ShowS
UploadMetadata -> String
(Int -> UploadMetadata -> ShowS)
-> (UploadMetadata -> String)
-> ([UploadMetadata] -> ShowS)
-> Show UploadMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UploadMetadata] -> ShowS
$cshowList :: [UploadMetadata] -> ShowS
show :: UploadMetadata -> String
$cshow :: UploadMetadata -> String
showsPrec :: Int -> UploadMetadata -> ShowS
$cshowsPrec :: Int -> UploadMetadata -> ShowS
Prelude.Show, (forall x. UploadMetadata -> Rep UploadMetadata x)
-> (forall x. Rep UploadMetadata x -> UploadMetadata)
-> Generic UploadMetadata
forall x. Rep UploadMetadata x -> UploadMetadata
forall x. UploadMetadata -> Rep UploadMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UploadMetadata x -> UploadMetadata
$cfrom :: forall x. UploadMetadata -> Rep UploadMetadata x
Prelude.Generic)

-- |
-- Create a value of 'UploadMetadata' 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:
--
-- 'urlExpiry', 'uploadMetadata_urlExpiry' - The expiration time of the URL in ISO timestamp. It\'s specified in ISO
-- 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For example,
-- 2019-11-08T02:41:28.172Z.
--
-- 'headersToInclude', 'uploadMetadata_headersToInclude' - The headers to be provided while uploading the file to the URL.
--
-- 'url', 'uploadMetadata_url' - The pre-signed URL using which file would be downloaded from Amazon S3
-- by the API caller.
newUploadMetadata ::
  UploadMetadata
newUploadMetadata :: UploadMetadata
newUploadMetadata =
  UploadMetadata' :: Maybe Text
-> Maybe (HashMap Text Text) -> Maybe Text -> UploadMetadata
UploadMetadata'
    { $sel:urlExpiry:UploadMetadata' :: Maybe Text
urlExpiry = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:headersToInclude:UploadMetadata' :: Maybe (HashMap Text Text)
headersToInclude = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:url:UploadMetadata' :: Maybe Text
url = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The expiration time of the URL in ISO timestamp. It\'s specified in ISO
-- 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For example,
-- 2019-11-08T02:41:28.172Z.
uploadMetadata_urlExpiry :: Lens.Lens' UploadMetadata (Prelude.Maybe Prelude.Text)
uploadMetadata_urlExpiry :: (Maybe Text -> f (Maybe Text))
-> UploadMetadata -> f UploadMetadata
uploadMetadata_urlExpiry = (UploadMetadata -> Maybe Text)
-> (UploadMetadata -> Maybe Text -> UploadMetadata)
-> Lens UploadMetadata UploadMetadata (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadMetadata' {Maybe Text
urlExpiry :: Maybe Text
$sel:urlExpiry:UploadMetadata' :: UploadMetadata -> Maybe Text
urlExpiry} -> Maybe Text
urlExpiry) (\s :: UploadMetadata
s@UploadMetadata' {} Maybe Text
a -> UploadMetadata
s {$sel:urlExpiry:UploadMetadata' :: Maybe Text
urlExpiry = Maybe Text
a} :: UploadMetadata)

-- | The headers to be provided while uploading the file to the URL.
uploadMetadata_headersToInclude :: Lens.Lens' UploadMetadata (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
uploadMetadata_headersToInclude :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> UploadMetadata -> f UploadMetadata
uploadMetadata_headersToInclude = (UploadMetadata -> Maybe (HashMap Text Text))
-> (UploadMetadata -> Maybe (HashMap Text Text) -> UploadMetadata)
-> Lens
     UploadMetadata
     UploadMetadata
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadMetadata' {Maybe (HashMap Text Text)
headersToInclude :: Maybe (HashMap Text Text)
$sel:headersToInclude:UploadMetadata' :: UploadMetadata -> Maybe (HashMap Text Text)
headersToInclude} -> Maybe (HashMap Text Text)
headersToInclude) (\s :: UploadMetadata
s@UploadMetadata' {} Maybe (HashMap Text Text)
a -> UploadMetadata
s {$sel:headersToInclude:UploadMetadata' :: Maybe (HashMap Text Text)
headersToInclude = Maybe (HashMap Text Text)
a} :: UploadMetadata) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> UploadMetadata -> f UploadMetadata)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> UploadMetadata
-> f UploadMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The pre-signed URL using which file would be downloaded from Amazon S3
-- by the API caller.
uploadMetadata_url :: Lens.Lens' UploadMetadata (Prelude.Maybe Prelude.Text)
uploadMetadata_url :: (Maybe Text -> f (Maybe Text))
-> UploadMetadata -> f UploadMetadata
uploadMetadata_url = (UploadMetadata -> Maybe Text)
-> (UploadMetadata -> Maybe Text -> UploadMetadata)
-> Lens UploadMetadata UploadMetadata (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadMetadata' {Maybe Text
url :: Maybe Text
$sel:url:UploadMetadata' :: UploadMetadata -> Maybe Text
url} -> Maybe Text
url) (\s :: UploadMetadata
s@UploadMetadata' {} Maybe Text
a -> UploadMetadata
s {$sel:url:UploadMetadata' :: Maybe Text
url = Maybe Text
a} :: UploadMetadata)

instance Core.FromJSON UploadMetadata where
  parseJSON :: Value -> Parser UploadMetadata
parseJSON =
    String
-> (Object -> Parser UploadMetadata)
-> Value
-> Parser UploadMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UploadMetadata"
      ( \Object
x ->
          Maybe Text
-> Maybe (HashMap Text Text) -> Maybe Text -> UploadMetadata
UploadMetadata'
            (Maybe Text
 -> Maybe (HashMap Text Text) -> Maybe Text -> UploadMetadata)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text Text) -> Maybe Text -> UploadMetadata)
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
"UrlExpiry")
            Parser (Maybe (HashMap Text Text) -> Maybe Text -> UploadMetadata)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Maybe Text -> UploadMetadata)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"HeadersToInclude"
                            Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> UploadMetadata)
-> Parser (Maybe Text) -> Parser UploadMetadata
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
"Url")
      )

instance Prelude.Hashable UploadMetadata

instance Prelude.NFData UploadMetadata