{-# 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.CreateResolver
-- 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)
--
-- Creates a @Resolver@ object.
--
-- A resolver converts incoming requests into a format that a data source
-- can understand and converts the data source\'s responses into GraphQL.
module Amazonka.AppSync.CreateResolver
  ( -- * Creating a Request
    CreateResolver (..),
    newCreateResolver,

    -- * Request Lenses
    createResolver_dataSourceName,
    createResolver_requestMappingTemplate,
    createResolver_kind,
    createResolver_cachingConfig,
    createResolver_responseMappingTemplate,
    createResolver_syncConfig,
    createResolver_pipelineConfig,
    createResolver_apiId,
    createResolver_typeName,
    createResolver_fieldName,

    -- * Destructuring the Response
    CreateResolverResponse (..),
    newCreateResolverResponse,

    -- * Response Lenses
    createResolverResponse_resolver,
    createResolverResponse_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:/ 'newCreateResolver' smart constructor.
data CreateResolver = CreateResolver'
  { -- | The name of the data source for which the resolver is being created.
    CreateResolver -> Maybe Text
dataSourceName :: Prelude.Maybe Prelude.Text,
    -- | The mapping template to be used for requests.
    --
    -- A resolver uses a request mapping template to convert a GraphQL
    -- expression into a format that a data source can understand. Mapping
    -- templates are written in Apache Velocity Template Language (VTL).
    --
    -- VTL request mapping templates are optional when using a Lambda data
    -- source. For all other data sources, VTL request and response mapping
    -- templates are required.
    CreateResolver -> Maybe Text
requestMappingTemplate :: Prelude.Maybe Prelude.Text,
    -- | The resolver type.
    --
    -- -   __UNIT__: A UNIT resolver type. A UNIT resolver is the default
    --     resolver type. A UNIT resolver enables you to execute a GraphQL
    --     query against a single data source.
    --
    -- -   __PIPELINE__: A PIPELINE resolver type. A PIPELINE resolver enables
    --     you to execute a series of @Function@ in a serial manner. You can
    --     use a pipeline resolver to execute a GraphQL query against multiple
    --     data sources.
    CreateResolver -> Maybe ResolverKind
kind :: Prelude.Maybe ResolverKind,
    -- | The caching configuration for the resolver.
    CreateResolver -> Maybe CachingConfig
cachingConfig :: Prelude.Maybe CachingConfig,
    -- | The mapping template to be used for responses from the data source.
    CreateResolver -> Maybe Text
responseMappingTemplate :: Prelude.Maybe Prelude.Text,
    -- | The @SyncConfig@ for a resolver attached to a versioned datasource.
    CreateResolver -> Maybe SyncConfig
syncConfig :: Prelude.Maybe SyncConfig,
    -- | The @PipelineConfig@.
    CreateResolver -> Maybe PipelineConfig
pipelineConfig :: Prelude.Maybe PipelineConfig,
    -- | The ID for the GraphQL API for which the resolver is being created.
    CreateResolver -> Text
apiId :: Prelude.Text,
    -- | The name of the @Type@.
    CreateResolver -> Text
typeName :: Prelude.Text,
    -- | The name of the field to attach the resolver to.
    CreateResolver -> Text
fieldName :: Prelude.Text
  }
  deriving (CreateResolver -> CreateResolver -> Bool
(CreateResolver -> CreateResolver -> Bool)
-> (CreateResolver -> CreateResolver -> Bool) -> Eq CreateResolver
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateResolver -> CreateResolver -> Bool
$c/= :: CreateResolver -> CreateResolver -> Bool
== :: CreateResolver -> CreateResolver -> Bool
$c== :: CreateResolver -> CreateResolver -> Bool
Prelude.Eq, ReadPrec [CreateResolver]
ReadPrec CreateResolver
Int -> ReadS CreateResolver
ReadS [CreateResolver]
(Int -> ReadS CreateResolver)
-> ReadS [CreateResolver]
-> ReadPrec CreateResolver
-> ReadPrec [CreateResolver]
-> Read CreateResolver
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateResolver]
$creadListPrec :: ReadPrec [CreateResolver]
readPrec :: ReadPrec CreateResolver
$creadPrec :: ReadPrec CreateResolver
readList :: ReadS [CreateResolver]
$creadList :: ReadS [CreateResolver]
readsPrec :: Int -> ReadS CreateResolver
$creadsPrec :: Int -> ReadS CreateResolver
Prelude.Read, Int -> CreateResolver -> ShowS
[CreateResolver] -> ShowS
CreateResolver -> String
(Int -> CreateResolver -> ShowS)
-> (CreateResolver -> String)
-> ([CreateResolver] -> ShowS)
-> Show CreateResolver
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateResolver] -> ShowS
$cshowList :: [CreateResolver] -> ShowS
show :: CreateResolver -> String
$cshow :: CreateResolver -> String
showsPrec :: Int -> CreateResolver -> ShowS
$cshowsPrec :: Int -> CreateResolver -> ShowS
Prelude.Show, (forall x. CreateResolver -> Rep CreateResolver x)
-> (forall x. Rep CreateResolver x -> CreateResolver)
-> Generic CreateResolver
forall x. Rep CreateResolver x -> CreateResolver
forall x. CreateResolver -> Rep CreateResolver x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateResolver x -> CreateResolver
$cfrom :: forall x. CreateResolver -> Rep CreateResolver x
Prelude.Generic)

