1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package proton
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/proton/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Deploy a new environment. An AWS Proton environment is created from an
15// environment template that defines infrastructure and resources that can be
16// shared across services. For more information, see the Environments
17// (https://docs.aws.amazon.com/proton/latest/adminguide/ag-environments.html) in
18// the AWS Proton Administrator Guide.
19func (c *Client) CreateEnvironment(ctx context.Context, params *CreateEnvironmentInput, optFns ...func(*Options)) (*CreateEnvironmentOutput, error) {
20	if params == nil {
21		params = &CreateEnvironmentInput{}
22	}
23
24	result, metadata, err := c.invokeOperation(ctx, "CreateEnvironment", params, optFns, c.addOperationCreateEnvironmentMiddlewares)
25	if err != nil {
26		return nil, err
27	}
28
29	out := result.(*CreateEnvironmentOutput)
30	out.ResultMetadata = metadata
31	return out, nil
32}
33
34type CreateEnvironmentInput struct {
35
36	// The name of the environment.
37	//
38	// This member is required.
39	Name *string
40
41	// A link to a YAML formatted spec file that provides inputs as defined in the
42	// environment template bundle schema file. For more information, see Environments
43	// (https://docs.aws.amazon.com/proton/latest/adminguide/ag-environments.html) in
44	// the AWS Proton Administrator Guide.
45	//
46	// This value conforms to the media type: application/yaml
47	//
48	// This member is required.
49	Spec *string
50
51	// The ID of the major version of the environment template.
52	//
53	// This member is required.
54	TemplateMajorVersion *string
55
56	// The name of the environment template. For more information, see Environment
57	// Templates
58	// (https://docs.aws.amazon.com/proton/latest/adminguide/ag-templates.html) in the
59	// AWS Proton Administrator Guide.
60	//
61	// This member is required.
62	TemplateName *string
63
64	// A description of the environment that's being created and deployed.
65	Description *string
66
67	// The ID of the environment account connection that you provide if you're
68	// provisioning your environment infrastructure resources to an environment
69	// account. You must include either the environmentAccountConnectionId or
70	// protonServiceRoleArn parameter and value. For more information, see Environment
71	// account connections
72	// (https://docs.aws.amazon.com/proton/latest/adminguide/ag-env-account-connections.html)
73	// in the AWS Proton Administrator guide.
74	EnvironmentAccountConnectionId *string
75
76	// The Amazon Resource Name (ARN) of the AWS Proton service role that allows AWS
77	// Proton to make calls to other services on your behalf. You must include either
78	// the environmentAccountConnectionId or protonServiceRoleArn parameter and value.
79	ProtonServiceRoleArn *string
80
81	// Create tags for your environment. For more information, see AWS Proton resources
82	// and tagging in the AWS Proton Administrator Guide
83	// (https://docs.aws.amazon.com/proton/latest/adminguide/resources.html) or AWS
84	// Proton User Guide
85	// (https://docs.aws.amazon.com/proton/latest/userguide/resources.html).
86	Tags []types.Tag
87
88	// The ID of the minor version of the environment template.
89	TemplateMinorVersion *string
90
91	noSmithyDocumentSerde
92}
93
94type CreateEnvironmentOutput struct {
95
96	// The environment detail data that's returned by AWS Proton.
97	//
98	// This member is required.
99	Environment *types.Environment
100
101	// Metadata pertaining to the operation's result.
102	ResultMetadata middleware.Metadata
103
104	noSmithyDocumentSerde
105}
106
107func (c *Client) addOperationCreateEnvironmentMiddlewares(stack *middleware.Stack, options Options) (err error) {
108	err = stack.Serialize.Add(&awsAwsjson10_serializeOpCreateEnvironment{}, middleware.After)
109	if err != nil {
110		return err
111	}
112	err = stack.Deserialize.Add(&awsAwsjson10_deserializeOpCreateEnvironment{}, middleware.After)
113	if err != nil {
114		return err
115	}
116	if err = addSetLoggerMiddleware(stack, options); err != nil {
117		return err
118	}
119	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
120		return err
121	}
122	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
123		return err
124	}
125	if err = addResolveEndpointMiddleware(stack, options); err != nil {
126		return err
127	}
128	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
129		return err
130	}
131	if err = addRetryMiddlewares(stack, options); err != nil {
132		return err
133	}
134	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
135		return err
136	}
137	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
138		return err
139	}
140	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
141		return err
142	}
143	if err = addClientUserAgent(stack); err != nil {
144		return err
145	}
146	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
147		return err
148	}
149	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
150		return err
151	}
152	if err = addOpCreateEnvironmentValidationMiddleware(stack); err != nil {
153		return err
154	}
155	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateEnvironment(options.Region), middleware.Before); err != nil {
156		return err
157	}
158	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
159		return err
160	}
161	if err = addResponseErrorMiddleware(stack); err != nil {
162		return err
163	}
164	if err = addRequestResponseLogging(stack, options); err != nil {
165		return err
166	}
167	return nil
168}
169
170func newServiceMetadataMiddleware_opCreateEnvironment(region string) *awsmiddleware.RegisterServiceMetadata {
171	return &awsmiddleware.RegisterServiceMetadata{
172		Region:        region,
173		ServiceID:     ServiceID,
174		SigningName:   "proton",
175		OperationName: "CreateEnvironment",
176	}
177}
178