{-# 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.WorkDocs.Types.ResourceMetadata
-- 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.WorkDocs.Types.ResourceMetadata where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkDocs.Types.ResourceType
import Amazonka.WorkDocs.Types.UserMetadata

-- | Describes the metadata of a resource.
--
-- /See:/ 'newResourceMetadata' smart constructor.
data ResourceMetadata = ResourceMetadata'
  { -- | The version ID of the resource. This is an optional field and is filled
    -- for action on document version.
    ResourceMetadata -> Maybe Text
versionId :: Prelude.Maybe Prelude.Text,
    -- | The owner of the resource.
    ResourceMetadata -> Maybe UserMetadata
owner :: Prelude.Maybe UserMetadata,
    -- | The name of the resource.
    ResourceMetadata -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ID of the resource.
    ResourceMetadata -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The type of resource.
    ResourceMetadata -> Maybe ResourceType
type' :: Prelude.Maybe ResourceType,
    -- | The original name of the resource before a rename operation.
    ResourceMetadata -> Maybe Text
originalName :: Prelude.Maybe Prelude.Text,
    -- | The parent ID of the resource before a rename operation.
    ResourceMetadata -> Maybe Text
parentId :: Prelude.Maybe Prelude.Text
  }
  deriving (ResourceMetadata -> ResourceMetadata -> Bool
(ResourceMetadata -> ResourceMetadata -> Bool)
-> (ResourceMetadata -> ResourceMetadata -> Bool)
-> Eq ResourceMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceMetadata -> ResourceMetadata -> Bool
$c/= :: ResourceMetadata -> ResourceMetadata -> Bool
== :: ResourceMetadata -> ResourceMetadata -> Bool
$c== :: ResourceMetadata -> ResourceMetadata -> Bool
Prelude.Eq, ReadPrec [ResourceMetadata]
ReadPrec ResourceMetadata
Int -> ReadS ResourceMetadata
ReadS [ResourceMetadata]
(Int -> ReadS ResourceMetadata)
-> ReadS [ResourceMetadata]
-> ReadPrec ResourceMetadata
-> ReadPrec [ResourceMetadata]
-> Read ResourceMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceMetadata]
$creadListPrec :: ReadPrec [ResourceMetadata]
readPrec :: ReadPrec ResourceMetadata
$creadPrec :: ReadPrec ResourceMetadata
readList :: ReadS [ResourceMetadata]
$creadList :: ReadS [ResourceMetadata]
readsPrec :: Int -> ReadS ResourceMetadata
$creadsPrec :: Int -> ReadS ResourceMetadata
Prelude.Read, Int -> ResourceMetadata -> ShowS
[ResourceMetadata] -> ShowS
ResourceMetadata -> String
(Int -> ResourceMetadata -> ShowS)
-> (ResourceMetadata -> String)
-> ([ResourceMetadata] -> ShowS)
-> Show ResourceMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceMetadata] -> ShowS
$cshowList :: [ResourceMetadata] -> ShowS
show :: ResourceMetadata -> String
$cshow :: ResourceMetadata -> String
showsPrec :: Int -> ResourceMetadata -> ShowS
$cshowsPrec :: Int -> ResourceMetadata -> ShowS
Prelude.Show, (forall x. ResourceMetadata -> Rep ResourceMetadata x)
-> (forall x. Rep ResourceMetadata x -> ResourceMetadata)
-> Generic ResourceMetadata
forall x. Rep ResourceMetadata x -> ResourceMetadata
forall x. ResourceMetadata -> Rep ResourceMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceMetadata x -> ResourceMetadata
$cfrom :: forall x. ResourceMetadata -> Rep ResourceMetadata x
Prelude.Generic)

-- |
-- Create a value of 'ResourceMetadata' 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:
--
-- 'versionId', 'resourceMetadata_versionId' - The version ID of the resource. This is an optional field and is filled
-- for action on document version.
--
-- 'owner', 'resourceMetadata_owner' - The owner of the resource.
--
-- 'name', 'resourceMetadata_name' - The name of the resource.
--
-- 'id', 'resourceMetadata_id' - The ID of the resource.
--
-- 'type'', 'resourceMetadata_type' - The type of resource.
--
-- 'originalName', 'resourceMetadata_originalName' - The original name of the resource before a rename operation.
--
-- 'parentId', 'resourceMetadata_parentId' - The parent ID of the resource before a rename operation.
newResourceMetadata ::
  ResourceMetadata
