1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ec2 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/ec2/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Gets information about the resources that are associated with the specified 16// managed prefix list. 17func (c *Client) GetManagedPrefixListAssociations(ctx context.Context, params *GetManagedPrefixListAssociationsInput, optFns ...func(*Options)) (*GetManagedPrefixListAssociationsOutput, error) { 18 if params == nil { 19 params = &GetManagedPrefixListAssociationsInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "GetManagedPrefixListAssociations", params, optFns, addOperationGetManagedPrefixListAssociationsMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*GetManagedPrefixListAssociationsOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type GetManagedPrefixListAssociationsInput struct { 33 34 // The ID of the prefix list. 35 // 36 // This member is required. 37 PrefixListId *string 38 39 // Checks whether you have the required permissions for the action, without 40 // actually making the request, and provides an error response. If you have the 41 // required permissions, the error response is DryRunOperation. Otherwise, it is 42 // UnauthorizedOperation. 43 DryRun *bool 44 45 // The maximum number of results to return with a single call. To retrieve the 46 // remaining results, make another call with the returned nextToken value. 47 MaxResults *int32 48 49 // The token for the next page of results. 50 NextToken *string 51} 52 53type GetManagedPrefixListAssociationsOutput struct { 54 55 // The token to use to retrieve the next page of results. This value is null when 56 // there are no more results to return. 57 NextToken *string 58 59 // Information about the associations. 60 PrefixListAssociations []types.PrefixListAssociation 61 62 // Metadata pertaining to the operation's result. 63 ResultMetadata middleware.Metadata 64} 65 66func addOperationGetManagedPrefixListAssociationsMiddlewares(stack *middleware.Stack, options Options) (err error) { 67 err = stack.Serialize.Add(&awsEc2query_serializeOpGetManagedPrefixListAssociations{}, middleware.After) 68 if err != nil { 69 return err 70 } 71 err = stack.Deserialize.Add(&awsEc2query_deserializeOpGetManagedPrefixListAssociations{}, middleware.After) 72 if err != nil { 73 return err 74 } 75 if err = addSetLoggerMiddleware(stack, options); err != nil { 76 return err 77 } 78 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 79 return err 80 } 81 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 82 return err 83 } 84 if err = addResolveEndpointMiddleware(stack, options); err != nil { 85 return err 86 } 87 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 88 return err 89 } 90 if err = addRetryMiddlewares(stack, options); err != nil { 91 return err 92 } 93 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 94 return err 95 } 96 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 97 return err 98 } 99 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 100 return err 101 } 102 if err = addClientUserAgent(stack); err != nil { 103 return err 104 } 105 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 106 return err 107 } 108 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 109 return err 110 } 111 if err = addOpGetManagedPrefixListAssociationsValidationMiddleware(stack); err != nil { 112 return err 113 } 114 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetManagedPrefixListAssociations(options.Region), middleware.Before); err != nil { 115 return err 116 } 117 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 118 return err 119 } 120 if err = addResponseErrorMiddleware(stack); err != nil { 121 return err 122 } 123 if err = addRequestResponseLogging(stack, options); err != nil { 124 return err 125 } 126 return nil 127} 128 129// GetManagedPrefixListAssociationsAPIClient is a client that implements the 130// GetManagedPrefixListAssociations operation. 131type GetManagedPrefixListAssociationsAPIClient interface { 132 GetManagedPrefixListAssociations(context.Context, *GetManagedPrefixListAssociationsInput, ...func(*Options)) (*GetManagedPrefixListAssociationsOutput, error) 133} 134 135var _ GetManagedPrefixListAssociationsAPIClient = (*Client)(nil) 136 137// GetManagedPrefixListAssociationsPaginatorOptions is the paginator options for 138// GetManagedPrefixListAssociations 139type GetManagedPrefixListAssociationsPaginatorOptions struct { 140 // The maximum number of results to return with a single call. To retrieve the 141 // remaining results, make another call with the returned nextToken value. 142 Limit int32 143 144 // Set to true if pagination should stop if the service returns a pagination token 145 // that matches the most recent token provided to the service. 146 StopOnDuplicateToken bool 147} 148 149// GetManagedPrefixListAssociationsPaginator is a paginator for 150// GetManagedPrefixListAssociations 151type GetManagedPrefixListAssociationsPaginator struct { 152 options GetManagedPrefixListAssociationsPaginatorOptions 153 client GetManagedPrefixListAssociationsAPIClient 154 params *GetManagedPrefixListAssociationsInput 155 nextToken *string 156 firstPage bool 157} 158 159// NewGetManagedPrefixListAssociationsPaginator returns a new 160// GetManagedPrefixListAssociationsPaginator 161func NewGetManagedPrefixListAssociationsPaginator(client GetManagedPrefixListAssociationsAPIClient, params *GetManagedPrefixListAssociationsInput, optFns ...func(*GetManagedPrefixListAssociationsPaginatorOptions)) *GetManagedPrefixListAssociationsPaginator { 162 if params == nil { 163 params = &GetManagedPrefixListAssociationsInput{} 164 } 165 166 options := GetManagedPrefixListAssociationsPaginatorOptions{} 167 if params.MaxResults != nil { 168 options.Limit = *params.MaxResults 169 } 170 171 for _, fn := range optFns { 172 fn(&options) 173 } 174 175 return &GetManagedPrefixListAssociationsPaginator{ 176 options: options, 177 client: client, 178 params: params, 179 firstPage: true, 180 } 181} 182 183// HasMorePages returns a boolean indicating whether more pages are available 184func (p *GetManagedPrefixListAssociationsPaginator) HasMorePages() bool { 185 return p.firstPage || p.nextToken != nil 186} 187 188// NextPage retrieves the next GetManagedPrefixListAssociations page. 189func (p *GetManagedPrefixListAssociationsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetManagedPrefixListAssociationsOutput, error) { 190 if !p.HasMorePages() { 191 return nil, fmt.Errorf("no more pages available") 192 } 193 194 params := *p.params 195 params.NextToken = p.nextToken 196 197 var limit *int32 198 if p.options.Limit > 0 { 199 limit = &p.options.Limit 200 } 201 params.MaxResults = limit 202 203 result, err := p.client.GetManagedPrefixListAssociations(ctx, ¶ms, optFns...) 204 if err != nil { 205 return nil, err 206 } 207 p.firstPage = false 208 209 prevToken := p.nextToken 210 p.nextToken = result.NextToken 211 212 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 213 p.nextToken = nil 214 } 215 216 return result, nil 217} 218 219func newServiceMetadataMiddleware_opGetManagedPrefixListAssociations(region string) *awsmiddleware.RegisterServiceMetadata { 220 return &awsmiddleware.RegisterServiceMetadata{ 221 Region: region, 222 ServiceID: ServiceID, 223 SigningName: "ec2", 224 OperationName: "GetManagedPrefixListAssociations", 225 } 226} 227