{-# 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.ResourcePath
-- 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.ResourcePath where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkDocs.Types.ResourcePathComponent

-- | Describes the path information of a resource.
--
-- /See:/ 'newResourcePath' smart constructor.
data ResourcePath = ResourcePath'
  { -- | The components of the resource path.
    ResourcePath -> Maybe [ResourcePathComponent]
components :: Prelude.Maybe [ResourcePathComponent]
  }
  deriving (ResourcePath -> ResourcePath -> Bool
(ResourcePath -> ResourcePath -> Bool)
-> (ResourcePath -> ResourcePath -> Bool) -> Eq ResourcePath
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourcePath -> ResourcePath -> Bool
$c/= :: ResourcePath -> ResourcePath -> Bool
== :: ResourcePath -> ResourcePath -> Bool
$c== :: ResourcePath -> ResourcePath -> Bool
Prelude.Eq, ReadPrec [ResourcePath]
ReadPrec ResourcePath
Int -> ReadS ResourcePath
ReadS [ResourcePath]
(Int -> ReadS ResourcePath)
-> ReadS [ResourcePath]
-> ReadPrec ResourcePath
-> ReadPrec [ResourcePath]
-> Read ResourcePath
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourcePath]
$creadListPrec :: ReadPrec [ResourcePath]
readPrec :: ReadPrec ResourcePath
$creadPrec :: ReadPrec ResourcePath
readList :: ReadS [ResourcePath]
$creadList :: ReadS [ResourcePath]
readsPrec :: Int -> ReadS ResourcePath
$creadsPrec :: Int -> ReadS ResourcePath
Prelude.Read, Int -> ResourcePath -> ShowS
[ResourcePath] -> ShowS
ResourcePath -> String
(Int -> ResourcePath -> ShowS)
-> (ResourcePath -> String)
-> ([ResourcePath] -> ShowS)
-> Show ResourcePath
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourcePath] -> ShowS
$cshowList :: [ResourcePath] -> ShowS
show :: ResourcePath -> String
$cshow :: ResourcePath -> String
showsPrec :: Int -> ResourcePath -> ShowS
$cshowsPrec :: Int -> ResourcePath -> ShowS
Prelude.Show, (forall x. ResourcePath -> Rep ResourcePath x)
-> (forall x. Rep ResourcePath x -> ResourcePath)
-> Generic ResourcePath
forall x. Rep ResourcePath x -> ResourcePath
forall x. ResourcePath -> Rep ResourcePath x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourcePath x -> ResourcePath
$cfrom :: forall x. ResourcePath -> Rep ResourcePath x
Prelude.Generic)

-- |
-- Create a value of 'ResourcePath' 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:
--
-- 'components', 'resourcePath_components' - The components of the resource path.
newResourcePath ::
  ResourcePath
newResourcePath :: ResourcePath
newResourcePath =
  ResourcePath' :: Maybe [ResourcePathComponent] -> ResourcePath
ResourcePath' {$sel:components:ResourcePath' :: Maybe [ResourcePathComponent]
components = Maybe [ResourcePathComponent]
forall a. Maybe a
Prelude.Nothing}

-- | The components of the resource path.
resourcePath_components :: Lens.Lens' ResourcePath (Prelude.Maybe [ResourcePathComponent])
resourcePath_components :: (Maybe [ResourcePathComponent]
 -> f (Maybe [ResourcePathComponent]))
-> ResourcePath -> f ResourcePath
resourcePath_components = (ResourcePath -> Maybe [ResourcePathComponent])
-> (ResourcePath -> Maybe [ResourcePathComponent] -> ResourcePath)
-> Lens
     ResourcePath
     ResourcePath
     (Maybe [ResourcePathComponent])
     (Maybe [ResourcePathComponent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourcePath' {Maybe [ResourcePathComponent]
components :: Maybe [ResourcePathComponent]
$sel:components:ResourcePath' :: ResourcePath -> Maybe [ResourcePathComponent]
components} -> Maybe [ResourcePathComponent]
components) (\s :: ResourcePath
s@ResourcePath' {} Maybe [ResourcePathComponent]
a -> ResourcePath
s {$sel:components:ResourcePath' :: Maybe [ResourcePathComponent]
components = Maybe [ResourcePathComponent]
a} :: ResourcePath) ((Maybe [ResourcePathComponent]
  -> f (Maybe [ResourcePathComponent]))
 -> ResourcePath -> f ResourcePath)
-> ((Maybe [ResourcePathComponent]
     -> f (Maybe [ResourcePathComponent]))
    -> Maybe [ResourcePathComponent]
    -> f (Maybe [ResourcePathComponent]))
-> (Maybe [ResourcePathComponent]
    -> f (Maybe [ResourcePathComponent]))
-> ResourcePath
-> f ResourcePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ResourcePathComponent]
  [ResourcePathComponent]
  [ResourcePathComponent]
  [ResourcePathComponent]
-> Iso
     (Maybe [ResourcePathComponent])
     (Maybe [ResourcePathComponent])
     (Maybe [ResourcePathComponent])
     (Maybe [ResourcePathComponent])
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
  [ResourcePathComponent]
  [ResourcePathComponent]
  [ResourcePathComponent]
  [ResourcePathComponent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ResourcePath where
  parseJSON :: Value -> Parser ResourcePath
parseJSON =
    String
-> (Object -> Parser ResourcePath) -> Value -> Parser ResourcePath
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourcePath"
      ( \Object
x ->
          Maybe [ResourcePathComponent] -> ResourcePath
ResourcePath'
            (Maybe [ResourcePathComponent] -> ResourcePath)
-> Parser (Maybe [ResourcePathComponent]) -> Parser ResourcePath
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [ResourcePathComponent]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Components" Parser (Maybe (Maybe [ResourcePathComponent]))
-> Maybe [ResourcePathComponent]
-> Parser (Maybe [ResourcePathComponent])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ResourcePathComponent]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ResourcePath

instance Prelude.NFData ResourcePath