{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SNS.SetEndpointAttributes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Sets the attributes for an endpoint for a device on one of the supported
-- push notification services, such as GCM (Firebase Cloud Messaging) and
-- APNS. For more information, see
-- <https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html Using Amazon SNS Mobile Push Notifications>.
module Amazonka.SNS.SetEndpointAttributes
  ( -- * Creating a Request
    SetEndpointAttributes (..),
    newSetEndpointAttributes,

    -- * Request Lenses
    setEndpointAttributes_endpointArn,
    setEndpointAttributes_attributes,

    -- * Destructuring the Response
    SetEndpointAttributesResponse (..),
    newSetEndpointAttributesResponse,
  )
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SNS.Types

-- | Input for SetEndpointAttributes action.
--
-- /See:/ 'newSetEndpointAttributes' smart constructor.
data SetEndpointAttributes = SetEndpointAttributes'
  { -- | EndpointArn used for SetEndpointAttributes action.
    SetEndpointAttributes -> Text
endpointArn :: Prelude.Text,
    -- | A map of the endpoint attributes. Attributes in this map include the
    -- following:
    --
    -- -   @CustomUserData@ – arbitrary user data to associate with the
    --     endpoint. Amazon SNS does not use this data. The data must be in
    --     UTF-8 format and less than 2KB.
    --
    -- -   @Enabled@ – flag that enables\/disables delivery to the endpoint.
    --     Amazon SNS will set this to false when a notification service
    --     indicates to Amazon SNS that the endpoint is invalid. Users can set
    --     it back to true, typically after updating Token.
    --
    -- -   @Token@ – device token, also referred to as a registration id, for
    --     an app and mobile device. This is returned from the notification
    --     service when an app and mobile device are registered with the
    --     notification service.
    SetEndpointAttributes -> HashMap Text Text
attributes :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (SetEndpointAttributes -> SetEndpointAttributes -> Bool
(SetEndpointAttributes -> SetEndpointAttributes -> Bool)
-> (SetEndpointAttributes -> SetEndpointAttributes -> Bool)
-> Eq SetEndpointAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetEndpointAttributes -> SetEndpointAttributes -> Bool
== :: SetEndpointAttributes -> SetEndpointAttributes -> Bool
$c/= :: SetEndpointAttributes -> SetEndpointAttributes -> Bool
/= :: SetEndpointAttributes -> SetEndpointAttributes -> Bool
Prelude.Eq, ReadPrec [SetEndpointAttributes]
ReadPrec SetEndpointAttributes
Int -> ReadS SetEndpointAttributes
ReadS [SetEndpointAttributes]
(Int -> ReadS SetEndpointAttributes)
-> ReadS [SetEndpointAttributes]
-> ReadPrec SetEndpointAttributes
-> ReadPrec [SetEndpointAttributes]
-> Read SetEndpointAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS SetEndpointAttributes
readsPrec :: Int -> ReadS SetEndpointAttributes
$creadList :: ReadS [SetEndpointAttributes]
readList :: ReadS [SetEndpointAttributes]
$creadPrec :: ReadPrec SetEndpointAttributes
readPrec :: ReadPrec SetEndpointAttributes
$creadListPrec :: ReadPrec [SetEndpointAttributes]
readListPrec :: ReadPrec [SetEndpointAttributes]
Prelude.Read, Int -> SetEndpointAttributes -> ShowS
[SetEndpointAttributes] -> ShowS
SetEndpointAttributes -> String
(Int -> SetEndpointAttributes -> ShowS)
-> (SetEndpointAttributes -> String)
-> ([SetEndpointAttributes] -> ShowS)
-> Show SetEndpointAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetEndpointAttributes -> ShowS
showsPrec :: Int -> SetEndpointAttributes -> ShowS
$cshow :: SetEndpointAttributes -> String
show :: SetEndpointAttributes -> String
$cshowList :: [SetEndpointAttributes] -> ShowS
showList :: [SetEndpointAttributes] -> ShowS
Prelude.Show, (forall x. SetEndpointAttributes -> Rep SetEndpointAttributes x)
-> (forall x. Rep SetEndpointAttributes x -> SetEndpointAttributes)
-> Generic SetEndpointAttributes
forall x. Rep SetEndpointAttributes x -> SetEndpointAttributes
forall x. SetEndpointAttributes -> Rep SetEndpointAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SetEndpointAttributes -> Rep SetEndpointAttributes x
from :: forall x. SetEndpointAttributes -> Rep SetEndpointAttributes x
$cto :: forall x. Rep SetEndpointAttributes x -> SetEndpointAttributes
to :: forall x. Rep SetEndpointAttributes x -> SetEndpointAttributes
Prelude.Generic)

-- |
-- Create a value of 'SetEndpointAttributes' 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:
--
-- 'endpointArn', 'setEndpointAttributes_endpointArn' - EndpointArn used for SetEndpointAttributes action.
--
-- 'attributes', 'setEndpointAttributes_attributes' - A map of the endpoint attributes. Attributes in this map include the
-- following:
--
-- -   @CustomUserData@ – arbitrary user data to associate with the
--     endpoint. Amazon SNS does not use this data. The data must be in
--     UTF-8 format and less than 2KB.
--
-- -   @Enabled@ – flag that enables\/disables delivery to the endpoint.
--     Amazon SNS will set this to false when a notification service
--     indicates to Amazon SNS that the endpoint is invalid. Users can set
--     it back to true, typically after updating Token.
--
-- -   @Token@ – device token, also referred to as a registration id, for
--     an app and mobile device. This is returned from the notification
--     service when an app and mobile device are registered with the
--     notification service.
newSetEndpointAttributes ::
  -- | 'endpointArn'
  Prelude.Text ->
  SetEndpointAttributes
newSetEndpointAttributes :: Text -> SetEndpointAttributes
newSetEndpointAttributes Text
pEndpointArn_ =
  SetEndpointAttributes'
    { endpointArn :: Text
endpointArn = Text
pEndpointArn_,
      attributes :: HashMap Text Text
attributes = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
    }

-- | EndpointArn used for SetEndpointAttributes action.
setEndpointAttributes_endpointArn :: Lens.Lens' SetEndpointAttributes Prelude.Text
setEndpointAttributes_endpointArn :: Lens' SetEndpointAttributes Text
setEndpointAttributes_endpointArn = (SetEndpointAttributes -> Text)
-> (SetEndpointAttributes -> Text -> SetEndpointAttributes)
-> Lens' SetEndpointAttributes Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetEndpointAttributes' {Text
endpointArn :: SetEndpointAttributes -> Text
endpointArn :: Text
endpointArn} -> Text
endpointArn) (\s :: SetEndpointAttributes
s@SetEndpointAttributes' {} Text
a -> SetEndpointAttributes
s {endpointArn = a} :: SetEndpointAttributes)

-- | A map of the endpoint attributes. Attributes in this map include the
-- following:
--
-- -   @CustomUserData@ – arbitrary user data to associate with the
--     endpoint. Amazon SNS does not use this data. The data must be in
--     UTF-8 format and less than 2KB.
--
-- -   @Enabled@ – flag that enables\/disables delivery to the endpoint.
--     Amazon SNS will set this to false when a notification service
--     indicates to Amazon SNS that the endpoint is invalid. Users can set
--     it back to true, typically after updating Token.
--
-- -   @Token@ – device token, also referred to as a registration id, for
--     an app and mobile device. This is returned from the notification
--     service when an app and mobile device are registered with the
--     notification service.
setEndpointAttributes_attributes :: Lens.Lens' SetEndpointAttributes (Prelude.HashMap Prelude.Text Prelude.Text)
setEndpointAttributes_attributes :: Lens' SetEndpointAttributes (HashMap Text Text)
setEndpointAttributes_attributes = (SetEndpointAttributes -> HashMap Text Text)
-> (SetEndpointAttributes
    -> HashMap Text Text -> SetEndpointAttributes)
-> Lens' SetEndpointAttributes (HashMap Text Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetEndpointAttributes' {HashMap Text Text
attributes :: SetEndpointAttributes -> HashMap Text Text
attributes :: HashMap Text Text
attributes} -> HashMap Text Text
attributes) (\s :: SetEndpointAttributes
s@SetEndpointAttributes' {} HashMap Text Text
a -> SetEndpointAttributes
s {attributes = a} :: SetEndpointAttributes) ((HashMap Text Text -> f (HashMap Text Text))
 -> SetEndpointAttributes -> f SetEndpointAttributes)
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> SetEndpointAttributes
-> f SetEndpointAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Iso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
Lens.coerced

instance Core.AWSRequest SetEndpointAttributes where
  type
    AWSResponse SetEndpointAttributes =
      SetEndpointAttributesResponse
  request :: (Service -> Service)
-> SetEndpointAttributes -> Request SetEndpointAttributes
request Service -> Service
overrides =
    Service -> SetEndpointAttributes -> Request SetEndpointAttributes
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy SetEndpointAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetEndpointAttributes)))
response =
    AWSResponse SetEndpointAttributes
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy SetEndpointAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetEndpointAttributes)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse SetEndpointAttributes
SetEndpointAttributesResponse
SetEndpointAttributesResponse'

instance Prelude.Hashable SetEndpointAttributes where
  hashWithSalt :: Int -> SetEndpointAttributes -> Int
hashWithSalt Int
_salt SetEndpointAttributes' {Text
HashMap Text Text
endpointArn :: SetEndpointAttributes -> Text
attributes :: SetEndpointAttributes -> HashMap Text Text
endpointArn :: Text
attributes :: HashMap Text Text
..} =
    Int
_salt
      Int -> Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
endpointArn
      Int -> HashMap Text Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text Text
attributes

instance Prelude.NFData SetEndpointAttributes where
  rnf :: SetEndpointAttributes -> ()
rnf SetEndpointAttributes' {Text
HashMap Text Text
endpointArn :: SetEndpointAttributes -> Text
attributes :: SetEndpointAttributes -> HashMap Text Text
endpointArn :: Text
attributes :: HashMap Text Text
..} =
    Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Text
endpointArn () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq`
      HashMap Text Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf HashMap Text Text
attributes

instance Data.ToHeaders SetEndpointAttributes where
  toHeaders :: SetEndpointAttributes -> [Header]
toHeaders = [Header] -> SetEndpointAttributes -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath SetEndpointAttributes where
  toPath :: SetEndpointAttributes -> ByteString
toPath = ByteString -> SetEndpointAttributes -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery SetEndpointAttributes where
  toQuery :: SetEndpointAttributes -> QueryString
toQuery SetEndpointAttributes' {Text
HashMap Text Text
endpointArn :: SetEndpointAttributes -> Text
attributes :: SetEndpointAttributes -> HashMap Text Text
endpointArn :: Text
attributes :: HashMap Text Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"SetEndpointAttributes" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
        ByteString
"EndpointArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
endpointArn,
        ByteString
"Attributes"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ByteString
-> ByteString -> ByteString -> HashMap Text Text -> QueryString
forall k v.
(ToQuery k, ToQuery v) =>
ByteString
-> ByteString -> ByteString -> HashMap k v -> QueryString
Data.toQueryMap ByteString
"entry" ByteString
"key" ByteString
"value" HashMap Text Text
attributes
      ]

-- | /See:/ 'newSetEndpointAttributesResponse' smart constructor.
data SetEndpointAttributesResponse = SetEndpointAttributesResponse'
  {
  }
  deriving (SetEndpointAttributesResponse
-> SetEndpointAttributesResponse -> Bool
(SetEndpointAttributesResponse
 -> SetEndpointAttributesResponse -> Bool)
-> (SetEndpointAttributesResponse
    -> SetEndpointAttributesResponse -> Bool)
-> Eq SetEndpointAttributesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetEndpointAttributesResponse
-> SetEndpointAttributesResponse -> Bool
== :: SetEndpointAttributesResponse
-> SetEndpointAttributesResponse -> Bool
$c/= :: SetEndpointAttributesResponse
-> SetEndpointAttributesResponse -> Bool
/= :: SetEndpointAttributesResponse
-> SetEndpointAttributesResponse -> Bool
Prelude.Eq, ReadPrec [SetEndpointAttributesResponse]
ReadPrec SetEndpointAttributesResponse
Int -> ReadS SetEndpointAttributesResponse
ReadS [SetEndpointAttributesResponse]
(Int -> ReadS SetEndpointAttributesResponse)
-> ReadS [SetEndpointAttributesResponse]
-> ReadPrec SetEndpointAttributesResponse
-> ReadPrec [SetEndpointAttributesResponse]
-> Read SetEndpointAttributesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS SetEndpointAttributesResponse
readsPrec :: Int -> ReadS SetEndpointAttributesResponse
$creadList :: ReadS [SetEndpointAttributesResponse]
readList :: ReadS [SetEndpointAttributesResponse]
$creadPrec :: ReadPrec SetEndpointAttributesResponse
readPrec :: ReadPrec SetEndpointAttributesResponse
$creadListPrec :: ReadPrec [SetEndpointAttributesResponse]
readListPrec :: ReadPrec [SetEndpointAttributesResponse]
Prelude.Read, Int -> SetEndpointAttributesResponse -> ShowS
[SetEndpointAttributesResponse] -> ShowS
SetEndpointAttributesResponse -> String
(Int -> SetEndpointAttributesResponse -> ShowS)
-> (SetEndpointAttributesResponse -> String)
-> ([SetEndpointAttributesResponse] -> ShowS)
-> Show SetEndpointAttributesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetEndpointAttributesResponse -> ShowS
showsPrec :: Int -> SetEndpointAttributesResponse -> ShowS
$cshow :: SetEndpointAttributesResponse -> String
show :: SetEndpointAttributesResponse -> String
$cshowList :: [SetEndpointAttributesResponse] -> ShowS
showList :: [SetEndpointAttributesResponse] -> ShowS
Prelude.Show, (forall x.
 SetEndpointAttributesResponse
 -> Rep SetEndpointAttributesResponse x)
-> (forall x.
    Rep SetEndpointAttributesResponse x
    -> SetEndpointAttributesResponse)
-> Generic SetEndpointAttributesResponse
forall x.
Rep SetEndpointAttributesResponse x
-> SetEndpointAttributesResponse
forall x.
SetEndpointAttributesResponse
-> Rep SetEndpointAttributesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
SetEndpointAttributesResponse
-> Rep SetEndpointAttributesResponse x
from :: forall x.
SetEndpointAttributesResponse
-> Rep SetEndpointAttributesResponse x
$cto :: forall x.
Rep SetEndpointAttributesResponse x
-> SetEndpointAttributesResponse
to :: forall x.
Rep SetEndpointAttributesResponse x
-> SetEndpointAttributesResponse
Prelude.Generic)

-- |
-- Create a value of 'SetEndpointAttributesResponse' 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.
newSetEndpointAttributesResponse ::
  SetEndpointAttributesResponse
newSetEndpointAttributesResponse :: SetEndpointAttributesResponse
newSetEndpointAttributesResponse =
  SetEndpointAttributesResponse
SetEndpointAttributesResponse'

instance Prelude.NFData SetEndpointAttributesResponse where
  rnf :: SetEndpointAttributesResponse -> ()
rnf SetEndpointAttributesResponse
_ = ()