{-# 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.MachineLearning.CreateDataSourceFromRedshift
-- 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 @DataSource@ from a database hosted on an Amazon Redshift
-- cluster. A @DataSource@ references data that can be used to perform
-- either @CreateMLModel@, @CreateEvaluation@, or @CreateBatchPrediction@
-- operations.
--
-- @CreateDataSourceFromRedshift@ is an asynchronous operation. In response
-- to @CreateDataSourceFromRedshift@, Amazon Machine Learning (Amazon ML)
-- immediately returns and sets the @DataSource@ status to @PENDING@. After
-- the @DataSource@ is created and ready for use, Amazon ML sets the
-- @Status@ parameter to @COMPLETED@. @DataSource@ in @COMPLETED@ or
-- @PENDING@ states can be used to perform only @CreateMLModel@,
-- @CreateEvaluation@, or @CreateBatchPrediction@ operations.
--
-- If Amazon ML can\'t accept the input source, it sets the @Status@
-- parameter to @FAILED@ and includes an error message in the @Message@
-- attribute of the @GetDataSource@ operation response.
--
-- The observations should be contained in the database hosted on an Amazon
-- Redshift cluster and should be specified by a @SelectSqlQuery@ query.
-- Amazon ML executes an @Unload@ command in Amazon Redshift to transfer
-- the result set of the @SelectSqlQuery@ query to @S3StagingLocation@.
--
-- After the @DataSource@ has been created, it\'s ready for use in
-- evaluations and batch predictions. If you plan to use the @DataSource@
-- to train an @MLModel@, the @DataSource@ also requires a recipe. A recipe
-- describes how each input variable will be used in training an @MLModel@.
-- Will the variable be included or excluded from training? Will the
-- variable be manipulated; for example, will it be combined with another
-- variable or will it be split apart into word combinations? The recipe
-- provides answers to these questions.
--
-- You can\'t change an existing datasource, but you can copy and modify
-- the settings from an existing Amazon Redshift datasource to create a new
-- datasource. To do so, call @GetDataSource@ for an existing datasource
-- and copy the values to a @CreateDataSource@ call. Change the settings
-- that you want to change and make sure that all required fields have the
-- appropriate values.
module Amazonka.MachineLearning.CreateDataSourceFromRedshift
  ( -- * Creating a Request
    CreateDataSourceFromRedshift (..),
    newCreateDataSourceFromRedshift,

    -- * Request Lenses
    createDataSourceFromRedshift_dataSourceName,
    createDataSourceFromRedshift_computeStatistics,
    createDataSourceFromRedshift_dataSourceId,
    createDataSourceFromRedshift_dataSpec,
    createDataSourceFromRedshift_roleARN,

    -- * Destructuring the Response
    CreateDataSourceFromRedshiftResponse (..),
    newCreateDataSourceFromRedshiftResponse,

    -- * Response Lenses
    createDataSourceFromRedshiftResponse_dataSourceId,
    createDataSourceFromRedshiftResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateDataSourceFromRedshift' smart constructor.
data CreateDataSourceFromRedshift = CreateDataSourceFromRedshift'
  { -- | A user-supplied name or description of the @DataSource@.
    CreateDataSourceFromRedshift -> Maybe Text
dataSourceName :: Prelude.Maybe Prelude.Text,
    -- | The compute statistics for a @DataSource@. The statistics are generated
    -- from the observation data referenced by a @DataSource@. Amazon ML uses
    -- the statistics internally during @MLModel@ training. This parameter must
    -- be set to @true@ if the @DataSource@ needs to be used for @MLModel@
    -- training.
    CreateDataSourceFromRedshift -> Maybe Bool
computeStatistics :: Prelude.Maybe Prelude.Bool,
    -- | A user-supplied ID that uniquely identifies the @DataSource@.
    CreateDataSourceFromRedshift -> Text
dataSourceId :: Prelude.Text,
    -- | The data specification of an Amazon Redshift @DataSource@:
    --
    -- -   DatabaseInformation -
    --
    --     -   @DatabaseName@ - The name of the Amazon Redshift database.
    --
    --     -   @ ClusterIdentifier@ - The unique ID for the Amazon Redshift
    --         cluster.
    --
    -- -   DatabaseCredentials - The AWS Identity and Access Management (IAM)
    --     credentials that are used to connect to the Amazon Redshift
    --     database.
    --
    -- -   SelectSqlQuery - The query that is used to retrieve the observation
    --     data for the @Datasource@.
    --
    -- -   S3StagingLocation - The Amazon Simple Storage Service (Amazon S3)
    --     location for staging Amazon Redshift data. The data retrieved from
    --     Amazon Redshift using the @SelectSqlQuery@ query is stored in this
    --     location.
    --
    -- -   DataSchemaUri - The Amazon S3 location of the @DataSchema@.
    --
    -- -   DataSchema - A JSON string representing the schema. This is not
    --     required if @DataSchemaUri@ is specified.
    --
    -- -   DataRearrangement - A JSON string that represents the splitting and
    --     rearrangement requirements for the @DataSource@.
    --
    --     Sample -
    --     @ \"{\\\"splitting\\\":{\\\"percentBegin\\\":10,\\\"percentEnd\\\":60}}\"@
    CreateDataSourceFromRedshift -> RedshiftDataSpec
dataSpec :: RedshiftDataSpec,
    -- | A fully specified role Amazon Resource Name (ARN). Amazon ML assumes the
    -- role on behalf of the user to create the following:
    --
    -- -   A security group to allow Amazon ML to execute the @SelectSqlQuery@
    --     query on an Amazon Redshift cluster
    --
    -- -   An Amazon S3 bucket policy to grant Amazon ML read\/write
    --     permissions on the @S3StagingLocation@
    CreateDataSourceFromRedshift -> Text
roleARN :: Prelude.Text
  }
  deriving (CreateDataSourceFromRedshift
-> CreateDataSourceFromRedshift -> Bool
(CreateDataSourceFromRedshift
 -> CreateDataSourceFromRedshift -> Bool)
-> (CreateDataSourceFromRedshift
    -> CreateDataSourceFromRedshift -> Bool)
-> Eq CreateDataSourceFromRedshift
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDataSourceFromRedshift
-> CreateDataSourceFromRedshift -> Bool
$c/= :: CreateDataSourceFromRedshift
-> CreateDataSourceFromRedshift -> Bool
== :: CreateDataSourceFromRedshift
-> CreateDataSourceFromRedshift -> Bool
$c== :: CreateDataSourceFromRedshift
-> CreateDataSourceFromRedshift -> Bool
Prelude.Eq, ReadPrec [CreateDataSourceFromRedshift]
ReadPrec CreateDataSourceFromRedshift
Int -> ReadS CreateDataSourceFromRedshift
ReadS [CreateDataSourceFromRedshift]
(Int -> ReadS CreateDataSourceFromRedshift)
-> ReadS [CreateDataSourceFromRedshift]
-> ReadPrec CreateDataSourceFromRedshift
-> ReadPrec [CreateDataSourceFromRedshift]
-> Read CreateDataSourceFromRedshift
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDataSourceFromRedshift]
$creadListPrec :: ReadPrec [CreateDataSourceFromRedshift]
readPrec :: ReadPrec CreateDataSourceFromRedshift
$creadPrec :: ReadPrec CreateDataSourceFromRedshift
readList :: ReadS [CreateDataSourceFromRedshift]
$creadList :: ReadS [CreateDataSourceFromRedshift]
readsPrec :: Int -> ReadS CreateDataSourceFromRedshift
$creadsPrec :: Int -> ReadS CreateDataSourceFromRedshift
Prelude.Read, Int -> CreateDataSourceFromRedshift -> ShowS
[CreateDataSourceFromRedshift] -> ShowS
CreateDataSourceFromRedshift -> String
(Int -> CreateDataSourceFromRedshift -> ShowS)
-> (CreateDataSourceFromRedshift -> String)
-> ([CreateDataSourceFromRedshift] -> ShowS)
-> Show CreateDataSourceFromRedshift
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDataSourceFromRedshift] -> ShowS
$cshowList :: [CreateDataSourceFromRedshift] -> ShowS
show :: CreateDataSourceFromRedshift -> String
$cshow :: CreateDataSourceFromRedshift -> String
showsPrec :: Int -> CreateDataSourceFromRedshift -> ShowS
$cshowsPrec :: Int -> CreateDataSourceFromRedshift -> ShowS
Prelude.Show, (forall x.
 CreateDataSourceFromRedshift -> Rep CreateDataSourceFromRedshift x)
-> (forall x.
    Rep CreateDataSourceFromRedshift x -> CreateDataSourceFromRedshift)
-> Generic CreateDataSourceFromRedshift
forall x.
Rep CreateDataSourceFromRedshift x -> CreateDataSourceFromRedshift
forall x.
CreateDataSourceFromRedshift -> Rep CreateDataSourceFromRedshift x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDataSourceFromRedshift x -> CreateDataSourceFromRedshift
$cfrom :: forall x.
CreateDataSourceFromRedshift -> Rep CreateDataSourceFromRedshift x
Prelude.Generic)

