1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package inspector 4 5import ( 6 "context" 7 "fmt" 8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 9 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 10 "github.com/aws/aws-sdk-go-v2/service/inspector/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Lists the assessment templates that correspond to the assessment targets that 16// are specified by the ARNs of the assessment targets. 17func (c *Client) ListAssessmentTemplates(ctx context.Context, params *ListAssessmentTemplatesInput, optFns ...func(*Options)) (*ListAssessmentTemplatesOutput, error) { 18 if params == nil { 19 params = &ListAssessmentTemplatesInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "ListAssessmentTemplates", params, optFns, addOperationListAssessmentTemplatesMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*ListAssessmentTemplatesOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type ListAssessmentTemplatesInput struct { 33 34 // A list of ARNs that specifies the assessment targets whose assessment templates 35 // you want to list. 36 AssessmentTargetArns []string 37 38 // You can use this parameter to specify a subset of data to be included in the 39 // action's response. For a record to match a filter, all specified filter 40 // attributes must match. When multiple values are specified for a filter 41 // attribute, any of the values can match. 42 Filter *types.AssessmentTemplateFilter 43 44 // You can use this parameter to indicate the maximum number of items you want in 45 // the response. The default value is 10. The maximum value is 500. 46 MaxResults *int32 47 48 // You can use this parameter when paginating results. Set the value of this 49 // parameter to null on your first call to the ListAssessmentTemplates action. 50 // Subsequent calls to the action fill nextToken in the request with the value of 51 // NextToken from the previous response to continue listing data. 52 NextToken *string 53} 54 55type ListAssessmentTemplatesOutput struct { 56 57 // A list of ARNs that specifies the assessment templates returned by the action. 58 // 59 // This member is required. 60 AssessmentTemplateArns []string 61 62 // When a response is generated, if there is more data to be listed, this parameter 63 // is present in the response and contains the value to use for the nextToken 64 // parameter in a subsequent pagination request. If there is no more data to be 65 // listed, this parameter is set to null. 66 NextToken *string 67 68 // Metadata pertaining to the operation's result. 69 ResultMetadata middleware.Metadata 70} 71 72func addOperationListAssessmentTemplatesMiddlewares(stack *middleware.Stack, options Options) (err error) { 73 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListAssessmentTemplates{}, middleware.After) 74 if err != nil { 75 return err 76 } 77 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListAssessmentTemplates{}, middleware.After) 78 if err != nil { 79 return err 80 } 81 if err = addSetLoggerMiddleware(stack, options); err != nil { 82 return err 83 } 84 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 85 return err 86 } 87 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 88 return err 89 } 90 if err = addResolveEndpointMiddleware(stack, options); err != nil { 91 return err 92 } 93 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 94 return err 95 } 96 if err = addRetryMiddlewares(stack, options); err != nil { 97 return err 98 } 99 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 100 return err 101 } 102 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 103 return err 104 } 105 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 106 return err 107 } 108 if err = addClientUserAgent(stack); err != nil { 109 return err 110 } 111 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 112 return err 113 } 114 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 115 return err 116 } 117 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListAssessmentTemplates(options.Region), middleware.Before); err != nil { 118 return err 119 } 120 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 121 return err 122 } 123 if err = addResponseErrorMiddleware(stack); err != nil { 124 return err 125 } 126 if err = addRequestResponseLogging(stack, options); err != nil { 127 return err 128 } 129 return nil 130} 131 132// ListAssessmentTemplatesAPIClient is a client that implements the 133// ListAssessmentTemplates operation. 134type ListAssessmentTemplatesAPIClient interface { 135 ListAssessmentTemplates(context.Context, *ListAssessmentTemplatesInput, ...func(*Options)) (*ListAssessmentTemplatesOutput, error) 136} 137 138var _ ListAssessmentTemplatesAPIClient = (*Client)(nil) 139 140// ListAssessmentTemplatesPaginatorOptions is the paginator options for 141// ListAssessmentTemplates 142type ListAssessmentTemplatesPaginatorOptions struct { 143 // You can use this parameter to indicate the maximum number of items you want in 144 // the response. The default value is 10. The maximum value is 500. 145 Limit int32 146 147 // Set to true if pagination should stop if the service returns a pagination token 148 // that matches the most recent token provided to the service. 149 StopOnDuplicateToken bool 150} 151 152// ListAssessmentTemplatesPaginator is a paginator for ListAssessmentTemplates 153type ListAssessmentTemplatesPaginator struct { 154 options ListAssessmentTemplatesPaginatorOptions 155 client ListAssessmentTemplatesAPIClient 156 params *ListAssessmentTemplatesInput 157 nextToken *string 158 firstPage bool 159} 160 161// NewListAssessmentTemplatesPaginator returns a new 162// ListAssessmentTemplatesPaginator 163func NewListAssessmentTemplatesPaginator(client ListAssessmentTemplatesAPIClient, params *ListAssessmentTemplatesInput, optFns ...func(*ListAssessmentTemplatesPaginatorOptions)) *ListAssessmentTemplatesPaginator { 164 options := ListAssessmentTemplatesPaginatorOptions{} 165 if params.MaxResults != nil { 166 options.Limit = *params.MaxResults 167 } 168 169 for _, fn := range optFns { 170 fn(&options) 171 } 172 173 if params == nil { 174 params = &ListAssessmentTemplatesInput{} 175 } 176 177 return &ListAssessmentTemplatesPaginator{ 178 options: options, 179 client: client, 180 params: params, 181 firstPage: true, 182 } 183} 184 185// HasMorePages returns a boolean indicating whether more pages are available 186func (p *ListAssessmentTemplatesPaginator) HasMorePages() bool { 187 return p.firstPage || p.nextToken != nil 188} 189 190// NextPage retrieves the next ListAssessmentTemplates page. 191func (p *ListAssessmentTemplatesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListAssessmentTemplatesOutput, error) { 192 if !p.HasMorePages() { 193 return nil, fmt.Errorf("no more pages available") 194 } 195 196 params := *p.params 197 params.NextToken = p.nextToken 198 199 var limit *int32 200 if p.options.Limit > 0 { 201 limit = &p.options.Limit 202 } 203 params.MaxResults = limit 204 205 result, err := p.client.ListAssessmentTemplates(ctx, ¶ms, optFns...) 206 if err != nil { 207 return nil, err 208 } 209 p.firstPage = false 210 211 prevToken := p.nextToken 212 p.nextToken = result.NextToken 213 214 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 215 p.nextToken = nil 216 } 217 218 return result, nil 219} 220 221func newServiceMetadataMiddleware_opListAssessmentTemplates(region string) *awsmiddleware.RegisterServiceMetadata { 222 return &awsmiddleware.RegisterServiceMetadata{ 223 Region: region, 224 ServiceID: ServiceID, 225 SigningName: "inspector", 226 OperationName: "ListAssessmentTemplates", 227 } 228} 229