1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package gamelift
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/gamelift/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates a new Amazon GameLift build resource for your game server binary files.
15// Game server binaries must be combined into a zip file for use with Amazon
16// GameLift. When setting up a new game build for GameLift, we recommend using the
17// AWS CLI command upload-build
18// (https://docs.aws.amazon.com/cli/latest/reference/gamelift/upload-build.html) .
19// This helper command combines two tasks: (1) it uploads your build files from a
20// file directory to a GameLift Amazon S3 location, and (2) it creates a new build
21// resource. The CreateBuild operation can used in the following scenarios:
22//
23// * To
24// create a new game build with build files that are in an Amazon S3 location under
25// an AWS account that you control. To use this option, you must first give Amazon
26// GameLift access to the Amazon S3 bucket. With permissions in place, call
27// CreateBuild and specify a build name, operating system, and the Amazon S3
28// storage location of your game build.
29//
30// * To directly upload your build files to a
31// GameLift Amazon S3 location. To use this option, first call CreateBuild and
32// specify a build name and operating system. This operation creates a new build
33// resource and also returns an Amazon S3 location with temporary access
34// credentials. Use the credentials to manually upload your build files to the
35// specified Amazon S3 location. For more information, see Uploading Objects
36// (https://docs.aws.amazon.com/AmazonS3/latest/dev/UploadingObjects.html) in the
37// Amazon S3 Developer Guide. Build files can be uploaded to the GameLift Amazon S3
38// location once only; that can't be updated.
39//
40// If successful, this operation
41// creates a new build resource with a unique build ID and places it in INITIALIZED
42// status. A build must be in READY status before you can create fleets with it.
43// Learn more Uploading Your Game
44// (https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-build-intro.html)
45// Create a Build with Files in Amazon S3
46// (https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-build-cli-uploading.html#gamelift-build-cli-uploading-create-build)
47// Related actions CreateBuild | ListBuilds | DescribeBuild | UpdateBuild |
48// DeleteBuild | All APIs by task
49// (https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets)
50func (c *Client) CreateBuild(ctx context.Context, params *CreateBuildInput, optFns ...func(*Options)) (*CreateBuildOutput, error) {
51	if params == nil {
52		params = &CreateBuildInput{}
53	}
54
55	result, metadata, err := c.invokeOperation(ctx, "CreateBuild", params, optFns, c.addOperationCreateBuildMiddlewares)
56	if err != nil {
57		return nil, err
58	}
59
60	out := result.(*CreateBuildOutput)
61	out.ResultMetadata = metadata
62	return out, nil
63}
64
65// Represents the input for a request operation.
66type CreateBuildInput struct {
67
68	// A descriptive label that is associated with a build. Build names do not need to
69	// be unique. You can use UpdateBuild to change this value later.
70	Name *string
71
72	// The operating system that the game server binaries are built to run on. This
73	// value determines the type of fleet resources that you can use for this build. If
74	// your game build contains multiple executables, they all must run on the same
75	// operating system. If an operating system is not specified when creating a build,
76	// Amazon GameLift uses the default value (WINDOWS_2012). This value cannot be
77	// changed later.
78	OperatingSystem types.OperatingSystem
79
80	// Information indicating where your game build files are stored. Use this
81	// parameter only when creating a build with files stored in an Amazon S3 bucket
82	// that you own. The storage location must specify an Amazon S3 bucket name and
83	// key. The location must also specify a role ARN that you set up to allow Amazon
84	// GameLift to access your Amazon S3 bucket. The S3 bucket and your new build must
85	// be in the same Region.
86	StorageLocation *types.S3Location
87
88	// A list of labels to assign to the new build resource. Tags are developer-defined
89	// key-value pairs. Tagging AWS resources are useful for resource management,
90	// access management and cost allocation. For more information, see  Tagging AWS
91	// Resources (https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html) in
92	// the AWS General Reference. Once the resource is created, you can use
93	// TagResource, UntagResource, and ListTagsForResource to add, remove, and view
94	// tags. The maximum tag limit may be lower than stated. See the AWS General
95	// Reference for actual tagging limits.
96	Tags []types.Tag
97
98	// Version information that is associated with a build or script. Version strings
99	// do not need to be unique. You can use UpdateBuild to change this value later.
100	Version *string
101
102	noSmithyDocumentSerde
103}
104
105// Represents the returned data in response to a request operation.
106type CreateBuildOutput struct {
107
108	// The newly created build resource, including a unique build IDs and status.
109	Build *types.Build
110
111	// Amazon S3 location for your game build file, including bucket name and key.
112	StorageLocation *types.S3Location
113
114	// This element is returned only when the operation is called without a storage
115	// location. It contains credentials to use when you are uploading a build file to
116	// an Amazon S3 bucket that is owned by Amazon GameLift. Credentials have a limited
117	// life span. To refresh these credentials, call RequestUploadCredentials.
118	UploadCredentials *types.AwsCredentials
119
120	// Metadata pertaining to the operation's result.
121	ResultMetadata middleware.Metadata
122
123	noSmithyDocumentSerde
124}
125
126func (c *Client) addOperationCreateBuildMiddlewares(stack *middleware.Stack, options Options) (err error) {
127	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateBuild{}, middleware.After)
128	if err != nil {
129		return err
130	}
131	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateBuild{}, middleware.After)
132	if err != nil {
133		return err
134	}
135	if err = addSetLoggerMiddleware(stack, options); err != nil {
136		return err
137	}
138	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
139		return err
140	}
141	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
142		return err
143	}
144	if err = addResolveEndpointMiddleware(stack, options); err != nil {
145		return err
146	}
147	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
148		return err
149	}
150	if err = addRetryMiddlewares(stack, options); err != nil {
151		return err
152	}
153	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
154		return err
155	}
156	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
157		return err
158	}
159	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
160		return err
161	}
162	if err = addClientUserAgent(stack); err != nil {
163		return err
164	}
165	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
166		return err
167	}
168	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
169		return err
170	}
171	if err = addOpCreateBuildValidationMiddleware(stack); err != nil {
172		return err
173	}
174	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateBuild(options.Region), middleware.Before); err != nil {
175		return err
176	}
177	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
178		return err
179	}
180	if err = addResponseErrorMiddleware(stack); err != nil {
181		return err
182	}
183	if err = addRequestResponseLogging(stack, options); err != nil {
184		return err
185	}
186	return nil
187}
188
189func newServiceMetadataMiddleware_opCreateBuild(region string) *awsmiddleware.RegisterServiceMetadata {
190	return &awsmiddleware.RegisterServiceMetadata{
191		Region:        region,
192		ServiceID:     ServiceID,
193		SigningName:   "gamelift",
194		OperationName: "CreateBuild",
195	}
196}
197