-- |
-- Create a value of 'CreateDataSourceFromRedshift' 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', 'createDataSourceFromRedshift_dataSourceName' - A user-supplied name or description of the @DataSource@.
--
-- 'computeStatistics', 'createDataSourceFromRedshift_computeStatistics' - The compute statistics for a @DataSource@. The statistics are generated
-- from the observation data referenced by a @DataSource@. Amazon ML uses
-- the statistics internally during @MLModel@ training. This parameter must
-- be set to @true@ if the @DataSource@ needs to be used for @MLModel@
-- training.
--
-- 'dataSourceId', 'createDataSourceFromRedshift_dataSourceId' - A user-supplied ID that uniquely identifies the @DataSource@.
--
-- 'dataSpec', 'createDataSourceFromRedshift_dataSpec' - The data specification of an Amazon Redshift @DataSource@:
--
-- -   DatabaseInformation -
--
--     -   @DatabaseName@ - The name of the Amazon Redshift database.
--
--     -   @ ClusterIdentifier@ - The unique ID for the Amazon Redshift
--         cluster.
--
-- -   DatabaseCredentials - The AWS Identity and Access Management (IAM)
--     credentials that are used to connect to the Amazon Redshift
--     database.
--
-- -   SelectSqlQuery - The query that is used to retrieve the observation
--     data for the @Datasource@.
--
-- -   S3StagingLocation - The Amazon Simple Storage Service (Amazon S3)
--     location for staging Amazon Redshift data. The data retrieved from
--     Amazon Redshift using the @SelectSqlQuery@ query is stored in this
--     location.
--
-- -   DataSchemaUri - The Amazon S3 location of the @DataSchema@.
--
-- -   DataSchema - A JSON string representing the schema. This is not
--     required if @DataSchemaUri@ is specified.
--
-- -   DataRearrangement - A JSON string that represents the splitting and
--     rearrangement requirements for the @DataSource@.
--
--     Sample -
--     @ \"{\\\"splitting\\\":{\\\"percentBegin\\\":10,\\\"percentEnd\\\":60}}\"@
--
-- 'roleARN', 'createDataSourceFromRedshift_roleARN' - A fully specified role Amazon Resource Name (ARN). Amazon ML assumes the
-- role on behalf of the user to create the following:
--
-- -   A security group to allow Amazon ML to execute the @SelectSqlQuery@
--     query on an Amazon Redshift cluster
--
-- -   An Amazon S3 bucket policy to grant Amazon ML read\/write
--     permissions on the @S3StagingLocation@
newCreateDataSourceFromRedshift ::
  -- | 'dataSourceId'
  Prelude.Text ->
  -- | 'dataSpec'
  RedshiftDataSpec ->
  -- | 'roleARN'
  Prelude.Text ->
  CreateDataSourceFromRedshift
