{-# 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.GetEndpoint
-- 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 settings and attributes of a specific
-- endpoint for an application.
module Amazonka.Pinpoint.GetEndpoint
  ( -- * Creating a Request
    GetEndpoint (..),
    newGetEndpoint,

    -- * Request Lenses
    getEndpoint_applicationId,
    getEndpoint_endpointId,

    -- * Destructuring the Response
    GetEndpointResponse (..),
    newGetEndpointResponse,

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

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

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

-- | The unique identifier for the endpoint.
getEndpoint_endpointId :: Lens.Lens' GetEndpoint Prelude.Text
getEndpoint_endpointId :: (Text -> f Text) -> GetEndpoint -> f GetEndpoint
getEndpoint_endpointId = (GetEndpoint -> Text)
-> (GetEndpoint -> Text -> GetEndpoint)
-> Lens GetEndpoint GetEndpoint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEndpoint' {Text
endpointId :: Text
$sel:endpointId:GetEndpoint' :: GetEndpoint -> Text
endpointId} -> Text
endpointId) (\s :: GetEndpoint
s@GetEndpoint' {} Text
a -> GetEndpoint
s {$sel:endpointId:GetEndpoint' :: Text
endpointId = Text
a} :: GetEndpoint)

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

instance Prelude.Hashable GetEndpoint

instance Prelude.NFData GetEndpoint

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

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

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

-- |
-- Create a value of 'GetEndpointResponse' 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', 'getEndpointResponse_httpStatus' - The response's http status code.
--
-- 'endpointResponse', 'getEndpointResponse_endpointResponse' - Undocumented member.
newGetEndpointResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'endpointResponse'
  EndpointResponse ->
  GetEndpointResponse
newGetEndpointResponse :: Int -> EndpointResponse -> GetEndpointResponse
newGetEndpointResponse
  Int
pHttpStatus_
  EndpointResponse
pEndpointResponse_ =
    GetEndpointResponse' :: Int -> EndpointResponse -> GetEndpointResponse
GetEndpointResponse'
      { $sel:httpStatus:GetEndpointResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:endpointResponse:GetEndpointResponse' :: EndpointResponse
endpointResponse = EndpointResponse
pEndpointResponse_
      }

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

-- | Undocumented member.
getEndpointResponse_endpointResponse :: Lens.Lens' GetEndpointResponse EndpointResponse
getEndpointResponse_endpointResponse :: (EndpointResponse -> f EndpointResponse)
-> GetEndpointResponse -> f GetEndpointResponse
getEndpointResponse_endpointResponse = (GetEndpointResponse -> EndpointResponse)
-> (GetEndpointResponse -> EndpointResponse -> GetEndpointResponse)
-> Lens
     GetEndpointResponse
     GetEndpointResponse
     EndpointResponse
     EndpointResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEndpointResponse' {EndpointResponse
endpointResponse :: EndpointResponse
$sel:endpointResponse:GetEndpointResponse' :: GetEndpointResponse -> EndpointResponse
endpointResponse} -> EndpointResponse
endpointResponse) (\s :: GetEndpointResponse
s@GetEndpointResponse' {} EndpointResponse
a -> GetEndpointResponse
s {$sel:endpointResponse:GetEndpointResponse' :: EndpointResponse
endpointResponse = EndpointResponse
a} :: GetEndpointResponse)

instance Prelude.NFData GetEndpointResponse