src

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

api_op_ListQueryLoggingConfigs.go (9708B)


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