newCreateDataSourceFromRedshift :: Text -> RedshiftDataSpec -> Text -> CreateDataSourceFromRedshift
newCreateDataSourceFromRedshift
  Text
pDataSourceId_
  RedshiftDataSpec
pDataSpec_
  Text
pRoleARN_ =
    CreateDataSourceFromRedshift' :: Maybe Text
-> Maybe Bool
-> Text
-> RedshiftDataSpec
-> Text
-> CreateDataSourceFromRedshift
CreateDataSourceFromRedshift'
      { $sel:dataSourceName:CreateDataSourceFromRedshift' :: Maybe Text
dataSourceName =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:computeStatistics:CreateDataSourceFromRedshift' :: Maybe Bool
computeStatistics = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:dataSourceId:CreateDataSourceFromRedshift' :: Text
dataSourceId = Text
pDataSourceId_,
        $sel:dataSpec:CreateDataSourceFromRedshift' :: RedshiftDataSpec
dataSpec = RedshiftDataSpec
pDataSpec_,
        $sel:roleARN:CreateDataSourceFromRedshift' :: Text
roleARN = Text
pRoleARN_
      }

-- | A user-supplied name or description of the @DataSource@.
createDataSourceFromRedshift_dataSourceName :: Lens.Lens' CreateDataSourceFromRedshift (Prelude.Maybe Prelude.Text)
createDataSourceFromRedshift_dataSourceName :: (Maybe Text -> f (Maybe Text))
-> CreateDataSourceFromRedshift -> f CreateDataSourceFromRedshift
createDataSourceFromRedshift_dataSourceName = (CreateDataSourceFromRedshift -> Maybe Text)
-> (CreateDataSourceFromRedshift
    -> Maybe Text -> CreateDataSourceFromRedshift)
