{-# 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.AppSync.GetResolver
-- 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 a @Resolver@ object.
module Amazonka.AppSync.GetResolver
  ( -- * Creating a Request
    GetResolver (..),
    newGetResolver,

    -- * Request Lenses
    getResolver_apiId,
    getResolver_typeName,
    getResolver_fieldName,

    -- * Destructuring the Response
    GetResolverResponse (..),
    newGetResolverResponse,

    -- * Response Lenses
    getResolverResponse_resolver,
    getResolverResponse_httpStatus,
  )
where

import Amazonka.AppSync.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetResolver' smart constructor.
data GetResolver = GetResolver'
  { -- | The API ID.
    GetResolver -> Text
apiId :: Prelude.Text,
    -- | The resolver type name.
    GetResolver -> Text
typeName :: Prelude.Text,
    -- | The resolver field name.
    GetResolver -> Text
fieldName :: Prelude.Text
  }
  deriving (GetResolver -> GetResolver -> Bool
(GetResolver -> GetResolver -> Bool)
-> (GetResolver -> GetResolver -> Bool) -> Eq GetResolver
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResolver -> GetResolver -> Bool
$c/= :: GetResolver -> GetResolver -> Bool
== :: GetResolver -> GetResolver -> Bool
$c== :: GetResolver -> GetResolver -> Bool
Prelude.Eq, ReadPrec [GetResolver]
ReadPrec GetResolver
Int -> ReadS GetResolver
ReadS [GetResolver]
(Int -> ReadS GetResolver)
-> ReadS [GetResolver]
-> ReadPrec GetResolver
-> ReadPrec [GetResolver]
-> Read GetResolver
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResolver]
$creadListPrec :: ReadPrec [GetResolver]
readPrec :: ReadPrec GetResolver
$creadPrec :: ReadPrec GetResolver
readList :: ReadS [GetResolver]
$creadList :: ReadS [GetResolver]
readsPrec :: Int -> ReadS GetResolver
$creadsPrec :: Int -> ReadS GetResolver
Prelude.Read, Int -> GetResolver -> ShowS
[GetResolver] -> ShowS
GetResolver -> String
(Int -> GetResolver -> ShowS)
-> (GetResolver -> String)
-> ([GetResolver] -> ShowS)
-> Show GetResolver
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResolver] -> ShowS
$cshowList :: [GetResolver] -> ShowS
show :: GetResolver -> String
$cshow :: GetResolver -> String
showsPrec :: Int -> GetResolver -> ShowS
$cshowsPrec :: Int -> GetResolver -> ShowS
Prelude.Show, (forall x. GetResolver -> Rep GetResolver x)
-> (forall x. Rep GetResolver x -> GetResolver)
-> Generic GetResolver
forall x. Rep GetResolver x -> GetResolver
forall x. GetResolver -> Rep GetResolver x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetResolver x -> GetResolver
$cfrom :: forall x. GetResolver -> Rep GetResolver x
Prelude.Generic)

-- |
-- Create a value of 'GetResolver' 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:
--
-- 'apiId', 'getResolver_apiId' - The API ID.
--
-- 'typeName', 'getResolver_typeName' - The resolver type name.
--
-- 'fieldName', 'getResolver_fieldName' - The resolver field name.
newGetResolver ::
  -- | 'apiId'
  Prelude.Text ->
  -- | 'typeName'
  Prelude.Text ->
  -- | 'fieldName'
  Prelude.Text ->
  GetResolver
newGetResolver :: Text -> Text -> Text -> GetResolver
newGetResolver Text
pApiId_ Text
pTypeName_ Text
pFieldName_ =
  GetResolver' :: Text -> Text -> Text -> GetResolver
GetResolver'
    { $sel:apiId:GetResolver' :: Text
apiId = Text
pApiId_,
      $sel:typeName:GetResolver' :: Text
typeName = Text
pTypeName_,
      $sel:fieldName:GetResolver' :: Text
fieldName = Text
pFieldName_
    }

-- | The API ID.
getResolver_apiId :: Lens.Lens' GetResolver Prelude.Text
getResolver_apiId :: (Text -> f Text) -> GetResolver -> f GetResolver
getResolver_apiId = (GetResolver -> Text)
-> (GetResolver -> Text -> GetResolver)
-> Lens GetResolver GetResolver Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResolver' {Text
apiId :: Text
$sel:apiId:GetResolver' :: GetResolver -> Text
apiId} -> Text
apiId) (\s :: GetResolver
s@GetResolver' {} Text
a -> GetResolver
s {$sel:apiId:GetResolver' :: Text
apiId = Text
a} :: GetResolver)

