{-# 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.CreateDataSourceFromRDS
-- 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@ object from an
-- <http://aws.amazon.com/rds/ Amazon Relational Database Service> (Amazon
-- RDS). A @DataSource@ references data that can be used to perform
-- @CreateMLModel@, @CreateEvaluation@, or @CreateBatchPrediction@
-- operations.
--
-- @CreateDataSourceFromRDS@ is an asynchronous operation. In response to
-- @CreateDataSourceFromRDS@, 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 the @COMPLETED@ or
-- @PENDING@ state can be used only to perform @>CreateMLModel@>,
-- @CreateEvaluation@, or @CreateBatchPrediction@ operations.
--
-- If Amazon ML cannot 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.
module Amazonka.MachineLearning.CreateDataSourceFromRDS
  ( -- * Creating a Request
    CreateDataSourceFromRDS (..),
    newCreateDataSourceFromRDS,

    -- * Request Lenses
    createDataSourceFromRDS_dataSourceName,
    createDataSourceFromRDS_computeStatistics,
    createDataSourceFromRDS_dataSourceId,
    createDataSourceFromRDS_rDSData,
    createDataSourceFromRDS_roleARN,

    -- * Destructuring the Response
    CreateDataSourceFromRDSResponse (..),
    newCreateDataSourceFromRDSResponse,

    -- * Response Lenses
    createDataSourceFromRDSResponse_dataSourceId,
    createDataSourceFromRDSResponse_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:/ 'newCreateDataSourceFromRDS' smart constructor.
data CreateDataSourceFromRDS = CreateDataSourceFromRDS'
  { -- | A user-supplied name or description of the @DataSource@.
    CreateDataSourceFromRDS -> 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.
    CreateDataSourceFromRDS -> Maybe Bool
computeStatistics :: Prelude.Maybe Prelude.Bool,
    -- | A user-supplied ID that uniquely identifies the @DataSource@. Typically,
    -- an Amazon Resource Number (ARN) becomes the ID for a @DataSource@.
    CreateDataSourceFromRDS -> Text
dataSourceId :: Prelude.Text,
    -- | The data specification of an Amazon RDS @DataSource@:
    --
    -- -   DatabaseInformation -
    --
    --     -   @DatabaseName@ - The name of the Amazon RDS database.
    --
    --     -   @InstanceIdentifier @ - A unique identifier for the Amazon RDS
    --         database instance.
    --
    -- -   DatabaseCredentials - AWS Identity and Access Management (IAM)
    --     credentials that are used to connect to the Amazon RDS database.
    --
    -- -   ResourceRole - A role (DataPipelineDefaultResourceRole) assumed by
    --     an EC2 instance to carry out the copy task from Amazon RDS to Amazon
    --     Simple Storage Service (Amazon S3). For more information, see
    --     <https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-iam-roles.html Role templates>
    --     for data pipelines.
    --
    -- -   ServiceRole - A role (DataPipelineDefaultRole) assumed by the AWS
    --     Data Pipeline service to monitor the progress of the copy task from
    --     Amazon RDS to Amazon S3. For more information, see
    --     <https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-iam-roles.html Role templates>
    --     for data pipelines.
    --
    -- -   SecurityInfo - The security information to use to access an RDS DB
    --     instance. You need to set up appropriate ingress rules for the
    --     security entity IDs provided to allow access to the Amazon RDS
    --     instance. Specify a [@SubnetId@, @SecurityGroupIds@] pair for a
    --     VPC-based RDS DB instance.
    --
    -- -   SelectSqlQuery - A query that is used to retrieve the observation
    --     data for the @Datasource@.
    --
    -- -   S3StagingLocation - The Amazon S3 location for staging Amazon RDS
    --     data. The data retrieved from Amazon RDS using @SelectSqlQuery@ 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}}\"@
    CreateDataSourceFromRDS -> RDSDataSpec
rDSData :: RDSDataSpec,
    -- | The role that Amazon ML assumes on behalf of the user to create and
    -- activate a data pipeline in the user\'s account and copy data using the
    -- @SelectSqlQuery@ query from Amazon RDS to Amazon S3.
    CreateDataSourceFromRDS -> Text
