{-# 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.Pinpoint.UpdateApplicationSettings
-- 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)
--
-- Updates the settings for an application.
module Amazonka.Pinpoint.UpdateApplicationSettings
  ( -- * Creating a Request
    UpdateApplicationSettings (..),
    newUpdateApplicationSettings,

    -- * Request Lenses
    updateApplicationSettings_applicationId,
    updateApplicationSettings_writeApplicationSettingsRequest,

    -- * Destructuring the Response
    UpdateApplicationSettingsResponse (..),
    newUpdateApplicationSettingsResponse,

    -- * Response Lenses
    updateApplicationSettingsResponse_httpStatus,
    updateApplicationSettingsResponse_applicationSettingsResource,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateApplicationSettings' smart constructor.
data UpdateApplicationSettings = UpdateApplicationSettings'
  { -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    UpdateApplicationSettings -> Text
applicationId :: Prelude.Text,
    UpdateApplicationSettings -> WriteApplicationSettingsRequest
writeApplicationSettingsRequest :: WriteApplicationSettingsRequest
  }
  deriving (UpdateApplicationSettings -> UpdateApplicationSettings -> Bool
(UpdateApplicationSettings -> UpdateApplicationSettings -> Bool)
-> (UpdateApplicationSettings -> UpdateApplicationSettings -> Bool)
-> Eq UpdateApplicationSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateApplicationSettings -> UpdateApplicationSettings -> Bool
$c/= :: UpdateApplicationSettings -> UpdateApplicationSettings -> Bool
== :: UpdateApplicationSettings -> UpdateApplicationSettings -> Bool
$c== :: UpdateApplicationSettings -> UpdateApplicationSettings -> Bool
Prelude.Eq, ReadPrec [UpdateApplicationSettings]
ReadPrec UpdateApplicationSettings
Int -> ReadS UpdateApplicationSettings
ReadS [UpdateApplicationSettings]
(Int -> ReadS UpdateApplicationSettings)
-> ReadS [UpdateApplicationSettings]
-> ReadPrec UpdateApplicationSettings
-> ReadPrec [UpdateApplicationSettings]
-> Read UpdateApplicationSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateApplicationSettings]
$creadListPrec :: ReadPrec [UpdateApplicationSettings]
readPrec :: ReadPrec UpdateApplicationSettings
$creadPrec :: ReadPrec UpdateApplicationSettings
readList :: ReadS [UpdateApplicationSettings]
$creadList :: ReadS [UpdateApplicationSettings]
readsPrec :: Int -> ReadS UpdateApplicationSettings
$creadsPrec :: Int -> ReadS UpdateApplicationSettings
Prelude.Read, Int -> UpdateApplicationSettings -> ShowS
[UpdateApplicationSettings] -> ShowS
UpdateApplicationSettings -> String
(Int -> UpdateApplicationSettings -> ShowS)
-> (UpdateApplicationSettings -> String)
-> ([UpdateApplicationSettings] -> ShowS)
-> Show UpdateApplicationSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateApplicationSettings] -> ShowS
$cshowList :: [UpdateApplicationSettings] -> ShowS
show :: UpdateApplicationSettings -> String
$cshow :: UpdateApplicationSettings -> String
showsPrec :: Int -> UpdateApplicationSettings -> ShowS
$cshowsPrec :: Int -> UpdateApplicationSettings -> ShowS
Prelude.Show, (forall x.
 UpdateApplicationSettings -> Rep UpdateApplicationSettings x)
-> (forall x.
    Rep UpdateApplicationSettings x -> UpdateApplicationSettings)
-> Generic UpdateApplicationSettings
forall x.
Rep UpdateApplicationSettings x -> UpdateApplicationSettings
forall x.
UpdateApplicationSettings -> Rep UpdateApplicationSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateApplicationSettings x -> UpdateApplicationSettings
$cfrom :: forall x.
UpdateApplicationSettings -> Rep UpdateApplicationSettings x
Prelude.Generic)

-- |
-- Create a value of 'UpdateApplicationSettings' 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:
--
-- 'applicationId', 'updateApplicationSettings_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
--
-- 'writeApplicationSettingsRequest', 'updateApplicationSettings_writeApplicationSettingsRequest' - Undocumented member.
newUpdateApplicationSettings ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'writeApplicationSettingsRequest'
  WriteApplicationSettingsRequest ->
  UpdateApplicationSettings
newUpdateApplicationSettings :: Text
-> WriteApplicationSettingsRequest -> UpdateApplicationSettings
newUpdateApplicationSettings
  Text
