{-# 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.WorkMail.Types.Resource
-- 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.WorkMail.Types.Resource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkMail.Types.EntityState
import Amazonka.WorkMail.Types.ResourceType

-- | The representation of a resource.
--
-- /See:/ 'newResource' smart constructor.
data Resource = Resource'
  { -- | The email of the resource.
    Resource -> Maybe Text
email :: Prelude.Maybe Prelude.Text,
    -- | The state of the resource, which can be ENABLED, DISABLED, or DELETED.
    Resource -> Maybe EntityState
state :: Prelude.Maybe EntityState,
    -- | The date indicating when the resource was disabled from Amazon WorkMail
    -- use.
    Resource -> Maybe POSIX
disabledDate :: Prelude.Maybe Core.POSIX,
    -- | The name of the resource.
    Resource -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the resource.
    Resource -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The type of the resource: equipment or room.
    Resource -> Maybe ResourceType
type' :: Prelude.Maybe ResourceType,
    -- | The date indicating when the resource was enabled for Amazon WorkMail
    -- use.
    Resource -> Maybe POSIX
enabledDate :: Prelude.Maybe Core.POSIX
  }
  deriving (Resource -> Resource -> Bool
(Resource -> Resource -> Bool)
-> (Resource -> Resource -> Bool) -> Eq Resource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Resource -> Resource -> Bool
$c/= :: Resource -> Resource -> Bool
== :: Resource -> Resource -> Bool
$c== :: Resource -> Resource -> Bool
Prelude.Eq, ReadPrec [Resource]
ReadPrec Resource
Int -> ReadS Resource
ReadS [Resource]
(Int -> ReadS Resource)
-> ReadS [Resource]
-> ReadPrec Resource
-> ReadPrec [Resource]
-> Read Resource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Resource]
$creadListPrec :: ReadPrec [Resource]
readPrec :: ReadPrec Resource
$creadPrec :: ReadPrec Resource
readList :: ReadS [Resource]
$creadList :: ReadS [Resource]
readsPrec :: Int -> ReadS Resource
$creadsPrec :: Int -> ReadS Resource
Prelude.Read, Int -> Resource -> ShowS
[Resource] -> ShowS
Resource -> String
(Int -> Resource -> ShowS)
-> (Resource -> String) -> ([Resource] -> ShowS) -> Show Resource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Resource] -> ShowS
$cshowList :: [Resource] -> ShowS
show :: Resource -> String
$cshow :: Resource -> String
showsPrec :: Int -> Resource -> ShowS
$cshowsPrec :: Int -> Resource -> ShowS
Prelude.Show, (forall x. Resource -> Rep Resource x)
-> (forall x. Rep Resource x -> Resource) -> Generic Resource
forall x. Rep Resource x -> Resource
forall x. Resource -> Rep Resource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Resource x -> Resource
$cfrom :: forall x. Resource -> Rep Resource x
Prelude.Generic)

-- |
-- Create a value of 'Resource' 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:
--
-- 'email', 'resource_email' - The email of the resource.
--
-- 'state', 'resource_state' - The state of the resource, which can be ENABLED, DISABLED, or DELETED.
--
-- 'disabledDate', 'resource_disabledDate' - The date indicating when the resource was disabled from Amazon WorkMail
-- use.
--
-- 'name', 'resource_name' - The name of the resource.
--
-- 'id', 'resource_id' - The identifier of the resource.
--
-- 'type'', 'resource_type' - The type of the resource: equipment or room.
--
-- 'enabledDate', 'resource_enabledDate' - The date indicating when the resource was enabled for Amazon WorkMail
-- use.
newResource ::
  Resource
newResource :: Resource
newResource =
  Resource' :: Maybe Text
-> Maybe EntityState
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe ResourceType
-> Maybe POSIX
-> Resource
Resource'
    { $sel:email:Resource' :: Maybe Text
email = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:state:Resource' :: Maybe EntityState
state = Maybe EntityState
forall a. Maybe a
Prelude.Nothing,
      $sel:disabledDate:Resource' :: Maybe POSIX
disabledDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Resource' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Resource' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Resource' :: Maybe ResourceType
type' = Maybe ResourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:enabledDate:Resource' :: Maybe POSIX
enabledDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The email of the resource.
resource_email :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_email :: (Maybe Text -> f (Maybe Text)) -> Resource -> f Resource
resource_email = (Resource -> Maybe Text)
-> (Resource -> Maybe Text -> Resource)
-> Lens Resource Resource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
email :: Maybe Text
$sel:email:Resource' :: Resource -> Maybe Text
email} -> Maybe Text
email) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:email:Resource' :: Maybe Text
email = Maybe Text
a} :: Resource)

-- | The state of the resource, which can be ENABLED, DISABLED, or DELETED.
resource_state :: Lens.Lens' Resource (Prelude.Maybe EntityState)
resource_state :: (Maybe EntityState -> f (Maybe EntityState))
-> Resource -> f Resource
resource_state = (Resource -> Maybe EntityState)
-> (Resource -> Maybe EntityState -> Resource)
-> Lens Resource Resource (Maybe EntityState) (Maybe EntityState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe EntityState
state :: Maybe EntityState
$sel:state:Resource' :: Resource -> Maybe EntityState
state} -> Maybe EntityState
state) (\s :: Resource
s@Resource' {} Maybe EntityState
a -> Resource
s {$sel:state:Resource' :: Maybe EntityState
state = Maybe EntityState
a} :: Resource)

