{-# 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.UpdateAdmChannel
-- 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)
--
-- Enables the ADM channel for an application or updates the status and
-- settings of the ADM channel for an application.
module Amazonka.Pinpoint.UpdateAdmChannel
  ( -- * Creating a Request
    UpdateAdmChannel (..),
    newUpdateAdmChannel,

    -- * Request Lenses
    updateAdmChannel_applicationId,
    updateAdmChannel_aDMChannelRequest,

    -- * Destructuring the Response
    UpdateAdmChannelResponse (..),
    newUpdateAdmChannelResponse,

    -- * Response Lenses
    updateAdmChannelResponse_httpStatus,
    updateAdmChannelResponse_aDMChannelResponse,
  )
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:/ 'newUpdateAdmChannel' smart constructor.
data UpdateAdmChannel = UpdateAdmChannel'
  { -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    UpdateAdmChannel -> Text
applicationId :: Prelude.Text,
    UpdateAdmChannel -> ADMChannelRequest
aDMChannelRequest :: ADMChannelRequest
  }
  deriving (UpdateAdmChannel -> UpdateAdmChannel -> Bool
(UpdateAdmChannel -> UpdateAdmChannel -> Bool)
-> (UpdateAdmChannel -> UpdateAdmChannel -> Bool)
-> Eq UpdateAdmChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAdmChannel -> UpdateAdmChannel -> Bool
$c/= :: UpdateAdmChannel -> UpdateAdmChannel -> Bool
== :: UpdateAdmChannel -> UpdateAdmChannel -> Bool
$c== :: UpdateAdmChannel -> UpdateAdmChannel -> Bool
Prelude.Eq, ReadPrec [UpdateAdmChannel]
ReadPrec UpdateAdmChannel
Int -> ReadS UpdateAdmChannel
ReadS [UpdateAdmChannel]
(Int -> ReadS UpdateAdmChannel)
-> ReadS [UpdateAdmChannel]
-> ReadPrec UpdateAdmChannel
-> ReadPrec [UpdateAdmChannel]
-> Read UpdateAdmChannel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAdmChannel]
$creadListPrec :: ReadPrec [UpdateAdmChannel]
readPrec :: ReadPrec UpdateAdmChannel
$creadPrec :: ReadPrec UpdateAdmChannel
readList :: ReadS [UpdateAdmChannel]
$creadList :: ReadS [UpdateAdmChannel]
readsPrec :: Int -> ReadS UpdateAdmChannel
$creadsPrec :: Int -> ReadS UpdateAdmChannel
Prelude.Read, Int -> UpdateAdmChannel -> ShowS
[UpdateAdmChannel] -> ShowS
UpdateAdmChannel -> String
(Int -> UpdateAdmChannel -> ShowS)
-> (UpdateAdmChannel -> String)
-> ([UpdateAdmChannel] -> ShowS)
-> Show UpdateAdmChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAdmChannel] -> ShowS
$cshowList :: [UpdateAdmChannel] -> ShowS
show :: UpdateAdmChannel -> String
$cshow :: UpdateAdmChannel -> String
showsPrec :: Int -> UpdateAdmChannel -> ShowS
$cshowsPrec :: Int -> UpdateAdmChannel -> ShowS
Prelude.Show, (forall x. UpdateAdmChannel -> Rep UpdateAdmChannel x)
-> (forall x. Rep UpdateAdmChannel x -> UpdateAdmChannel)
-> Generic UpdateAdmChannel
forall x. Rep UpdateAdmChannel x -> UpdateAdmChannel
forall x. UpdateAdmChannel -> Rep UpdateAdmChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAdmChannel x -> UpdateAdmChannel
$cfrom :: forall x. UpdateAdmChannel -> Rep UpdateAdmChannel x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAdmChannel' 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', 'updateAdmChannel_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
--
-- 'aDMChannelRequest', 'updateAdmChannel_aDMChannelRequest' - Undocumented member.
newUpdateAdmChannel ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'aDMChannelRequest'
  ADMChannelRequest ->
  UpdateAdmChannel
newUpdateAdmChannel :: Text -> ADMChannelRequest -> UpdateAdmChannel
newUpdateAdmChannel
  Text
pApplicationId_
  ADMChannelRequest
pADMChannelRequest_ =
    UpdateAdmChannel' :: Text -> ADMChannelRequest -> UpdateAdmChannel
UpdateAdmChannel'
      { $sel:applicationId:UpdateAdmChannel' :: Text
applicationId = Text
pApplicationId_,
        $sel:aDMChannelRequest:UpdateAdmChannel' :: ADMChannelRequest
aDMChannelRequest = ADMChannelRequest
pADMChannelRequest_
      }

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

-- | Undocumented member.
updateAdmChannel_aDMChannelRequest :: Lens.Lens' UpdateAdmChannel ADMChannelRequest
updateAdmChannel_aDMChannelRequest :: (ADMChannelRequest -> f ADMChannelRequest)
-> UpdateAdmChannel -> f UpdateAdmChannel
updateAdmChannel_aDMChannelRequest = (UpdateAdmChannel -> ADMChannelRequest)
-> (UpdateAdmChannel -> ADMChannelRequest -> UpdateAdmChannel)
-> Lens
     UpdateAdmChannel
     UpdateAdmChannel
     ADMChannelRequest
     ADMChannelRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAdmChannel' {ADMChannelRequest
