1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package glue
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/glue/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Remove versions from the specified schema. A version number or range may be
15// supplied. If the compatibility mode forbids deleting of a version that is
16// necessary, such as BACKWARDS_FULL, an error is returned. Calling the
17// GetSchemaVersions API after this call will list the status of the deleted
18// versions. When the range of version numbers contain check pointed version, the
19// API will return a 409 conflict and will not proceed with the deletion. You have
20// to remove the checkpoint first using the DeleteSchemaCheckpoint API before using
21// this API. You cannot use the DeleteSchemaVersions API to delete the first schema
22// version in the schema set. The first schema version can only be deleted by the
23// DeleteSchema API. This operation will also delete the attached
24// SchemaVersionMetadata under the schema versions. Hard deletes will be enforced
25// on the database. If the compatibility mode forbids deleting of a version that is
26// necessary, such as BACKWARDS_FULL, an error is returned.
27func (c *Client) DeleteSchemaVersions(ctx context.Context, params *DeleteSchemaVersionsInput, optFns ...func(*Options)) (*DeleteSchemaVersionsOutput, error) {
28	if params == nil {
29		params = &DeleteSchemaVersionsInput{}
30	}
31
32	result, metadata, err := c.invokeOperation(ctx, "DeleteSchemaVersions", params, optFns, addOperationDeleteSchemaVersionsMiddlewares)
33	if err != nil {
34		return nil, err
35	}
36
37	out := result.(*DeleteSchemaVersionsOutput)
38	out.ResultMetadata = metadata
39	return out, nil
40}
41
42type DeleteSchemaVersionsInput struct {
43
44	// This is a wrapper structure that may contain the schema name and Amazon Resource
45	// Name (ARN).
46	//
47	// This member is required.
48	SchemaId *types.SchemaId
49
50	// A version range may be supplied which may be of the format:
51	//
52	// * a single version
53	// number, 5
54	//
55	// * a range, 5-8 : deletes versions 5, 6, 7, 8
56	//
57	// This member is required.
58	Versions *string
59}
60
61type DeleteSchemaVersionsOutput struct {
62
63	// A list of SchemaVersionErrorItem objects, each containing an error and schema
64	// version.
65	SchemaVersionErrors []types.SchemaVersionErrorItem
66
67	// Metadata pertaining to the operation's result.
68	ResultMetadata middleware.Metadata
69}
70
71func addOperationDeleteSchemaVersionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
72	err = stack.Serialize.Add(&awsAwsjson11_serializeOpDeleteSchemaVersions{}, middleware.After)
73	if err != nil {
74		return err
75	}
76	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDeleteSchemaVersions{}, middleware.After)
77	if err != nil {
78		return err
79	}
80	if err = addSetLoggerMiddleware(stack, options); err != nil {
81		return err
82	}
83	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
84		return err
85	}
86	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
87		return err
88	}
89	if err = addResolveEndpointMiddleware(stack, options); err != nil {
90		return err
91	}
92	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
93		return err
94	}
95	if err = addRetryMiddlewares(stack, options); err != nil {
96		return err
97	}
98	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
99		return err
100	}
101	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
102		return err
103	}
104	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
105		return err
106	}
107	if err = addClientUserAgent(stack); err != nil {
108		return err
109	}
110	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
111		return err
112	}
113	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
114		return err
115	}
116	if err = addOpDeleteSchemaVersionsValidationMiddleware(stack); err != nil {
117		return err
118	}
119	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDeleteSchemaVersions(options.Region), middleware.Before); err != nil {
120		return err
121	}
122	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
123		return err
124	}
125	if err = addResponseErrorMiddleware(stack); err != nil {
126		return err
127	}
128	if err = addRequestResponseLogging(stack, options); err != nil {
129		return err
130	}
131	return nil
132}
133
134func newServiceMetadataMiddleware_opDeleteSchemaVersions(region string) *awsmiddleware.RegisterServiceMetadata {
135	return &awsmiddleware.RegisterServiceMetadata{
136		Region:        region,
137		ServiceID:     ServiceID,
138		SigningName:   "glue",
139		OperationName: "DeleteSchemaVersions",
140	}
141}
142