pApplicationId_
  WriteApplicationSettingsRequest
pWriteApplicationSettingsRequest_ =
    UpdateApplicationSettings' :: Text
-> WriteApplicationSettingsRequest -> UpdateApplicationSettings
UpdateApplicationSettings'
      { $sel:applicationId:UpdateApplicationSettings' :: Text
applicationId =
          Text
pApplicationId_,
        $sel:writeApplicationSettingsRequest:UpdateApplicationSettings' :: WriteApplicationSettingsRequest
writeApplicationSettingsRequest =
          WriteApplicationSettingsRequest
pWriteApplicationSettingsRequest_
      }

-- | The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
updateApplicationSettings_applicationId :: Lens.Lens' UpdateApplicationSettings Prelude.Text
updateApplicationSettings_applicationId :: (Text -> f Text)
-> UpdateApplicationSettings -> f UpdateApplicationSettings
updateApplicationSettings_applicationId = (UpdateApplicationSettings -> Text)
-> (UpdateApplicationSettings -> Text -> UpdateApplicationSettings)
-> Lens
     UpdateApplicationSettings UpdateApplicationSettings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApplicationSettings' {Text
applicationId :: Text
$sel:applicationId:UpdateApplicationSettings' :: UpdateApplicationSettings -> Text
applicationId} -> Text
applicationId) (\s :: UpdateApplicationSettings
s@UpdateApplicationSettings' {} Text
a -> UpdateApplicationSettings
s {$sel:applicationId:UpdateApplicationSettings' :: Text
applicationId = Text
a} :: UpdateApplicationSettings)

-- | Undocumented member.
updateApplicationSettings_writeApplicationSettingsRequest :: Lens.Lens' UpdateApplicationSettings WriteApplicationSettingsRequest
updateApplicationSettings_writeApplicationSettingsRequest :: (WriteApplicationSettingsRequest
 -> f WriteApplicationSettingsRequest)
-> UpdateApplicationSettings -> f UpdateApplicationSettings
updateApplicationSettings_writeApplicationSettingsRequest = (UpdateApplicationSettings -> WriteApplicationSettingsRequest)
-> (UpdateApplicationSettings
    -> WriteApplicationSettingsRequest -> UpdateApplicationSettings)
-> Lens
     UpdateApplicationSettings
     UpdateApplicationSettings
     WriteApplicationSettingsRequest
     WriteApplicationSettingsRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApplicationSettings' {WriteApplicationSettingsRequest
writeApplicationSettingsRequest :: WriteApplicationSettingsRequest
$sel:writeApplicationSettingsRequest:UpdateApplicationSettings' :: UpdateApplicationSettings -> WriteApplicationSettingsRequest
writeApplicationSettingsRequest} -> WriteApplicationSettingsRequest
writeApplicationSettingsRequest) (\s :: UpdateApplicationSettings
s@UpdateApplicationSettings' {} WriteApplicationSettingsRequest
a -> UpdateApplicationSettings
s {$sel:writeApplicationSettingsRequest:UpdateApplicationSettings' :: WriteApplicationSettingsRequest
writeApplicationSettingsRequest = WriteApplicationSettingsRequest
a} :: UpdateApplicationSettings)

instance Core.AWSRequest UpdateApplicationSettings where
  type
    AWSResponse UpdateApplicationSettings =
      UpdateApplicationSettingsResponse
  request :: UpdateApplicationSettings -> Request UpdateApplicationSettings
request = Service
-> UpdateApplicationSettings -> Request UpdateApplicationSettings
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateApplicationSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateApplicationSettings)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateApplicationSettings))
-> Logger
-> Service
-> Proxy UpdateApplicationSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateApplicationSettings)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int
-> ApplicationSettingsResource -> UpdateApplicationSettingsResponse
UpdateApplicationSettingsResponse'
            (Int
 -> ApplicationSettingsResource
 -> UpdateApplicationSettingsResponse)
-> Either String Int
-> Either
     String
     (ApplicationSettingsResource -> UpdateApplicationSettingsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either
  String
  (ApplicationSettingsResource -> UpdateApplicationSettingsResponse)
-> Either String ApplicationSettingsResource
-> Either String UpdateApplicationSettingsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String ApplicationSettingsResource
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable UpdateApplicationSettings

instance Prelude.NFData UpdateApplicationSettings

instance Core.ToHeaders UpdateApplicationSettings where
  toHeaders :: UpdateApplicationSettings -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateApplicationSettings -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateApplicationSettings where
  toJSON :: UpdateApplicationSettings -> Value
toJSON UpdateApplicationSettings' {Text
WriteApplicationSettingsRequest
writeApplicationSettingsRequest :: WriteApplicationSettingsRequest
applicationId :: Text
$sel:writeApplicationSettingsRequest:UpdateApplicationSettings' :: UpdateApplicationSettings -> WriteApplicationSettingsRequest
$sel:applicationId:UpdateApplicationSettings' :: UpdateApplicationSettings -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"WriteApplicationSettingsRequest"
                  Text -> WriteApplicationSettingsRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= WriteApplicationSettingsRequest
writeApplicationSettingsRequest
              )
          ]
      )