-> Lens
     CreateDataSourceFromRedshift
     CreateDataSourceFromRedshift
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceFromRedshift' {Maybe Text
dataSourceName :: Maybe Text
$sel:dataSourceName:CreateDataSourceFromRedshift' :: CreateDataSourceFromRedshift -> Maybe Text
dataSourceName} -> Maybe Text
dataSourceName) (\s :: CreateDataSourceFromRedshift
s@CreateDataSourceFromRedshift' {} Maybe Text
a -> CreateDataSourceFromRedshift
s {$sel:dataSourceName:CreateDataSourceFromRedshift' :: Maybe Text
dataSourceName = Maybe Text
a} :: CreateDataSourceFromRedshift)

-- | The compute statistics for a @DataSource@. The statistics are generated
-- from the observation data referenced by a @DataSource@. Amazon ML uses
-- the statistics internally during @MLModel@ training. This parameter must
-- be set to @true@ if the @DataSource@ needs to be used for @MLModel@
-- training.
createDataSourceFromRedshift_computeStatistics :: Lens.Lens' CreateDataSourceFromRedshift (Prelude.Maybe Prelude.Bool)
createDataSourceFromRedshift_computeStatistics :: (Maybe Bool -> f (Maybe Bool))
-> CreateDataSourceFromRedshift -> f CreateDataSourceFromRedshift
createDataSourceFromRedshift_computeStatistics = (CreateDataSourceFromRedshift -> Maybe Bool)
-> (CreateDataSourceFromRedshift
    -> Maybe Bool -> CreateDataSourceFromRedshift)
-> Lens
     CreateDataSourceFromRedshift
     CreateDataSourceFromRedshift
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceFromRedshift' {Maybe Bool
computeStatistics :: Maybe Bool
$sel:computeStatistics:CreateDataSourceFromRedshift' :: CreateDataSourceFromRedshift -> Maybe Bool
computeStatistics} -> Maybe Bool
computeStatistics) (\s :: CreateDataSourceFromRedshift
s@CreateDataSourceFromRedshift' {} Maybe Bool
a -> CreateDataSourceFromRedshift
s {$sel:computeStatistics:CreateDataSourceFromRedshift' :: Maybe Bool
computeStatistics = Maybe Bool
a} :: CreateDataSourceFromRedshift)

-- | A user-supplied ID that uniquely identifies the @DataSource@.
createDataSourceFromRedshift_dataSourceId :: Lens.Lens' CreateDataSourceFromRedshift Prelude.Text
createDataSourceFromRedshift_dataSourceId :: (Text -> f Text)
-> CreateDataSourceFromRedshift -> f CreateDataSourceFromRedshift
createDataSourceFromRedshift_dataSourceId = (CreateDataSourceFromRedshift -> Text)
-> (CreateDataSourceFromRedshift
    -> Text -> CreateDataSourceFromRedshift)
-> Lens
     CreateDataSourceFromRedshift CreateDataSourceFromRedshift Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceFromRedshift' {Text
dataSourceId :: Text
$sel:dataSourceId:CreateDataSourceFromRedshift' :: CreateDataSourceFromRedshift -> Text
dataSourceId} -> Text
dataSourceId) (\s :: CreateDataSourceFromRedshift
s@CreateDataSourceFromRedshift' {} Text
a -> CreateDataSourceFromRedshift
s {$sel:dataSourceId:CreateDataSourceFromRedshift' :: Text
dataSourceId = Text
a} :: CreateDataSourceFromRedshift)

