{-# 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-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)
--
-- 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.Lens as Lens
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
/= :: 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]
(Int -> ReadS SetEndpointAttributes)
-> ReadS [SetEndpointAttributes]
-> ReadPrec SetEndpointAttributes
-> ReadPrec [SetEndpointAttributes]
-> Read 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
(Int -> SetEndpointAttributes -> ShowS)
-> (SetEndpointAttributes -> String)
-> ([SetEndpointAttributes] -> ShowS)
-> Show SetEndpointAttributes
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. 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
$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' :: Text -> HashMap Text Text -> SetEndpointAttributes
SetEndpointAttributes'
    { $sel:endpointArn:SetEndpointAttributes' :: Text
endpointArn = Text
pEndpointArn_,
      $sel:attributes:SetEndpointAttributes' :: 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 :: (Text -> f Text)
-> SetEndpointAttributes -> f SetEndpointAttributes
setEndpointAttributes_endpointArn = (SetEndpointAttributes -> Text)
-> (SetEndpointAttributes -> Text -> SetEndpointAttributes)
-> Lens SetEndpointAttributes SetEndpointAttributes Text Text
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 :: (HashMap Text Text -> f (HashMap Text Text))
-> SetEndpointAttributes -> f SetEndpointAttributes
setEndpointAttributes_attributes = (SetEndpointAttributes -> HashMap Text Text)
-> (SetEndpointAttributes
    -> HashMap Text Text -> SetEndpointAttributes)
-> Lens
     SetEndpointAttributes
     SetEndpointAttributes
     (HashMap Text Text)
     (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 :: 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) ((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
Lens.coerced

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

instance Prelude.Hashable SetEndpointAttributes

instance Prelude.NFData SetEndpointAttributes

instance Core.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 Core.ToPath SetEndpointAttributes where
  toPath :: SetEndpointAttributes -> ByteString
toPath = ByteString -> SetEndpointAttributes -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"SetEndpointAttributes" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
        ByteString
"EndpointArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
endpointArn,
        ByteString
"Attributes"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString
-> ByteString -> ByteString -> HashMap Text Text -> QueryString
forall k v.
(ToQuery k, ToQuery v) =>
ByteString
-> ByteString -> ByteString -> HashMap k v -> QueryString
Core.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
/= :: 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]
(Int -> ReadS SetEndpointAttributesResponse)
-> ReadS [SetEndpointAttributesResponse]
-> ReadPrec SetEndpointAttributesResponse
-> ReadPrec [SetEndpointAttributesResponse]
-> Read 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
(Int -> SetEndpointAttributesResponse -> ShowS)
-> (SetEndpointAttributesResponse -> String)
-> ([SetEndpointAttributesResponse] -> ShowS)
-> Show SetEndpointAttributesResponse
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.
 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
$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