{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.StorageGateway.NotifyWhenUploaded
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Sends you notification through CloudWatch Events when all files written
-- to your file share have been uploaded to S3. Amazon S3.
--
-- Storage Gateway can send a notification through Amazon CloudWatch Events
-- when all files written to your file share up to that point in time have
-- been uploaded to Amazon S3. These files include files written to the
-- file share up to the time that you make a request for notification. When
-- the upload is done, Storage Gateway sends you notification through an
-- Amazon CloudWatch Event. You can configure CloudWatch Events to send the
-- notification through event targets such as Amazon SNS or Lambda
-- function. This operation is only supported for S3 File Gateways.
--
-- For more information, see
-- <https://docs.aws.amazon.com/storagegateway/latest/userguide/monitoring-file-gateway.html#get-upload-notification Getting file upload notification>
-- in the /Storage Gateway User Guide/.
module Amazonka.StorageGateway.NotifyWhenUploaded
  ( -- * Creating a Request
    NotifyWhenUploaded (..),
    newNotifyWhenUploaded,

    -- * Request Lenses
    notifyWhenUploaded_fileShareARN,

    -- * Destructuring the Response
    NotifyWhenUploadedResponse (..),
    newNotifyWhenUploadedResponse,

    -- * Response Lenses
    notifyWhenUploadedResponse_fileShareARN,
    notifyWhenUploadedResponse_notificationId,
    notifyWhenUploadedResponse_httpStatus,
  )
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
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.StorageGateway.Types

-- | /See:/ 'newNotifyWhenUploaded' smart constructor.
data NotifyWhenUploaded = NotifyWhenUploaded'
  { NotifyWhenUploaded -> Text
fileShareARN :: Prelude.Text
  }
  deriving (NotifyWhenUploaded -> NotifyWhenUploaded -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotifyWhenUploaded -> NotifyWhenUploaded -> Bool
$c/= :: NotifyWhenUploaded -> NotifyWhenUploaded -> Bool
== :: NotifyWhenUploaded -> NotifyWhenUploaded -> Bool
$c== :: NotifyWhenUploaded -> NotifyWhenUploaded -> Bool
Prelude.Eq, ReadPrec [NotifyWhenUploaded]
ReadPrec NotifyWhenUploaded
Int -> ReadS NotifyWhenUploaded
ReadS [NotifyWhenUploaded]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotifyWhenUploaded]
$creadListPrec :: ReadPrec [NotifyWhenUploaded]
readPrec :: ReadPrec NotifyWhenUploaded
$creadPrec :: ReadPrec NotifyWhenUploaded
readList :: ReadS [NotifyWhenUploaded]
$creadList :: ReadS [NotifyWhenUploaded]
readsPrec :: Int -> ReadS NotifyWhenUploaded
$creadsPrec :: Int -> ReadS NotifyWhenUploaded
Prelude.Read, Int -> NotifyWhenUploaded -> ShowS
[NotifyWhenUploaded] -> ShowS
NotifyWhenUploaded -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotifyWhenUploaded] -> ShowS
$cshowList :: [NotifyWhenUploaded] -> ShowS
show :: NotifyWhenUploaded -> String
$cshow :: NotifyWhenUploaded -> String
showsPrec :: Int -> NotifyWhenUploaded -> ShowS
$cshowsPrec :: Int -> NotifyWhenUploaded -> ShowS
Prelude.Show, forall x. Rep NotifyWhenUploaded x -> NotifyWhenUploaded
forall x. NotifyWhenUploaded -> Rep NotifyWhenUploaded x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NotifyWhenUploaded x -> NotifyWhenUploaded
$cfrom :: forall x. NotifyWhenUploaded -> Rep NotifyWhenUploaded x
Prelude.Generic)

-- |
-- Create a value of 'NotifyWhenUploaded' 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:
--
-- 'fileShareARN', 'notifyWhenUploaded_fileShareARN' - Undocumented member.
newNotifyWhenUploaded ::
  -- | 'fileShareARN'
  Prelude.Text ->
  NotifyWhenUploaded
newNotifyWhenUploaded :: Text -> NotifyWhenUploaded
newNotifyWhenUploaded Text
pFileShareARN_ =
  NotifyWhenUploaded' {$sel:fileShareARN:NotifyWhenUploaded' :: Text
fileShareARN = Text
pFileShareARN_}

