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// Retrieves the exclusions preview (a list of ExclusionPreview objects) specified 16// by the preview token. You can obtain the preview token by running the 17// CreateExclusionsPreview API. 18func (c *Client) GetExclusionsPreview(ctx context.Context, params *GetExclusionsPreviewInput, optFns ...func(*Options)) (*GetExclusionsPreviewOutput, error) { 19 if params == nil { 20 params = &GetExclusionsPreviewInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "GetExclusionsPreview", params, optFns, addOperationGetExclusionsPreviewMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*GetExclusionsPreviewOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33type GetExclusionsPreviewInput struct { 34 35 // The ARN that specifies the assessment template for which the exclusions preview 36 // was requested. 37 // 38 // This member is required. 39 AssessmentTemplateArn *string 40 41 // The unique identifier associated of the exclusions preview. 42 // 43 // This member is required. 44 PreviewToken *string 45 46 // The locale into which you want to translate the exclusion's title, description, 47 // and recommendation. 48 Locale types.Locale 49 50 // You can use this parameter to indicate the maximum number of items you want in 51 // the response. The default value is 100. The maximum value is 500. 52 MaxResults *int32 53 54 // You can use this parameter when paginating results. Set the value of this 55 // parameter to null on your first call to the GetExclusionsPreviewRequest action. 56 // Subsequent calls to the action fill nextToken in the request with the value of 57 // nextToken from the previous response to continue listing data. 58 NextToken *string 59} 60 61type GetExclusionsPreviewOutput struct { 62 63 // Specifies the status of the request to generate an exclusions preview. 64 // 65 // This member is required. 66 PreviewStatus types.PreviewStatus 67 68 // Information about the exclusions included in the preview. 69 ExclusionPreviews []types.ExclusionPreview 70 71 // When a response is generated, if there is more data to be listed, this 72 // parameters is present in the response and contains the value to use for the 73 // nextToken parameter in a subsequent pagination request. If there is no more data 74 // to be listed, this parameter is set to null. 75 NextToken *string 76 77 // Metadata pertaining to the operation's result. 78 ResultMetadata middleware.Metadata 79} 80 81func addOperationGetExclusionsPreviewMiddlewares(stack *middleware.Stack, options Options) (err error) { 82 err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetExclusionsPreview{}, middleware.After) 83 if err != nil { 84 return err 85 } 86 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetExclusionsPreview{}, middleware.After) 87 if err != nil { 88 return err 89 } 90 if err = addSetLoggerMiddleware(stack, options); err != nil { 91 return err 92 } 93 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 94 return err 95 } 96 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 97 return err 98 } 99 if err = addResolveEndpointMiddleware(stack, options); err != nil { 100 return err 101 } 102 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 103 return err 104 } 105 if err = addRetryMiddlewares(stack, options); err != nil { 106 return err 107 } 108 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 109 return err 110 } 111 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 112 return err 113 } 114 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 115 return err 116 } 117 if err = addClientUserAgent(stack); err != nil { 118 return err 119 } 120 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 121 return err 122 } 123 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 124 return err 125 } 126 if err = addOpGetExclusionsPreviewValidationMiddleware(stack); err != nil { 127 return err 128 } 129 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetExclusionsPreview(options.Region), middleware.Before); err != nil { 130 return err 131 } 132 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 133 return err 134 } 135 if err = addResponseErrorMiddleware(stack); err != nil { 136 return err 137 } 138 if err = addRequestResponseLogging(stack, options); err != nil { 139 return err 140 } 141 return nil 142} 143 144// GetExclusionsPreviewAPIClient is a client that implements the 145// GetExclusionsPreview operation. 146type GetExclusionsPreviewAPIClient interface { 147 GetExclusionsPreview(context.Context, *GetExclusionsPreviewInput, ...func(*Options)) (*GetExclusionsPreviewOutput, error) 148} 149 150var _ GetExclusionsPreviewAPIClient = (*Client)(nil) 151 152// GetExclusionsPreviewPaginatorOptions is the paginator options for 153// GetExclusionsPreview 154type GetExclusionsPreviewPaginatorOptions struct { 155 // You can use this parameter to indicate the maximum number of items you want in 156 // the response. The default value is 100. The maximum value is 500. 157 Limit int32 158 159 // Set to true if pagination should stop if the service returns a pagination token 160 // that matches the most recent token provided to the service. 161 StopOnDuplicateToken bool 162} 163 164// GetExclusionsPreviewPaginator is a paginator for GetExclusionsPreview 165type GetExclusionsPreviewPaginator struct { 166 options GetExclusionsPreviewPaginatorOptions 167 client GetExclusionsPreviewAPIClient 168 params *GetExclusionsPreviewInput 169 nextToken *string 170 firstPage bool 171} 172 173// NewGetExclusionsPreviewPaginator returns a new GetExclusionsPreviewPaginator 174func NewGetExclusionsPreviewPaginator(client GetExclusionsPreviewAPIClient, params *GetExclusionsPreviewInput, optFns ...func(*GetExclusionsPreviewPaginatorOptions)) *GetExclusionsPreviewPaginator { 175 options := GetExclusionsPreviewPaginatorOptions{} 176 if params.MaxResults != nil { 177 options.Limit = *params.MaxResults 178 } 179 180 for _, fn := range optFns { 181 fn(&options) 182 } 183 184 if params == nil { 185 params = &GetExclusionsPreviewInput{} 186 } 187 188 return &GetExclusionsPreviewPaginator{ 189 options: options, 190 client: client, 191 params: params, 192 firstPage: true, 193 } 194} 195 196// HasMorePages returns a boolean indicating whether more pages are available 197func (p *GetExclusionsPreviewPaginator) HasMorePages() bool { 198 return p.firstPage || p.nextToken != nil 199} 200 201// NextPage retrieves the next GetExclusionsPreview page. 202func (p *GetExclusionsPreviewPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetExclusionsPreviewOutput, error) { 203 if !p.HasMorePages() { 204 return nil, fmt.Errorf("no more pages available") 205 } 206 207 params := *p.params 208 params.NextToken = p.nextToken 209 210 var limit *int32 211 if p.options.Limit > 0 { 212 limit = &p.options.Limit 213 } 214 params.MaxResults = limit 215 216 result, err := p.client.GetExclusionsPreview(ctx, ¶ms, optFns...) 217 if err != nil { 218 return nil, err 219 } 220 p.firstPage = false 221 222 prevToken := p.nextToken 223 p.nextToken = result.NextToken 224 225 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 226 p.nextToken = nil 227 } 228 229 return result, nil 230} 231 232func newServiceMetadataMiddleware_opGetExclusionsPreview(region string) *awsmiddleware.RegisterServiceMetadata { 233 return &awsmiddleware.RegisterServiceMetadata{ 234 Region: region, 235 ServiceID: ServiceID, 236 SigningName: "inspector", 237 OperationName: "GetExclusionsPreview", 238 } 239} 240