1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package athena
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/athena/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates (registers) a data catalog with the specified name and properties.
15// Catalogs created are visible to all users of the same AWS account.
16func (c *Client) CreateDataCatalog(ctx context.Context, params *CreateDataCatalogInput, optFns ...func(*Options)) (*CreateDataCatalogOutput, error) {
17	if params == nil {
18		params = &CreateDataCatalogInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "CreateDataCatalog", params, optFns, addOperationCreateDataCatalogMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*CreateDataCatalogOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type CreateDataCatalogInput struct {
32
33	// The name of the data catalog to create. The catalog name must be unique for the
34	// AWS account and can use a maximum of 128 alphanumeric, underscore, at sign, or
35	// hyphen characters.
36	//
37	// This member is required.
38	Name *string
39
40	// The type of data catalog to create: LAMBDA for a federated catalog or HIVE for
41	// an external hive metastore. Do not use the GLUE type. This refers to the
42	// AwsDataCatalog that already exists in your account, of which you can have only
43	// one. Specifying the GLUE type will result in an INVALID_INPUT error.
44	//
45	// This member is required.
46	Type types.DataCatalogType
47
48	// A description of the data catalog to be created.
49	Description *string
50
51	// Specifies the Lambda function or functions to use for creating the data catalog.
52	// This is a mapping whose values depend on the catalog type.
53	//
54	// * For the HIVE data
55	// catalog type, use the following syntax. The metadata-function parameter is
56	// required. The sdk-version parameter is optional and defaults to the currently
57	// supported version. metadata-function=lambda_arn, sdk-version=version_number
58	//
59	// *
60	// For the LAMBDA data catalog type, use one of the following sets of required
61	// parameters, but not both.
62	//
63	// * If you have one Lambda function that processes
64	// metadata and another for reading the actual data, use the following syntax. Both
65	// parameters are required. metadata-function=lambda_arn,
66	// record-function=lambda_arn
67	//
68	// * If you have a composite Lambda function that
69	// processes both metadata and data, use the following syntax to specify your
70	// Lambda function. function=lambda_arn
71	Parameters map[string]string
72
73	// A list of comma separated tags to add to the data catalog that is created.
74	Tags []types.Tag
75}
76
77type CreateDataCatalogOutput struct {
78	// Metadata pertaining to the operation's result.
79	ResultMetadata middleware.Metadata
80}
81
82func addOperationCreateDataCatalogMiddlewares(stack *middleware.Stack, options Options) (err error) {
83	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateDataCatalog{}, middleware.After)
84	if err != nil {
85		return err
86	}
87	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateDataCatalog{}, middleware.After)
88	if err != nil {
89		return err
90	}
91	if err = addSetLoggerMiddleware(stack, options); err != nil {
92		return err
93	}
94	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
95		return err
96	}
97	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
98		return err
99	}
100	if err = addResolveEndpointMiddleware(stack, options); err != nil {
101		return err
102	}
103	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
104		return err
105	}
106	if err = addRetryMiddlewares(stack, options); err != nil {
107		return err
108	}
109	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
110		return err
111	}
112	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
113		return err
114	}
115	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
116		return err
117	}
118	if err = addClientUserAgent(stack); err != nil {
119		return err
120	}
121	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
122		return err
123	}
124	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
125		return err
126	}
127	if err = addOpCreateDataCatalogValidationMiddleware(stack); err != nil {
128		return err
129	}
130	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateDataCatalog(options.Region), middleware.Before); err != nil {
131		return err
132	}
133	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
134		return err
135	}
136	if err = addResponseErrorMiddleware(stack); err != nil {
137		return err
138	}
139	if err = addRequestResponseLogging(stack, options); err != nil {
140		return err
141	}
142	return nil
143}
144
145func newServiceMetadataMiddleware_opCreateDataCatalog(region string) *awsmiddleware.RegisterServiceMetadata {
146	return &awsmiddleware.RegisterServiceMetadata{
147		Region:        region,
148		ServiceID:     ServiceID,
149		SigningName:   "athena",
150		OperationName: "CreateDataCatalog",
151	}
152}
153