-- | The data specification of an Amazon Redshift @DataSource@:
--
-- -   DatabaseInformation -
--
--     -   @DatabaseName@ - The name of the Amazon Redshift database.
--
--     -   @ ClusterIdentifier@ - The unique ID for the Amazon Redshift
--         cluster.
--
-- -   DatabaseCredentials - The AWS Identity and Access Management (IAM)
--     credentials that are used to connect to the Amazon Redshift
--     database.
--
-- -   SelectSqlQuery - The query that is used to retrieve the observation
--     data for the @Datasource@.
--
-- -   S3StagingLocation - The Amazon Simple Storage Service (Amazon S3)
--     location for staging Amazon Redshift data. The data retrieved from
--     Amazon Redshift using the @SelectSqlQuery@ query is stored in this
--     location.
--
-- -   DataSchemaUri - The Amazon S3 location of the @DataSchema@.
--
-- -   DataSchema - A JSON string representing the schema. This is not
--     required if @DataSchemaUri@ is specified.
--
-- -   DataRearrangement - A JSON string that represents the splitting and
--     rearrangement requirements for the @DataSource@.
--
--     Sample -
--     @ \"{\\\"splitting\\\":{\\\"percentBegin\\\":10,\\\"percentEnd\\\":60}}\"@
createDataSourceFromRedshift_dataSpec :: Lens.Lens' CreateDataSourceFromRedshift RedshiftDataSpec
createDataSourceFromRedshift_dataSpec :: (RedshiftDataSpec -> f RedshiftDataSpec)
-> CreateDataSourceFromRedshift -> f CreateDataSourceFromRedshift
createDataSourceFromRedshift_dataSpec = (CreateDataSourceFromRedshift -> RedshiftDataSpec)
-> (CreateDataSourceFromRedshift
    -> RedshiftDataSpec -> CreateDataSourceFromRedshift)
-> Lens
     CreateDataSourceFromRedshift
     CreateDataSourceFromRedshift
     RedshiftDataSpec
     RedshiftDataSpec
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceFromRedshift' {RedshiftDataSpec
dataSpec :: RedshiftDataSpec
$sel:dataSpec:CreateDataSourceFromRedshift' :: CreateDataSourceFromRedshift -> RedshiftDataSpec
dataSpec} -> RedshiftDataSpec
dataSpec) (\s :: CreateDataSourceFromRedshift
s@CreateDataSourceFromRedshift' {} RedshiftDataSpec
a -> CreateDataSourceFromRedshift
s {$sel:dataSpec:CreateDataSourceFromRedshift' :: RedshiftDataSpec
dataSpec = RedshiftDataSpec
a} :: CreateDataSourceFromRedshift)

-- | A fully specified role Amazon Resource Name (ARN). Amazon ML assumes the
-- role on behalf of the user to create the following:
--
-- -   A security group to allow Amazon ML to execute the @SelectSqlQuery@
--     query on an Amazon Redshift cluster
--
-- -   An Amazon S3 bucket policy to grant Amazon ML read\/write
--     permissions on the @S3StagingLocation@
createDataSourceFromRedshift_roleARN :: Lens.Lens' CreateDataSourceFromRedshift Prelude.Text
createDataSourceFromRedshift_roleARN :: (Text -> f Text)
-> CreateDataSourceFromRedshift -> f CreateDataSourceFromRedshift
createDataSourceFromRedshift_roleARN = (CreateDataSourceFromRedshift -> Text)
-> (CreateDataSourceFromRedshift
    -> Text -> CreateDataSourceFromRedshift)
-> Lens
     CreateDataSourceFromRedshift CreateDataSourceFromRedshift Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceFromRedshift' {Text
roleARN :: Text
$sel:roleARN:CreateDataSourceFromRedshift' :: CreateDataSourceFromRedshift -> Text
roleARN} -> Text
roleARN) (\s :: CreateDataSourceFromRedshift
s@CreateDataSourceFromRedshift' {} Text
a -> CreateDataSourceFromRedshift
s {$sel:roleARN:CreateDataSourceFromRedshift' :: Text
roleARN = Text
a} :: CreateDataSourceFromRedshift)

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

instance Prelude.NFData CreateDataSourceFromRedshift

instance Core.ToHeaders CreateDataSourceFromRedshift where
  toHeaders :: CreateDataSourceFromRedshift -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateDataSourceFromRedshift -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AmazonML_20141212.CreateDataSourceFromRedshift" ::
                          Prelude.ByteString
                      ),
            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 CreateDataSourceFromRedshift where
  toJSON :: CreateDataSourceFromRedshift -> Value
