{-# 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.Pinpoint.Types.AttributesResource
-- 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.Pinpoint.Types.AttributesResource where

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

-- | Provides information about the type and the names of attributes that
-- were removed from all the endpoints that are associated with an
-- application.
--
-- /See:/ 'newAttributesResource' smart constructor.
data AttributesResource = AttributesResource'
  { -- | An array that specifies the names of the attributes that were removed
    -- from the endpoints.
    AttributesResource -> Maybe [Text]
attributes :: Prelude.Maybe [Prelude.Text],
    -- | The type of attribute or attributes that were removed from the
    -- endpoints. Valid values are:
    --
    -- -   endpoint-custom-attributes - Custom attributes that describe
    --     endpoints.
    --
    -- -   endpoint-metric-attributes - Custom metrics that your app reports to
    --     Amazon Pinpoint for endpoints.
    --
    -- -   endpoint-user-attributes - Custom attributes that describe users.
    AttributesResource -> Text
attributeType :: Prelude.Text,
    -- | The unique identifier for the application.
    AttributesResource -> Text
applicationId :: Prelude.Text
  }
  deriving (AttributesResource -> AttributesResource -> Bool
(AttributesResource -> AttributesResource -> Bool)
-> (AttributesResource -> AttributesResource -> Bool)
-> Eq AttributesResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttributesResource -> AttributesResource -> Bool
$c/= :: AttributesResource -> AttributesResource -> Bool
== :: AttributesResource -> AttributesResource -> Bool
$c== :: AttributesResource -> AttributesResource -> Bool
Prelude.Eq, ReadPrec [AttributesResource]
ReadPrec AttributesResource
Int -> ReadS AttributesResource
ReadS [AttributesResource]
(Int -> ReadS AttributesResource)
-> ReadS [AttributesResource]
-> ReadPrec AttributesResource
-> ReadPrec [AttributesResource]
-> Read AttributesResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttributesResource]
$creadListPrec :: ReadPrec [AttributesResource]
readPrec :: ReadPrec AttributesResource
$creadPrec :: ReadPrec AttributesResource
readList :: ReadS [AttributesResource]
$creadList :: ReadS [AttributesResource]
readsPrec :: Int -> ReadS AttributesResource
$creadsPrec :: Int -> ReadS AttributesResource
Prelude.Read, Int -> AttributesResource -> ShowS
[AttributesResource] -> ShowS
AttributesResource -> String
(Int -> AttributesResource -> ShowS)
-> (AttributesResource -> String)
-> ([AttributesResource] -> ShowS)
-> Show AttributesResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttributesResource] -> ShowS
$cshowList :: [AttributesResource] -> ShowS
show :: AttributesResource -> String
$cshow :: AttributesResource -> String
showsPrec :: Int -> AttributesResource -> ShowS
$cshowsPrec :: Int -> AttributesResource -> ShowS
Prelude.Show, (forall x. AttributesResource -> Rep AttributesResource x)
-> (forall x. Rep AttributesResource x -> AttributesResource)
-> Generic AttributesResource
forall x. Rep AttributesResource x -> AttributesResource
forall x. AttributesResource -> Rep AttributesResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttributesResource x -> AttributesResource
$cfrom :: forall x. AttributesResource -> Rep AttributesResource x
Prelude.Generic)

-- |
-- Create a value of 'AttributesResource' 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:
--
-- 'attributes', 'attributesResource_attributes' - An array that specifies the names of the attributes that were removed
-- from the endpoints.
--
-- 'attributeType', 'attributesResource_attributeType' - The type of attribute or attributes that were removed from the
-- endpoints. Valid values are:
--
-- -   endpoint-custom-attributes - Custom attributes that describe
--     endpoints.
--
-- -   endpoint-metric-attributes - Custom metrics that your app reports to
--     Amazon Pinpoint for endpoints.
--
-- -   endpoint-user-attributes - Custom attributes that describe users.
--
-- 'applicationId', 'attributesResource_applicationId' - The unique identifier for the application.
newAttributesResource ::
  -- | 'attributeType'
  Prelude.Text ->
  -- | 'applicationId'
  Prelude.Text ->
  AttributesResource
