{-# 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.CloudFront.Types.Tags
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudFront.Types.Tags where

import Amazonka.CloudFront.Types.Tag
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

-- | A complex type that contains zero or more @Tag@ elements.
--
-- /See:/ 'newTags' smart constructor.
data Tags = Tags'
  { -- | A complex type that contains @Tag@ elements.
    Tags -> Maybe [Tag]
items :: Prelude.Maybe [Tag]
  }
  deriving (Tags -> Tags -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Tags -> Tags -> Bool
$c/= :: Tags -> Tags -> Bool
== :: Tags -> Tags -> Bool
$c== :: Tags -> Tags -> Bool
Prelude.Eq, ReadPrec [Tags]
ReadPrec Tags
Int -> ReadS Tags
ReadS [Tags]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Tags]
$creadListPrec :: ReadPrec [Tags]
readPrec :: ReadPrec Tags
$creadPrec :: ReadPrec Tags
readList :: ReadS [Tags]
$creadList :: ReadS [Tags]
readsPrec :: Int -> ReadS Tags
$creadsPrec :: Int -> ReadS Tags
Prelude.Read, Int -> Tags -> ShowS
[Tags] -> ShowS
Tags -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Tags] -> ShowS
$cshowList :: [Tags] -> ShowS
show :: Tags -> String
$cshow :: Tags -> String
showsPrec :: Int -> Tags -> ShowS
$cshowsPrec :: Int -> Tags -> ShowS
Prelude.Show, forall x. Rep Tags x -> Tags
forall x. Tags -> Rep Tags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Tags x -> Tags
$cfrom :: forall x. Tags -> Rep Tags x
Prelude.Generic)

-- |
-- Create a value of 'Tags' 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:
--
-- 'items', 'tags_items' - A complex type that contains @Tag@ elements.
newTags ::
  Tags
newTags :: Tags
newTags = Tags' {$sel:items:Tags' :: Maybe [Tag]
items = forall a. Maybe a
Prelude.Nothing}

-- | A complex type that contains @Tag@ elements.
tags_items :: Lens.Lens' Tags (Prelude.Maybe [Tag])
tags_items :: Lens' Tags (Maybe [Tag])
tags_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tags' {Maybe [Tag]
items :: Maybe [Tag]
$sel:items:Tags' :: Tags -> Maybe [Tag]
items} -> Maybe [Tag]
items) (\s :: Tags
s@Tags' {} Maybe [Tag]
a -> Tags
s {$sel:items:Tags' :: Maybe [Tag]
items = Maybe [Tag]
a} :: Tags) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromXML Tags where
  parseXML :: [Node] -> Either String Tags
parseXML [Node]
x =
    Maybe [Tag] -> Tags
Tags'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Items"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"Tag")
                  )

instance Prelude.Hashable Tags where
  hashWithSalt :: Int -> Tags -> Int
hashWithSalt Int
_salt Tags' {Maybe [Tag]
items :: Maybe [Tag]
$sel:items:Tags' :: Tags -> Maybe [Tag]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
items

instance Prelude.NFData Tags where
  rnf :: Tags -> ()
rnf Tags' {Maybe [Tag]
items :: Maybe [Tag]
$sel:items:Tags' :: Tags -> Maybe [Tag]
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
items

instance Data.ToXML Tags where
  toXML :: Tags -> XML
toXML Tags' {Maybe [Tag]
items :: Maybe [Tag]
$sel:items:Tags' :: Tags -> Maybe [Tag]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Items"
          forall a. ToXML a => Name -> a -> XML
Data.@= forall a. ToXML a => a -> XML
Data.toXML (forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Data.toXMLList Name
"Tag" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
items)
      ]