-- | Undocumented member.
notifyWhenUploaded_fileShareARN :: Lens.Lens' NotifyWhenUploaded Prelude.Text
notifyWhenUploaded_fileShareARN :: Lens' NotifyWhenUploaded Text
notifyWhenUploaded_fileShareARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyWhenUploaded' {Text
fileShareARN :: Text
$sel:fileShareARN:NotifyWhenUploaded' :: NotifyWhenUploaded -> Text
fileShareARN} -> Text
fileShareARN) (\s :: NotifyWhenUploaded
s@NotifyWhenUploaded' {} Text
a -> NotifyWhenUploaded
s {$sel:fileShareARN:NotifyWhenUploaded' :: Text
fileShareARN = Text
a} :: NotifyWhenUploaded)

instance Core.AWSRequest NotifyWhenUploaded where
  type
    AWSResponse NotifyWhenUploaded =
      NotifyWhenUploadedResponse
  request :: (Service -> Service)
-> NotifyWhenUploaded -> Request NotifyWhenUploaded
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy NotifyWhenUploaded
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse NotifyWhenUploaded)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe Text -> Int -> NotifyWhenUploadedResponse
NotifyWhenUploadedResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"FileShareARN")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NotificationId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable NotifyWhenUploaded where
  hashWithSalt :: Int -> NotifyWhenUploaded -> Int
hashWithSalt Int
_salt NotifyWhenUploaded' {Text
fileShareARN :: Text
$sel:fileShareARN:NotifyWhenUploaded' :: NotifyWhenUploaded -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fileShareARN

instance Prelude.NFData NotifyWhenUploaded where
  rnf :: NotifyWhenUploaded -> ()
rnf NotifyWhenUploaded' {Text
fileShareARN :: Text
$sel:fileShareARN:NotifyWhenUploaded' :: NotifyWhenUploaded -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
fileShareARN

instance Data.ToHeaders NotifyWhenUploaded where
  toHeaders :: NotifyWhenUploaded -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"StorageGateway_20130630.NotifyWhenUploaded" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON NotifyWhenUploaded where
  toJSON :: NotifyWhenUploaded -> Value
toJSON NotifyWhenUploaded' {Text
fileShareARN :: Text
$sel:fileShareARN:NotifyWhenUploaded' :: NotifyWhenUploaded -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"FileShareARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
fileShareARN)]
      )

instance Data.ToPath NotifyWhenUploaded where
  toPath :: NotifyWhenUploaded -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery NotifyWhenUploaded where
  toQuery :: NotifyWhenUploaded -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newNotifyWhenUploadedResponse' smart constructor.
data NotifyWhenUploadedResponse = NotifyWhenUploadedResponse'
  { NotifyWhenUploadedResponse -> Maybe Text
fileShareARN :: Prelude.Maybe Prelude.Text,
    NotifyWhenUploadedResponse -> Maybe Text
notificationId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    NotifyWhenUploadedResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (NotifyWhenUploadedResponse -> NotifyWhenUploadedResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotifyWhenUploadedResponse -> NotifyWhenUploadedResponse -> Bool
$c/= :: NotifyWhenUploadedResponse -> NotifyWhenUploadedResponse -> Bool
== :: NotifyWhenUploadedResponse -> NotifyWhenUploadedResponse -> Bool
$c== :: NotifyWhenUploadedResponse -> NotifyWhenUploadedResponse -> Bool
Prelude.Eq, ReadPrec [NotifyWhenUploadedResponse]
ReadPrec NotifyWhenUploadedResponse
Int -> ReadS NotifyWhenUploadedResponse
ReadS [NotifyWhenUploadedResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotifyWhenUploadedResponse]
$creadListPrec :: ReadPrec [NotifyWhenUploadedResponse]
readPrec :: ReadPrec NotifyWhenUploadedResponse
$creadPrec :: ReadPrec NotifyWhenUploadedResponse
readList :: ReadS [NotifyWhenUploadedResponse]
$creadList :: ReadS [NotifyWhenUploadedResponse]
readsPrec :: Int -> ReadS NotifyWhenUploadedResponse
$creadsPrec :: Int -> ReadS NotifyWhenUploadedResponse
Prelude.Read, Int -> NotifyWhenUploadedResponse -> ShowS
[NotifyWhenUploadedResponse] -> ShowS
NotifyWhenUploadedResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotifyWhenUploadedResponse] -> ShowS
$cshowList :: [NotifyWhenUploadedResponse] -> ShowS
show :: NotifyWhenUploadedResponse -> String
$cshow :: NotifyWhenUploadedResponse -> String
showsPrec :: Int -> NotifyWhenUploadedResponse -> ShowS
$cshowsPrec :: Int -> NotifyWhenUploadedResponse -> ShowS
Prelude.Show, forall x.
Rep NotifyWhenUploadedResponse x -> NotifyWhenUploadedResponse
forall x.
NotifyWhenUploadedResponse -> Rep NotifyWhenUploadedResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NotifyWhenUploadedResponse x -> NotifyWhenUploadedResponse
$cfrom :: forall x.
NotifyWhenUploadedResponse -> Rep NotifyWhenUploadedResponse x
Prelude.Generic)