-- | The date indicating when the resource was disabled from Amazon WorkMail
-- use.
resource_disabledDate :: Lens.Lens' Resource (Prelude.Maybe Prelude.UTCTime)
resource_disabledDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Resource -> f Resource
resource_disabledDate = (Resource -> Maybe POSIX)
-> (Resource -> Maybe POSIX -> Resource)
-> Lens Resource Resource (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe POSIX
disabledDate :: Maybe POSIX
$sel:disabledDate:Resource' :: Resource -> Maybe POSIX
disabledDate} -> Maybe POSIX
disabledDate) (\s :: Resource
s@Resource' {} Maybe POSIX
a -> Resource
s {$sel:disabledDate:Resource' :: Maybe POSIX
disabledDate = Maybe POSIX
a} :: Resource) ((Maybe POSIX -> f (Maybe POSIX)) -> Resource -> f Resource)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Resource
-> f Resource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the resource.
resource_name :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_name :: (Maybe Text -> f (Maybe Text)) -> Resource -> f Resource
resource_name = (Resource -> Maybe Text)
-> (Resource -> Maybe Text -> Resource)
-> Lens Resource Resource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
name :: Maybe Text
$sel:name:Resource' :: Resource -> Maybe Text
name} -> Maybe Text
name) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:name:Resource' :: Maybe Text
name = Maybe Text
a} :: Resource)

-- | The identifier of the resource.
resource_id :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_id :: (Maybe Text -> f (Maybe Text)) -> Resource -> f Resource
resource_id = (Resource -> Maybe Text)
-> (Resource -> Maybe Text -> Resource)
-> Lens Resource Resource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
id :: Maybe Text
$sel:id:Resource' :: Resource -> Maybe Text
id} -> Maybe Text
id) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:id:Resource' :: Maybe Text
id = Maybe Text
a} :: Resource)

-- | The type of the resource: equipment or room.
resource_type :: Lens.Lens' Resource (Prelude.Maybe ResourceType)
resource_type :: (Maybe ResourceType -> f (Maybe ResourceType))
-> Resource -> f Resource
resource_type = (Resource -> Maybe ResourceType)
-> (Resource -> Maybe ResourceType -> Resource)
-> Lens Resource Resource (Maybe ResourceType) (Maybe ResourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe ResourceType
type' :: Maybe ResourceType
$sel:type':Resource' :: Resource -> Maybe ResourceType
type'} -> Maybe ResourceType
type') (\s :: Resource
s@Resource' {} Maybe ResourceType
a -> Resource
s {$sel:type':Resource' :: Maybe ResourceType
type' = Maybe ResourceType
a} :: Resource)

-- | The date indicating when the resource was enabled for Amazon WorkMail
-- use.
resource_enabledDate :: Lens.Lens' Resource (Prelude.Maybe Prelude.UTCTime)
resource_enabledDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Resource -> f Resource
resource_enabledDate = (Resource -> Maybe POSIX)
-> (Resource -> Maybe POSIX -> Resource)
-> Lens Resource Resource (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe POSIX
enabledDate :: Maybe POSIX
$sel:enabledDate:Resource' :: Resource -> Maybe POSIX
enabledDate} -> Maybe POSIX
enabledDate) (\s :: Resource
s@Resource' {} Maybe POSIX
a -> Resource
s {$sel:enabledDate:Resource' :: Maybe POSIX
enabledDate = Maybe POSIX
a} :: Resource) ((Maybe POSIX -> f (Maybe POSIX)) -> Resource -> f Resource)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Resource
-> f Resource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON Resource where
  parseJSON :: Value -> Parser Resource
parseJSON =
    String -> (Object -> Parser Resource) -> Value -> Parser Resource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Resource"
      ( \Object
x ->
          Maybe Text
-> Maybe EntityState
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe ResourceType
-> Maybe POSIX
-> Resource
Resource'
            (Maybe Text
 -> Maybe EntityState
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe ResourceType
 -> Maybe POSIX
 -> Resource)
-> Parser (Maybe Text)
-> Parser
     (Maybe EntityState
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe ResourceType
      -> Maybe POSIX
      -> Resource)
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
"Email")
            Parser
  (Maybe EntityState
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe ResourceType
   -> Maybe POSIX
   -> Resource)
-> Parser (Maybe EntityState)
-> Parser
     (Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe ResourceType
      -> Maybe POSIX
      -> Resource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EntityState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe ResourceType
   -> Maybe POSIX
   -> Resource)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe ResourceType -> Maybe POSIX -> Resource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DisabledDate")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe ResourceType -> Maybe POSIX -> Resource)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe ResourceType -> Maybe POSIX -> Resource)
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
"Name")
            Parser
  (Maybe Text -> Maybe ResourceType -> Maybe POSIX -> Resource)
-> Parser (Maybe Text)
-> Parser (Maybe ResourceType -> Maybe POSIX -> Resource)
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
"Id")
            Parser (Maybe ResourceType -> Maybe POSIX -> Resource)
-> Parser (Maybe ResourceType) -> Parser (Maybe POSIX -> Resource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ResourceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Maybe POSIX -> Resource)
-> Parser (Maybe POSIX) -> Parser Resource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EnabledDate")
      )

instance Prelude.Hashable Resource

instance Prelude.NFData Resource