api_op_CreateRelationalDatabaseFromSnapshot.go raw

   1  // Code generated by smithy-go-codegen DO NOT EDIT.
   2  
   3  package lightsail
   4  
   5  import (
   6  	"context"
   7  	"fmt"
   8  	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
   9  	"github.com/aws/aws-sdk-go-v2/service/lightsail/types"
  10  	"github.com/aws/smithy-go/middleware"
  11  	smithyhttp "github.com/aws/smithy-go/transport/http"
  12  	"time"
  13  )
  14  
  15  // Creates a new database from an existing database snapshot in Amazon Lightsail.
  16  //
  17  // You can create a new database from a snapshot in if something goes wrong with
  18  // your original database, or to change it to a different plan, such as a high
  19  // availability or standard plan.
  20  //
  21  // The create relational database from snapshot operation supports tag-based
  22  // access control via request tags and resource tags applied to the resource
  23  // identified by relationalDatabaseSnapshotName. For more information, see the [Amazon Lightsail Developer Guide].
  24  //
  25  // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-controlling-access-using-tags
  26  func (c *Client) CreateRelationalDatabaseFromSnapshot(ctx context.Context, params *CreateRelationalDatabaseFromSnapshotInput, optFns ...func(*Options)) (*CreateRelationalDatabaseFromSnapshotOutput, error) {
  27  	if params == nil {
  28  		params = &CreateRelationalDatabaseFromSnapshotInput{}
  29  	}
  30  
  31  	result, metadata, err := c.invokeOperation(ctx, "CreateRelationalDatabaseFromSnapshot", params, optFns, c.addOperationCreateRelationalDatabaseFromSnapshotMiddlewares)
  32  	if err != nil {
  33  		return nil, err
  34  	}
  35  
  36  	out := result.(*CreateRelationalDatabaseFromSnapshotOutput)
  37  	out.ResultMetadata = metadata
  38  	return out, nil
  39  }
  40  
  41  type CreateRelationalDatabaseFromSnapshotInput struct {
  42  
  43  	// The name to use for your new Lightsail database resource.
  44  	//
  45  	// Constraints:
  46  	//
  47  	//   - Must contain from 2 to 255 alphanumeric characters, or hyphens.
  48  	//
  49  	//   - The first and last character must be a letter or number.
  50  	//
  51  	// This member is required.
  52  	RelationalDatabaseName *string
  53  
  54  	// The Availability Zone in which to create your new database. Use the us-east-2a
  55  	// case-sensitive format.
  56  	//
  57  	// You can get a list of Availability Zones by using the get regions operation. Be
  58  	// sure to add the include relational database Availability Zones parameter to
  59  	// your request.
  60  	AvailabilityZone *string
  61  
  62  	// Specifies the accessibility options for your new database. A value of true
  63  	// specifies a database that is available to resources outside of your Lightsail
  64  	// account. A value of false specifies a database that is available only to your
  65  	// Lightsail resources in the same region as your database.
  66  	PubliclyAccessible *bool
  67  
  68  	// The bundle ID for your new database. A bundle describes the performance
  69  	// specifications for your database.
  70  	//
  71  	// You can get a list of database bundle IDs by using the get relational database
  72  	// bundles operation.
  73  	//
  74  	// When creating a new database from a snapshot, you cannot choose a bundle that
  75  	// is smaller than the bundle of the source database.
  76  	RelationalDatabaseBundleId *string
  77  
  78  	// The name of the database snapshot from which to create your new database.
  79  	RelationalDatabaseSnapshotName *string
  80  
  81  	// The date and time to restore your database from.
  82  	//
  83  	// Constraints:
  84  	//
  85  	//   - Must be before the latest restorable time for the database.
  86  	//
  87  	//   - Cannot be specified if the use latest restorable time parameter is true .
  88  	//
  89  	//   - Specified in Coordinated Universal Time (UTC).
  90  	//
  91  	//   - Specified in the Unix time format.
  92  	//
  93  	// For example, if you wish to use a restore time of October 1, 2018, at 8 PM UTC,
  94  	//   then you input 1538424000 as the restore time.
  95  	RestoreTime *time.Time
  96  
  97  	// The name of the source database.
  98  	SourceRelationalDatabaseName *string
  99  
 100  	// The tag keys and optional values to add to the resource during create.
 101  	//
 102  	// Use the TagResource action to tag a resource after it's created.
 103  	Tags []types.Tag
 104  
 105  	// Specifies whether your database is restored from the latest backup time. A
 106  	// value of true restores from the latest backup time.
 107  	//
 108  	// Default: false
 109  	//
 110  	// Constraints: Cannot be specified if the restore time parameter is provided.
 111  	UseLatestRestorableTime *bool
 112  
 113  	noSmithyDocumentSerde
 114  }
 115  
 116  type CreateRelationalDatabaseFromSnapshotOutput struct {
 117  
 118  	// An array of objects that describe the result of the action, such as the status
 119  	// of the request, the timestamp of the request, and the resources affected by the
 120  	// request.
 121  	Operations []types.Operation
 122  
 123  	// Metadata pertaining to the operation's result.
 124  	ResultMetadata middleware.Metadata
 125  
 126  	noSmithyDocumentSerde
 127  }
 128  
 129  func (c *Client) addOperationCreateRelationalDatabaseFromSnapshotMiddlewares(stack *middleware.Stack, options Options) (err error) {
 130  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
 131  		return err
 132  	}
 133  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateRelationalDatabaseFromSnapshot{}, middleware.After)
 134  	if err != nil {
 135  		return err
 136  	}
 137  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateRelationalDatabaseFromSnapshot{}, middleware.After)
 138  	if err != nil {
 139  		return err
 140  	}
 141  	if err := addProtocolFinalizerMiddlewares(stack, options, "CreateRelationalDatabaseFromSnapshot"); err != nil {
 142  		return fmt.Errorf("add protocol finalizers: %v", err)
 143  	}
 144  
 145  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
 146  		return err
 147  	}
 148  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 149  		return err
 150  	}
 151  	if err = addClientRequestID(stack); err != nil {
 152  		return err
 153  	}
 154  	if err = addComputeContentLength(stack); err != nil {
 155  		return err
 156  	}
 157  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 158  		return err
 159  	}
 160  	if err = addComputePayloadSHA256(stack); err != nil {
 161  		return err
 162  	}
 163  	if err = addRetry(stack, options); err != nil {
 164  		return err
 165  	}
 166  	if err = addRawResponseToMetadata(stack); err != nil {
 167  		return err
 168  	}
 169  	if err = addRecordResponseTiming(stack); err != nil {
 170  		return err
 171  	}
 172  	if err = addSpanRetryLoop(stack, options); err != nil {
 173  		return err
 174  	}
 175  	if err = addClientUserAgent(stack, options); err != nil {
 176  		return err
 177  	}
 178  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 179  		return err
 180  	}
 181  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 182  		return err
 183  	}
 184  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 185  		return err
 186  	}
 187  	if err = addTimeOffsetBuild(stack, c); err != nil {
 188  		return err
 189  	}
 190  	if err = addUserAgentRetryMode(stack, options); err != nil {
 191  		return err
 192  	}
 193  	if err = addCredentialSource(stack, options); err != nil {
 194  		return err
 195  	}
 196  	if err = addOpCreateRelationalDatabaseFromSnapshotValidationMiddleware(stack); err != nil {
 197  		return err
 198  	}
 199  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateRelationalDatabaseFromSnapshot(options.Region), middleware.Before); err != nil {
 200  		return err
 201  	}
 202  	if err = addRecursionDetection(stack); err != nil {
 203  		return err
 204  	}
 205  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 206  		return err
 207  	}
 208  	if err = addResponseErrorMiddleware(stack); err != nil {
 209  		return err
 210  	}
 211  	if err = addRequestResponseLogging(stack, options); err != nil {
 212  		return err
 213  	}
 214  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 215  		return err
 216  	}
 217  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 218  		return err
 219  	}
 220  	if err = addInterceptAttempt(stack, options); err != nil {
 221  		return err
 222  	}
 223  	if err = addInterceptors(stack, options); err != nil {
 224  		return err
 225  	}
 226  	return nil
 227  }
 228  
 229  func newServiceMetadataMiddleware_opCreateRelationalDatabaseFromSnapshot(region string) *awsmiddleware.RegisterServiceMetadata {
 230  	return &awsmiddleware.RegisterServiceMetadata{
 231  		Region:        region,
 232  		ServiceID:     ServiceID,
 233  		OperationName: "CreateRelationalDatabaseFromSnapshot",
 234  	}
 235  }
 236