{-# 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.Route53.Types.ResourceTagSet
-- 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.Route53.Types.ResourceTagSet where

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
import Amazonka.Route53.Internal
import Amazonka.Route53.Types.Tag
import Amazonka.Route53.Types.TagResourceType

-- | A complex type containing a resource and its associated tags.
--
-- /See:/ 'newResourceTagSet' smart constructor.
data ResourceTagSet = ResourceTagSet'
  { -- | The ID for the specified resource.
    ResourceTagSet -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
    -- | The type of the resource.
    --
    -- -   The resource type for health checks is @healthcheck@.
    --
    -- -   The resource type for hosted zones is @hostedzone@.
    ResourceTagSet -> Maybe TagResourceType
resourceType :: Prelude.Maybe TagResourceType,
    -- | The tags associated with the specified resource.
    ResourceTagSet -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag)
  }
  deriving (ResourceTagSet -> ResourceTagSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceTagSet -> ResourceTagSet -> Bool
$c/= :: ResourceTagSet -> ResourceTagSet -> Bool
== :: ResourceTagSet -> ResourceTagSet -> Bool
$c== :: ResourceTagSet -> ResourceTagSet -> Bool
Prelude.Eq, ReadPrec [ResourceTagSet]
ReadPrec ResourceTagSet
Int -> ReadS ResourceTagSet
ReadS [ResourceTagSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceTagSet]
$creadListPrec :: ReadPrec [ResourceTagSet]
readPrec :: ReadPrec ResourceTagSet
$creadPrec :: ReadPrec ResourceTagSet
readList :: ReadS [ResourceTagSet]
$creadList :: ReadS [ResourceTagSet]
readsPrec :: Int -> ReadS ResourceTagSet
$creadsPrec :: Int -> ReadS ResourceTagSet
Prelude.Read, Int -> ResourceTagSet -> ShowS
[ResourceTagSet] -> ShowS
ResourceTagSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceTagSet] -> ShowS
$cshowList :: [ResourceTagSet] -> ShowS
show :: ResourceTagSet -> String
$cshow :: ResourceTagSet -> String
showsPrec :: Int -> ResourceTagSet -> ShowS
$cshowsPrec :: Int -> ResourceTagSet -> ShowS
Prelude.Show, forall x. Rep ResourceTagSet x -> ResourceTagSet
forall x. ResourceTagSet -> Rep ResourceTagSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceTagSet x -> ResourceTagSet
$cfrom :: forall x. ResourceTagSet -> Rep ResourceTagSet x
Prelude.Generic)

-- |
-- Create a value of 'ResourceTagSet' 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:
--
-- 'resourceId', 'resourceTagSet_resourceId' - The ID for the specified resource.
--
-- 'resourceType', 'resourceTagSet_resourceType' - The type of the resource.
--
-- -   The resource type for health checks is @healthcheck@.
--
-- -   The resource type for hosted zones is @hostedzone@.
--
-- 'tags', 'resourceTagSet_tags' - The tags associated with the specified resource.
newResourceTagSet ::
  ResourceTagSet
newResourceTagSet :: ResourceTagSet
newResourceTagSet =
  ResourceTagSet'
    { $sel:resourceId:ResourceTagSet' :: Maybe Text
resourceId = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:ResourceTagSet' :: Maybe TagResourceType
resourceType = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:ResourceTagSet' :: Maybe (NonEmpty Tag)
tags = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID for the specified resource.
resourceTagSet_resourceId :: Lens.Lens' ResourceTagSet (Prelude.Maybe Prelude.Text)
resourceTagSet_resourceId :: Lens' ResourceTagSet (Maybe Text)
resourceTagSet_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceTagSet' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:ResourceTagSet' :: ResourceTagSet -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: ResourceTagSet
s@ResourceTagSet' {} Maybe Text
a -> ResourceTagSet
s {$sel:resourceId:ResourceTagSet' :: Maybe Text
resourceId = Maybe Text
a} :: ResourceTagSet)

-- | The type of the resource.
--
-- -   The resource type for health checks is @healthcheck@.
--
-- -   The resource type for hosted zones is @hostedzone@.
resourceTagSet_resourceType :: Lens.Lens' ResourceTagSet (Prelude.Maybe TagResourceType)
resourceTagSet_resourceType :: Lens' ResourceTagSet (Maybe TagResourceType)
resourceTagSet_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceTagSet' {Maybe TagResourceType
resourceType :: Maybe TagResourceType
$sel:resourceType:ResourceTagSet' :: ResourceTagSet -> Maybe TagResourceType
resourceType} -> Maybe TagResourceType
resourceType) (\s :: ResourceTagSet
s@ResourceTagSet' {} Maybe TagResourceType
a -> ResourceTagSet
s {$sel:resourceType:ResourceTagSet' :: Maybe TagResourceType
resourceType = Maybe TagResourceType
a} :: ResourceTagSet)

-- | The tags associated with the specified resource.
resourceTagSet_tags :: Lens.Lens' ResourceTagSet (Prelude.Maybe (Prelude.NonEmpty Tag))
resourceTagSet_tags :: Lens' ResourceTagSet (Maybe (NonEmpty Tag))
resourceTagSet_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceTagSet' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:ResourceTagSet' :: ResourceTagSet -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: ResourceTagSet
s@ResourceTagSet' {} Maybe (NonEmpty Tag)
a -> ResourceTagSet
s {$sel:tags:ResourceTagSet' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: ResourceTagSet) 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 ResourceTagSet where
  parseXML :: [Node] -> Either String ResourceTagSet
parseXML [Node]
x =
    Maybe Text
-> Maybe TagResourceType -> Maybe (NonEmpty Tag) -> ResourceTagSet
ResourceTagSet'
      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
"ResourceId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ResourceType")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Tags"
                      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 (NonEmpty a)
Data.parseXMLList1 Text
"Tag")
                  )

instance Prelude.Hashable ResourceTagSet where
  hashWithSalt :: Int -> ResourceTagSet -> Int
hashWithSalt Int
_salt ResourceTagSet' {Maybe (NonEmpty Tag)
Maybe Text
Maybe TagResourceType
tags :: Maybe (NonEmpty Tag)
resourceType :: Maybe TagResourceType
resourceId :: Maybe Text
$sel:tags:ResourceTagSet' :: ResourceTagSet -> Maybe (NonEmpty Tag)
$sel:resourceType:ResourceTagSet' :: ResourceTagSet -> Maybe TagResourceType
$sel:resourceId:ResourceTagSet' :: ResourceTagSet -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TagResourceType
resourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Tag)
tags

instance Prelude.NFData ResourceTagSet where
  rnf :: ResourceTagSet -> ()
rnf ResourceTagSet' {Maybe (NonEmpty Tag)
Maybe Text
Maybe TagResourceType
tags :: Maybe (NonEmpty Tag)
resourceType :: Maybe TagResourceType
resourceId :: Maybe Text
$sel:tags:ResourceTagSet' :: ResourceTagSet -> Maybe (NonEmpty Tag)
$sel:resourceType:ResourceTagSet' :: ResourceTagSet -> Maybe TagResourceType
$sel:resourceId:ResourceTagSet' :: ResourceTagSet -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TagResourceType
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Tag)
tags