roleARN :: Prelude.Text
  }
  deriving (CreateDataSourceFromRDS -> CreateDataSourceFromRDS -> Bool
(CreateDataSourceFromRDS -> CreateDataSourceFromRDS -> Bool)
-> (CreateDataSourceFromRDS -> CreateDataSourceFromRDS -> Bool)
-> Eq CreateDataSourceFromRDS
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDataSourceFromRDS -> CreateDataSourceFromRDS -> Bool
$c/= :: CreateDataSourceFromRDS -> CreateDataSourceFromRDS -> Bool
== :: CreateDataSourceFromRDS -> CreateDataSourceFromRDS -> Bool
$c== :: CreateDataSourceFromRDS -> CreateDataSourceFromRDS -> Bool
Prelude.Eq, ReadPrec [CreateDataSourceFromRDS]
ReadPrec CreateDataSourceFromRDS
Int -> ReadS CreateDataSourceFromRDS
ReadS [CreateDataSourceFromRDS]
(Int -> ReadS CreateDataSourceFromRDS)
-> ReadS [CreateDataSourceFromRDS]
-> ReadPrec CreateDataSourceFromRDS
-> ReadPrec [CreateDataSourceFromRDS]
-> Read CreateDataSourceFromRDS
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDataSourceFromRDS]
$creadListPrec :: ReadPrec [CreateDataSourceFromRDS]
readPrec :: ReadPrec CreateDataSourceFromRDS
$creadPrec :: ReadPrec CreateDataSourceFromRDS
readList :: ReadS [CreateDataSourceFromRDS]
$creadList :: ReadS [CreateDataSourceFromRDS]
readsPrec :: Int -> ReadS CreateDataSourceFromRDS
$creadsPrec :: Int -> ReadS CreateDataSourceFromRDS
Prelude.Read, Int -> CreateDataSourceFromRDS -> ShowS
[CreateDataSourceFromRDS] -> ShowS
CreateDataSourceFromRDS -> String
(Int -> CreateDataSourceFromRDS -> ShowS)
-> (CreateDataSourceFromRDS -> String)
-> ([CreateDataSourceFromRDS] -> ShowS)
-> Show CreateDataSourceFromRDS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDataSourceFromRDS] -> ShowS
$cshowList :: [CreateDataSourceFromRDS] -> ShowS
show :: CreateDataSourceFromRDS -> String
$cshow :: CreateDataSourceFromRDS -> String
showsPrec :: Int -> CreateDataSourceFromRDS -> ShowS
$cshowsPrec :: Int -> CreateDataSourceFromRDS -> ShowS
Prelude.Show, (forall x.
 CreateDataSourceFromRDS -> Rep CreateDataSourceFromRDS x)
-> (forall x.
    Rep CreateDataSourceFromRDS x -> CreateDataSourceFromRDS)
-> Generic CreateDataSourceFromRDS
forall x. Rep CreateDataSourceFromRDS x -> CreateDataSourceFromRDS
forall x. CreateDataSourceFromRDS -> Rep CreateDataSourceFromRDS x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDataSourceFromRDS x -> CreateDataSourceFromRDS
$cfrom :: forall x. CreateDataSourceFromRDS -> Rep CreateDataSourceFromRDS x
Prelude.Generic)

