{-# 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.WorkMail.GetMailboxDetails
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Requests a user\'s mailbox details for a specified organization and
-- user.
module Amazonka.WorkMail.GetMailboxDetails
  ( -- * Creating a Request
    GetMailboxDetails (..),
    newGetMailboxDetails,

    -- * Request Lenses
    getMailboxDetails_organizationId,
    getMailboxDetails_userId,

    -- * Destructuring the Response
    GetMailboxDetailsResponse (..),
    newGetMailboxDetailsResponse,

    -- * Response Lenses
    getMailboxDetailsResponse_mailboxQuota,
    getMailboxDetailsResponse_mailboxSize,
    getMailboxDetailsResponse_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.WorkMail.Types

-- | /See:/ 'newGetMailboxDetails' smart constructor.
data GetMailboxDetails = GetMailboxDetails'
  { -- | The identifier for the organization that contains the user whose mailbox
    -- details are being requested.
    GetMailboxDetails -> Text
organizationId :: Prelude.Text,
    -- | The identifier for the user whose mailbox details are being requested.
    GetMailboxDetails -> Text
userId :: Prelude.Text
  }
  deriving (GetMailboxDetails -> GetMailboxDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMailboxDetails -> GetMailboxDetails -> Bool
$c/= :: GetMailboxDetails -> GetMailboxDetails -> Bool
== :: GetMailboxDetails -> GetMailboxDetails -> Bool
$c== :: GetMailboxDetails -> GetMailboxDetails -> Bool
Prelude.Eq, ReadPrec [GetMailboxDetails]
ReadPrec GetMailboxDetails
Int -> ReadS GetMailboxDetails
ReadS [GetMailboxDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMailboxDetails]
$creadListPrec :: ReadPrec [GetMailboxDetails]
readPrec :: ReadPrec GetMailboxDetails
$creadPrec :: ReadPrec GetMailboxDetails
readList :: ReadS [GetMailboxDetails]
$creadList :: ReadS [GetMailboxDetails]
readsPrec :: Int -> ReadS GetMailboxDetails
$creadsPrec :: Int -> ReadS GetMailboxDetails
Prelude.Read, Int -> GetMailboxDetails -> ShowS
[GetMailboxDetails] -> ShowS
GetMailboxDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMailboxDetails] -> ShowS
$cshowList :: [GetMailboxDetails] -> ShowS
show :: GetMailboxDetails -> String
$cshow :: GetMailboxDetails -> String
showsPrec :: Int -> GetMailboxDetails -> ShowS
$cshowsPrec :: Int -> GetMailboxDetails -> ShowS
Prelude.Show, forall x. Rep GetMailboxDetails x -> GetMailboxDetails
forall x. GetMailboxDetails -> Rep GetMailboxDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetMailboxDetails x -> GetMailboxDetails
$cfrom :: forall x. GetMailboxDetails -> Rep GetMailboxDetails x
Prelude.Generic)

-- |
-- Create a value of 'GetMailboxDetails' 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:
--
-- 'organizationId', 'getMailboxDetails_organizationId' - The identifier for the organization that contains the user whose mailbox
-- details are being requested.
--
-- 'userId', 'getMailboxDetails_userId' - The identifier for the user whose mailbox details are being requested.
newGetMailboxDetails ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'userId'
  Prelude.Text ->
  GetMailboxDetails
newGetMailboxDetails :: Text -> Text -> GetMailboxDetails
newGetMailboxDetails Text
pOrganizationId_ Text
pUserId_ =
  GetMailboxDetails'
    { $sel:organizationId:GetMailboxDetails' :: Text
organizationId =
        Text
pOrganizationId_,
      $sel:userId:GetMailboxDetails' :: Text
userId = Text
pUserId_
    }

-- | The identifier for the organization that contains the user whose mailbox
-- details are being requested.
getMailboxDetails_organizationId :: Lens.Lens' GetMailboxDetails Prelude.Text
getMailboxDetails_organizationId :: Lens' GetMailboxDetails Text
getMailboxDetails_organizationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMailboxDetails' {Text
organizationId :: Text
$sel:organizationId:GetMailboxDetails' :: GetMailboxDetails -> Text
organizationId} -> Text
organizationId) (\s :: GetMailboxDetails
s@GetMailboxDetails' {} Text
a -> GetMailboxDetails
s {$sel:organizationId:GetMailboxDetails' :: Text
organizationId = Text
a} :: GetMailboxDetails)

