1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package configservice 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/configservice/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Returns the resource types, the number of each resource type, and the total 15// number of resources that AWS Config is recording in this region for your AWS 16// account. Example 17// 18// * AWS Config is recording three resource types in the US East 19// (Ohio) Region for your account: 25 EC2 instances, 20 IAM users, and 15 S3 20// buckets. 21// 22// * You make a call to the GetDiscoveredResourceCounts action and 23// specify that you want all resource types. 24// 25// * AWS Config returns the 26// following: 27// 28// * The resource types (EC2 instances, IAM users, and S3 buckets). 29// 30// * 31// The number of each resource type (25, 20, and 15). 32// 33// * The total number of all 34// resources (60). 35// 36// The response is paginated. By default, AWS Config lists 100 37// ResourceCount objects on each page. You can customize this number with the limit 38// parameter. The response includes a nextToken string. To get the next page of 39// results, run the request again and specify the string for the nextToken 40// parameter. If you make a call to the GetDiscoveredResourceCounts action, you 41// might not immediately receive resource counts in the following situations: 42// 43// * 44// You are a new AWS Config customer. 45// 46// * You just enabled resource recording. 47// 48// It 49// might take a few minutes for AWS Config to record and count your resources. Wait 50// a few minutes and then retry the GetDiscoveredResourceCounts action. 51func (c *Client) GetDiscoveredResourceCounts(ctx context.Context, params *GetDiscoveredResourceCountsInput, optFns ...func(*Options)) (*GetDiscoveredResourceCountsOutput, error) { 52 if params == nil { 53 params = &GetDiscoveredResourceCountsInput{} 54 } 55 56 result, metadata, err := c.invokeOperation(ctx, "GetDiscoveredResourceCounts", params, optFns, addOperationGetDiscoveredResourceCountsMiddlewares) 57 if err != nil { 58 return nil, err 59 } 60 61 out := result.(*GetDiscoveredResourceCountsOutput) 62 out.ResultMetadata = metadata 63 return out, nil 64} 65 66type GetDiscoveredResourceCountsInput struct { 67 68 // The maximum number of ResourceCount objects returned on each page. The default 69 // is 100. You cannot specify a number greater than 100. If you specify 0, AWS 70 // Config uses the default. 71 Limit int32 72 73 // The nextToken string returned on a previous page that you use to get the next 74 // page of results in a paginated response. 75 NextToken *string 76 77 // The comma-separated list that specifies the resource types that you want AWS 78 // Config to return (for example, "AWS::EC2::Instance", "AWS::IAM::User"). If a 79 // value for resourceTypes is not specified, AWS Config returns all resource types 80 // that AWS Config is recording in the region for your account. If the 81 // configuration recorder is turned off, AWS Config returns an empty list of 82 // ResourceCount objects. If the configuration recorder is not recording a specific 83 // resource type (for example, S3 buckets), that resource type is not returned in 84 // the list of ResourceCount objects. 85 ResourceTypes []string 86} 87 88type GetDiscoveredResourceCountsOutput struct { 89 90 // The string that you use in a subsequent request to get the next page of results 91 // in a paginated response. 92 NextToken *string 93 94 // The list of ResourceCount objects. Each object is listed in descending order by 95 // the number of resources. 96 ResourceCounts []types.ResourceCount 97 98 // The total number of resources that AWS Config is recording in the region for 99 // your account. If you specify resource types in the request, AWS Config returns 100 // only the total number of resources for those resource types. Example 101 // 102 // * AWS 103 // Config is recording three resource types in the US East (Ohio) Region for your 104 // account: 25 EC2 instances, 20 IAM users, and 15 S3 buckets, for a total of 60 105 // resources. 106 // 107 // * You make a call to the GetDiscoveredResourceCounts action and 108 // specify the resource type, "AWS::EC2::Instances", in the request. 109 // 110 // * AWS Config 111 // returns 25 for totalDiscoveredResources. 112 TotalDiscoveredResources int64 113 114 // Metadata pertaining to the operation's result. 115 ResultMetadata middleware.Metadata 116} 117 118func addOperationGetDiscoveredResourceCountsMiddlewares(stack *middleware.Stack, options Options) (err error) { 119 err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetDiscoveredResourceCounts{}, middleware.After) 120 if err != nil { 121 return err 122 } 123 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetDiscoveredResourceCounts{}, middleware.After) 124 if err != nil { 125 return err 126 } 127 if err = addSetLoggerMiddleware(stack, options); err != nil { 128 return err 129 } 130 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 131 return err 132 } 133 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 134 return err 135 } 136 if err = addResolveEndpointMiddleware(stack, options); err != nil { 137 return err 138 } 139 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 140 return err 141 } 142 if err = addRetryMiddlewares(stack, options); err != nil { 143 return err 144 } 145 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 146 return err 147 } 148 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 149 return err 150 } 151 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 152 return err 153 } 154 if err = addClientUserAgent(stack); err != nil { 155 return err 156 } 157 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 158 return err 159 } 160 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 161 return err 162 } 163 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetDiscoveredResourceCounts(options.Region), middleware.Before); err != nil { 164 return err 165 } 166 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 167 return err 168 } 169 if err = addResponseErrorMiddleware(stack); err != nil { 170 return err 171 } 172 if err = addRequestResponseLogging(stack, options); err != nil { 173 return err 174 } 175 return nil 176} 177 178func newServiceMetadataMiddleware_opGetDiscoveredResourceCounts(region string) *awsmiddleware.RegisterServiceMetadata { 179 return &awsmiddleware.RegisterServiceMetadata{ 180 Region: region, 181 ServiceID: ServiceID, 182 SigningName: "config", 183 OperationName: "GetDiscoveredResourceCounts", 184 } 185} 186