{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' GetUserEndpoints Text
getUserEndpoints_applicationId = 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 :: Lens' GetUserEndpoints Text
getUserEndpoints_userId = 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 :: (Service -> Service)
-> GetUserEndpoints -> Request GetUserEndpoints
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetUserEndpoints
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetUserEndpoints)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> EndpointsResponse -> GetUserEndpointsResponse
GetUserEndpointsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)
      )

instance Prelude.Hashable GetUserEndpoints where
  hashWithSalt :: Int -> GetUserEndpoints -> Int
hashWithSalt Int
_salt GetUserEndpoints' {Text
userId :: Text
applicationId :: Text
$sel:userId:GetUserEndpoints' :: GetUserEndpoints -> Text
$sel:applicationId:GetUserEndpoints' :: GetUserEndpoints -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userId

instance Prelude.NFData GetUserEndpoints where
  rnf :: GetUserEndpoints -> ()
rnf GetUserEndpoints' {Text
userId :: Text
applicationId :: Text
$sel:userId:GetUserEndpoints' :: GetUserEndpoints -> Text
$sel:applicationId:GetUserEndpoints' :: GetUserEndpoints -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
applicationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userId

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

instance Data.ToPath GetUserEndpoints where
  toPath :: GetUserEndpoints -> ByteString
toPath GetUserEndpoints' {Text
userId :: Text
applicationId :: Text
$sel:userId:GetUserEndpoints' :: GetUserEndpoints -> Text
$sel:applicationId:GetUserEndpoints' :: GetUserEndpoints -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/apps/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
applicationId,
        ByteString
"/users/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
userId
      ]

instance Data.ToQuery GetUserEndpoints where
  toQuery :: GetUserEndpoints -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
      { $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 :: Lens' GetUserEndpointsResponse Int
getUserEndpointsResponse_httpStatus = 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 :: Lens' GetUserEndpointsResponse EndpointsResponse
getUserEndpointsResponse_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 where
  rnf :: GetUserEndpointsResponse -> ()
rnf GetUserEndpointsResponse' {Int
EndpointsResponse
endpointsResponse :: EndpointsResponse
httpStatus :: Int
$sel:endpointsResponse:GetUserEndpointsResponse' :: GetUserEndpointsResponse -> EndpointsResponse
$sel:httpStatus:GetUserEndpointsResponse' :: GetUserEndpointsResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EndpointsResponse
endpointsResponse