-- | The identifier for the user whose mailbox details are being requested.
getMailboxDetails_userId :: Lens.Lens' GetMailboxDetails Prelude.Text
getMailboxDetails_userId :: Lens' GetMailboxDetails Text
getMailboxDetails_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMailboxDetails' {Text
userId :: Text
$sel:userId:GetMailboxDetails' :: GetMailboxDetails -> Text
userId} -> Text
userId) (\s :: GetMailboxDetails
s@GetMailboxDetails' {} Text
a -> GetMailboxDetails
s {$sel:userId:GetMailboxDetails' :: Text
userId = Text
a} :: GetMailboxDetails)

instance Core.AWSRequest GetMailboxDetails where
  type
    AWSResponse GetMailboxDetails =
      GetMailboxDetailsResponse
  request :: (Service -> Service)
-> GetMailboxDetails -> Request GetMailboxDetails
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 GetMailboxDetails
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetMailboxDetails)))
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 Natural -> Maybe Double -> Int -> GetMailboxDetailsResponse
GetMailboxDetailsResponse'
            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
"MailboxQuota")
            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
"MailboxSize")
            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 GetMailboxDetails where
  hashWithSalt :: Int -> GetMailboxDetails -> Int
hashWithSalt Int
_salt GetMailboxDetails' {Text
userId :: Text
organizationId :: Text
$sel:userId:GetMailboxDetails' :: GetMailboxDetails -> Text
$sel:organizationId:GetMailboxDetails' :: GetMailboxDetails -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
organizationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userId

instance Prelude.NFData GetMailboxDetails where
  rnf :: GetMailboxDetails -> ()
rnf GetMailboxDetails' {Text
userId :: Text
organizationId :: Text
$sel:userId:GetMailboxDetails' :: GetMailboxDetails -> Text
$sel:organizationId:GetMailboxDetails' :: GetMailboxDetails -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
organizationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userId

instance Data.ToHeaders GetMailboxDetails where
  toHeaders :: GetMailboxDetails -> 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
"WorkMailService.GetMailboxDetails" ::
                          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 GetMailboxDetails where
  toJSON :: GetMailboxDetails -> Value
toJSON GetMailboxDetails' {Text
userId :: Text
organizationId :: Text
$sel:userId:GetMailboxDetails' :: GetMailboxDetails -> Text
$sel:organizationId:GetMailboxDetails' :: GetMailboxDetails -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"OrganizationId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
organizationId),
            forall a. a -> Maybe a
Prelude.Just (Key
"UserId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
userId)
          ]
      )

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

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