-- |
-- Create a value of 'CreateDataSourceFromRDS' 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', 'createDataSourceFromRDS_dataSourceName' - A user-supplied name or description of the @DataSource@.
--
-- 'computeStatistics', 'createDataSourceFromRDS_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', 'createDataSourceFromRDS_dataSourceId' - A user-supplied ID that uniquely identifies the @DataSource@. Typically,
-- an Amazon Resource Number (ARN) becomes the ID for a @DataSource@.
--
-- 'rDSData', 'createDataSourceFromRDS_rDSData' - The data specification of an Amazon RDS @DataSource@:
--
-- -   DatabaseInformation -
--
--     -   @DatabaseName@ - The name of the Amazon RDS database.
--
--     -   @InstanceIdentifier @ - A unique identifier for the Amazon RDS
--         database instance.
--
-- -   DatabaseCredentials - AWS Identity and Access Management (IAM)
--     credentials that are used to connect to the Amazon RDS database.
--
-- -   ResourceRole - A role (DataPipelineDefaultResourceRole) assumed by
--     an EC2 instance to carry out the copy task from Amazon RDS to Amazon
--     Simple Storage Service (Amazon S3). For more information, see
--     <https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-iam-roles.html Role templates>
--     for data pipelines.
--
-- -   ServiceRole - A role (DataPipelineDefaultRole) assumed by the AWS
--     Data Pipeline service to monitor the progress of the copy task from
--     Amazon RDS to Amazon S3. For more information, see
--     <https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-iam-roles.html Role templates>
--     for data pipelines.
--
-- -   SecurityInfo - The security information to use to access an RDS DB
--     instance. You need to set up appropriate ingress rules for the
--     security entity IDs provided to allow access to the Amazon RDS
--     instance. Specify a [@SubnetId@, @SecurityGroupIds@] pair for a
--     VPC-based RDS DB instance.
--
-- -   SelectSqlQuery - A query that is used to retrieve the observation
--     data for the @Datasource@.
--
-- -   S3StagingLocation - The Amazon S3 location for staging Amazon RDS
--     data. The data retrieved from Amazon RDS using @SelectSqlQuery@ 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', 'createDataSourceFromRDS_roleARN' - The role that Amazon ML assumes on behalf of the user to create and
-- activate a data pipeline in the user\'s account and copy data using the
-- @SelectSqlQuery@ query from Amazon RDS to Amazon S3.
newCreateDataSourceFromRDS ::
  -- | 'dataSourceId'
  Prelude.Text ->
  -- | 'rDSData'
  RDSDataSpec ->
  -- | 'roleARN'
  Prelude.Text ->
  CreateDataSourceFromRDS
newCreateDataSourceFromRDS :: Text -> RDSDataSpec -> Text -> CreateDataSourceFromRDS
newCreateDataSourceFromRDS
  Text
pDataSourceId_
  RDSDataSpec
pRDSData_
  Text
pRoleARN_ =
    CreateDataSourceFromRDS' :: Maybe Text
-> Maybe Bool
-> Text
-> RDSDataSpec
-> Text
-> CreateDataSourceFromRDS
CreateDataSourceFromRDS'
      { $sel:dataSourceName:CreateDataSourceFromRDS' :: Maybe Text
dataSourceName =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:computeStatistics:CreateDataSourceFromRDS' :: Maybe Bool
computeStatistics = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:dataSourceId:CreateDataSourceFromRDS' :: Text
dataSourceId = Text
pDataSourceId_,
        $sel:rDSData:CreateDataSourceFromRDS' :: RDSDataSpec
rDSData = RDSDataSpec
pRDSData_,
        $sel:roleARN:CreateDataSourceFromRDS' :: Text
roleARN = Text
pRoleARN_
      }

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

-- | 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.
createDataSourceFromRDS_computeStatistics :: Lens.Lens' CreateDataSourceFromRDS (Prelude.Maybe Prelude.Bool)
createDataSourceFromRDS_computeStatistics :: (Maybe Bool -> f (Maybe Bool))
-> CreateDataSourceFromRDS -> f CreateDataSourceFromRDS
createDataSourceFromRDS_computeStatistics = (CreateDataSourceFromRDS -> Maybe Bool)
-> (CreateDataSourceFromRDS
    -> Maybe Bool -> CreateDataSourceFromRDS)
-> Lens
     CreateDataSourceFromRDS
     CreateDataSourceFromRDS
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceFromRDS' {Maybe Bool
computeStatistics :: Maybe Bool
$sel:computeStatistics:CreateDataSourceFromRDS' :: CreateDataSourceFromRDS -> Maybe Bool
computeStatistics} -> Maybe Bool
computeStatistics) (\s :: CreateDataSourceFromRDS
s@CreateDataSourceFromRDS' {} Maybe Bool
a -> CreateDataSourceFromRDS
s {$sel:computeStatistics:CreateDataSourceFromRDS' :: Maybe Bool
computeStatistics = Maybe Bool
a} :: CreateDataSourceFromRDS)