instance Core.ToPath UpdateApplicationSettings where
  toPath :: UpdateApplicationSettings -> ByteString
toPath UpdateApplicationSettings' {Text
WriteApplicationSettingsRequest
writeApplicationSettingsRequest :: WriteApplicationSettingsRequest
applicationId :: Text
$sel:writeApplicationSettingsRequest:UpdateApplicationSettings' :: UpdateApplicationSettings -> WriteApplicationSettingsRequest
$sel:applicationId:UpdateApplicationSettings' :: UpdateApplicationSettings -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/apps/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId, ByteString
"/settings"]

instance Core.ToQuery UpdateApplicationSettings where
  toQuery :: UpdateApplicationSettings -> QueryString
toQuery = QueryString -> UpdateApplicationSettings -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateApplicationSettingsResponse' smart constructor.
data UpdateApplicationSettingsResponse = UpdateApplicationSettingsResponse'
  { -- | The response's http status code.
    UpdateApplicationSettingsResponse -> Int
httpStatus :: Prelude.Int,
    UpdateApplicationSettingsResponse -> ApplicationSettingsResource
applicationSettingsResource :: ApplicationSettingsResource
  }
  deriving (UpdateApplicationSettingsResponse
-> UpdateApplicationSettingsResponse -> Bool
(UpdateApplicationSettingsResponse
 -> UpdateApplicationSettingsResponse -> Bool)
-> (UpdateApplicationSettingsResponse
    -> UpdateApplicationSettingsResponse -> Bool)
-> Eq UpdateApplicationSettingsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateApplicationSettingsResponse
-> UpdateApplicationSettingsResponse -> Bool
$c/= :: UpdateApplicationSettingsResponse
-> UpdateApplicationSettingsResponse -> Bool
== :: UpdateApplicationSettingsResponse
-> UpdateApplicationSettingsResponse -> Bool
$c== :: UpdateApplicationSettingsResponse
-> UpdateApplicationSettingsResponse -> Bool
Prelude.Eq, ReadPrec [UpdateApplicationSettingsResponse]
ReadPrec UpdateApplicationSettingsResponse
Int -> ReadS UpdateApplicationSettingsResponse
ReadS [UpdateApplicationSettingsResponse]
(Int -> ReadS UpdateApplicationSettingsResponse)
-> ReadS [UpdateApplicationSettingsResponse]
-> ReadPrec UpdateApplicationSettingsResponse
-> ReadPrec [UpdateApplicationSettingsResponse]
-> Read UpdateApplicationSettingsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateApplicationSettingsResponse]
$creadListPrec :: ReadPrec [UpdateApplicationSettingsResponse]
readPrec :: ReadPrec UpdateApplicationSettingsResponse
$creadPrec :: ReadPrec UpdateApplicationSettingsResponse
readList :: ReadS [UpdateApplicationSettingsResponse]
$creadList :: ReadS [UpdateApplicationSettingsResponse]
readsPrec :: Int -> ReadS UpdateApplicationSettingsResponse
$creadsPrec :: Int -> ReadS UpdateApplicationSettingsResponse
Prelude.Read, Int -> UpdateApplicationSettingsResponse -> ShowS
[UpdateApplicationSettingsResponse] -> ShowS
UpdateApplicationSettingsResponse -> String
(Int -> UpdateApplicationSettingsResponse -> ShowS)
-> (UpdateApplicationSettingsResponse -> String)
-> ([UpdateApplicationSettingsResponse] -> ShowS)
-> Show UpdateApplicationSettingsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateApplicationSettingsResponse] -> ShowS
$cshowList :: [UpdateApplicationSettingsResponse] -> ShowS
show :: UpdateApplicationSettingsResponse -> String
$cshow :: UpdateApplicationSettingsResponse -> String
showsPrec :: Int -> UpdateApplicationSettingsResponse -> ShowS
$cshowsPrec :: Int -> UpdateApplicationSettingsResponse -> ShowS
Prelude.Show, (forall x.
 UpdateApplicationSettingsResponse
 -> Rep UpdateApplicationSettingsResponse x)