-- |
-- Create a value of 'CreateResolver' 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:
--
-- 'dataSourceName', 'createResolver_dataSourceName' - The name of the data source for which the resolver is being created.
--
-- 'requestMappingTemplate', 'createResolver_requestMappingTemplate' - The mapping template to be used for requests.
--
-- A resolver uses a request mapping template to convert a GraphQL
-- expression into a format that a data source can understand. Mapping
-- templates are written in Apache Velocity Template Language (VTL).
--
-- VTL request mapping templates are optional when using a Lambda data
-- source. For all other data sources, VTL request and response mapping
-- templates are required.
--
-- 'kind', 'createResolver_kind' - The resolver type.
--
-- -   __UNIT__: A UNIT resolver type. A UNIT resolver is the default
--     resolver type. A UNIT resolver enables you to execute a GraphQL
--     query against a single data source.
--
-- -   __PIPELINE__: A PIPELINE resolver type. A PIPELINE resolver enables
--     you to execute a series of @Function@ in a serial manner. You can
--     use a pipeline resolver to execute a GraphQL query against multiple
--     data sources.
--
-- 'cachingConfig', 'createResolver_cachingConfig' - The caching configuration for the resolver.
--
-- 'responseMappingTemplate', 'createResolver_responseMappingTemplate' - The mapping template to be used for responses from the data source.
--
-- 'syncConfig', 'createResolver_syncConfig' - The @SyncConfig@ for a resolver attached to a versioned datasource.
--
-- 'pipelineConfig', 'createResolver_pipelineConfig' - The @PipelineConfig@.
--
-- 'apiId', 'createResolver_apiId' - The ID for the GraphQL API for which the resolver is being created.
--
-- 'typeName', 'createResolver_typeName' - The name of the @Type@.
--
-- 'fieldName', 'createResolver_fieldName' - The name of the field to attach the resolver to.
newCreateResolver ::
  -- | 'apiId'
  Prelude.Text ->
  -- | 'typeName'
  Prelude.Text ->
  -- | 'fieldName'
  Prelude.Text ->
  CreateResolver
newCreateResolver :: Text -> Text -> Text -> CreateResolver
newCreateResolver Text
pApiId_ Text
pTypeName_ Text
pFieldName_ =
  CreateResolver' :: Maybe Text
