1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package appmesh
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/appmesh/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates a route that is associated with a virtual router. You can route several
15// different protocols and define a retry policy for a route. Traffic can be routed
16// to one or more virtual nodes. For more information about routes, see Routes
17// (https://docs.aws.amazon.com/app-mesh/latest/userguide/routes.html).
18func (c *Client) CreateRoute(ctx context.Context, params *CreateRouteInput, optFns ...func(*Options)) (*CreateRouteOutput, error) {
19	if params == nil {
20		params = &CreateRouteInput{}
21	}
22
23	result, metadata, err := c.invokeOperation(ctx, "CreateRoute", params, optFns, addOperationCreateRouteMiddlewares)
24	if err != nil {
25		return nil, err
26	}
27
28	out := result.(*CreateRouteOutput)
29	out.ResultMetadata = metadata
30	return out, nil
31}
32
33//
34type CreateRouteInput struct {
35
36	// The name of the service mesh to create the route in.
37	//
38	// This member is required.
39	MeshName *string
40
41	// The name to use for the route.
42	//
43	// This member is required.
44	RouteName *string
45
46	// The route specification to apply.
47	//
48	// This member is required.
49	Spec *types.RouteSpec
50
51	// The name of the virtual router in which to create the route. If the virtual
52	// router is in a shared mesh, then you must be the owner of the virtual router
53	// resource.
54	//
55	// This member is required.
56	VirtualRouterName *string
57
58	// Unique, case-sensitive identifier that you provide to ensure the idempotency of
59	// the request. Up to 36 letters, numbers, hyphens, and underscores are allowed.
60	ClientToken *string
61
62	// The AWS IAM account ID of the service mesh owner. If the account ID is not your
63	// own, then the account that you specify must share the mesh with your account
64	// before you can create the resource in the service mesh. For more information
65	// about mesh sharing, see Working with shared meshes
66	// (https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html).
67	MeshOwner *string
68
69	// Optional metadata that you can apply to the route to assist with categorization
70	// and organization. Each tag consists of a key and an optional value, both of
71	// which you define. Tag keys can have a maximum character length of 128
72	// characters, and tag values can have a maximum length of 256 characters.
73	Tags []types.TagRef
74}
75
76//
77type CreateRouteOutput struct {
78
79	// The full description of your mesh following the create call.
80	//
81	// This member is required.
82	Route *types.RouteData
83
84	// Metadata pertaining to the operation's result.
85	ResultMetadata middleware.Metadata
86}
87
88func addOperationCreateRouteMiddlewares(stack *middleware.Stack, options Options) (err error) {
89	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateRoute{}, middleware.After)
90	if err != nil {
91		return err
92	}
93	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateRoute{}, middleware.After)
94	if err != nil {
95		return err
96	}
97	if err = addSetLoggerMiddleware(stack, options); err != nil {
98		return err
99	}
100	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
101		return err
102	}
103	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
104		return err
105	}
106	if err = addResolveEndpointMiddleware(stack, options); err != nil {
107		return err
108	}
109	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
110		return err
111	}
112	if err = addRetryMiddlewares(stack, options); err != nil {
113		return err
114	}
115	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
116		return err
117	}
118	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
119		return err
120	}
121	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
122		return err
123	}
124	if err = addClientUserAgent(stack); err != nil {
125		return err
126	}
127	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
128		return err
129	}
130	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
131		return err
132	}
133	if err = addOpCreateRouteValidationMiddleware(stack); err != nil {
134		return err
135	}
136	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
137		return err
138	}
139	if err = addResponseErrorMiddleware(stack); err != nil {
140		return err
141	}
142	if err = addRequestResponseLogging(stack, options); err != nil {
143		return err
144	}
145	return nil
146}
147