toJSON CreateDataSourceFromRedshift' {Maybe Bool
Maybe Text
Text
RedshiftDataSpec
roleARN :: Text
dataSpec :: RedshiftDataSpec
dataSourceId :: Text
computeStatistics :: Maybe Bool
dataSourceName :: Maybe Text
$sel:roleARN:CreateDataSourceFromRedshift' :: CreateDataSourceFromRedshift -> Text
$sel:dataSpec:CreateDataSourceFromRedshift' :: CreateDataSourceFromRedshift -> RedshiftDataSpec
$sel:dataSourceId:CreateDataSourceFromRedshift' :: CreateDataSourceFromRedshift -> Text
$sel:computeStatistics:CreateDataSourceFromRedshift' :: CreateDataSourceFromRedshift -> Maybe Bool
$sel:dataSourceName:CreateDataSourceFromRedshift' :: CreateDataSourceFromRedshift -> 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
"ComputeStatistics" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
computeStatistics,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DataSourceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
dataSourceId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DataSpec" Text -> RedshiftDataSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RedshiftDataSpec
dataSpec),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RoleARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleARN)
          ]
      )

instance Core.ToPath CreateDataSourceFromRedshift where
  toPath :: CreateDataSourceFromRedshift -> ByteString
toPath = ByteString -> CreateDataSourceFromRedshift -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | Represents the output of a @CreateDataSourceFromRedshift@ operation, and
-- is an acknowledgement that Amazon ML received the request.
--
-- The @CreateDataSourceFromRedshift@ operation is asynchronous. You can
-- poll for updates by using the @GetBatchPrediction@ operation and
-- checking the @Status@ parameter.
--
-- /See:/ 'newCreateDataSourceFromRedshiftResponse' smart constructor.
data CreateDataSourceFromRedshiftResponse = CreateDataSourceFromRedshiftResponse'
  { -- | A user-supplied ID that uniquely identifies the datasource. This value
    -- should be identical to the value of the @DataSourceID@ in the request.
    CreateDataSourceFromRedshiftResponse -> Maybe Text
dataSourceId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateDataSourceFromRedshiftResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDataSourceFromRedshiftResponse
-> CreateDataSourceFromRedshiftResponse -> Bool
(CreateDataSourceFromRedshiftResponse
 -> CreateDataSourceFromRedshiftResponse -> Bool)
-> (CreateDataSourceFromRedshiftResponse
    -> CreateDataSourceFromRedshiftResponse -> Bool)
-> Eq CreateDataSourceFromRedshiftResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDataSourceFromRedshiftResponse
-> CreateDataSourceFromRedshiftResponse -> Bool
$c/= :: CreateDataSourceFromRedshiftResponse
-> CreateDataSourceFromRedshiftResponse -> Bool
== :: CreateDataSourceFromRedshiftResponse
-> CreateDataSourceFromRedshiftResponse -> Bool
$c== :: CreateDataSourceFromRedshiftResponse
-> CreateDataSourceFromRedshiftResponse -> Bool
Prelude.Eq, ReadPrec [CreateDataSourceFromRedshiftResponse]
ReadPrec CreateDataSourceFromRedshiftResponse
Int -> ReadS CreateDataSourceFromRedshiftResponse
ReadS [CreateDataSourceFromRedshiftResponse]
(Int -> ReadS CreateDataSourceFromRedshiftResponse)
-> ReadS [CreateDataSourceFromRedshiftResponse]
-> ReadPrec CreateDataSourceFromRedshiftResponse
-> ReadPrec [CreateDataSourceFromRedshiftResponse]
-> Read CreateDataSourceFromRedshiftResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDataSourceFromRedshiftResponse]
$creadListPrec :: ReadPrec [CreateDataSourceFromRedshiftResponse]
readPrec :: ReadPrec CreateDataSourceFromRedshiftResponse
$creadPrec :: ReadPrec CreateDataSourceFromRedshiftResponse
readList :: ReadS [CreateDataSourceFromRedshiftResponse]
$creadList :: ReadS [CreateDataSourceFromRedshiftResponse]
readsPrec :: Int -> ReadS CreateDataSourceFromRedshiftResponse
$creadsPrec :: Int -> ReadS CreateDataSourceFromRedshiftResponse
Prelude.Read, Int -> CreateDataSourceFromRedshiftResponse -> ShowS
[CreateDataSourceFromRedshiftResponse] -> ShowS
CreateDataSourceFromRedshiftResponse -> String
(Int -> CreateDataSourceFromRedshiftResponse -> ShowS)
-> (CreateDataSourceFromRedshiftResponse -> String)
-> ([CreateDataSourceFromRedshiftResponse] -> ShowS)
-> Show CreateDataSourceFromRedshiftResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDataSourceFromRedshiftResponse] -> ShowS
$cshowList :: [CreateDataSourceFromRedshiftResponse] -> ShowS
show :: CreateDataSourceFromRedshiftResponse -> String
$cshow :: CreateDataSourceFromRedshiftResponse -> String
showsPrec :: Int -> CreateDataSourceFromRedshiftResponse -> ShowS
$cshowsPrec :: Int -> CreateDataSourceFromRedshiftResponse -> ShowS
Prelude.Show, (forall x.
 CreateDataSourceFromRedshiftResponse
 -> Rep CreateDataSourceFromRedshiftResponse x)