-> Maybe Text
-> Maybe ResolverKind
-> Maybe CachingConfig
-> Maybe Text
-> Maybe SyncConfig
-> Maybe PipelineConfig
-> Text
-> Text
-> Text
-> CreateResolver
CreateResolver'
    { $sel:dataSourceName:CreateResolver' :: Maybe Text
dataSourceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:requestMappingTemplate:CreateResolver' :: Maybe Text
requestMappingTemplate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:kind:CreateResolver' :: Maybe ResolverKind
kind = Maybe ResolverKind
forall a. Maybe a
Prelude.Nothing,
      $sel:cachingConfig:CreateResolver' :: Maybe CachingConfig
cachingConfig = Maybe CachingConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:responseMappingTemplate:CreateResolver' :: Maybe Text
responseMappingTemplate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:syncConfig:CreateResolver' :: Maybe SyncConfig
syncConfig = Maybe SyncConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineConfig:CreateResolver' :: Maybe PipelineConfig
pipelineConfig = Maybe PipelineConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:apiId:CreateResolver' :: Text
apiId = Text
pApiId_,
      $sel:typeName:CreateResolver' :: Text
typeName = Text
pTypeName_,
      $sel:fieldName:CreateResolver' :: Text
fieldName = Text
pFieldName_
    }

-- | The name of the data source for which the resolver is being created.
createResolver_dataSourceName :: Lens.Lens' CreateResolver (Prelude.Maybe Prelude.Text)
createResolver_dataSourceName :: (Maybe Text -> f (Maybe Text))
-> CreateResolver -> f CreateResolver
createResolver_dataSourceName = (CreateResolver -> Maybe Text)
-> (CreateResolver -> Maybe Text -> CreateResolver)
-> Lens CreateResolver CreateResolver (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolver' {Maybe Text
dataSourceName :: Maybe Text
$sel:dataSourceName:CreateResolver' :: CreateResolver -> Maybe Text
dataSourceName} -> Maybe Text
dataSourceName) (\s :: CreateResolver
s@CreateResolver' {} Maybe Text
a -> CreateResolver
s {$sel:dataSourceName:CreateResolver' :: Maybe Text
dataSourceName = Maybe Text
a} :: CreateResolver)

-- | The mapping template to be used for requests.
--
-- A resolver uses a request mapping template to convert a GraphQL
-- expression into a format that a data source can understand. Mapping
-- templates are written in Apache Velocity Template Language (VTL).
--
-- VTL request mapping templates are optional when using a Lambda data
-- source. For all other data sources, VTL request and response mapping
-- templates are required.
createResolver_requestMappingTemplate :: Lens.Lens' CreateResolver (Prelude.Maybe Prelude.Text)
createResolver_requestMappingTemplate :: (Maybe Text -> f (Maybe Text))
-> CreateResolver -> f CreateResolver
createResolver_requestMappingTemplate = (CreateResolver -> Maybe Text)
-> (CreateResolver -> Maybe Text -> CreateResolver)
-> Lens CreateResolver CreateResolver (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolver' {Maybe Text
requestMappingTemplate :: Maybe Text
$sel:requestMappingTemplate:CreateResolver' :: CreateResolver -> Maybe Text
requestMappingTemplate} -> Maybe Text
requestMappingTemplate) (\s :: CreateResolver
s@CreateResolver' {} Maybe Text
a -> CreateResolver
s {$sel:requestMappingTemplate:CreateResolver' :: Maybe Text
requestMappingTemplate = Maybe Text
a} :: CreateResolver)

-- | The resolver type.
--
-- -   __UNIT__: A UNIT resolver type. A UNIT resolver is the default
--     resolver type. A UNIT resolver enables you to execute a GraphQL
--     query against a single data source.
--
-- -   __PIPELINE__: A PIPELINE resolver type. A PIPELINE resolver enables
--     you to execute a series of @Function@ in a serial manner. You can
--     use a pipeline resolver to execute a GraphQL query against multiple
--     data sources.
createResolver_kind :: Lens.Lens' CreateResolver (Prelude.Maybe ResolverKind)
createResolver_kind :: (Maybe ResolverKind -> f (Maybe ResolverKind))
-> CreateResolver -> f CreateResolver
createResolver_kind = (CreateResolver -> Maybe ResolverKind)
-> (CreateResolver -> Maybe ResolverKind -> CreateResolver)
-> Lens
     CreateResolver
     CreateResolver
     (Maybe ResolverKind)
     (Maybe ResolverKind)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolver' {Maybe ResolverKind