-> (forall x.
    Rep UpdateApplicationSettingsResponse x
    -> UpdateApplicationSettingsResponse)
-> Generic UpdateApplicationSettingsResponse
forall x.
Rep UpdateApplicationSettingsResponse x
-> UpdateApplicationSettingsResponse
forall x.
UpdateApplicationSettingsResponse
-> Rep UpdateApplicationSettingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateApplicationSettingsResponse x
-> UpdateApplicationSettingsResponse
$cfrom :: forall x.
UpdateApplicationSettingsResponse
-> Rep UpdateApplicationSettingsResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateApplicationSettingsResponse' 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:
--
-- 'httpStatus', 'updateApplicationSettingsResponse_httpStatus' - The response's http status code.
--
-- 'applicationSettingsResource', 'updateApplicationSettingsResponse_applicationSettingsResource' - Undocumented member.
newUpdateApplicationSettingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'applicationSettingsResource'
  ApplicationSettingsResource ->
  UpdateApplicationSettingsResponse
newUpdateApplicationSettingsResponse :: Int
-> ApplicationSettingsResource -> UpdateApplicationSettingsResponse
newUpdateApplicationSettingsResponse
  Int
pHttpStatus_
  ApplicationSettingsResource
pApplicationSettingsResource_ =
    UpdateApplicationSettingsResponse' :: Int
-> ApplicationSettingsResource -> UpdateApplicationSettingsResponse
UpdateApplicationSettingsResponse'
      { $sel:httpStatus:UpdateApplicationSettingsResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:applicationSettingsResource:UpdateApplicationSettingsResponse' :: ApplicationSettingsResource
applicationSettingsResource =
          ApplicationSettingsResource
pApplicationSettingsResource_
      }

-- | The response's http status code.
updateApplicationSettingsResponse_httpStatus :: Lens.Lens' UpdateApplicationSettingsResponse Prelude.Int
updateApplicationSettingsResponse_httpStatus :: (Int -> f Int)
-> UpdateApplicationSettingsResponse
-> f UpdateApplicationSettingsResponse
updateApplicationSettingsResponse_httpStatus = (UpdateApplicationSettingsResponse -> Int)
-> (UpdateApplicationSettingsResponse
    -> Int -> UpdateApplicationSettingsResponse)
-> Lens
     UpdateApplicationSettingsResponse
     UpdateApplicationSettingsResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApplicationSettingsResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateApplicationSettingsResponse' :: UpdateApplicationSettingsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateApplicationSettingsResponse
s@UpdateApplicationSettingsResponse' {} Int
a -> UpdateApplicationSettingsResponse
s {$sel:httpStatus:UpdateApplicationSettingsResponse' :: Int
httpStatus = Int
a} :: UpdateApplicationSettingsResponse)

-- | Undocumented member.
updateApplicationSettingsResponse_applicationSettingsResource :: Lens.Lens' UpdateApplicationSettingsResponse ApplicationSettingsResource
updateApplicationSettingsResponse_applicationSettingsResource :: (ApplicationSettingsResource -> f ApplicationSettingsResource)
-> UpdateApplicationSettingsResponse
-> f UpdateApplicationSettingsResponse
updateApplicationSettingsResponse_applicationSettingsResource = (UpdateApplicationSettingsResponse -> ApplicationSettingsResource)
-> (UpdateApplicationSettingsResponse
    -> ApplicationSettingsResource
    -> UpdateApplicationSettingsResponse)
-> Lens
     UpdateApplicationSettingsResponse
     UpdateApplicationSettingsResponse
     ApplicationSettingsResource
     ApplicationSettingsResource
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApplicationSettingsResponse' {ApplicationSettingsResource
applicationSettingsResource :: ApplicationSettingsResource
$sel:applicationSettingsResource:UpdateApplicationSettingsResponse' :: UpdateApplicationSettingsResponse -> ApplicationSettingsResource
applicationSettingsResource} -> ApplicationSettingsResource
applicationSettingsResource) (\s :: UpdateApplicationSettingsResponse
s@UpdateApplicationSettingsResponse' {} ApplicationSettingsResource
a -> UpdateApplicationSettingsResponse
s {$sel:applicationSettingsResource:UpdateApplicationSettingsResponse' :: ApplicationSettingsResource
applicationSettingsResource = ApplicationSettingsResource
a} :: UpdateApplicationSettingsResponse)

instance
  Prelude.NFData
    UpdateApplicationSettingsResponse