src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

api_op_ListQueryLoggingConfigs.go (8542B)


      1 // Code generated by smithy-go-codegen DO NOT EDIT.
      2 
      3 package route53
      4 
      5 import (
      6 	"context"
      7 	"fmt"
      8 
      9 	"github.com/aws/aws-sdk-go-v2/service/route53/types"
     10 	"github.com/aws/smithy-go/middleware"
     11 )
     12 
     13 // Lists the configurations for DNS query logging that are associated with the
     14 // current Amazon Web Services account or the configuration that is associated with
     15 // a specified hosted zone.
     16 //
     17 // For more information about DNS query logs, see [CreateQueryLoggingConfig]. Additional information,
     18 // including the format of DNS query logs, appears in [Logging DNS Queries]in the Amazon Route 53
     19 // Developer Guide.
     20 //
     21 // [CreateQueryLoggingConfig]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_CreateQueryLoggingConfig.html
     22 // [Logging DNS Queries]: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/query-logs.html
     23 func (c *Client) ListQueryLoggingConfigs(ctx context.Context, params *ListQueryLoggingConfigsInput, optFns ...func(*Options)) (*ListQueryLoggingConfigsOutput, error) {
     24 	if params == nil {
     25 		params = &ListQueryLoggingConfigsInput{}
     26 	}
     27 
     28 	result, metadata, err := c.invokeOperation(ctx, "ListQueryLoggingConfigs", params, optFns, c.addOperationListQueryLoggingConfigsMiddlewares)
     29 	if err != nil {
     30 		return nil, err
     31 	}
     32 
     33 	out := result.(*ListQueryLoggingConfigsOutput)
     34 	out.ResultMetadata = metadata
     35 	return out, nil
     36 }
     37 
     38 type ListQueryLoggingConfigsInput struct {
     39 
     40 	// (Optional) If you want to list the query logging configuration that is
     41 	// associated with a hosted zone, specify the ID in HostedZoneId .
     42 	//
     43 	// If you don't specify a hosted zone ID, ListQueryLoggingConfigs returns all of
     44 	// the configurations that are associated with the current Amazon Web Services
     45 	// account.
     46 	HostedZoneId *string
     47 
     48 	// (Optional) The maximum number of query logging configurations that you want
     49 	// Amazon Route 53 to return in response to the current request. If the current
     50 	// Amazon Web Services account has more than MaxResults configurations, use the
     51 	// value of [NextToken]in the response to get the next page of results.
     52 	//
     53 	// If you don't specify a value for MaxResults , Route 53 returns up to 100
     54 	// configurations.
     55 	//
     56 	// [NextToken]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ListQueryLoggingConfigs.html#API_ListQueryLoggingConfigs_RequestSyntax
     57 	MaxResults *int32
     58 
     59 	// (Optional) If the current Amazon Web Services account has more than MaxResults
     60 	// query logging configurations, use NextToken to get the second and subsequent
     61 	// pages of results.
     62 	//
     63 	// For the first ListQueryLoggingConfigs request, omit this value.
     64 	//
     65 	// For the second and subsequent requests, get the value of NextToken from the
     66 	// previous response and specify that value for NextToken in the request.
     67 	NextToken *string
     68 
     69 	noSmithyDocumentSerde
     70 }
     71 
     72 type ListQueryLoggingConfigsOutput struct {
     73 
     74 	// An array that contains one [QueryLoggingConfig] element for each configuration for DNS query
     75 	// logging that is associated with the current Amazon Web Services account.
     76 	//
     77 	// [QueryLoggingConfig]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_QueryLoggingConfig.html
     78 	//
     79 	// This member is required.
     80 	QueryLoggingConfigs []types.QueryLoggingConfig
     81 
     82 	// If a response includes the last of the query logging configurations that are
     83 	// associated with the current Amazon Web Services account, NextToken doesn't
     84 	// appear in the response.
     85 	//
     86 	// If a response doesn't include the last of the configurations, you can get more
     87 	// configurations by submitting another [ListQueryLoggingConfigs]request. Get the value of NextToken that
     88 	// Amazon Route 53 returned in the previous response and include it in NextToken
     89 	// in the next request.
     90 	//
     91 	// [ListQueryLoggingConfigs]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ListQueryLoggingConfigs.html
     92 	NextToken *string
     93 
     94 	// Metadata pertaining to the operation's result.
     95 	ResultMetadata middleware.Metadata
     96 
     97 	noSmithyDocumentSerde
     98 }
     99 
    100 func (c *Client) addOperationListQueryLoggingConfigsMiddlewares(stack *middleware.Stack, options Options) (err error) {
    101 	err = stack.Serialize.Add(&awsRestxml_serializeOpListQueryLoggingConfigs{}, middleware.After)
    102 	if err != nil {
    103 		return err
    104 	}
    105 	err = stack.Deserialize.Add(&awsRestxml_deserializeOpListQueryLoggingConfigs{}, middleware.After)
    106 	if err != nil {
    107 		return err
    108 	}
    109 
    110 	if err = addComputeContentLength(stack); err != nil {
    111 		return err
    112 	}
    113 	if err = addResolveEndpointMiddleware(stack, options); err != nil {
    114 		return err
    115 	}
    116 	if err = addComputePayloadSHA256(stack); err != nil {
    117 		return err
    118 	}
    119 	if err = addRecordResponseTiming(stack, options); err != nil {
    120 		return err
    121 	}
    122 	if err = addCredentialSource(stack, options); err != nil {
    123 		return err
    124 	}
    125 	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
    126 		return err
    127 	}
    128 	if err = addResponseErrorMiddleware(stack); err != nil {
    129 		return err
    130 	}
    131 	if err = addSanitizeURLMiddleware(stack); err != nil {
    132 		return err
    133 	}
    134 	if err = addRequestResponseLogging(stack, options); err != nil {
    135 		return err
    136 	}
    137 	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
    138 		return err
    139 	}
    140 	if err = addInterceptors(stack, options); err != nil {
    141 		return err
    142 	}
    143 	return nil
    144 }
    145 
    146 // ListQueryLoggingConfigsPaginatorOptions is the paginator options for
    147 // ListQueryLoggingConfigs
    148 type ListQueryLoggingConfigsPaginatorOptions struct {
    149 	// (Optional) The maximum number of query logging configurations that you want
    150 	// Amazon Route 53 to return in response to the current request. If the current
    151 	// Amazon Web Services account has more than MaxResults configurations, use the
    152 	// value of [NextToken]in the response to get the next page of results.
    153 	//
    154 	// If you don't specify a value for MaxResults , Route 53 returns up to 100
    155 	// configurations.
    156 	//
    157 	// [NextToken]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ListQueryLoggingConfigs.html#API_ListQueryLoggingConfigs_RequestSyntax
    158 	Limit int32
    159 
    160 	// Set to true if pagination should stop if the service returns a pagination token
    161 	// that matches the most recent token provided to the service.
    162 	StopOnDuplicateToken bool
    163 }
    164 
    165 // ListQueryLoggingConfigsPaginator is a paginator for ListQueryLoggingConfigs
    166 type ListQueryLoggingConfigsPaginator struct {
    167 	options   ListQueryLoggingConfigsPaginatorOptions
    168 	client    ListQueryLoggingConfigsAPIClient
    169 	params    *ListQueryLoggingConfigsInput
    170 	nextToken *string
    171 	firstPage bool
    172 }
    173 
    174 // NewListQueryLoggingConfigsPaginator returns a new
    175 // ListQueryLoggingConfigsPaginator
    176 func NewListQueryLoggingConfigsPaginator(client ListQueryLoggingConfigsAPIClient, params *ListQueryLoggingConfigsInput, optFns ...func(*ListQueryLoggingConfigsPaginatorOptions)) *ListQueryLoggingConfigsPaginator {
    177 	if params == nil {
    178 		params = &ListQueryLoggingConfigsInput{}
    179 	}
    180 
    181 	options := ListQueryLoggingConfigsPaginatorOptions{}
    182 	if params.MaxResults != nil {
    183 		options.Limit = *params.MaxResults
    184 	}
    185 
    186 	for _, fn := range optFns {
    187 		fn(&options)
    188 	}
    189 
    190 	return &ListQueryLoggingConfigsPaginator{
    191 		options:   options,
    192 		client:    client,
    193 		params:    params,
    194 		firstPage: true,
    195 		nextToken: params.NextToken,
    196 	}
    197 }
    198 
    199 // HasMorePages returns a boolean indicating whether more pages are available
    200 func (p *ListQueryLoggingConfigsPaginator) HasMorePages() bool {
    201 	return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
    202 }
    203 
    204 // NextPage retrieves the next ListQueryLoggingConfigs page.
    205 func (p *ListQueryLoggingConfigsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListQueryLoggingConfigsOutput, error) {
    206 	if !p.HasMorePages() {
    207 		return nil, fmt.Errorf("no more pages available")
    208 	}
    209 
    210 	params := *p.params
    211 	params.NextToken = p.nextToken
    212 
    213 	var limit *int32
    214 	if p.options.Limit > 0 {
    215 		limit = &p.options.Limit
    216 	}
    217 	params.MaxResults = limit
    218 
    219 	optFns = append([]func(*Options){
    220 		addIsPaginatorUserAgent,
    221 	}, optFns...)
    222 	result, err := p.client.ListQueryLoggingConfigs(ctx, &params, optFns...)
    223 	if err != nil {
    224 		return nil, err
    225 	}
    226 	p.firstPage = false
    227 
    228 	prevToken := p.nextToken
    229 	p.nextToken = result.NextToken
    230 
    231 	if p.options.StopOnDuplicateToken &&
    232 		prevToken != nil &&
    233 		p.nextToken != nil &&
    234 		*prevToken == *p.nextToken {
    235 		p.nextToken = nil
    236 	}
    237 
    238 	return result, nil
    239 }
    240 
    241 // ListQueryLoggingConfigsAPIClient is a client that implements the
    242 // ListQueryLoggingConfigs operation.
    243 type ListQueryLoggingConfigsAPIClient interface {
    244 	ListQueryLoggingConfigs(context.Context, *ListQueryLoggingConfigsInput, ...func(*Options)) (*ListQueryLoggingConfigsOutput, error)
    245 }
    246 
    247 var _ ListQueryLoggingConfigsAPIClient = (*Client)(nil)