-> (forall x.
    Rep CreateDataSourceFromRedshiftResponse x
    -> CreateDataSourceFromRedshiftResponse)
-> Generic CreateDataSourceFromRedshiftResponse
forall x.
Rep CreateDataSourceFromRedshiftResponse x
-> CreateDataSourceFromRedshiftResponse
forall x.
CreateDataSourceFromRedshiftResponse
-> Rep CreateDataSourceFromRedshiftResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDataSourceFromRedshiftResponse x
-> CreateDataSourceFromRedshiftResponse
$cfrom :: forall x.
CreateDataSourceFromRedshiftResponse
-> Rep CreateDataSourceFromRedshiftResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateDataSourceFromRedshiftResponse' 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:
--
-- 'dataSourceId', 'createDataSourceFromRedshiftResponse_dataSourceId' - A user-supplied ID that uniquely identifies the datasource. This value
-- should be identical to the value of the @DataSourceID@ in the request.
--
-- 'httpStatus', 'createDataSourceFromRedshiftResponse_httpStatus' - The response's http status code.
newCreateDataSourceFromRedshiftResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDataSourceFromRedshiftResponse
newCreateDataSourceFromRedshiftResponse :: Int -> CreateDataSourceFromRedshiftResponse
newCreateDataSourceFromRedshiftResponse Int
pHttpStatus_ =
  CreateDataSourceFromRedshiftResponse' :: Maybe Text -> Int -> CreateDataSourceFromRedshiftResponse
CreateDataSourceFromRedshiftResponse'
    { $sel:dataSourceId:CreateDataSourceFromRedshiftResponse' :: Maybe Text
dataSourceId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateDataSourceFromRedshiftResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A user-supplied ID that uniquely identifies the datasource. This value
-- should be identical to the value of the @DataSourceID@ in the request.
createDataSourceFromRedshiftResponse_dataSourceId :: Lens.Lens' CreateDataSourceFromRedshiftResponse (Prelude.Maybe Prelude.Text)
createDataSourceFromRedshiftResponse_dataSourceId :: (Maybe Text -> f (Maybe Text))
-> CreateDataSourceFromRedshiftResponse
-> f CreateDataSourceFromRedshiftResponse
createDataSourceFromRedshiftResponse_dataSourceId = (CreateDataSourceFromRedshiftResponse -> Maybe Text)
-> (CreateDataSourceFromRedshiftResponse
    -> Maybe Text -> CreateDataSourceFromRedshiftResponse)
-> Lens
     CreateDataSourceFromRedshiftResponse
     CreateDataSourceFromRedshiftResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceFromRedshiftResponse' {Maybe Text
dataSourceId :: Maybe Text
$sel:dataSourceId:CreateDataSourceFromRedshiftResponse' :: CreateDataSourceFromRedshiftResponse -> Maybe Text
dataSourceId} -> Maybe Text
dataSourceId) (\s :: CreateDataSourceFromRedshiftResponse
s@CreateDataSourceFromRedshiftResponse' {} Maybe Text
a -> CreateDataSourceFromRedshiftResponse
s {$sel:dataSourceId:CreateDataSourceFromRedshiftResponse' :: Maybe Text
dataSourceId = Maybe Text
a} :: CreateDataSourceFromRedshiftResponse)

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

instance
  Prelude.NFData
    CreateDataSourceFromRedshiftResponse