1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package machinelearning
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/machinelearning/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates a DataSource object from an  Amazon Relational Database Service
15// (http://aws.amazon.com/rds/) (Amazon RDS). A DataSource references data that can
16// be used to perform CreateMLModel, CreateEvaluation, or CreateBatchPrediction
17// operations. CreateDataSourceFromRDS is an asynchronous operation. In response to
18// CreateDataSourceFromRDS, Amazon Machine Learning (Amazon ML) immediately returns
19// and sets the DataSource status to PENDING. After the DataSource is created and
20// ready for use, Amazon ML sets the Status parameter to COMPLETED. DataSource in
21// the COMPLETED or PENDING state can be used only to perform >CreateMLModel>,
22// CreateEvaluation, or CreateBatchPrediction operations. If Amazon ML cannot
23// accept the input source, it sets the Status parameter to FAILED and includes an
24// error message in the Message attribute of the GetDataSource operation response.
25func (c *Client) CreateDataSourceFromRDS(ctx context.Context, params *CreateDataSourceFromRDSInput, optFns ...func(*Options)) (*CreateDataSourceFromRDSOutput, error) {
26	if params == nil {
27		params = &CreateDataSourceFromRDSInput{}
28	}
29
30	result, metadata, err := c.invokeOperation(ctx, "CreateDataSourceFromRDS", params, optFns, addOperationCreateDataSourceFromRDSMiddlewares)
31	if err != nil {
32		return nil, err
33	}
34
35	out := result.(*CreateDataSourceFromRDSOutput)
36	out.ResultMetadata = metadata
37	return out, nil
38}
39
40type CreateDataSourceFromRDSInput struct {
41
42	// A user-supplied ID that uniquely identifies the DataSource. Typically, an Amazon
43	// Resource Number (ARN) becomes the ID for a DataSource.
44	//
45	// This member is required.
46	DataSourceId *string
47
48	// The data specification of an Amazon RDS DataSource:
49	//
50	// * DatabaseInformation -
51	//
52	// *
53	// DatabaseName - The name of the Amazon RDS database.
54	//
55	// * InstanceIdentifier  - A
56	// unique identifier for the Amazon RDS database instance.
57	//
58	// * DatabaseCredentials -
59	// AWS Identity and Access Management (IAM) credentials that are used to connect to
60	// the Amazon RDS database.
61	//
62	// * ResourceRole - A role
63	// (DataPipelineDefaultResourceRole) assumed by an EC2 instance to carry out the
64	// copy task from Amazon RDS to Amazon Simple Storage Service (Amazon S3). For more
65	// information, see Role templates
66	// (https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-iam-roles.html)
67	// for data pipelines.
68	//
69	// * ServiceRole - A role (DataPipelineDefaultRole) assumed by
70	// the AWS Data Pipeline service to monitor the progress of the copy task from
71	// Amazon RDS to Amazon S3. For more information, see Role templates
72	// (https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-iam-roles.html)
73	// for data pipelines.
74	//
75	// * SecurityInfo - The security information to use to access
76	// an RDS DB instance. You need to set up appropriate ingress rules for the
77	// security entity IDs provided to allow access to the Amazon RDS instance. Specify
78	// a [SubnetId, SecurityGroupIds] pair for a VPC-based RDS DB instance.
79	//
80	// *
81	// SelectSqlQuery - A query that is used to retrieve the observation data for the
82	// Datasource.
83	//
84	// * S3StagingLocation - The Amazon S3 location for staging Amazon RDS
85	// data. The data retrieved from Amazon RDS using SelectSqlQuery is stored in this
86	// location.
87	//
88	// * DataSchemaUri - The Amazon S3 location of the DataSchema.
89	//
90	// *
91	// DataSchema - A JSON string representing the schema. This is not required if
92	// DataSchemaUri is specified.
93	//
94	// * DataRearrangement - A JSON string that represents
95	// the splitting and rearrangement requirements for the Datasource. Sample -
96	// "{\"splitting\":{\"percentBegin\":10,\"percentEnd\":60}}"
97	//
98	// This member is required.
99	RDSData *types.RDSDataSpec
100
101	// The role that Amazon ML assumes on behalf of the user to create and activate a
102	// data pipeline in the user's account and copy data using the SelectSqlQuery query
103	// from Amazon RDS to Amazon S3.
104	//
105	// This member is required.
106	RoleARN *string
107
108	// The compute statistics for a DataSource. The statistics are generated from the
109	// observation data referenced by a DataSource. Amazon ML uses the statistics
110	// internally during MLModel training. This parameter must be set to true if the
111	// DataSource needs to be used for MLModel training.
112	ComputeStatistics bool
113
114	// A user-supplied name or description of the DataSource.
115	DataSourceName *string
116}
117
118// Represents the output of a CreateDataSourceFromRDS operation, and is an
119// acknowledgement that Amazon ML received the request. The
120// CreateDataSourceFromRDS> operation is asynchronous. You can poll for updates by
121// using the GetBatchPrediction operation and checking the Status parameter. You
122// can inspect the Message when Status shows up as FAILED. You can also check the
123// progress of the copy operation by going to the DataPipeline console and looking
124// up the pipeline using the pipelineId  from the describe call.
125type CreateDataSourceFromRDSOutput struct {
126
127	// A user-supplied ID that uniquely identifies the datasource. This value should be
128	// identical to the value of the DataSourceID in the request.
129	DataSourceId *string
130
131	// Metadata pertaining to the operation's result.
132	ResultMetadata middleware.Metadata
133}
134
135func addOperationCreateDataSourceFromRDSMiddlewares(stack *middleware.Stack, options Options) (err error) {
136	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateDataSourceFromRDS{}, middleware.After)
137	if err != nil {
138		return err
139	}
140	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateDataSourceFromRDS{}, middleware.After)
141	if err != nil {
142		return err
143	}
144	if err = addSetLoggerMiddleware(stack, options); err != nil {
145		return err
146	}
147	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
148		return err
149	}
150	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
151		return err
152	}
153	if err = addResolveEndpointMiddleware(stack, options); err != nil {
154		return err
155	}
156	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
157		return err
158	}
159	if err = addRetryMiddlewares(stack, options); err != nil {
160		return err
161	}
162	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
163		return err
164	}
165	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
166		return err
167	}
168	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
169		return err
170	}
171	if err = addClientUserAgent(stack); err != nil {
172		return err
173	}
174	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
175		return err
176	}
177	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
178		return err
179	}
180	if err = addOpCreateDataSourceFromRDSValidationMiddleware(stack); err != nil {
181		return err
182	}
183	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateDataSourceFromRDS(options.Region), middleware.Before); err != nil {
184		return err
185	}
186	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
187		return err
188	}
189	if err = addResponseErrorMiddleware(stack); err != nil {
190		return err
191	}
192	if err = addRequestResponseLogging(stack, options); err != nil {
193		return err
194	}
195	return nil
196}
197
198func newServiceMetadataMiddleware_opCreateDataSourceFromRDS(region string) *awsmiddleware.RegisterServiceMetadata {
199	return &awsmiddleware.RegisterServiceMetadata{
200		Region:        region,
201		ServiceID:     ServiceID,
202		SigningName:   "machinelearning",
203		OperationName: "CreateDataSourceFromRDS",
204	}
205}
206