kind :: Maybe ResolverKind
$sel:kind:CreateResolver' :: CreateResolver -> Maybe ResolverKind
kind} -> Maybe ResolverKind
kind) (\s :: CreateResolver
s@CreateResolver' {} Maybe ResolverKind
a -> CreateResolver
s {$sel:kind:CreateResolver' :: Maybe ResolverKind
kind = Maybe ResolverKind
a} :: CreateResolver)

-- | The caching configuration for the resolver.
createResolver_cachingConfig :: Lens.Lens' CreateResolver (Prelude.Maybe CachingConfig)
createResolver_cachingConfig :: (Maybe CachingConfig -> f (Maybe CachingConfig))
-> CreateResolver -> f CreateResolver
createResolver_cachingConfig = (CreateResolver -> Maybe CachingConfig)
-> (CreateResolver -> Maybe CachingConfig -> CreateResolver)
-> Lens
     CreateResolver
     CreateResolver
     (Maybe CachingConfig)
     (Maybe CachingConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolver' {Maybe CachingConfig
cachingConfig :: Maybe CachingConfig
$sel:cachingConfig:CreateResolver' :: CreateResolver -> Maybe CachingConfig
cachingConfig} -> Maybe CachingConfig
cachingConfig) (\s :: CreateResolver
s@CreateResolver' {} Maybe CachingConfig
a -> CreateResolver
s {$sel:cachingConfig:CreateResolver' :: Maybe CachingConfig
cachingConfig = Maybe CachingConfig
a} :: CreateResolver)

-- | The mapping template to be used for responses from the data source.
createResolver_responseMappingTemplate :: Lens.Lens' CreateResolver (Prelude.Maybe Prelude.Text)
createResolver_responseMappingTemplate :: (Maybe Text -> f (Maybe Text))
-> CreateResolver -> f CreateResolver
createResolver_responseMappingTemplate = (CreateResolver -> Maybe Text)
-> (CreateResolver -> Maybe Text -> CreateResolver)
-> Lens CreateResolver CreateResolver (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolver' {Maybe Text
responseMappingTemplate :: Maybe Text
$sel:responseMappingTemplate:CreateResolver' :: CreateResolver -> Maybe Text
responseMappingTemplate} -> Maybe Text
responseMappingTemplate) (\s :: CreateResolver
s@CreateResolver' {} Maybe Text
a -> CreateResolver
s {$sel:responseMappingTemplate:CreateResolver' :: Maybe Text
responseMappingTemplate = Maybe Text
a} :: CreateResolver)

-- | The @SyncConfig@ for a resolver attached to a versioned datasource.
createResolver_syncConfig :: Lens.Lens' CreateResolver (Prelude.Maybe SyncConfig)
createResolver_syncConfig :: (Maybe SyncConfig -> f (Maybe SyncConfig))
-> CreateResolver -> f CreateResolver
createResolver_syncConfig = (CreateResolver -> Maybe SyncConfig)
-> (CreateResolver -> Maybe SyncConfig -> CreateResolver)
-> Lens
     CreateResolver CreateResolver (Maybe SyncConfig) (Maybe SyncConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolver' {Maybe SyncConfig
syncConfig :: Maybe SyncConfig
$sel:syncConfig:CreateResolver' :: CreateResolver -> Maybe SyncConfig
syncConfig} -> Maybe SyncConfig
syncConfig) (\s :: CreateResolver
s@CreateResolver' {} Maybe SyncConfig
a -> CreateResolver
s {$sel:syncConfig:CreateResolver' :: Maybe SyncConfig
syncConfig = Maybe SyncConfig
a} :: CreateResolver)

