{-# 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-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)
--
-- Sends you notification through CloudWatch Events when all files written
-- to your file share have been uploaded to 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.Lens as Lens
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
(NotifyWhenUploaded -> NotifyWhenUploaded -> Bool)
-> (NotifyWhenUploaded -> NotifyWhenUploaded -> Bool)
-> Eq NotifyWhenUploaded
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]
(Int -> ReadS NotifyWhenUploaded)
-> ReadS [NotifyWhenUploaded]
-> ReadPrec NotifyWhenUploaded
-> ReadPrec [NotifyWhenUploaded]
-> Read 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
(Int -> NotifyWhenUploaded -> ShowS)
-> (NotifyWhenUploaded -> String)
-> ([NotifyWhenUploaded] -> ShowS)
-> Show NotifyWhenUploaded
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. NotifyWhenUploaded -> Rep NotifyWhenUploaded x)
-> (forall x. Rep NotifyWhenUploaded x -> NotifyWhenUploaded)
-> Generic NotifyWhenUploaded
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' :: Text -> NotifyWhenUploaded
NotifyWhenUploaded' {$sel:fileShareARN:NotifyWhenUploaded' :: Text
fileShareARN = Text
pFileShareARN_}

-- | Undocumented member.
notifyWhenUploaded_fileShareARN :: Lens.Lens' NotifyWhenUploaded Prelude.Text
notifyWhenUploaded_fileShareARN :: (Text -> f Text) -> NotifyWhenUploaded -> f NotifyWhenUploaded
notifyWhenUploaded_fileShareARN = (NotifyWhenUploaded -> Text)
-> (NotifyWhenUploaded -> Text -> NotifyWhenUploaded)
-> Lens NotifyWhenUploaded NotifyWhenUploaded Text Text
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 :: NotifyWhenUploaded -> Request NotifyWhenUploaded
request = Service -> NotifyWhenUploaded -> Request NotifyWhenUploaded
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy NotifyWhenUploaded
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse NotifyWhenUploaded)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse NotifyWhenUploaded))
-> Logger
-> Service
-> Proxy NotifyWhenUploaded
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse NotifyWhenUploaded)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Maybe Text -> Maybe Text -> Int -> NotifyWhenUploadedResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> NotifyWhenUploadedResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FileShareARN")
            Either String (Maybe Text -> Int -> NotifyWhenUploadedResponse)
-> Either String (Maybe Text)
-> Either String (Int -> NotifyWhenUploadedResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NotificationId")
            Either String (Int -> NotifyWhenUploadedResponse)
-> Either String Int -> Either String NotifyWhenUploadedResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable NotifyWhenUploaded

instance Prelude.NFData NotifyWhenUploaded

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

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

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

instance Core.ToQuery NotifyWhenUploaded where
  toQuery :: NotifyWhenUploaded -> QueryString
toQuery = QueryString -> NotifyWhenUploaded -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(NotifyWhenUploadedResponse -> NotifyWhenUploadedResponse -> Bool)
-> (NotifyWhenUploadedResponse
    -> NotifyWhenUploadedResponse -> Bool)
-> Eq NotifyWhenUploadedResponse
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]
(Int -> ReadS NotifyWhenUploadedResponse)
-> ReadS [NotifyWhenUploadedResponse]
-> ReadPrec NotifyWhenUploadedResponse
-> ReadPrec [NotifyWhenUploadedResponse]
-> Read 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
(Int -> NotifyWhenUploadedResponse -> ShowS)
-> (NotifyWhenUploadedResponse -> String)
-> ([NotifyWhenUploadedResponse] -> ShowS)
-> Show NotifyWhenUploadedResponse
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.
 NotifyWhenUploadedResponse -> Rep NotifyWhenUploadedResponse x)
-> (forall x.
    Rep NotifyWhenUploadedResponse x -> NotifyWhenUploadedResponse)
-> Generic NotifyWhenUploadedResponse
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' :: Maybe Text -> Maybe Text -> Int -> NotifyWhenUploadedResponse
NotifyWhenUploadedResponse'
    { $sel:fileShareARN:NotifyWhenUploadedResponse' :: Maybe Text
fileShareARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:notificationId:NotifyWhenUploadedResponse' :: Maybe Text
notificationId = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> NotifyWhenUploadedResponse -> f NotifyWhenUploadedResponse
notifyWhenUploadedResponse_fileShareARN = (NotifyWhenUploadedResponse -> Maybe Text)
-> (NotifyWhenUploadedResponse
    -> Maybe Text -> NotifyWhenUploadedResponse)
-> Lens
     NotifyWhenUploadedResponse
     NotifyWhenUploadedResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> NotifyWhenUploadedResponse -> f NotifyWhenUploadedResponse
notifyWhenUploadedResponse_notificationId = (NotifyWhenUploadedResponse -> Maybe Text)
-> (NotifyWhenUploadedResponse
    -> Maybe Text -> NotifyWhenUploadedResponse)
-> Lens
     NotifyWhenUploadedResponse
     NotifyWhenUploadedResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> NotifyWhenUploadedResponse -> f NotifyWhenUploadedResponse
notifyWhenUploadedResponse_httpStatus = (NotifyWhenUploadedResponse -> Int)
-> (NotifyWhenUploadedResponse
    -> Int -> NotifyWhenUploadedResponse)
-> Lens
     NotifyWhenUploadedResponse NotifyWhenUploadedResponse Int Int
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