1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package rds
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/rds/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12	"time"
13)
14
15// Restores a DB instance to an arbitrary point in time. You can restore to any
16// point in time before the time identified by the LatestRestorableTime property.
17// You can restore to a point up to the number of days specified by the
18// BackupRetentionPeriod property. The target database is created with most of the
19// original configuration, but in a system-selected Availability Zone, with the
20// default security group, the default subnet group, and the default DB parameter
21// group. By default, the new DB instance is created as a single-AZ deployment
22// except when the instance is a SQL Server instance that has an option group that
23// is associated with mirroring; in this case, the instance becomes a mirrored
24// deployment and not a single-AZ deployment. This command doesn't apply to Aurora
25// MySQL and Aurora PostgreSQL. For Aurora, use RestoreDBClusterToPointInTime.
26func (c *Client) RestoreDBInstanceToPointInTime(ctx context.Context, params *RestoreDBInstanceToPointInTimeInput, optFns ...func(*Options)) (*RestoreDBInstanceToPointInTimeOutput, error) {
27	if params == nil {
28		params = &RestoreDBInstanceToPointInTimeInput{}
29	}
30
31	result, metadata, err := c.invokeOperation(ctx, "RestoreDBInstanceToPointInTime", params, optFns, c.addOperationRestoreDBInstanceToPointInTimeMiddlewares)
32	if err != nil {
33		return nil, err
34	}
35
36	out := result.(*RestoreDBInstanceToPointInTimeOutput)
37	out.ResultMetadata = metadata
38	return out, nil
39}
40
41//
42type RestoreDBInstanceToPointInTimeInput struct {
43
44	// The name of the new DB instance to be created. Constraints:
45	//
46	// * Must contain from
47	// 1 to 63 letters, numbers, or hyphens
48	//
49	// * First character must be a letter
50	//
51	// *
52	// Can't end with a hyphen or contain two consecutive hyphens
53	//
54	// This member is required.
55	TargetDBInstanceIdentifier *string
56
57	// A value that indicates whether minor version upgrades are applied automatically
58	// to the DB instance during the maintenance window.
59	AutoMinorVersionUpgrade *bool
60
61	// The Availability Zone (AZ) where the DB instance will be created. Default: A
62	// random, system-chosen Availability Zone. Constraint: You can't specify the
63	// AvailabilityZone parameter if the DB instance is a Multi-AZ deployment. Example:
64	// us-east-1a
65	AvailabilityZone *string
66
67	// A value that indicates whether to copy all tags from the restored DB instance to
68	// snapshots of the DB instance. By default, tags are not copied.
69	CopyTagsToSnapshot *bool
70
71	// The compute and memory capacity of the Amazon RDS DB instance, for example,
72	// db.m4.large. Not all DB instance classes are available in all Amazon Web
73	// Services Regions, or for all database engines. For the full list of DB instance
74	// classes, and availability for your engine, see DB Instance Class
75	// (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html)
76	// in the Amazon RDS User Guide. Default: The same DBInstanceClass as the original
77	// DB instance.
78	DBInstanceClass *string
79
80	// The database name for the restored DB instance. This parameter isn't used for
81	// the MySQL or MariaDB engines.
82	DBName *string
83
84	// The name of the DB parameter group to associate with this DB instance. If you do
85	// not specify a value for DBParameterGroupName, then the default DBParameterGroup
86	// for the specified DB engine is used. Constraints:
87	//
88	// * If supplied, must match the
89	// name of an existing DBParameterGroup.
90	//
91	// * Must be 1 to 255 letters, numbers, or
92	// hyphens.
93	//
94	// * First character must be a letter.
95	//
96	// * Can't end with a hyphen or
97	// contain two consecutive hyphens.
98	DBParameterGroupName *string
99
100	// The DB subnet group name to use for the new instance. Constraints: If supplied,
101	// must match the name of an existing DBSubnetGroup. Example: mySubnetgroup
102	DBSubnetGroupName *string
103
104	// A value that indicates whether the DB instance has deletion protection enabled.
105	// The database can't be deleted when deletion protection is enabled. By default,
106	// deletion protection is disabled. For more information, see  Deleting a DB
107	// Instance
108	// (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_DeleteInstance.html).
109	DeletionProtection *bool
110
111	// Specify the Active Directory directory ID to restore the DB instance in. The
112	// domain must be created prior to this operation. Currently, only MySQL, Microsoft
113	// SQL Server, Oracle, and PostgreSQL DB instances can be created in an Active
114	// Directory Domain. For more information, see  Kerberos Authentication
115	// (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/kerberos-authentication.html)
116	// in the Amazon RDS User Guide.
117	Domain *string
118
119	// Specify the name of the IAM role to be used when making API calls to the
120	// Directory Service.
121	DomainIAMRoleName *string
122
123	// The list of logs that the restored DB instance is to export to CloudWatch Logs.
124	// The values in the list depend on the DB engine being used. For more information,
125	// see Publishing Database Logs to Amazon CloudWatch Logs
126	// (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.html#USER_LogAccess.Procedural.UploadtoCloudWatch)
127	// in the Amazon RDS User Guide.
128	EnableCloudwatchLogsExports []string
129
130	// A value that indicates whether to enable a customer-owned IP address (CoIP) for
131	// an RDS on Outposts DB instance. A CoIP provides local or external connectivity
132	// to resources in your Outpost subnets through your on-premises network. For some
133	// use cases, a CoIP can provide lower latency for connections to the DB instance
134	// from outside of its virtual private cloud (VPC) on your local network. For more
135	// information about RDS on Outposts, see Working with Amazon RDS on Amazon Web
136	// Services Outposts
137	// (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-on-outposts.html) in
138	// the Amazon RDS User Guide. For more information about CoIPs, see Customer-owned
139	// IP addresses
140	// (https://docs.aws.amazon.com/outposts/latest/userguide/outposts-networking-components.html#ip-addressing)
141	// in the Amazon Web Services Outposts User Guide.
142	EnableCustomerOwnedIp *bool
143
144	// A value that indicates whether to enable mapping of Amazon Web Services Identity
145	// and Access Management (IAM) accounts to database accounts. By default, mapping
146	// is disabled. For more information about IAM database authentication, see  IAM
147	// Database Authentication for MySQL and PostgreSQL
148	// (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html)
149	// in the Amazon RDS User Guide.
150	EnableIAMDatabaseAuthentication *bool
151
152	// The database engine to use for the new instance. Default: The same as source
153	// Constraint: Must be compatible with the engine of the source Valid Values:
154	//
155	// *
156	// mariadb
157	//
158	// * mysql
159	//
160	// * oracle-ee
161	//
162	// * oracle-ee-cdb
163	//
164	// * oracle-se2
165	//
166	// *
167	// oracle-se2-cdb
168	//
169	// * postgres
170	//
171	// * sqlserver-ee
172	//
173	// * sqlserver-se
174	//
175	// * sqlserver-ex
176	//
177	// *
178	// sqlserver-web
179	Engine *string
180
181	// The amount of Provisioned IOPS (input/output operations per second) to be
182	// initially allocated for the DB instance. Constraints: Must be an integer greater
183	// than 1000. SQL Server Setting the IOPS value for the SQL Server database engine
184	// isn't supported.
185	Iops *int32
186
187	// License model information for the restored DB instance. Default: Same as source.
188	// Valid values: license-included | bring-your-own-license | general-public-license
189	LicenseModel *string
190
191	// The upper limit in gibibytes (GiB) to which Amazon RDS can automatically scale
192	// the storage of the DB instance. For more information about this setting,
193	// including limitations that apply to it, see  Managing capacity automatically
194	// with Amazon RDS storage autoscaling
195	// (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PIOPS.StorageTypes.html#USER_PIOPS.Autoscaling)
196	// in the Amazon RDS User Guide.
197	MaxAllocatedStorage *int32
198
199	// A value that indicates whether the DB instance is a Multi-AZ deployment.
200	// Constraint: You can't specify the AvailabilityZone parameter if the DB instance
201	// is a Multi-AZ deployment.
202	MultiAZ *bool
203
204	// The name of the option group to be used for the restored DB instance. Permanent
205	// options, such as the TDE option for Oracle Advanced Security TDE, can't be
206	// removed from an option group, and that option group can't be removed from a DB
207	// instance once it is associated with a DB instance
208	OptionGroupName *string
209
210	// The port number on which the database accepts connections. Constraints: Value
211	// must be 1150-65535 Default: The same port as the original DB instance.
212	Port *int32
213
214	// The number of CPU cores and the number of threads per core for the DB instance
215	// class of the DB instance.
216	ProcessorFeatures []types.ProcessorFeature
217
218	// A value that indicates whether the DB instance is publicly accessible. When the
219	// DB instance is publicly accessible, its DNS endpoint resolves to the private IP
220	// address from within the DB instance's VPC, and to the public IP address from
221	// outside of the DB instance's VPC. Access to the DB instance is ultimately
222	// controlled by the security group it uses, and that public access is not
223	// permitted if the security group assigned to the DB instance doesn't permit it.
224	// When the DB instance isn't publicly accessible, it is an internal DB instance
225	// with a DNS name that resolves to a private IP address. For more information, see
226	// CreateDBInstance.
227	PubliclyAccessible *bool
228
229	// The date and time to restore from. Valid Values: Value must be a time in
230	// Universal Coordinated Time (UTC) format Constraints:
231	//
232	// * Must be before the
233	// latest restorable time for the DB instance
234	//
235	// * Can't be specified if the
236	// UseLatestRestorableTime parameter is enabled
237	//
238	// Example: 2009-09-07T23:45:00Z
239	RestoreTime *time.Time
240
241	// The Amazon Resource Name (ARN) of the replicated automated backups from which to
242	// restore, for example,
243	// arn:aws:rds:useast-1:123456789012:auto-backup:ab-L2IJCEXJP7XQ7HOJ4SIEXAMPLE.
244	SourceDBInstanceAutomatedBackupsArn *string
245
246	// The identifier of the source DB instance from which to restore. Constraints:
247	//
248	// *
249	// Must match the identifier of an existing DB instance.
250	SourceDBInstanceIdentifier *string
251
252	// The resource ID of the source DB instance from which to restore.
253	SourceDbiResourceId *string
254
255	// Specifies the storage type to be associated with the DB instance. Valid values:
256	// standard | gp2 | io1 If you specify io1, you must also include a value for the
257	// Iops parameter. Default: io1 if the Iops parameter is specified, otherwise gp2
258	StorageType *string
259
260	// A list of tags. For more information, see Tagging Amazon RDS Resources
261	// (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html) in
262	// the Amazon RDS User Guide.
263	Tags []types.Tag
264
265	// The ARN from the key store with which to associate the instance for TDE
266	// encryption.
267	TdeCredentialArn *string
268
269	// The password for the given ARN from the key store in order to access the device.
270	TdeCredentialPassword *string
271
272	// A value that indicates whether the DB instance class of the DB instance uses its
273	// default processor features.
274	UseDefaultProcessorFeatures *bool
275
276	// A value that indicates whether the DB instance is restored from the latest
277	// backup time. By default, the DB instance isn't restored from the latest backup
278	// time. Constraints: Can't be specified if the RestoreTime parameter is provided.
279	UseLatestRestorableTime bool
280
281	// A list of EC2 VPC security groups to associate with this DB instance. Default:
282	// The default EC2 VPC security group for the DB subnet group's VPC.
283	VpcSecurityGroupIds []string
284
285	noSmithyDocumentSerde
286}
287
288type RestoreDBInstanceToPointInTimeOutput struct {
289
290	// Contains the details of an Amazon RDS DB instance. This data type is used as a
291	// response element in the DescribeDBInstances action.
292	DBInstance *types.DBInstance
293
294	// Metadata pertaining to the operation's result.
295	ResultMetadata middleware.Metadata
296
297	noSmithyDocumentSerde
298}
299
300func (c *Client) addOperationRestoreDBInstanceToPointInTimeMiddlewares(stack *middleware.Stack, options Options) (err error) {
301	err = stack.Serialize.Add(&awsAwsquery_serializeOpRestoreDBInstanceToPointInTime{}, middleware.After)
302	if err != nil {
303		return err
304	}
305	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpRestoreDBInstanceToPointInTime{}, middleware.After)
306	if err != nil {
307		return err
308	}
309	if err = addSetLoggerMiddleware(stack, options); err != nil {
310		return err
311	}
312	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
313		return err
314	}
315	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
316		return err
317	}
318	if err = addResolveEndpointMiddleware(stack, options); err != nil {
319		return err
320	}
321	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
322		return err
323	}
324	if err = addRetryMiddlewares(stack, options); err != nil {
325		return err
326	}
327	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
328		return err
329	}
330	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
331		return err
332	}
333	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
334		return err
335	}
336	if err = addClientUserAgent(stack); err != nil {
337		return err
338	}
339	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
340		return err
341	}
342	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
343		return err
344	}
345	if err = addOpRestoreDBInstanceToPointInTimeValidationMiddleware(stack); err != nil {
346		return err
347	}
348	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opRestoreDBInstanceToPointInTime(options.Region), middleware.Before); err != nil {
349		return err
350	}
351	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
352		return err
353	}
354	if err = addResponseErrorMiddleware(stack); err != nil {
355		return err
356	}
357	if err = addRequestResponseLogging(stack, options); err != nil {
358		return err
359	}
360	return nil
361}
362
363func newServiceMetadataMiddleware_opRestoreDBInstanceToPointInTime(region string) *awsmiddleware.RegisterServiceMetadata {
364	return &awsmiddleware.RegisterServiceMetadata{
365		Region:        region,
366		ServiceID:     ServiceID,
367		SigningName:   "rds",
368		OperationName: "RestoreDBInstanceToPointInTime",
369	}
370}
371