aDMChannelRequest :: ADMChannelRequest
$sel:aDMChannelRequest:UpdateAdmChannel' :: UpdateAdmChannel -> ADMChannelRequest
aDMChannelRequest} -> ADMChannelRequest
aDMChannelRequest) (\s :: UpdateAdmChannel
s@UpdateAdmChannel' {} ADMChannelRequest
a -> UpdateAdmChannel
s {$sel:aDMChannelRequest:UpdateAdmChannel' :: ADMChannelRequest
aDMChannelRequest = ADMChannelRequest
a} :: UpdateAdmChannel)

instance Core.AWSRequest UpdateAdmChannel where
  type
    AWSResponse UpdateAdmChannel =
      UpdateAdmChannelResponse
  request :: UpdateAdmChannel -> Request UpdateAdmChannel
request = Service -> UpdateAdmChannel -> Request UpdateAdmChannel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateAdmChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateAdmChannel)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateAdmChannel))
-> Logger
-> Service
-> Proxy UpdateAdmChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateAdmChannel)))
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 -> ADMChannelResponse -> UpdateAdmChannelResponse
UpdateAdmChannelResponse'
            (Int -> ADMChannelResponse -> UpdateAdmChannelResponse)
-> Either String Int
-> Either String (ADMChannelResponse -> UpdateAdmChannelResponse)
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 (ADMChannelResponse -> UpdateAdmChannelResponse)
-> Either String ADMChannelResponse
-> Either String UpdateAdmChannelResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String ADMChannelResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable UpdateAdmChannel

instance Prelude.NFData UpdateAdmChannel

instance Core.ToHeaders UpdateAdmChannel where
  toHeaders :: UpdateAdmChannel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateAdmChannel -> 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 UpdateAdmChannel where
  toJSON :: UpdateAdmChannel -> Value
toJSON UpdateAdmChannel' {Text
ADMChannelRequest
aDMChannelRequest :: ADMChannelRequest
applicationId :: Text
$sel:aDMChannelRequest:UpdateAdmChannel' :: UpdateAdmChannel -> ADMChannelRequest
$sel:applicationId:UpdateAdmChannel' :: UpdateAdmChannel -> 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
"ADMChannelRequest" Text -> ADMChannelRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ADMChannelRequest
aDMChannelRequest)
          ]
      )

instance Core.ToPath UpdateAdmChannel where
  toPath :: UpdateAdmChannel -> ByteString
toPath UpdateAdmChannel' {Text
ADMChannelRequest
aDMChannelRequest :: ADMChannelRequest
applicationId :: Text
$sel:aDMChannelRequest:UpdateAdmChannel' :: UpdateAdmChannel -> ADMChannelRequest
$sel:applicationId:UpdateAdmChannel' :: UpdateAdmChannel -> 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
"/channels/adm"
      ]

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

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

-- |
-- Create a value of 'UpdateAdmChannelResponse' 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', 'updateAdmChannelResponse_httpStatus' - The response's http status code.
--
-- 'aDMChannelResponse', 'updateAdmChannelResponse_aDMChannelResponse' - Undocumented member.
newUpdateAdmChannelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'aDMChannelResponse'
  ADMChannelResponse ->
  UpdateAdmChannelResponse
newUpdateAdmChannelResponse :: Int -> ADMChannelResponse -> UpdateAdmChannelResponse
newUpdateAdmChannelResponse
  Int
pHttpStatus_
  ADMChannelResponse
pADMChannelResponse_ =
    UpdateAdmChannelResponse' :: Int -> ADMChannelResponse -> UpdateAdmChannelResponse
UpdateAdmChannelResponse'
      { $sel:httpStatus:UpdateAdmChannelResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:aDMChannelResponse:UpdateAdmChannelResponse' :: ADMChannelResponse
aDMChannelResponse = ADMChannelResponse
pADMChannelResponse_
      }

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

-- | Undocumented member.
updateAdmChannelResponse_aDMChannelResponse :: Lens.Lens' UpdateAdmChannelResponse ADMChannelResponse
updateAdmChannelResponse_aDMChannelResponse :: (ADMChannelResponse -> f ADMChannelResponse)
-> UpdateAdmChannelResponse -> f UpdateAdmChannelResponse
updateAdmChannelResponse_aDMChannelResponse = (UpdateAdmChannelResponse -> ADMChannelResponse)
-> (UpdateAdmChannelResponse
    -> ADMChannelResponse -> UpdateAdmChannelResponse)
-> Lens
     UpdateAdmChannelResponse
     UpdateAdmChannelResponse
     ADMChannelResponse
     ADMChannelResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAdmChannelResponse' {ADMChannelResponse
aDMChannelResponse :: ADMChannelResponse
$sel:aDMChannelResponse:UpdateAdmChannelResponse' :: UpdateAdmChannelResponse -> ADMChannelResponse
aDMChannelResponse} -> ADMChannelResponse
aDMChannelResponse) (\s :: UpdateAdmChannelResponse
s@UpdateAdmChannelResponse' {} ADMChannelResponse
a -> UpdateAdmChannelResponse
s {$sel:aDMChannelResponse:UpdateAdmChannelResponse' :: ADMChannelResponse
aDMChannelResponse = ADMChannelResponse
a} :: UpdateAdmChannelResponse)

instance Prelude.NFData UpdateAdmChannelResponse