-- | /See:/ 'newGetMailboxDetailsResponse' smart constructor.
data GetMailboxDetailsResponse = GetMailboxDetailsResponse'
  { -- | The maximum allowed mailbox size, in MB, for the specified user.
    GetMailboxDetailsResponse -> Maybe Natural
mailboxQuota :: Prelude.Maybe Prelude.Natural,
    -- | The current mailbox size, in MB, for the specified user.
    GetMailboxDetailsResponse -> Maybe Double
mailboxSize :: Prelude.Maybe Prelude.Double,
    -- | The response's http status code.
    GetMailboxDetailsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetMailboxDetailsResponse -> GetMailboxDetailsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetMailboxDetailsResponse -> GetMailboxDetailsResponse -> Bool
$c/= :: GetMailboxDetailsResponse -> GetMailboxDetailsResponse -> Bool
== :: GetMailboxDetailsResponse -> GetMailboxDetailsResponse -> Bool
$c== :: GetMailboxDetailsResponse -> GetMailboxDetailsResponse -> Bool
Prelude.Eq, ReadPrec [GetMailboxDetailsResponse]
ReadPrec GetMailboxDetailsResponse
Int -> ReadS GetMailboxDetailsResponse
ReadS [GetMailboxDetailsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetMailboxDetailsResponse]
$creadListPrec :: ReadPrec [GetMailboxDetailsResponse]
readPrec :: ReadPrec GetMailboxDetailsResponse
$creadPrec :: ReadPrec GetMailboxDetailsResponse
readList :: ReadS [GetMailboxDetailsResponse]
$creadList :: ReadS [GetMailboxDetailsResponse]
readsPrec :: Int -> ReadS GetMailboxDetailsResponse
$creadsPrec :: Int -> ReadS GetMailboxDetailsResponse
Prelude.Read, Int -> GetMailboxDetailsResponse -> ShowS
[GetMailboxDetailsResponse] -> ShowS
GetMailboxDetailsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetMailboxDetailsResponse] -> ShowS
$cshowList :: [GetMailboxDetailsResponse] -> ShowS
show :: GetMailboxDetailsResponse -> String
$cshow :: GetMailboxDetailsResponse -> String
showsPrec :: Int -> GetMailboxDetailsResponse -> ShowS
$cshowsPrec :: Int -> GetMailboxDetailsResponse -> ShowS
Prelude.Show, forall x.
Rep GetMailboxDetailsResponse x -> GetMailboxDetailsResponse
forall x.
GetMailboxDetailsResponse -> Rep GetMailboxDetailsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetMailboxDetailsResponse x -> GetMailboxDetailsResponse
$cfrom :: forall x.
GetMailboxDetailsResponse -> Rep GetMailboxDetailsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetMailboxDetailsResponse' 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:
--
-- 'mailboxQuota', 'getMailboxDetailsResponse_mailboxQuota' - The maximum allowed mailbox size, in MB, for the specified user.
--
-- 'mailboxSize', 'getMailboxDetailsResponse_mailboxSize' - The current mailbox size, in MB, for the specified user.
--
-- 'httpStatus', 'getMailboxDetailsResponse_httpStatus' - The response's http status code.
newGetMailboxDetailsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetMailboxDetailsResponse
newGetMailboxDetailsResponse :: Int -> GetMailboxDetailsResponse
newGetMailboxDetailsResponse Int
pHttpStatus_ =
  GetMailboxDetailsResponse'
    { $sel:mailboxQuota:GetMailboxDetailsResponse' :: Maybe Natural
mailboxQuota =
        forall a. Maybe a
Prelude.Nothing,
      $sel:mailboxSize:GetMailboxDetailsResponse' :: Maybe Double
mailboxSize = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetMailboxDetailsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The maximum allowed mailbox size, in MB, for the specified user.
getMailboxDetailsResponse_mailboxQuota :: Lens.Lens' GetMailboxDetailsResponse (Prelude.Maybe Prelude.Natural)
getMailboxDetailsResponse_mailboxQuota :: Lens' GetMailboxDetailsResponse (Maybe Natural)
getMailboxDetailsResponse_mailboxQuota = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMailboxDetailsResponse' {Maybe Natural
mailboxQuota :: Maybe Natural
$sel:mailboxQuota:GetMailboxDetailsResponse' :: GetMailboxDetailsResponse -> Maybe Natural
mailboxQuota} -> Maybe Natural
mailboxQuota) (\s :: GetMailboxDetailsResponse
s@GetMailboxDetailsResponse' {} Maybe Natural
a -> GetMailboxDetailsResponse
s {$sel:mailboxQuota:GetMailboxDetailsResponse' :: Maybe Natural
mailboxQuota = Maybe Natural
a} :: GetMailboxDetailsResponse)

-- | The current mailbox size, in MB, for the specified user.
getMailboxDetailsResponse_mailboxSize :: Lens.Lens' GetMailboxDetailsResponse (Prelude.Maybe Prelude.Double)
getMailboxDetailsResponse_mailboxSize :: Lens' GetMailboxDetailsResponse (Maybe Double)
getMailboxDetailsResponse_mailboxSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetMailboxDetailsResponse' {Maybe Double
mailboxSize :: Maybe Double
$sel:mailboxSize:GetMailboxDetailsResponse' :: GetMailboxDetailsResponse -> Maybe Double
mailboxSize} -> Maybe Double
mailboxSize) (\s :: GetMailboxDetailsResponse
s@GetMailboxDetailsResponse' {} Maybe Double
a -> GetMailboxDetailsResponse
s {$sel:mailboxSize:GetMailboxDetailsResponse' :: Maybe Double
mailboxSize = Maybe Double
a} :: GetMailboxDetailsResponse)

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

instance Prelude.NFData GetMailboxDetailsResponse where
  rnf :: GetMailboxDetailsResponse -> ()
rnf GetMailboxDetailsResponse' {Int
Maybe Double
Maybe Natural
httpStatus :: Int
mailboxSize :: Maybe Double
mailboxQuota :: Maybe Natural
$sel:httpStatus:GetMailboxDetailsResponse' :: GetMailboxDetailsResponse -> Int
$sel:mailboxSize:GetMailboxDetailsResponse' :: GetMailboxDetailsResponse -> Maybe Double
$sel:mailboxQuota:GetMailboxDetailsResponse' :: GetMailboxDetailsResponse -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
mailboxQuota
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
mailboxSize
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus