1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package docdb
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/docdb/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates a new cluster from a snapshot or cluster snapshot. If a snapshot is
15// specified, the target cluster is created from the source DB snapshot with a
16// default configuration and default security group. If a cluster snapshot is
17// specified, the target cluster is created from the source cluster restore point
18// with the same configuration as the original source DB cluster, except that the
19// new cluster is created with the default security group.
20func (c *Client) RestoreDBClusterFromSnapshot(ctx context.Context, params *RestoreDBClusterFromSnapshotInput, optFns ...func(*Options)) (*RestoreDBClusterFromSnapshotOutput, error) {
21	if params == nil {
22		params = &RestoreDBClusterFromSnapshotInput{}
23	}
24
25	result, metadata, err := c.invokeOperation(ctx, "RestoreDBClusterFromSnapshot", params, optFns, addOperationRestoreDBClusterFromSnapshotMiddlewares)
26	if err != nil {
27		return nil, err
28	}
29
30	out := result.(*RestoreDBClusterFromSnapshotOutput)
31	out.ResultMetadata = metadata
32	return out, nil
33}
34
35// Represents the input to RestoreDBClusterFromSnapshot.
36type RestoreDBClusterFromSnapshotInput struct {
37
38	// The name of the cluster to create from the snapshot or cluster snapshot. This
39	// parameter isn't case sensitive. Constraints:
40	//
41	// * Must contain from 1 to 63
42	// letters, numbers, or hyphens.
43	//
44	// * The first character must be a letter.
45	//
46	// * Cannot
47	// end with a hyphen or contain two consecutive hyphens.
48	//
49	// Example: my-snapshot-id
50	//
51	// This member is required.
52	DBClusterIdentifier *string
53
54	// The database engine to use for the new cluster. Default: The same as source.
55	// Constraint: Must be compatible with the engine of the source.
56	//
57	// This member is required.
58	Engine *string
59
60	// The identifier for the snapshot or cluster snapshot to restore from. You can use
61	// either the name or the Amazon Resource Name (ARN) to specify a cluster snapshot.
62	// However, you can use only the ARN to specify a snapshot. Constraints:
63	//
64	// * Must
65	// match the identifier of an existing snapshot.
66	//
67	// This member is required.
68	SnapshotIdentifier *string
69
70	// Provides the list of Amazon EC2 Availability Zones that instances in the
71	// restored DB cluster can be created in.
72	AvailabilityZones []string
73
74	// The name of the subnet group to use for the new cluster. Constraints: If
75	// provided, must match the name of an existing DBSubnetGroup. Example:
76	// mySubnetgroup
77	DBSubnetGroupName *string
78
79	// Specifies whether this cluster can be deleted. If DeletionProtection is enabled,
80	// the cluster cannot be deleted unless it is modified and DeletionProtection is
81	// disabled. DeletionProtection protects clusters from being accidentally deleted.
82	DeletionProtection *bool
83
84	// A list of log types that must be enabled for exporting to Amazon CloudWatch
85	// Logs.
86	EnableCloudwatchLogsExports []string
87
88	// The version of the database engine to use for the new cluster.
89	EngineVersion *string
90
91	// The AWS KMS key identifier to use when restoring an encrypted cluster from a DB
92	// snapshot or cluster snapshot. The AWS KMS key identifier is the Amazon Resource
93	// Name (ARN) for the AWS KMS encryption key. If you are restoring a cluster with
94	// the same AWS account that owns the AWS KMS encryption key used to encrypt the
95	// new cluster, then you can use the AWS KMS key alias instead of the ARN for the
96	// AWS KMS encryption key. If you do not specify a value for the KmsKeyId
97	// parameter, then the following occurs:
98	//
99	// * If the snapshot or cluster snapshot in
100	// SnapshotIdentifier is encrypted, then the restored cluster is encrypted using
101	// the AWS KMS key that was used to encrypt the snapshot or the cluster
102	// snapshot.
103	//
104	// * If the snapshot or the cluster snapshot in SnapshotIdentifier is
105	// not encrypted, then the restored DB cluster is not encrypted.
106	KmsKeyId *string
107
108	// The port number on which the new cluster accepts connections. Constraints: Must
109	// be a value from 1150 to 65535. Default: The same port as the original cluster.
110	Port *int32
111
112	// The tags to be assigned to the restored cluster.
113	Tags []types.Tag
114
115	// A list of virtual private cloud (VPC) security groups that the new cluster will
116	// belong to.
117	VpcSecurityGroupIds []string
118}
119
120type RestoreDBClusterFromSnapshotOutput struct {
121
122	// Detailed information about a cluster.
123	DBCluster *types.DBCluster
124
125	// Metadata pertaining to the operation's result.
126	ResultMetadata middleware.Metadata
127}
128
129func addOperationRestoreDBClusterFromSnapshotMiddlewares(stack *middleware.Stack, options Options) (err error) {
130	err = stack.Serialize.Add(&awsAwsquery_serializeOpRestoreDBClusterFromSnapshot{}, middleware.After)
131	if err != nil {
132		return err
133	}
134	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpRestoreDBClusterFromSnapshot{}, middleware.After)
135	if err != nil {
136		return err
137	}
138	if err = addSetLoggerMiddleware(stack, options); err != nil {
139		return err
140	}
141	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
142		return err
143	}
144	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
145		return err
146	}
147	if err = addResolveEndpointMiddleware(stack, options); err != nil {
148		return err
149	}
150	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
151		return err
152	}
153	if err = addRetryMiddlewares(stack, options); err != nil {
154		return err
155	}
156	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
157		return err
158	}
159	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
160		return err
161	}
162	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
163		return err
164	}
165	if err = addClientUserAgent(stack); err != nil {
166		return err
167	}
168	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
169		return err
170	}
171	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
172		return err
173	}
174	if err = addOpRestoreDBClusterFromSnapshotValidationMiddleware(stack); err != nil {
175		return err
176	}
177	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opRestoreDBClusterFromSnapshot(options.Region), middleware.Before); err != nil {
178		return err
179	}
180	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
181		return err
182	}
183	if err = addResponseErrorMiddleware(stack); err != nil {
184		return err
185	}
186	if err = addRequestResponseLogging(stack, options); err != nil {
187		return err
188	}
189	return nil
190}
191
192func newServiceMetadataMiddleware_opRestoreDBClusterFromSnapshot(region string) *awsmiddleware.RegisterServiceMetadata {
193	return &awsmiddleware.RegisterServiceMetadata{
194		Region:        region,
195		ServiceID:     ServiceID,
196		SigningName:   "rds",
197		OperationName: "RestoreDBClusterFromSnapshot",
198	}
199}
200