1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package licensemanager
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/licensemanager/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates a license.
15func (c *Client) CreateLicense(ctx context.Context, params *CreateLicenseInput, optFns ...func(*Options)) (*CreateLicenseOutput, error) {
16	if params == nil {
17		params = &CreateLicenseInput{}
18	}
19
20	result, metadata, err := c.invokeOperation(ctx, "CreateLicense", params, optFns, addOperationCreateLicenseMiddlewares)
21	if err != nil {
22		return nil, err
23	}
24
25	out := result.(*CreateLicenseOutput)
26	out.ResultMetadata = metadata
27	return out, nil
28}
29
30type CreateLicenseInput struct {
31
32	// License beneficiary.
33	//
34	// This member is required.
35	Beneficiary *string
36
37	// Unique, case-sensitive identifier that you provide to ensure the idempotency of
38	// the request.
39	//
40	// This member is required.
41	ClientToken *string
42
43	// Configuration for consumption of the license. Choose a provisional configuration
44	// for workloads running with continuous connectivity. Choose a borrow
45	// configuration for workloads with offline usage.
46	//
47	// This member is required.
48	ConsumptionConfiguration *types.ConsumptionConfiguration
49
50	// License entitlements.
51	//
52	// This member is required.
53	Entitlements []types.Entitlement
54
55	// Home Region for the license.
56	//
57	// This member is required.
58	HomeRegion *string
59
60	// License issuer.
61	//
62	// This member is required.
63	Issuer *types.Issuer
64
65	// License name.
66	//
67	// This member is required.
68	LicenseName *string
69
70	// Product name.
71	//
72	// This member is required.
73	ProductName *string
74
75	// Product SKU.
76	//
77	// This member is required.
78	ProductSKU *string
79
80	// Date and time range during which the license is valid, in ISO8601-UTC format.
81	//
82	// This member is required.
83	Validity *types.DatetimeRange
84
85	// Information about the license.
86	LicenseMetadata []types.Metadata
87}
88
89type CreateLicenseOutput struct {
90
91	// Amazon Resource Name (ARN) of the license.
92	LicenseArn *string
93
94	// License status.
95	Status types.LicenseStatus
96
97	// License version.
98	Version *string
99
100	// Metadata pertaining to the operation's result.
101	ResultMetadata middleware.Metadata
102}
103
104func addOperationCreateLicenseMiddlewares(stack *middleware.Stack, options Options) (err error) {
105	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateLicense{}, middleware.After)
106	if err != nil {
107		return err
108	}
109	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateLicense{}, middleware.After)
110	if err != nil {
111		return err
112	}
113	if err = addSetLoggerMiddleware(stack, options); err != nil {
114		return err
115	}
116	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
117		return err
118	}
119	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
120		return err
121	}
122	if err = addResolveEndpointMiddleware(stack, options); err != nil {
123		return err
124	}
125	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
126		return err
127	}
128	if err = addRetryMiddlewares(stack, options); err != nil {
129		return err
130	}
131	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
132		return err
133	}
134	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
135		return err
136	}
137	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
138		return err
139	}
140	if err = addClientUserAgent(stack); err != nil {
141		return err
142	}
143	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
144		return err
145	}
146	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
147		return err
148	}
149	if err = addOpCreateLicenseValidationMiddleware(stack); err != nil {
150		return err
151	}
152	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateLicense(options.Region), middleware.Before); err != nil {
153		return err
154	}
155	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
156		return err
157	}
158	if err = addResponseErrorMiddleware(stack); err != nil {
159		return err
160	}
161	if err = addRequestResponseLogging(stack, options); err != nil {
162		return err
163	}
164	return nil
165}
166
167func newServiceMetadataMiddleware_opCreateLicense(region string) *awsmiddleware.RegisterServiceMetadata {
168	return &awsmiddleware.RegisterServiceMetadata{
169		Region:        region,
170		ServiceID:     ServiceID,
171		SigningName:   "license-manager",
172		OperationName: "CreateLicense",
173	}
174}
175