{-# 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.GetUserEndpoints
-- 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 all the endpoints that are associated with a
-- specific user ID.
module Amazonka.Pinpoint.GetUserEndpoints
  ( -- * Creating a Request
    GetUserEndpoints (..),
    newGetUserEndpoints,

    -- * Request Lenses
    getUserEndpoints_applicationId,
    getUserEndpoints_userId,

    -- * Destructuring the Response
    GetUserEndpointsResponse (..),
    newGetUserEndpointsResponse,

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

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

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

-- | The unique identifier for the user.
getUserEndpoints_userId :: Lens.Lens' GetUserEndpoints Prelude.Text
getUserEndpoints_userId :: (Text -> f Text) -> GetUserEndpoints -> f GetUserEndpoints
getUserEndpoints_userId = (GetUserEndpoints -> Text)
-> (GetUserEndpoints -> Text -> GetUserEndpoints)
-> Lens GetUserEndpoints GetUserEndpoints Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUserEndpoints' {Text
userId :: Text
$sel:userId:GetUserEndpoints' :: GetUserEndpoints -> Text
userId} -> Text
userId) (\s :: GetUserEndpoints
s@GetUserEndpoints' {} Text
a -> GetUserEndpoints
s {$sel:userId:GetUserEndpoints' :: Text
userId = Text
a} :: GetUserEndpoints)

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

instance Prelude.Hashable GetUserEndpoints

instance Prelude.NFData GetUserEndpoints

instance Core.ToHeaders GetUserEndpoints where
  toHeaders :: GetUserEndpoints -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetUserEndpoints -> 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 GetUserEndpoints where
  toPath :: GetUserEndpoints -> ByteString
toPath GetUserEndpoints' {Text
userId :: Text
applicationId :: Text
$sel:userId:GetUserEndpoints' :: GetUserEndpoints -> Text
$sel:applicationId:GetUserEndpoints' :: GetUserEndpoints -> 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
"/users/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
userId
      ]

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

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

-- |
-- Create a value of 'GetUserEndpointsResponse' 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', 'getUserEndpointsResponse_httpStatus' - The response's http status code.
--
-- 'endpointsResponse', 'getUserEndpointsResponse_endpointsResponse' - Undocumented member.
newGetUserEndpointsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'endpointsResponse'
  EndpointsResponse ->
  GetUserEndpointsResponse
newGetUserEndpointsResponse :: Int -> EndpointsResponse -> GetUserEndpointsResponse
newGetUserEndpointsResponse
  Int
pHttpStatus_
  EndpointsResponse
pEndpointsResponse_ =
    GetUserEndpointsResponse' :: Int -> EndpointsResponse -> GetUserEndpointsResponse
GetUserEndpointsResponse'
      { $sel:httpStatus:GetUserEndpointsResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:endpointsResponse:GetUserEndpointsResponse' :: EndpointsResponse
endpointsResponse = EndpointsResponse
pEndpointsResponse_
      }

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

-- | Undocumented member.
getUserEndpointsResponse_endpointsResponse :: Lens.Lens' GetUserEndpointsResponse EndpointsResponse
getUserEndpointsResponse_endpointsResponse :: (EndpointsResponse -> f EndpointsResponse)
-> GetUserEndpointsResponse -> f GetUserEndpointsResponse
getUserEndpointsResponse_endpointsResponse = (GetUserEndpointsResponse -> EndpointsResponse)
-> (GetUserEndpointsResponse
    -> EndpointsResponse -> GetUserEndpointsResponse)
-> Lens
     GetUserEndpointsResponse
     GetUserEndpointsResponse
     EndpointsResponse
     EndpointsResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUserEndpointsResponse' {EndpointsResponse
endpointsResponse :: EndpointsResponse
$sel:endpointsResponse:GetUserEndpointsResponse' :: GetUserEndpointsResponse -> EndpointsResponse
endpointsResponse} -> EndpointsResponse
endpointsResponse) (\s :: GetUserEndpointsResponse
s@GetUserEndpointsResponse' {} EndpointsResponse
a -> GetUserEndpointsResponse
s {$sel:endpointsResponse:GetUserEndpointsResponse' :: EndpointsResponse
endpointsResponse = EndpointsResponse
a} :: GetUserEndpointsResponse)

instance Prelude.NFData GetUserEndpointsResponse