newResourceMetadata :: ResourceMetadata
newResourceMetadata =
  ResourceMetadata' :: Maybe Text
-> Maybe UserMetadata
-> Maybe Text
-> Maybe Text
-> Maybe ResourceType
-> Maybe Text
-> Maybe Text
-> ResourceMetadata
ResourceMetadata'
    { $sel:versionId:ResourceMetadata' :: Maybe Text
versionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:owner:ResourceMetadata' :: Maybe UserMetadata
owner = Maybe UserMetadata
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ResourceMetadata' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:ResourceMetadata' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':ResourceMetadata' :: Maybe ResourceType
type' = Maybe ResourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:originalName:ResourceMetadata' :: Maybe Text
originalName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parentId:ResourceMetadata' :: Maybe Text
parentId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The version ID of the resource. This is an optional field and is filled
-- for action on document version.
resourceMetadata_versionId :: Lens.Lens' ResourceMetadata (Prelude.Maybe Prelude.Text)
resourceMetadata_versionId :: (Maybe Text -> f (Maybe Text))
-> ResourceMetadata -> f ResourceMetadata
resourceMetadata_versionId = (ResourceMetadata -> Maybe Text)
-> (ResourceMetadata -> Maybe Text -> ResourceMetadata)
-> Lens ResourceMetadata ResourceMetadata (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceMetadata' {Maybe Text
versionId :: Maybe Text
$sel:versionId:ResourceMetadata' :: ResourceMetadata -> Maybe Text
versionId} -> Maybe Text
versionId) (\s :: ResourceMetadata
s@ResourceMetadata' {} Maybe Text
a -> ResourceMetadata
s {$sel:versionId:ResourceMetadata' :: Maybe Text
versionId = Maybe Text
a} :: ResourceMetadata)

-- | The owner of the resource.
resourceMetadata_owner :: Lens.Lens' ResourceMetadata (Prelude.Maybe UserMetadata)
resourceMetadata_owner :: (Maybe UserMetadata -> f (Maybe UserMetadata))
-> ResourceMetadata -> f ResourceMetadata
resourceMetadata_owner = (ResourceMetadata -> Maybe UserMetadata)
-> (ResourceMetadata -> Maybe UserMetadata -> ResourceMetadata)
-> Lens
     ResourceMetadata
     ResourceMetadata
     (Maybe UserMetadata)
     (Maybe UserMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceMetadata' {Maybe UserMetadata
owner :: Maybe UserMetadata
$sel:owner:ResourceMetadata' :: ResourceMetadata -> Maybe UserMetadata
owner} -> Maybe UserMetadata
owner) (\s :: ResourceMetadata
s@ResourceMetadata' {} Maybe UserMetadata
a -> ResourceMetadata
s {$sel:owner:ResourceMetadata' :: Maybe UserMetadata
owner = Maybe UserMetadata
a} :: ResourceMetadata)

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

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

-- | The type of resource.
resourceMetadata_type :: Lens.Lens' ResourceMetadata (Prelude.Maybe ResourceType)
resourceMetadata_type :: (Maybe ResourceType -> f (Maybe ResourceType))
-> ResourceMetadata -> f ResourceMetadata
resourceMetadata_type = (ResourceMetadata -> Maybe ResourceType)
-> (ResourceMetadata -> Maybe ResourceType -> ResourceMetadata)
-> Lens
     ResourceMetadata
     ResourceMetadata
     (Maybe ResourceType)
     (Maybe ResourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceMetadata' {Maybe ResourceType
type' :: Maybe ResourceType
$sel:type':ResourceMetadata' :: ResourceMetadata -> Maybe ResourceType
type'} -> Maybe ResourceType
type') (\s :: ResourceMetadata
s@ResourceMetadata' {} Maybe ResourceType
a -> ResourceMetadata
s {$sel:type':ResourceMetadata' :: Maybe ResourceType
type' = Maybe ResourceType
a} :: ResourceMetadata)