-- | The @PipelineConfig@.
createResolver_pipelineConfig :: Lens.Lens' CreateResolver (Prelude.Maybe PipelineConfig)
createResolver_pipelineConfig :: (Maybe PipelineConfig -> f (Maybe PipelineConfig))
-> CreateResolver -> f CreateResolver
createResolver_pipelineConfig = (CreateResolver -> Maybe PipelineConfig)
-> (CreateResolver -> Maybe PipelineConfig -> CreateResolver)
-> Lens
     CreateResolver
     CreateResolver
     (Maybe PipelineConfig)
     (Maybe PipelineConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolver' {Maybe PipelineConfig
pipelineConfig :: Maybe PipelineConfig
$sel:pipelineConfig:CreateResolver' :: CreateResolver -> Maybe PipelineConfig
pipelineConfig} -> Maybe PipelineConfig
pipelineConfig) (\s :: CreateResolver
s@CreateResolver' {} Maybe PipelineConfig
a -> CreateResolver
s {$sel:pipelineConfig:CreateResolver' :: Maybe PipelineConfig
pipelineConfig = Maybe PipelineConfig
a} :: CreateResolver)

-- | The ID for the GraphQL API for which the resolver is being created.
createResolver_apiId :: Lens.Lens' CreateResolver Prelude.Text
createResolver_apiId :: (Text -> f Text) -> CreateResolver -> f CreateResolver
createResolver_apiId = (CreateResolver -> Text)
-> (CreateResolver -> Text -> CreateResolver)
-> Lens CreateResolver CreateResolver Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolver' {Text
apiId :: Text
$sel:apiId:CreateResolver' :: CreateResolver -> Text
apiId} -> Text
apiId) (\s :: CreateResolver
s@CreateResolver' {} Text
a -> CreateResolver
s {$sel:apiId:CreateResolver' :: Text
apiId = Text
a} :: CreateResolver)

-- | The name of the @Type@.
createResolver_typeName :: Lens.Lens' CreateResolver Prelude.Text
createResolver_typeName :: (Text -> f Text) -> CreateResolver -> f CreateResolver
createResolver_typeName = (CreateResolver -> Text)
-> (CreateResolver -> Text -> CreateResolver)
-> Lens CreateResolver CreateResolver Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolver' {Text
typeName :: Text
$sel:typeName:CreateResolver' :: CreateResolver -> Text
typeName} -> Text
typeName) (\s :: CreateResolver
s@CreateResolver' {} Text
a -> CreateResolver
s {$sel:typeName:CreateResolver' :: Text
typeName = Text
a} :: CreateResolver)

-- | The name of the field to attach the resolver to.
createResolver_fieldName :: Lens.Lens' CreateResolver Prelude.Text
createResolver_fieldName :: (Text -> f Text) -> CreateResolver -> f CreateResolver
createResolver_fieldName = (CreateResolver -> Text)
-> (CreateResolver -> Text -> CreateResolver)
-> Lens CreateResolver CreateResolver Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolver' {Text
fieldName :: Text
$sel:fieldName:CreateResolver' :: CreateResolver -> Text
fieldName} -> Text
fieldName) (\s :: CreateResolver
s@CreateResolver' {} Text
a -> CreateResolver
s {$sel:fieldName:CreateResolver' :: Text
fieldName = Text
a} :: CreateResolver)

instance Core.AWSRequest CreateResolver where
  type
    AWSResponse CreateResolver =
      CreateResolverResponse
  request :: CreateResolver -> Request CreateResolver
request = Service -> CreateResolver -> Request CreateResolver
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateResolver
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateResolver)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateResolver))
-> Logger
-> Service
-> Proxy CreateResolver
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateResolver)))
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 -> CreateResolverResponse
CreateResolverResponse'
            (Maybe Resolver -> Int -> CreateResolverResponse)
-> Either String (Maybe Resolver)
-> Either String (Int -> CreateResolverResponse)
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 -> CreateResolverResponse)
-> Either String Int -> Either String CreateResolverResponse
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 CreateResolver

instance Prelude.NFData CreateResolver

