{-# 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.CreateRecommenderConfiguration
-- 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 an Amazon Pinpoint configuration for a recommender model.
module Amazonka.Pinpoint.CreateRecommenderConfiguration
  ( -- * Creating a Request
    CreateRecommenderConfiguration' (..),
    newCreateRecommenderConfiguration',

    -- * Request Lenses
    createRecommenderConfiguration'_createRecommenderConfiguration,

    -- * Destructuring the Response
    CreateRecommenderConfigurationResponse (..),
    newCreateRecommenderConfigurationResponse,

    -- * Response Lenses
    createRecommenderConfigurationResponse_httpStatus,
    createRecommenderConfigurationResponse_recommenderConfigurationResponse,
  )
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:/ 'newCreateRecommenderConfiguration'' smart constructor.
data CreateRecommenderConfiguration' = CreateRecommenderConfiguration''
  { CreateRecommenderConfiguration' -> CreateRecommenderConfiguration
createRecommenderConfiguration :: CreateRecommenderConfiguration
  }
  deriving (CreateRecommenderConfiguration'
-> CreateRecommenderConfiguration' -> Bool
(CreateRecommenderConfiguration'
 -> CreateRecommenderConfiguration' -> Bool)
-> (CreateRecommenderConfiguration'
    -> CreateRecommenderConfiguration' -> Bool)
-> Eq CreateRecommenderConfiguration'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRecommenderConfiguration'
-> CreateRecommenderConfiguration' -> Bool
$c/= :: CreateRecommenderConfiguration'
-> CreateRecommenderConfiguration' -> Bool
== :: CreateRecommenderConfiguration'
-> CreateRecommenderConfiguration' -> Bool
$c== :: CreateRecommenderConfiguration'
-> CreateRecommenderConfiguration' -> Bool
Prelude.Eq, ReadPrec [CreateRecommenderConfiguration']
ReadPrec CreateRecommenderConfiguration'
Int -> ReadS CreateRecommenderConfiguration'
ReadS [CreateRecommenderConfiguration']
(Int -> ReadS CreateRecommenderConfiguration')
-> ReadS [CreateRecommenderConfiguration']
-> ReadPrec CreateRecommenderConfiguration'
-> ReadPrec [CreateRecommenderConfiguration']
-> Read CreateRecommenderConfiguration'
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRecommenderConfiguration']
$creadListPrec :: ReadPrec [CreateRecommenderConfiguration']
readPrec :: ReadPrec CreateRecommenderConfiguration'
$creadPrec :: ReadPrec CreateRecommenderConfiguration'
readList :: ReadS [CreateRecommenderConfiguration']
$creadList :: ReadS [CreateRecommenderConfiguration']
readsPrec :: Int -> ReadS CreateRecommenderConfiguration'
$creadsPrec :: Int -> ReadS CreateRecommenderConfiguration'
Prelude.Read, Int -> CreateRecommenderConfiguration' -> ShowS
[CreateRecommenderConfiguration'] -> ShowS
CreateRecommenderConfiguration' -> String
(Int -> CreateRecommenderConfiguration' -> ShowS)
-> (CreateRecommenderConfiguration' -> String)
-> ([CreateRecommenderConfiguration'] -> ShowS)
-> Show CreateRecommenderConfiguration'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRecommenderConfiguration'] -> ShowS
$cshowList :: [CreateRecommenderConfiguration'] -> ShowS
show :: CreateRecommenderConfiguration' -> String
$cshow :: CreateRecommenderConfiguration' -> String
showsPrec :: Int -> CreateRecommenderConfiguration' -> ShowS
$cshowsPrec :: Int -> CreateRecommenderConfiguration' -> ShowS
Prelude.Show, (forall x.
 CreateRecommenderConfiguration'
 -> Rep CreateRecommenderConfiguration' x)
-> (forall x.
    Rep CreateRecommenderConfiguration' x
    -> CreateRecommenderConfiguration')
-> Generic CreateRecommenderConfiguration'
forall x.
Rep CreateRecommenderConfiguration' x
-> CreateRecommenderConfiguration'
forall x.
CreateRecommenderConfiguration'
-> Rep CreateRecommenderConfiguration' x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateRecommenderConfiguration' x
-> CreateRecommenderConfiguration'
$cfrom :: forall x.
CreateRecommenderConfiguration'
-> Rep CreateRecommenderConfiguration' x
Prelude.Generic)

-- |
-- Create a value of 'CreateRecommenderConfiguration'' 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:
--
-- 'createRecommenderConfiguration', 'createRecommenderConfiguration'_createRecommenderConfiguration' - Undocumented member.
newCreateRecommenderConfiguration' ::
  -- | 'createRecommenderConfiguration'
  CreateRecommenderConfiguration ->
  CreateRecommenderConfiguration'
newCreateRecommenderConfiguration' :: CreateRecommenderConfiguration -> CreateRecommenderConfiguration'
newCreateRecommenderConfiguration'
  CreateRecommenderConfiguration
pCreateRecommenderConfiguration_ =
    CreateRecommenderConfiguration'' :: CreateRecommenderConfiguration -> CreateRecommenderConfiguration'
CreateRecommenderConfiguration''
      { $sel:createRecommenderConfiguration:CreateRecommenderConfiguration'' :: CreateRecommenderConfiguration
createRecommenderConfiguration =
          CreateRecommenderConfiguration
pCreateRecommenderConfiguration_
      }

-- | Undocumented member.
createRecommenderConfiguration'_createRecommenderConfiguration :: Lens.Lens' CreateRecommenderConfiguration' CreateRecommenderConfiguration
createRecommenderConfiguration'_createRecommenderConfiguration :: (CreateRecommenderConfiguration
 -> f CreateRecommenderConfiguration)
-> CreateRecommenderConfiguration'
-> f CreateRecommenderConfiguration'
createRecommenderConfiguration'_createRecommenderConfiguration = (CreateRecommenderConfiguration' -> CreateRecommenderConfiguration)
-> (CreateRecommenderConfiguration'
    -> CreateRecommenderConfiguration
    -> CreateRecommenderConfiguration')
-> Lens
     CreateRecommenderConfiguration'
     CreateRecommenderConfiguration'
     CreateRecommenderConfiguration
     CreateRecommenderConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRecommenderConfiguration'' {CreateRecommenderConfiguration
createRecommenderConfiguration :: CreateRecommenderConfiguration
$sel:createRecommenderConfiguration:CreateRecommenderConfiguration'' :: CreateRecommenderConfiguration' -> CreateRecommenderConfiguration
createRecommenderConfiguration} -> CreateRecommenderConfiguration
createRecommenderConfiguration) (\s :: CreateRecommenderConfiguration'
s@CreateRecommenderConfiguration'' {} CreateRecommenderConfiguration
a -> CreateRecommenderConfiguration'
s {$sel:createRecommenderConfiguration:CreateRecommenderConfiguration'' :: CreateRecommenderConfiguration
createRecommenderConfiguration = CreateRecommenderConfiguration
a} :: CreateRecommenderConfiguration')

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

instance
  Prelude.Hashable
    CreateRecommenderConfiguration'

instance
  Prelude.NFData
    CreateRecommenderConfiguration'

instance
  Core.ToHeaders
    CreateRecommenderConfiguration'
  where
  toHeaders :: CreateRecommenderConfiguration' -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> CreateRecommenderConfiguration' -> 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 CreateRecommenderConfiguration' where
  toJSON :: CreateRecommenderConfiguration' -> Value
toJSON CreateRecommenderConfiguration'' {CreateRecommenderConfiguration
createRecommenderConfiguration :: CreateRecommenderConfiguration
$sel:createRecommenderConfiguration:CreateRecommenderConfiguration'' :: CreateRecommenderConfiguration' -> CreateRecommenderConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"CreateRecommenderConfiguration"
                  Text -> CreateRecommenderConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CreateRecommenderConfiguration
createRecommenderConfiguration
              )
          ]
      )

instance Core.ToPath CreateRecommenderConfiguration' where
  toPath :: CreateRecommenderConfiguration' -> ByteString
toPath = ByteString -> CreateRecommenderConfiguration' -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/v1/recommenders"

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

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

-- |
-- Create a value of 'CreateRecommenderConfigurationResponse' 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', 'createRecommenderConfigurationResponse_httpStatus' - The response's http status code.
--
-- 'recommenderConfigurationResponse', 'createRecommenderConfigurationResponse_recommenderConfigurationResponse' - Undocumented member.
newCreateRecommenderConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'recommenderConfigurationResponse'
  RecommenderConfigurationResponse ->
  CreateRecommenderConfigurationResponse
newCreateRecommenderConfigurationResponse :: Int
-> RecommenderConfigurationResponse
-> CreateRecommenderConfigurationResponse
newCreateRecommenderConfigurationResponse
  Int
pHttpStatus_
  RecommenderConfigurationResponse
pRecommenderConfigurationResponse_ =
    CreateRecommenderConfigurationResponse' :: Int
-> RecommenderConfigurationResponse
-> CreateRecommenderConfigurationResponse
CreateRecommenderConfigurationResponse'
      { $sel:httpStatus:CreateRecommenderConfigurationResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:recommenderConfigurationResponse:CreateRecommenderConfigurationResponse' :: RecommenderConfigurationResponse
recommenderConfigurationResponse =
          RecommenderConfigurationResponse
pRecommenderConfigurationResponse_
      }

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

-- | Undocumented member.
createRecommenderConfigurationResponse_recommenderConfigurationResponse :: Lens.Lens' CreateRecommenderConfigurationResponse RecommenderConfigurationResponse
createRecommenderConfigurationResponse_recommenderConfigurationResponse :: (RecommenderConfigurationResponse
 -> f RecommenderConfigurationResponse)
-> CreateRecommenderConfigurationResponse
-> f CreateRecommenderConfigurationResponse
createRecommenderConfigurationResponse_recommenderConfigurationResponse = (CreateRecommenderConfigurationResponse
 -> RecommenderConfigurationResponse)
-> (CreateRecommenderConfigurationResponse
    -> RecommenderConfigurationResponse
    -> CreateRecommenderConfigurationResponse)
-> Lens
     CreateRecommenderConfigurationResponse
     CreateRecommenderConfigurationResponse
     RecommenderConfigurationResponse
     RecommenderConfigurationResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRecommenderConfigurationResponse' {RecommenderConfigurationResponse
recommenderConfigurationResponse :: RecommenderConfigurationResponse
$sel:recommenderConfigurationResponse:CreateRecommenderConfigurationResponse' :: CreateRecommenderConfigurationResponse
-> RecommenderConfigurationResponse
recommenderConfigurationResponse} -> RecommenderConfigurationResponse
recommenderConfigurationResponse) (\s :: CreateRecommenderConfigurationResponse
s@CreateRecommenderConfigurationResponse' {} RecommenderConfigurationResponse
a -> CreateRecommenderConfigurationResponse
s {$sel:recommenderConfigurationResponse:CreateRecommenderConfigurationResponse' :: RecommenderConfigurationResponse
recommenderConfigurationResponse = RecommenderConfigurationResponse
a} :: CreateRecommenderConfigurationResponse)

instance
  Prelude.NFData
    CreateRecommenderConfigurationResponse