-- |
-- Create a value of 'NotifyWhenUploadedResponse' 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:
--
-- 'fileShareARN', 'notifyWhenUploadedResponse_fileShareARN' - Undocumented member.
--
-- 'notificationId', 'notifyWhenUploadedResponse_notificationId' - Undocumented member.
--
-- 'httpStatus', 'notifyWhenUploadedResponse_httpStatus' - The response's http status code.
newNotifyWhenUploadedResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  NotifyWhenUploadedResponse
newNotifyWhenUploadedResponse :: Int -> NotifyWhenUploadedResponse
newNotifyWhenUploadedResponse Int
pHttpStatus_ =
  NotifyWhenUploadedResponse'
    { $sel:fileShareARN:NotifyWhenUploadedResponse' :: Maybe Text
fileShareARN =
        forall a. Maybe a
Prelude.Nothing,
      $sel:notificationId:NotifyWhenUploadedResponse' :: Maybe Text
notificationId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:NotifyWhenUploadedResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
notifyWhenUploadedResponse_fileShareARN :: Lens.Lens' NotifyWhenUploadedResponse (Prelude.Maybe Prelude.Text)
notifyWhenUploadedResponse_fileShareARN :: Lens' NotifyWhenUploadedResponse (Maybe Text)
notifyWhenUploadedResponse_fileShareARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyWhenUploadedResponse' {Maybe Text
fileShareARN :: Maybe Text
$sel:fileShareARN:NotifyWhenUploadedResponse' :: NotifyWhenUploadedResponse -> Maybe Text
fileShareARN} -> Maybe Text
fileShareARN) (\s :: NotifyWhenUploadedResponse
s@NotifyWhenUploadedResponse' {} Maybe Text
a -> NotifyWhenUploadedResponse
s {$sel:fileShareARN:NotifyWhenUploadedResponse' :: Maybe Text
fileShareARN = Maybe Text
a} :: NotifyWhenUploadedResponse)

-- | Undocumented member.
notifyWhenUploadedResponse_notificationId :: Lens.Lens' NotifyWhenUploadedResponse (Prelude.Maybe Prelude.Text)
notifyWhenUploadedResponse_notificationId :: Lens' NotifyWhenUploadedResponse (Maybe Text)
notifyWhenUploadedResponse_notificationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyWhenUploadedResponse' {Maybe Text
notificationId :: Maybe Text
$sel:notificationId:NotifyWhenUploadedResponse' :: NotifyWhenUploadedResponse -> Maybe Text
notificationId} -> Maybe Text
notificationId) (\s :: NotifyWhenUploadedResponse
s@NotifyWhenUploadedResponse' {} Maybe Text
a -> NotifyWhenUploadedResponse
s {$sel:notificationId:NotifyWhenUploadedResponse' :: Maybe Text
notificationId = Maybe Text
a} :: NotifyWhenUploadedResponse)

-- | The response's http status code.
notifyWhenUploadedResponse_httpStatus :: Lens.Lens' NotifyWhenUploadedResponse Prelude.Int
notifyWhenUploadedResponse_httpStatus :: Lens' NotifyWhenUploadedResponse Int
notifyWhenUploadedResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotifyWhenUploadedResponse' {Int
httpStatus :: Int
$sel:httpStatus:NotifyWhenUploadedResponse' :: NotifyWhenUploadedResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: NotifyWhenUploadedResponse
s@NotifyWhenUploadedResponse' {} Int
a -> NotifyWhenUploadedResponse
s {$sel:httpStatus:NotifyWhenUploadedResponse' :: Int
httpStatus = Int
a} :: NotifyWhenUploadedResponse)

instance Prelude.NFData NotifyWhenUploadedResponse where
  rnf :: NotifyWhenUploadedResponse -> ()
rnf NotifyWhenUploadedResponse' {Int
Maybe Text
httpStatus :: Int
notificationId :: Maybe Text
fileShareARN :: Maybe Text
$sel:httpStatus:NotifyWhenUploadedResponse' :: NotifyWhenUploadedResponse -> Int
$sel:notificationId:NotifyWhenUploadedResponse' :: NotifyWhenUploadedResponse -> Maybe Text
$sel:fileShareARN:NotifyWhenUploadedResponse' :: NotifyWhenUploadedResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fileShareARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
notificationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus