{-# 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetEndpointAttributes -> SetEndpointAttributes -> Bool
$c/= :: SetEndpointAttributes -> SetEndpointAttributes -> Bool
== :: SetEndpointAttributes -> SetEndpointAttributes -> Bool
$c== :: SetEndpointAttributes -> SetEndpointAttributes -> Bool
Prelude.Eq, ReadPrec [SetEndpointAttributes]
ReadPrec SetEndpointAttributes
Int -> ReadS SetEndpointAttributes
ReadS [SetEndpointAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetEndpointAttributes]
$creadListPrec :: ReadPrec [SetEndpointAttributes]
readPrec :: ReadPrec SetEndpointAttributes
$creadPrec :: ReadPrec SetEndpointAttributes
readList :: ReadS [SetEndpointAttributes]
$creadList :: ReadS [SetEndpointAttributes]
readsPrec :: Int -> ReadS SetEndpointAttributes
$creadsPrec :: Int -> ReadS SetEndpointAttributes
Prelude.Read, Int -> SetEndpointAttributes -> ShowS
[SetEndpointAttributes] -> ShowS
SetEndpointAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetEndpointAttributes] -> ShowS
$cshowList :: [SetEndpointAttributes] -> ShowS
show :: SetEndpointAttributes -> String
$cshow :: SetEndpointAttributes -> String
showsPrec :: Int -> SetEndpointAttributes -> ShowS
$cshowsPrec :: Int -> SetEndpointAttributes -> ShowS
Prelude.Show, 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
$cto :: forall x. Rep SetEndpointAttributes x -> SetEndpointAttributes
$cfrom :: forall x. SetEndpointAttributes -> Rep SetEndpointAttributes x
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'
    { $sel:endpointArn:SetEndpointAttributes' :: Text
endpointArn = Text
pEndpointArn_,
      $sel:attributes:SetEndpointAttributes' :: HashMap Text Text
attributes = 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 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetEndpointAttributes' {Text
endpointArn :: Text
$sel:endpointArn:SetEndpointAttributes' :: SetEndpointAttributes -> Text
endpointArn} -> Text
endpointArn) (\s :: SetEndpointAttributes
s@SetEndpointAttributes' {} Text
a -> SetEndpointAttributes
s {$sel:endpointArn:SetEndpointAttributes' :: Text
endpointArn = Text
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 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetEndpointAttributes' {HashMap Text Text
attributes :: HashMap Text Text
$sel:attributes:SetEndpointAttributes' :: SetEndpointAttributes -> HashMap Text Text
attributes} -> HashMap Text Text
attributes) (\s :: SetEndpointAttributes
s@SetEndpointAttributes' {} HashMap Text Text
a -> SetEndpointAttributes
s {$sel:attributes:SetEndpointAttributes' :: HashMap Text Text
attributes = HashMap Text Text
a} :: SetEndpointAttributes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest SetEndpointAttributes where
  type
    AWSResponse SetEndpointAttributes =
      SetEndpointAttributesResponse
  request :: (Service -> Service)
-> SetEndpointAttributes -> Request SetEndpointAttributes
request Service -> Service
overrides =
    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 =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull SetEndpointAttributesResponse
SetEndpointAttributesResponse'

instance Prelude.Hashable SetEndpointAttributes where
  hashWithSalt :: Int -> SetEndpointAttributes -> Int
hashWithSalt Int
_salt SetEndpointAttributes' {Text
HashMap Text Text
attributes :: HashMap Text Text
endpointArn :: Text
$sel:attributes:SetEndpointAttributes' :: SetEndpointAttributes -> HashMap Text Text
$sel:endpointArn:SetEndpointAttributes' :: SetEndpointAttributes -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
endpointArn
      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
attributes :: HashMap Text Text
endpointArn :: Text
$sel:attributes:SetEndpointAttributes' :: SetEndpointAttributes -> HashMap Text Text
$sel:endpointArn:SetEndpointAttributes' :: SetEndpointAttributes -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
endpointArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text Text
attributes

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

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

instance Data.ToQuery SetEndpointAttributes where
  toQuery :: SetEndpointAttributes -> QueryString
toQuery SetEndpointAttributes' {Text
HashMap Text Text
attributes :: HashMap Text Text
endpointArn :: Text
$sel:attributes:SetEndpointAttributes' :: SetEndpointAttributes -> HashMap Text Text
$sel:endpointArn:SetEndpointAttributes' :: SetEndpointAttributes -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"SetEndpointAttributes" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
        ByteString
"EndpointArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
endpointArn,
        ByteString
"Attributes"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetEndpointAttributesResponse
-> SetEndpointAttributesResponse -> Bool
$c/= :: SetEndpointAttributesResponse
-> SetEndpointAttributesResponse -> Bool
== :: SetEndpointAttributesResponse
-> SetEndpointAttributesResponse -> Bool
$c== :: SetEndpointAttributesResponse
-> SetEndpointAttributesResponse -> Bool
Prelude.Eq, ReadPrec [SetEndpointAttributesResponse]
ReadPrec SetEndpointAttributesResponse
Int -> ReadS SetEndpointAttributesResponse
ReadS [SetEndpointAttributesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetEndpointAttributesResponse]
$creadListPrec :: ReadPrec [SetEndpointAttributesResponse]
readPrec :: ReadPrec SetEndpointAttributesResponse
$creadPrec :: ReadPrec SetEndpointAttributesResponse
readList :: ReadS [SetEndpointAttributesResponse]
$creadList :: ReadS [SetEndpointAttributesResponse]
readsPrec :: Int -> ReadS SetEndpointAttributesResponse
$creadsPrec :: Int -> ReadS SetEndpointAttributesResponse
Prelude.Read, Int -> SetEndpointAttributesResponse -> ShowS
[SetEndpointAttributesResponse] -> ShowS
SetEndpointAttributesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetEndpointAttributesResponse] -> ShowS
$cshowList :: [SetEndpointAttributesResponse] -> ShowS
show :: SetEndpointAttributesResponse -> String
$cshow :: SetEndpointAttributesResponse -> String
showsPrec :: Int -> SetEndpointAttributesResponse -> ShowS
$cshowsPrec :: Int -> SetEndpointAttributesResponse -> ShowS
Prelude.Show, 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
$cto :: forall x.
Rep SetEndpointAttributesResponse x
-> SetEndpointAttributesResponse
$cfrom :: forall x.
SetEndpointAttributesResponse
-> Rep SetEndpointAttributesResponse x
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
_ = ()