-- | A user-supplied ID that uniquely identifies the @DataSource@. Typically,
-- an Amazon Resource Number (ARN) becomes the ID for a @DataSource@.
createDataSourceFromRDS_dataSourceId :: Lens.Lens' CreateDataSourceFromRDS Prelude.Text
createDataSourceFromRDS_dataSourceId :: (Text -> f Text)
-> CreateDataSourceFromRDS -> f CreateDataSourceFromRDS
createDataSourceFromRDS_dataSourceId = (CreateDataSourceFromRDS -> Text)
-> (CreateDataSourceFromRDS -> Text -> CreateDataSourceFromRDS)
-> Lens CreateDataSourceFromRDS CreateDataSourceFromRDS Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceFromRDS' {Text
dataSourceId :: Text
$sel:dataSourceId:CreateDataSourceFromRDS' :: CreateDataSourceFromRDS -> Text
dataSourceId} -> Text
dataSourceId) (\s :: CreateDataSourceFromRDS
s@CreateDataSourceFromRDS' {} Text
a -> CreateDataSourceFromRDS
s {$sel:dataSourceId:CreateDataSourceFromRDS' :: Text
dataSourceId = Text
a} :: CreateDataSourceFromRDS)

-- | The data specification of an Amazon RDS @DataSource@:
--
-- -   DatabaseInformation -
--
--     -   @DatabaseName@ - The name of the Amazon RDS database.
--
--     -   @InstanceIdentifier @ - A unique identifier for the Amazon RDS
--         database instance.
--
-- -   DatabaseCredentials - AWS Identity and Access Management (IAM)
--     credentials that are used to connect to the Amazon RDS database.
--
-- -   ResourceRole - A role (DataPipelineDefaultResourceRole) assumed by
--     an EC2 instance to carry out the copy task from Amazon RDS to Amazon
--     Simple Storage Service (Amazon S3). For more information, see
--     <https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-iam-roles.html Role templates>
--     for data pipelines.
--
-- -   ServiceRole - A role (DataPipelineDefaultRole) assumed by the AWS
--     Data Pipeline service to monitor the progress of the copy task from
--     Amazon RDS to Amazon S3. For more information, see
--     <https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-iam-roles.html Role templates>
--     for data pipelines.
--
-- -   SecurityInfo - The security information to use to access an RDS DB
--     instance. You need to set up appropriate ingress rules for the
--     security entity IDs provided to allow access to the Amazon RDS
--     instance. Specify a [@SubnetId@, @SecurityGroupIds@] pair for a
--     VPC-based RDS DB instance.
--
-- -   SelectSqlQuery - A query that is used to retrieve the observation
--     data for the @Datasource@.
--
-- -   S3StagingLocation - The Amazon S3 location for staging Amazon RDS
--     data. The data retrieved from Amazon RDS using @SelectSqlQuery@ 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}}\"@
createDataSourceFromRDS_rDSData :: Lens.Lens' CreateDataSourceFromRDS RDSDataSpec
createDataSourceFromRDS_rDSData :: (RDSDataSpec -> f RDSDataSpec)
-> CreateDataSourceFromRDS -> f CreateDataSourceFromRDS
createDataSourceFromRDS_rDSData = (CreateDataSourceFromRDS -> RDSDataSpec)
-> (CreateDataSourceFromRDS
    -> RDSDataSpec -> CreateDataSourceFromRDS)
-> Lens
     CreateDataSourceFromRDS
     CreateDataSourceFromRDS
     RDSDataSpec
     RDSDataSpec
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceFromRDS' {RDSDataSpec
rDSData :: RDSDataSpec
$sel:rDSData:CreateDataSourceFromRDS' :: CreateDataSourceFromRDS -> RDSDataSpec
rDSData} -> RDSDataSpec
rDSData) (\s :: CreateDataSourceFromRDS
s@CreateDataSourceFromRDS' {} RDSDataSpec
a -> CreateDataSourceFromRDS
s {$sel:rDSData:CreateDataSourceFromRDS' :: RDSDataSpec
rDSData = RDSDataSpec
a} :: CreateDataSourceFromRDS)

-- | The role that Amazon ML assumes on behalf of the user to create and
-- activate a data pipeline in the user\'s account and copy data using the
-- @SelectSqlQuery@ query from Amazon RDS to Amazon S3.
createDataSourceFromRDS_roleARN :: Lens.Lens' CreateDataSourceFromRDS Prelude.Text
createDataSourceFromRDS_roleARN :: (Text -> f Text)
-> CreateDataSourceFromRDS -> f CreateDataSourceFromRDS
createDataSourceFromRDS_roleARN = (CreateDataSourceFromRDS -> Text)
-> (CreateDataSourceFromRDS -> Text -> CreateDataSourceFromRDS)
-> Lens CreateDataSourceFromRDS CreateDataSourceFromRDS Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceFromRDS' {Text
roleARN :: Text
$sel:roleARN:CreateDataSourceFromRDS' :: CreateDataSourceFromRDS -> Text
roleARN} -> Text
roleARN) (\s :: CreateDataSourceFromRDS
s@CreateDataSourceFromRDS' {} Text
a -> CreateDataSourceFromRDS
s {$sel:roleARN:CreateDataSourceFromRDS' :: Text
roleARN = Text
a} :: CreateDataSourceFromRDS)

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

