1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package resourcegroups 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/resourcegroups/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Creates a resource group with the specified name and description. You can 15// optionally include a resource query, or a service configuration. For more 16// information about constructing a resource query, see Create a tag-based group in 17// Resource Groups 18// (https://docs.aws.amazon.com/ARG/latest/userguide/gettingstarted-query.html#gettingstarted-query-cli-tag). 19// For more information about service configurations, see Service configurations 20// for resource groups 21// (https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html). Minimum 22// permissions To run this command, you must have the following permissions: 23// 24// * 25// resource-groups:CreateGroup 26func (c *Client) CreateGroup(ctx context.Context, params *CreateGroupInput, optFns ...func(*Options)) (*CreateGroupOutput, error) { 27 if params == nil { 28 params = &CreateGroupInput{} 29 } 30 31 result, metadata, err := c.invokeOperation(ctx, "CreateGroup", params, optFns, addOperationCreateGroupMiddlewares) 32 if err != nil { 33 return nil, err 34 } 35 36 out := result.(*CreateGroupOutput) 37 out.ResultMetadata = metadata 38 return out, nil 39} 40 41type CreateGroupInput struct { 42 43 // The name of the group, which is the identifier of the group in other operations. 44 // You can't change the name of a resource group after you create it. A resource 45 // group name can consist of letters, numbers, hyphens, periods, and underscores. 46 // The name cannot start with AWS or aws; these are reserved. A resource group name 47 // must be unique within each AWS Region in your AWS account. 48 // 49 // This member is required. 50 Name *string 51 52 // A configuration associates the resource group with an AWS service and specifies 53 // how the service can interact with the resources in the group. A configuration is 54 // an array of GroupConfigurationItem elements. For details about the syntax of 55 // service configurations, see Service configurations for resource groups 56 // (https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html). A resource 57 // group can contain either a Configuration or a ResourceQuery, but not both. 58 Configuration []types.GroupConfigurationItem 59 60 // The description of the resource group. Descriptions can consist of letters, 61 // numbers, hyphens, underscores, periods, and spaces. 62 Description *string 63 64 // The resource query that determines which AWS resources are members of this 65 // group. For more information about resource queries, see Create a tag-based group 66 // in Resource Groups 67 // (https://docs.aws.amazon.com/ARG/latest/userguide/gettingstarted-query.html#gettingstarted-query-cli-tag). 68 // A resource group can contain either a ResourceQuery or a Configuration, but not 69 // both. 70 ResourceQuery *types.ResourceQuery 71 72 // The tags to add to the group. A tag is key-value pair string. 73 Tags map[string]string 74} 75 76type CreateGroupOutput struct { 77 78 // The description of the resource group. 79 Group *types.Group 80 81 // The service configuration associated with the resource group. For details about 82 // the syntax of a service configuration, see Service configurations for resource 83 // groups (https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html). 84 GroupConfiguration *types.GroupConfiguration 85 86 // The resource query associated with the group. For more information about 87 // resource queries, see Create a tag-based group in Resource Groups 88 // (https://docs.aws.amazon.com/ARG/latest/userguide/gettingstarted-query.html#gettingstarted-query-cli-tag). 89 ResourceQuery *types.ResourceQuery 90 91 // The tags associated with the group. 92 Tags map[string]string 93 94 // Metadata pertaining to the operation's result. 95 ResultMetadata middleware.Metadata 96} 97 98func addOperationCreateGroupMiddlewares(stack *middleware.Stack, options Options) (err error) { 99 err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateGroup{}, middleware.After) 100 if err != nil { 101 return err 102 } 103 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateGroup{}, middleware.After) 104 if err != nil { 105 return err 106 } 107 if err = addSetLoggerMiddleware(stack, options); err != nil { 108 return err 109 } 110 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 111 return err 112 } 113 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 114 return err 115 } 116 if err = addResolveEndpointMiddleware(stack, options); err != nil { 117 return err 118 } 119 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 120 return err 121 } 122 if err = addRetryMiddlewares(stack, options); err != nil { 123 return err 124 } 125 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 126 return err 127 } 128 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 129 return err 130 } 131 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 132 return err 133 } 134 if err = addClientUserAgent(stack); err != nil { 135 return err 136 } 137 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 138 return err 139 } 140 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 141 return err 142 } 143 if err = addOpCreateGroupValidationMiddleware(stack); err != nil { 144 return err 145 } 146 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateGroup(options.Region), middleware.Before); err != nil { 147 return err 148 } 149 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 150 return err 151 } 152 if err = addResponseErrorMiddleware(stack); err != nil { 153 return err 154 } 155 if err = addRequestResponseLogging(stack, options); err != nil { 156 return err 157 } 158 return nil 159} 160 161func newServiceMetadataMiddleware_opCreateGroup(region string) *awsmiddleware.RegisterServiceMetadata { 162 return &awsmiddleware.RegisterServiceMetadata{ 163 Region: region, 164 ServiceID: ServiceID, 165 SigningName: "resource-groups", 166 OperationName: "CreateGroup", 167 } 168} 169