{-# 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.ELBV2.Types.TagDescription
-- 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.ELBV2.Types.TagDescription where

import qualified Amazonka.Core as Core
import Amazonka.ELBV2.Types.Tag
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The tags associated with a resource.
--
-- /See:/ 'newTagDescription' smart constructor.
data TagDescription = TagDescription'
  { -- | The Amazon Resource Name (ARN) of the resource.
    TagDescription -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | Information about the tags.
    TagDescription -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag)
  }
  deriving (TagDescription -> TagDescription -> Bool
(TagDescription -> TagDescription -> Bool)
-> (TagDescription -> TagDescription -> Bool) -> Eq TagDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagDescription -> TagDescription -> Bool
$c/= :: TagDescription -> TagDescription -> Bool
== :: TagDescription -> TagDescription -> Bool
$c== :: TagDescription -> TagDescription -> Bool
Prelude.Eq, ReadPrec [TagDescription]
ReadPrec TagDescription
Int -> ReadS TagDescription
ReadS [TagDescription]
(Int -> ReadS TagDescription)
-> ReadS [TagDescription]
-> ReadPrec TagDescription
-> ReadPrec [TagDescription]
-> Read TagDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagDescription]
$creadListPrec :: ReadPrec [TagDescription]
readPrec :: ReadPrec TagDescription
$creadPrec :: ReadPrec TagDescription
readList :: ReadS [TagDescription]
$creadList :: ReadS [TagDescription]
readsPrec :: Int -> ReadS TagDescription
$creadsPrec :: Int -> ReadS TagDescription
Prelude.Read, Int -> TagDescription -> ShowS
[TagDescription] -> ShowS
TagDescription -> String
(Int -> TagDescription -> ShowS)
-> (TagDescription -> String)
-> ([TagDescription] -> ShowS)
-> Show TagDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagDescription] -> ShowS
$cshowList :: [TagDescription] -> ShowS
show :: TagDescription -> String
$cshow :: TagDescription -> String
showsPrec :: Int -> TagDescription -> ShowS
$cshowsPrec :: Int -> TagDescription -> ShowS
Prelude.Show, (forall x. TagDescription -> Rep TagDescription x)
-> (forall x. Rep TagDescription x -> TagDescription)
-> Generic TagDescription
forall x. Rep TagDescription x -> TagDescription
forall x. TagDescription -> Rep TagDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagDescription x -> TagDescription
$cfrom :: forall x. TagDescription -> Rep TagDescription x
Prelude.Generic)

-- |
-- Create a value of 'TagDescription' 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:
--
-- 'resourceArn', 'tagDescription_resourceArn' - The Amazon Resource Name (ARN) of the resource.
--
-- 'tags', 'tagDescription_tags' - Information about the tags.
newTagDescription ::
  TagDescription
newTagDescription :: TagDescription
newTagDescription =
  TagDescription' :: Maybe Text -> Maybe (NonEmpty Tag) -> TagDescription
TagDescription'
    { $sel:resourceArn:TagDescription' :: Maybe Text
resourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:TagDescription' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the resource.
tagDescription_resourceArn :: Lens.Lens' TagDescription (Prelude.Maybe Prelude.Text)
tagDescription_resourceArn :: (Maybe Text -> f (Maybe Text))
-> TagDescription -> f TagDescription
tagDescription_resourceArn = (TagDescription -> Maybe Text)
-> (TagDescription -> Maybe Text -> TagDescription)
-> Lens TagDescription TagDescription (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagDescription' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:TagDescription' :: TagDescription -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: TagDescription
s@TagDescription' {} Maybe Text
a -> TagDescription
s {$sel:resourceArn:TagDescription' :: Maybe Text
resourceArn = Maybe Text
a} :: TagDescription)

-- | Information about the tags.
tagDescription_tags :: Lens.Lens' TagDescription (Prelude.Maybe (Prelude.NonEmpty Tag))
tagDescription_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> TagDescription -> f TagDescription
tagDescription_tags = (TagDescription -> Maybe (NonEmpty Tag))
-> (TagDescription -> Maybe (NonEmpty Tag) -> TagDescription)
-> Lens
     TagDescription
     TagDescription
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagDescription' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:TagDescription' :: TagDescription -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: TagDescription
s@TagDescription' {} Maybe (NonEmpty Tag)
a -> TagDescription
s {$sel:tags:TagDescription' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: TagDescription) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> TagDescription -> f TagDescription)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> TagDescription
-> f TagDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
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 (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML TagDescription where
  parseXML :: [Node] -> Either String TagDescription
parseXML [Node]
x =
    Maybe Text -> Maybe (NonEmpty Tag) -> TagDescription
TagDescription'
      (Maybe Text -> Maybe (NonEmpty Tag) -> TagDescription)
-> Either String (Maybe Text)
-> Either String (Maybe (NonEmpty Tag) -> TagDescription)
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
"ResourceArn")
      Either String (Maybe (NonEmpty Tag) -> TagDescription)
-> Either String (Maybe (NonEmpty Tag))
-> Either String TagDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Tags" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe (NonEmpty Tag)))
-> Either String (Maybe (NonEmpty Tag))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String (NonEmpty Tag))
-> [Node] -> Either String (Maybe (NonEmpty Tag))
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String (NonEmpty Tag)
forall a. FromXML a => Text -> [Node] -> Either String (NonEmpty a)
Core.parseXMLList1 Text
"member")
                  )

instance Prelude.Hashable TagDescription

instance Prelude.NFData TagDescription