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, c.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 noSmithyDocumentSerde 76} 77 78// 79type CreateRouteOutput struct { 80 81 // The full description of your mesh following the create call. 82 // 83 // This member is required. 84 Route *types.RouteData 85 86 // Metadata pertaining to the operation's result. 87 ResultMetadata middleware.Metadata 88 89 noSmithyDocumentSerde 90} 91 92func (c *Client) addOperationCreateRouteMiddlewares(stack *middleware.Stack, options Options) (err error) { 93 err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateRoute{}, middleware.After) 94 if err != nil { 95 return err 96 } 97 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateRoute{}, middleware.After) 98 if err != nil { 99 return err 100 } 101 if err = addSetLoggerMiddleware(stack, options); err != nil { 102 return err 103 } 104 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 105 return err 106 } 107 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 108 return err 109 } 110 if err = addResolveEndpointMiddleware(stack, options); err != nil { 111 return err 112 } 113 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 114 return err 115 } 116 if err = addRetryMiddlewares(stack, options); err != nil { 117 return err 118 } 119 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 120 return err 121 } 122 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 123 return err 124 } 125 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 126 return err 127 } 128 if err = addClientUserAgent(stack); err != nil { 129 return err 130 } 131 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 132 return err 133 } 134 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 135 return err 136 } 137 if err = addOpCreateRouteValidationMiddleware(stack); err != nil { 138 return err 139 } 140 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateRoute(options.Region), middleware.Before); err != nil { 141 return err 142 } 143 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 144 return err 145 } 146 if err = addResponseErrorMiddleware(stack); err != nil { 147 return err 148 } 149 if err = addRequestResponseLogging(stack, options); err != nil { 150 return err 151 } 152 return nil 153} 154 155func newServiceMetadataMiddleware_opCreateRoute(region string) *awsmiddleware.RegisterServiceMetadata { 156 return &awsmiddleware.RegisterServiceMetadata{ 157 Region: region, 158 ServiceID: ServiceID, 159 SigningName: "appmesh", 160 OperationName: "CreateRoute", 161 } 162} 163