{-# 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.S3.Types.CommonPrefix
-- 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.S3.Types.CommonPrefix where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal

-- | Container for all (if there are any) keys between Prefix and the next
-- occurrence of the string specified by a delimiter. CommonPrefixes lists
-- keys that act like subdirectories in the directory specified by Prefix.
-- For example, if the prefix is notes\/ and the delimiter is a slash (\/)
-- as in notes\/summer\/july, the common prefix is notes\/summer\/.
--
-- /See:/ 'newCommonPrefix' smart constructor.
data CommonPrefix = CommonPrefix'
  { -- | Container for the specified common prefix.
    CommonPrefix -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text
  }
  deriving (CommonPrefix -> CommonPrefix -> Bool
(CommonPrefix -> CommonPrefix -> Bool)
-> (CommonPrefix -> CommonPrefix -> Bool) -> Eq CommonPrefix
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CommonPrefix -> CommonPrefix -> Bool
$c/= :: CommonPrefix -> CommonPrefix -> Bool
== :: CommonPrefix -> CommonPrefix -> Bool
$c== :: CommonPrefix -> CommonPrefix -> Bool
Prelude.Eq, ReadPrec [CommonPrefix]
ReadPrec CommonPrefix
Int -> ReadS CommonPrefix
ReadS [CommonPrefix]
(Int -> ReadS CommonPrefix)
-> ReadS [CommonPrefix]
-> ReadPrec CommonPrefix
-> ReadPrec [CommonPrefix]
-> Read CommonPrefix
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CommonPrefix]
$creadListPrec :: ReadPrec [CommonPrefix]
readPrec :: ReadPrec CommonPrefix
$creadPrec :: ReadPrec CommonPrefix
readList :: ReadS [CommonPrefix]
$creadList :: ReadS [CommonPrefix]
readsPrec :: Int -> ReadS CommonPrefix
$creadsPrec :: Int -> ReadS CommonPrefix
Prelude.Read, Int -> CommonPrefix -> ShowS
[CommonPrefix] -> ShowS
CommonPrefix -> String
(Int -> CommonPrefix -> ShowS)
-> (CommonPrefix -> String)
-> ([CommonPrefix] -> ShowS)
-> Show CommonPrefix
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CommonPrefix] -> ShowS
$cshowList :: [CommonPrefix] -> ShowS
show :: CommonPrefix -> String
$cshow :: CommonPrefix -> String
showsPrec :: Int -> CommonPrefix -> ShowS
$cshowsPrec :: Int -> CommonPrefix -> ShowS
Prelude.Show, (forall x. CommonPrefix -> Rep CommonPrefix x)
-> (forall x. Rep CommonPrefix x -> CommonPrefix)
-> Generic CommonPrefix
forall x. Rep CommonPrefix x -> CommonPrefix
forall x. CommonPrefix -> Rep CommonPrefix x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CommonPrefix x -> CommonPrefix
$cfrom :: forall x. CommonPrefix -> Rep CommonPrefix x
Prelude.Generic)

-- |
-- Create a value of 'CommonPrefix' 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:
--
-- 'prefix', 'commonPrefix_prefix' - Container for the specified common prefix.
newCommonPrefix ::
  CommonPrefix
newCommonPrefix :: CommonPrefix
newCommonPrefix =
  CommonPrefix' :: Maybe Text -> CommonPrefix
CommonPrefix' {$sel:prefix:CommonPrefix' :: Maybe Text
prefix = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | Container for the specified common prefix.
commonPrefix_prefix :: Lens.Lens' CommonPrefix (Prelude.Maybe Prelude.Text)
commonPrefix_prefix :: (Maybe Text -> f (Maybe Text)) -> CommonPrefix -> f CommonPrefix
commonPrefix_prefix = (CommonPrefix -> Maybe Text)
-> (CommonPrefix -> Maybe Text -> CommonPrefix)
-> Lens CommonPrefix CommonPrefix (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommonPrefix' {Maybe Text
prefix :: Maybe Text
$sel:prefix:CommonPrefix' :: CommonPrefix -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: CommonPrefix
s@CommonPrefix' {} Maybe Text
a -> CommonPrefix
s {$sel:prefix:CommonPrefix' :: Maybe Text
prefix = Maybe Text
a} :: CommonPrefix)

instance Core.FromXML CommonPrefix where
  parseXML :: [Node] -> Either String CommonPrefix
parseXML [Node]
x =
    Maybe Text -> CommonPrefix
CommonPrefix' (Maybe Text -> CommonPrefix)
-> Either String (Maybe Text) -> Either String CommonPrefix
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Prefix")

instance Prelude.Hashable CommonPrefix

instance Prelude.NFData CommonPrefix