newAttributesResource :: Text -> Text -> AttributesResource
newAttributesResource Text
pAttributeType_ Text
pApplicationId_ =
  AttributesResource' :: Maybe [Text] -> Text -> Text -> AttributesResource
AttributesResource'
    { $sel:attributes:AttributesResource' :: Maybe [Text]
attributes = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeType:AttributesResource' :: Text
attributeType = Text
pAttributeType_,
      $sel:applicationId:AttributesResource' :: Text
applicationId = Text
pApplicationId_
    }

-- | An array that specifies the names of the attributes that were removed
-- from the endpoints.
attributesResource_attributes :: Lens.Lens' AttributesResource (Prelude.Maybe [Prelude.Text])
attributesResource_attributes :: (Maybe [Text] -> f (Maybe [Text]))
-> AttributesResource -> f AttributesResource
attributesResource_attributes = (AttributesResource -> Maybe [Text])
-> (AttributesResource -> Maybe [Text] -> AttributesResource)
-> Lens
     AttributesResource AttributesResource (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributesResource' {Maybe [Text]
attributes :: Maybe [Text]
$sel:attributes:AttributesResource' :: AttributesResource -> Maybe [Text]
attributes} -> Maybe [Text]
attributes) (\s :: AttributesResource
s@AttributesResource' {} Maybe [Text]
a -> AttributesResource
s {$sel:attributes:AttributesResource' :: Maybe [Text]
attributes = Maybe [Text]
a} :: AttributesResource) ((Maybe [Text] -> f (Maybe [Text]))
 -> AttributesResource -> f AttributesResource)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AttributesResource
-> f AttributesResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type of attribute or attributes that were removed from the
-- endpoints. Valid values are:
--
-- -   endpoint-custom-attributes - Custom attributes that describe
--     endpoints.
--
-- -   endpoint-metric-attributes - Custom metrics that your app reports to
--     Amazon Pinpoint for endpoints.
--
-- -   endpoint-user-attributes - Custom attributes that describe users.
attributesResource_attributeType :: Lens.Lens' AttributesResource Prelude.Text
attributesResource_attributeType :: (Text -> f Text) -> AttributesResource -> f AttributesResource
attributesResource_attributeType = (AttributesResource -> Text)
-> (AttributesResource -> Text -> AttributesResource)
-> Lens AttributesResource AttributesResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributesResource' {Text
attributeType :: Text
$sel:attributeType:AttributesResource' :: AttributesResource -> Text
attributeType} -> Text
attributeType) (\s :: AttributesResource
s@AttributesResource' {} Text
a -> AttributesResource
s {$sel:attributeType:AttributesResource' :: Text
attributeType = Text
a} :: AttributesResource)

-- | The unique identifier for the application.
attributesResource_applicationId :: Lens.Lens' AttributesResource Prelude.Text
attributesResource_applicationId :: (Text -> f Text) -> AttributesResource -> f AttributesResource
attributesResource_applicationId = (AttributesResource -> Text)
-> (AttributesResource -> Text -> AttributesResource)
-> Lens AttributesResource AttributesResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributesResource' {Text
applicationId :: Text
$sel:applicationId:AttributesResource' :: AttributesResource -> Text
applicationId} -> Text
applicationId) (\s :: AttributesResource
s@AttributesResource' {} Text
a -> AttributesResource
s {$sel:applicationId:AttributesResource' :: Text
applicationId = Text
a} :: AttributesResource)

instance Core.FromJSON AttributesResource where
  parseJSON :: Value -> Parser AttributesResource
parseJSON =
    String
-> (Object -> Parser AttributesResource)
-> Value
-> Parser AttributesResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AttributesResource"
      ( \Object
x ->
          Maybe [Text] -> Text -> Text -> AttributesResource
AttributesResource'
            (Maybe [Text] -> Text -> Text -> AttributesResource)
-> Parser (Maybe [Text])
-> Parser (Text -> Text -> AttributesResource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Attributes" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> Text -> AttributesResource)
-> Parser Text -> Parser (Text -> AttributesResource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AttributeType")
            Parser (Text -> AttributesResource)
-> Parser Text -> Parser AttributesResource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ApplicationId")
      )

instance Prelude.Hashable AttributesResource

instance Prelude.NFData AttributesResource