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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ResourceTagSet -> ResourceTagSet -> Bool)
-> (ResourceTagSet -> ResourceTagSet -> Bool) -> Eq ResourceTagSet
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]
(Int -> ReadS ResourceTagSet)
-> ReadS [ResourceTagSet]
-> ReadPrec ResourceTagSet
-> ReadPrec [ResourceTagSet]
-> Read 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
(Int -> ResourceTagSet -> ShowS)
-> (ResourceTagSet -> String)
-> ([ResourceTagSet] -> ShowS)
-> Show ResourceTagSet
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. ResourceTagSet -> Rep ResourceTagSet x)
-> (forall x. Rep ResourceTagSet x -> ResourceTagSet)
-> Generic ResourceTagSet
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' :: Maybe Text
-> Maybe TagResourceType -> Maybe (NonEmpty Tag) -> ResourceTagSet
ResourceTagSet'
    { $sel:resourceId:ResourceTagSet' :: Maybe Text
resourceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:ResourceTagSet' :: Maybe TagResourceType
resourceType = Maybe TagResourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:ResourceTagSet' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID for the specified resource.
resourceTagSet_resourceId :: Lens.Lens' ResourceTagSet (Prelude.Maybe Prelude.Text)
resourceTagSet_resourceId :: (Maybe Text -> f (Maybe Text))
-> ResourceTagSet -> f ResourceTagSet
resourceTagSet_resourceId = (ResourceTagSet -> Maybe Text)
-> (ResourceTagSet -> Maybe Text -> ResourceTagSet)
-> Lens ResourceTagSet ResourceTagSet (Maybe Text) (Maybe Text)
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 :: (Maybe TagResourceType -> f (Maybe TagResourceType))
-> ResourceTagSet -> f ResourceTagSet
resourceTagSet_resourceType = (ResourceTagSet -> Maybe TagResourceType)
-> (ResourceTagSet -> Maybe TagResourceType -> ResourceTagSet)
-> Lens
     ResourceTagSet
     ResourceTagSet
     (Maybe TagResourceType)
     (Maybe TagResourceType)
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 :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> ResourceTagSet -> f ResourceTagSet
resourceTagSet_tags = (ResourceTagSet -> Maybe (NonEmpty Tag))
-> (ResourceTagSet -> Maybe (NonEmpty Tag) -> ResourceTagSet)
-> Lens
     ResourceTagSet
     ResourceTagSet
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
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) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> ResourceTagSet -> f ResourceTagSet)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> ResourceTagSet
-> f ResourceTagSet
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 ResourceTagSet where
  parseXML :: [Node] -> Either String ResourceTagSet
parseXML [Node]
x =
    Maybe Text
-> Maybe TagResourceType -> Maybe (NonEmpty Tag) -> ResourceTagSet
ResourceTagSet'
      (Maybe Text
 -> Maybe TagResourceType -> Maybe (NonEmpty Tag) -> ResourceTagSet)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe TagResourceType -> Maybe (NonEmpty Tag) -> ResourceTagSet)
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
"ResourceId")
      Either
  String
  (Maybe TagResourceType -> Maybe (NonEmpty Tag) -> ResourceTagSet)
-> Either String (Maybe TagResourceType)
-> Either String (Maybe (NonEmpty Tag) -> ResourceTagSet)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe TagResourceType)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ResourceType")
      Either String (Maybe (NonEmpty Tag) -> ResourceTagSet)
-> Either String (Maybe (NonEmpty Tag))
-> Either String ResourceTagSet
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
"Tag")
                  )

instance Prelude.Hashable ResourceTagSet

instance Prelude.NFData ResourceTagSet