instance Core.ToHeaders CreateResolver where
  toHeaders :: CreateResolver -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateResolver -> 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.ToJSON CreateResolver where
  toJSON :: CreateResolver -> Value
toJSON CreateResolver' {Maybe Text
Maybe CachingConfig
Maybe PipelineConfig
Maybe ResolverKind
Maybe SyncConfig
Text
fieldName :: Text
typeName :: Text
apiId :: Text
pipelineConfig :: Maybe PipelineConfig
syncConfig :: Maybe SyncConfig
responseMappingTemplate :: Maybe Text
cachingConfig :: Maybe CachingConfig
kind :: Maybe ResolverKind
requestMappingTemplate :: Maybe Text
dataSourceName :: Maybe Text
$sel:fieldName:CreateResolver' :: CreateResolver -> Text
$sel:typeName:CreateResolver' :: CreateResolver -> Text
$sel:apiId:CreateResolver' :: CreateResolver -> Text
$sel:pipelineConfig:CreateResolver' :: CreateResolver -> Maybe PipelineConfig
$sel:syncConfig:CreateResolver' :: CreateResolver -> Maybe SyncConfig
$sel:responseMappingTemplate:CreateResolver' :: CreateResolver -> Maybe Text
$sel:cachingConfig:CreateResolver' :: CreateResolver -> Maybe CachingConfig
$sel:kind:CreateResolver' :: CreateResolver -> Maybe ResolverKind
$sel:requestMappingTemplate:CreateResolver' :: CreateResolver -> Maybe Text
$sel:dataSourceName:CreateResolver' :: CreateResolver -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"dataSourceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
dataSourceName,
            (Text
"requestMappingTemplate" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
requestMappingTemplate,
            (Text
"kind" Text -> ResolverKind -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ResolverKind -> Pair) -> Maybe ResolverKind -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResolverKind
kind,
            (Text
"cachingConfig" Text -> CachingConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CachingConfig -> Pair) -> Maybe CachingConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CachingConfig
cachingConfig,
            (Text
"responseMappingTemplate" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
responseMappingTemplate,
            (Text
"syncConfig" Text -> SyncConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SyncConfig -> Pair) -> Maybe SyncConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SyncConfig
syncConfig,
            (Text
"pipelineConfig" Text -> PipelineConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (PipelineConfig -> Pair) -> Maybe PipelineConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PipelineConfig
pipelineConfig,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"fieldName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fieldName)
          ]
      )

instance Core.ToPath CreateResolver where
  toPath :: CreateResolver -> ByteString
toPath CreateResolver' {Maybe Text
Maybe CachingConfig
Maybe PipelineConfig
Maybe ResolverKind
Maybe SyncConfig
Text
fieldName :: Text
typeName :: Text
apiId :: Text
pipelineConfig :: Maybe PipelineConfig
syncConfig :: Maybe SyncConfig
responseMappingTemplate :: Maybe Text
cachingConfig :: Maybe CachingConfig
kind :: Maybe ResolverKind
requestMappingTemplate :: Maybe Text
dataSourceName :: Maybe Text
$sel:fieldName:CreateResolver' :: CreateResolver -> Text
$sel:typeName:CreateResolver' :: CreateResolver -> Text
$sel:apiId:CreateResolver' :: CreateResolver -> Text
$sel:pipelineConfig:CreateResolver' :: CreateResolver -> Maybe PipelineConfig
$sel:syncConfig:CreateResolver' :: CreateResolver -> Maybe SyncConfig
$sel:responseMappingTemplate:CreateResolver' :: CreateResolver -> Maybe Text
$sel:cachingConfig:CreateResolver' :: CreateResolver -> Maybe CachingConfig
$sel:kind:CreateResolver' :: CreateResolver -> Maybe ResolverKind
$sel:requestMappingTemplate:CreateResolver' :: CreateResolver -> Maybe Text
$sel:dataSourceName:CreateResolver' :: CreateResolver -> Maybe 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"
      ]

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

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

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

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

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

instance Prelude.NFData CreateResolverResponse