instance Prelude.NFData CreateDataSourceFromRDS

instance Core.ToHeaders CreateDataSourceFromRDS where
  toHeaders :: CreateDataSourceFromRDS -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateDataSourceFromRDS -> 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.CreateDataSourceFromRDS" ::
                          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 CreateDataSourceFromRDS where
  toJSON :: CreateDataSourceFromRDS -> Value
toJSON CreateDataSourceFromRDS' {Maybe Bool
Maybe Text
Text
RDSDataSpec
roleARN :: Text
rDSData :: RDSDataSpec
dataSourceId :: Text
computeStatistics :: Maybe Bool
dataSourceName :: Maybe Text
$sel:roleARN:CreateDataSourceFromRDS' :: CreateDataSourceFromRDS -> Text
$sel:rDSData:CreateDataSourceFromRDS' :: CreateDataSourceFromRDS -> RDSDataSpec
$sel:dataSourceId:CreateDataSourceFromRDS' :: CreateDataSourceFromRDS -> Text
$sel:computeStatistics:CreateDataSourceFromRDS' :: CreateDataSourceFromRDS -> Maybe Bool
$sel:dataSourceName:CreateDataSourceFromRDS' :: CreateDataSourceFromRDS -> 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
"RDSData" Text -> RDSDataSpec -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RDSDataSpec
rDSData),
            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 CreateDataSourceFromRDS where
  toPath :: CreateDataSourceFromRDS -> ByteString
toPath = ByteString -> CreateDataSourceFromRDS -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'CreateDataSourceFromRDSResponse' 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', 'createDataSourceFromRDSResponse_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', 'createDataSourceFromRDSResponse_httpStatus' - The response's http status code.
newCreateDataSourceFromRDSResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDataSourceFromRDSResponse
newCreateDataSourceFromRDSResponse :: Int -> CreateDataSourceFromRDSResponse
newCreateDataSourceFromRDSResponse Int
pHttpStatus_ =
  CreateDataSourceFromRDSResponse' :: Maybe Text -> Int -> CreateDataSourceFromRDSResponse
CreateDataSourceFromRDSResponse'
    { $sel:dataSourceId:CreateDataSourceFromRDSResponse' :: Maybe Text
dataSourceId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateDataSourceFromRDSResponse' :: 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.
createDataSourceFromRDSResponse_dataSourceId :: Lens.Lens' CreateDataSourceFromRDSResponse (Prelude.Maybe Prelude.Text)
createDataSourceFromRDSResponse_dataSourceId :: (Maybe Text -> f (Maybe Text))
-> CreateDataSourceFromRDSResponse
-> f CreateDataSourceFromRDSResponse
createDataSourceFromRDSResponse_dataSourceId = (CreateDataSourceFromRDSResponse -> Maybe Text)
-> (CreateDataSourceFromRDSResponse
    -> Maybe Text -> CreateDataSourceFromRDSResponse)
-> Lens
     CreateDataSourceFromRDSResponse
     CreateDataSourceFromRDSResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceFromRDSResponse' {Maybe Text
dataSourceId :: Maybe Text
$sel:dataSourceId:CreateDataSourceFromRDSResponse' :: CreateDataSourceFromRDSResponse -> Maybe Text
dataSourceId} -> Maybe Text
dataSourceId) (\s :: CreateDataSourceFromRDSResponse
s@CreateDataSourceFromRDSResponse' {} Maybe Text
a -> CreateDataSourceFromRDSResponse
s {$sel:dataSourceId:CreateDataSourceFromRDSResponse' :: Maybe Text
dataSourceId = Maybe Text
a} :: CreateDataSourceFromRDSResponse)

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

instance
  Prelude.NFData
    CreateDataSourceFromRDSResponse