-- | The original name of the resource before a rename operation.
resourceMetadata_originalName :: Lens.Lens' ResourceMetadata (Prelude.Maybe Prelude.Text)
resourceMetadata_originalName :: (Maybe Text -> f (Maybe Text))
-> ResourceMetadata -> f ResourceMetadata
resourceMetadata_originalName = (ResourceMetadata -> Maybe Text)
-> (ResourceMetadata -> Maybe Text -> ResourceMetadata)
-> Lens ResourceMetadata ResourceMetadata (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceMetadata' {Maybe Text
originalName :: Maybe Text
$sel:originalName:ResourceMetadata' :: ResourceMetadata -> Maybe Text
originalName} -> Maybe Text
originalName) (\s :: ResourceMetadata
s@ResourceMetadata' {} Maybe Text
a -> ResourceMetadata
s {$sel:originalName:ResourceMetadata' :: Maybe Text
originalName = Maybe Text
a} :: ResourceMetadata)

-- | The parent ID of the resource before a rename operation.
resourceMetadata_parentId :: Lens.Lens' ResourceMetadata (Prelude.Maybe Prelude.Text)
resourceMetadata_parentId :: (Maybe Text -> f (Maybe Text))
-> ResourceMetadata -> f ResourceMetadata
resourceMetadata_parentId = (ResourceMetadata -> Maybe Text)
-> (ResourceMetadata -> Maybe Text -> ResourceMetadata)
-> Lens ResourceMetadata ResourceMetadata (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceMetadata' {Maybe Text
parentId :: Maybe Text
$sel:parentId:ResourceMetadata' :: ResourceMetadata -> Maybe Text
parentId} -> Maybe Text
parentId) (\s :: ResourceMetadata
s@ResourceMetadata' {} Maybe Text
a -> ResourceMetadata
s {$sel:parentId:ResourceMetadata' :: Maybe Text
parentId = Maybe Text
a} :: ResourceMetadata)

instance Core.FromJSON ResourceMetadata where
  parseJSON :: Value -> Parser ResourceMetadata
parseJSON =
    String
-> (Object -> Parser ResourceMetadata)
-> Value
-> Parser ResourceMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceMetadata"
      ( \Object
x ->
          Maybe Text
-> Maybe UserMetadata
-> Maybe Text
-> Maybe Text
-> Maybe ResourceType
-> Maybe Text
-> Maybe Text
-> ResourceMetadata
ResourceMetadata'
            (Maybe Text
 -> Maybe UserMetadata
 -> Maybe Text
 -> Maybe Text
 -> Maybe ResourceType
 -> Maybe Text
 -> Maybe Text
 -> ResourceMetadata)
-> Parser (Maybe Text)
-> Parser
     (Maybe UserMetadata
      -> Maybe Text
      -> Maybe Text
      -> Maybe ResourceType
      -> Maybe Text
      -> Maybe Text
      -> ResourceMetadata)
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
"VersionId")
            Parser
  (Maybe UserMetadata
   -> Maybe Text
   -> Maybe Text
   -> Maybe ResourceType
   -> Maybe Text
   -> Maybe Text
   -> ResourceMetadata)
-> Parser (Maybe UserMetadata)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe ResourceType
      -> Maybe Text
      -> Maybe Text
      -> ResourceMetadata)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe UserMetadata)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Owner")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe ResourceType
   -> Maybe Text
   -> Maybe Text
   -> ResourceMetadata)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe ResourceType
      -> Maybe Text
      -> Maybe Text
      -> ResourceMetadata)
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 Text
   -> Maybe Text
   -> ResourceMetadata)
-> Parser (Maybe Text)
-> Parser
     (Maybe ResourceType
      -> Maybe Text -> Maybe Text -> ResourceMetadata)
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 Text -> Maybe Text -> ResourceMetadata)
-> Parser (Maybe ResourceType)
-> Parser (Maybe Text -> Maybe Text -> ResourceMetadata)
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 Text -> Maybe Text -> ResourceMetadata)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ResourceMetadata)
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
"OriginalName")
            Parser (Maybe Text -> ResourceMetadata)
-> Parser (Maybe Text) -> Parser ResourceMetadata
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
"ParentId")
      )

instance Prelude.Hashable ResourceMetadata

instance Prelude.NFData ResourceMetadata