{-# 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.GetChannels
-- 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)
--
-- Retrieves information about the history and status of each channel for
-- an application.
module Amazonka.Pinpoint.GetChannels
  ( -- * Creating a Request
    GetChannels (..),
    newGetChannels,

    -- * Request Lenses
    getChannels_applicationId,

    -- * Destructuring the Response
    GetChannelsResponse (..),
    newGetChannelsResponse,

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

-- |
-- Create a value of 'GetChannels' 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', 'getChannels_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
newGetChannels ::
  -- | 'applicationId'
  Prelude.Text ->
  GetChannels
newGetChannels :: Text -> GetChannels
newGetChannels Text
pApplicationId_ =
  GetChannels' :: Text -> GetChannels
GetChannels' {$sel:applicationId:GetChannels' :: Text
applicationId = Text
pApplicationId_}

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

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

instance Prelude.Hashable GetChannels

instance Prelude.NFData GetChannels

instance Core.ToHeaders GetChannels where
  toHeaders :: GetChannels -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetChannels -> 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.ToPath GetChannels where
  toPath :: GetChannels -> ByteString
toPath GetChannels' {Text
applicationId :: Text
$sel:applicationId:GetChannels' :: GetChannels -> 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"]

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

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

-- |
-- Create a value of 'GetChannelsResponse' 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', 'getChannelsResponse_httpStatus' - The response's http status code.
--
-- 'channelsResponse', 'getChannelsResponse_channelsResponse' - Undocumented member.
newGetChannelsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'channelsResponse'
  ChannelsResponse ->
  GetChannelsResponse
newGetChannelsResponse :: Int -> ChannelsResponse -> GetChannelsResponse
newGetChannelsResponse
  Int
pHttpStatus_
  ChannelsResponse
pChannelsResponse_ =
    GetChannelsResponse' :: Int -> ChannelsResponse -> GetChannelsResponse
GetChannelsResponse'
      { $sel:httpStatus:GetChannelsResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:channelsResponse:GetChannelsResponse' :: ChannelsResponse
channelsResponse = ChannelsResponse
pChannelsResponse_
      }

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

-- | Undocumented member.
getChannelsResponse_channelsResponse :: Lens.Lens' GetChannelsResponse ChannelsResponse
getChannelsResponse_channelsResponse :: (ChannelsResponse -> f ChannelsResponse)
-> GetChannelsResponse -> f GetChannelsResponse
getChannelsResponse_channelsResponse = (GetChannelsResponse -> ChannelsResponse)
-> (GetChannelsResponse -> ChannelsResponse -> GetChannelsResponse)
-> Lens
     GetChannelsResponse
     GetChannelsResponse
     ChannelsResponse
     ChannelsResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetChannelsResponse' {ChannelsResponse
channelsResponse :: ChannelsResponse
$sel:channelsResponse:GetChannelsResponse' :: GetChannelsResponse -> ChannelsResponse
channelsResponse} -> ChannelsResponse
channelsResponse) (\s :: GetChannelsResponse
s@GetChannelsResponse' {} ChannelsResponse
a -> GetChannelsResponse
s {$sel:channelsResponse:GetChannelsResponse' :: ChannelsResponse
channelsResponse = ChannelsResponse
a} :: GetChannelsResponse)

instance Prelude.NFData GetChannelsResponse