code.dwrz.net

Go monorepo.
Log | Files | Refs

api_op_ListQueryLoggingConfigs.go (9370B)


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