-- | The resolver type name.
getResolver_typeName :: Lens.Lens' GetResolver Prelude.Text
getResolver_typeName :: (Text -> f Text) -> GetResolver -> f GetResolver
getResolver_typeName = (GetResolver -> Text)
-> (GetResolver -> Text -> GetResolver)
-> Lens GetResolver GetResolver Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResolver' {Text
typeName :: Text
$sel:typeName:GetResolver' :: GetResolver -> Text
typeName} -> Text
typeName) (\s :: GetResolver
s@GetResolver' {} Text
a -> GetResolver
s {$sel:typeName:GetResolver' :: Text
typeName = Text
a} :: GetResolver)

-- | The resolver field name.
getResolver_fieldName :: Lens.Lens' GetResolver Prelude.Text
getResolver_fieldName :: (Text -> f Text) -> GetResolver -> f GetResolver
getResolver_fieldName = (GetResolver -> Text)
-> (GetResolver -> Text -> GetResolver)
-> Lens GetResolver GetResolver Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResolver' {Text
fieldName :: Text
$sel:fieldName:GetResolver' :: GetResolver -> Text
fieldName} -> Text
fieldName) (\s :: GetResolver
s@GetResolver' {} Text
a -> GetResolver
s {$sel:fieldName:GetResolver' :: Text
fieldName = Text
a} :: GetResolver)

instance Core.AWSRequest GetResolver where
  type AWSResponse GetResolver = GetResolverResponse
  request :: GetResolver -> Request GetResolver
request = Service -> GetResolver -> Request GetResolver
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetResolver
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetResolver)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetResolver))
-> Logger
-> Service
-> Proxy GetResolver
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetResolver)))
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 ->
          Maybe Resolver -> Int -> GetResolverResponse
GetResolverResponse'
            (Maybe Resolver -> Int -> GetResolverResponse)
-> Either String (Maybe Resolver)
-> Either String (Int -> GetResolverResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Resolver)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"resolver")
            Either String (Int -> GetResolverResponse)
-> Either String Int -> Either String GetResolverResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable GetResolver

instance Prelude.NFData GetResolver

instance Core.ToHeaders GetResolver where
  toHeaders :: GetResolver -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetResolver -> 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 GetResolver where
  toPath :: GetResolver -> ByteString
toPath GetResolver' {Text
fieldName :: Text
typeName :: Text
apiId :: Text
$sel:fieldName:GetResolver' :: GetResolver -> Text
$sel:typeName:GetResolver' :: GetResolver -> Text
$sel:apiId:GetResolver' :: GetResolver -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/apis/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
apiId,
        ByteString
"/types/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
typeName,
        ByteString
"/resolvers/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
fieldName
      ]

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

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

-- |
-- Create a value of 'GetResolverResponse' 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:
--
-- 'resolver', 'getResolverResponse_resolver' - The @Resolver@ object.
--
-- 'httpStatus', 'getResolverResponse_httpStatus' - The response's http status code.
newGetResolverResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetResolverResponse
newGetResolverResponse :: Int -> GetResolverResponse
newGetResolverResponse Int
pHttpStatus_ =
  GetResolverResponse' :: Maybe Resolver -> Int -> GetResolverResponse
GetResolverResponse'
    { $sel:resolver:GetResolverResponse' :: Maybe Resolver
resolver = Maybe Resolver
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetResolverResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The @Resolver@ object.
getResolverResponse_resolver :: Lens.Lens' GetResolverResponse (Prelude.Maybe Resolver)
getResolverResponse_resolver :: (Maybe Resolver -> f (Maybe Resolver))
-> GetResolverResponse -> f GetResolverResponse
getResolverResponse_resolver = (GetResolverResponse -> Maybe Resolver)
-> (GetResolverResponse -> Maybe Resolver -> GetResolverResponse)
-> Lens
     GetResolverResponse
     GetResolverResponse
     (Maybe Resolver)
     (Maybe Resolver)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResolverResponse' {Maybe Resolver
resolver :: Maybe Resolver
$sel:resolver:GetResolverResponse' :: GetResolverResponse -> Maybe Resolver
resolver} -> Maybe Resolver
resolver) (\s :: GetResolverResponse
s@GetResolverResponse' {} Maybe Resolver
a -> GetResolverResponse
s {$sel:resolver:GetResolverResponse' :: Maybe Resolver
resolver = Maybe Resolver
a} :: GetResolverResponse)

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

instance Prelude.NFData GetResolverResponse