src

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

api_op_ListQueryLoggingConfigs.go (11383B)


      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.
     17 //
     18 // For more information about DNS query logs, see [CreateQueryLoggingConfig]. Additional information,
     19 // including the format of DNS query logs, appears in [Logging DNS Queries]in the Amazon Route 53
     20 // Developer Guide.
     21 //
     22 // [CreateQueryLoggingConfig]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_CreateQueryLoggingConfig.html
     23 // [Logging DNS Queries]: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/query-logs.html
     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 .
     43 	//
     44 	// If you don't specify a hosted zone ID, ListQueryLoggingConfigs returns all of
     45 	// the configurations that are associated with the current Amazon Web Services
     46 	// account.
     47 	HostedZoneId *string
     48 
     49 	// (Optional) The maximum number of query logging configurations that you want
     50 	// Amazon Route 53 to return in response to the current request. If the current
     51 	// Amazon Web Services account has more than MaxResults configurations, use the
     52 	// value of [NextToken]in the response to get the next page of results.
     53 	//
     54 	// If you don't specify a value for MaxResults , Route 53 returns up to 100
     55 	// configurations.
     56 	//
     57 	// [NextToken]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ListQueryLoggingConfigs.html#API_ListQueryLoggingConfigs_RequestSyntax
     58 	MaxResults *int32
     59 
     60 	// (Optional) If the current Amazon Web Services account has more than MaxResults
     61 	// query logging configurations, use NextToken to get the second and subsequent
     62 	// pages of results.
     63 	//
     64 	// For the first ListQueryLoggingConfigs request, omit this value.
     65 	//
     66 	// For the second and subsequent requests, get the value of NextToken from the
     67 	// previous response and specify that value for NextToken in the request.
     68 	NextToken *string
     69 
     70 	noSmithyDocumentSerde
     71 }
     72 
     73 type ListQueryLoggingConfigsOutput struct {
     74 
     75 	// An array that contains one [QueryLoggingConfig] element for each configuration for DNS query
     76 	// logging that is associated with the current Amazon Web Services account.
     77 	//
     78 	// [QueryLoggingConfig]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_QueryLoggingConfig.html
     79 	//
     80 	// This member is required.
     81 	QueryLoggingConfigs []types.QueryLoggingConfig
     82 
     83 	// If a response includes the last of the query logging configurations that are
     84 	// associated with the current Amazon Web Services account, NextToken doesn't
     85 	// appear in the response.
     86 	//
     87 	// If a response doesn't include the last of the configurations, you can get more
     88 	// configurations by submitting another [ListQueryLoggingConfigs]request. Get the value of NextToken that
     89 	// Amazon Route 53 returned in the previous response and include it in NextToken
     90 	// in the next request.
     91 	//
     92 	// [ListQueryLoggingConfigs]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ListQueryLoggingConfigs.html
     93 	NextToken *string
     94 
     95 	// Metadata pertaining to the operation's result.
     96 	ResultMetadata middleware.Metadata
     97 
     98 	noSmithyDocumentSerde
     99 }
    100 
    101 func (c *Client) addOperationListQueryLoggingConfigsMiddlewares(stack *middleware.Stack, options Options) (err error) {
    102 	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
    103 		return err
    104 	}
    105 	err = stack.Serialize.Add(&awsRestxml_serializeOpListQueryLoggingConfigs{}, middleware.After)
    106 	if err != nil {
    107 		return err
    108 	}
    109 	err = stack.Deserialize.Add(&awsRestxml_deserializeOpListQueryLoggingConfigs{}, middleware.After)
    110 	if err != nil {
    111 		return err
    112 	}
    113 	if err := addProtocolFinalizerMiddlewares(stack, options, "ListQueryLoggingConfigs"); err != nil {
    114 		return fmt.Errorf("add protocol finalizers: %v", err)
    115 	}
    116 
    117 	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
    118 		return err
    119 	}
    120 	if err = addSetLoggerMiddleware(stack, options); err != nil {
    121 		return err
    122 	}
    123 	if err = addClientRequestID(stack); err != nil {
    124 		return err
    125 	}
    126 	if err = addComputeContentLength(stack); err != nil {
    127 		return err
    128 	}
    129 	if err = addResolveEndpointMiddleware(stack, options); err != nil {
    130 		return err
    131 	}
    132 	if err = addComputePayloadSHA256(stack); err != nil {
    133 		return err
    134 	}
    135 	if err = addRetry(stack, options); err != nil {
    136 		return err
    137 	}
    138 	if err = addRawResponseToMetadata(stack); err != nil {
    139 		return err
    140 	}
    141 	if err = addRecordResponseTiming(stack); err != nil {
    142 		return err
    143 	}
    144 	if err = addSpanRetryLoop(stack, options); err != nil {
    145 		return err
    146 	}
    147 	if err = addClientUserAgent(stack, options); err != nil {
    148 		return err
    149 	}
    150 	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
    151 		return err
    152 	}
    153 	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
    154 		return err
    155 	}
    156 	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
    157 		return err
    158 	}
    159 	if err = addTimeOffsetBuild(stack, c); err != nil {
    160 		return err
    161 	}
    162 	if err = addUserAgentRetryMode(stack, options); err != nil {
    163 		return err
    164 	}
    165 	if err = addCredentialSource(stack, options); err != nil {
    166 		return err
    167 	}
    168 	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListQueryLoggingConfigs(options.Region), middleware.Before); err != nil {
    169 		return err
    170 	}
    171 	if err = addRecursionDetection(stack); err != nil {
    172 		return err
    173 	}
    174 	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
    175 		return err
    176 	}
    177 	if err = addResponseErrorMiddleware(stack); err != nil {
    178 		return err
    179 	}
    180 	if err = addSanitizeURLMiddleware(stack); err != nil {
    181 		return err
    182 	}
    183 	if err = addRequestResponseLogging(stack, options); err != nil {
    184 		return err
    185 	}
    186 	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
    187 		return err
    188 	}
    189 	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
    190 		return err
    191 	}
    192 	if err = addInterceptAttempt(stack, options); err != nil {
    193 		return err
    194 	}
    195 	if err = addInterceptExecution(stack, options); err != nil {
    196 		return err
    197 	}
    198 	if err = addInterceptBeforeSerialization(stack, options); err != nil {
    199 		return err
    200 	}
    201 	if err = addInterceptAfterSerialization(stack, options); err != nil {
    202 		return err
    203 	}
    204 	if err = addInterceptBeforeSigning(stack, options); err != nil {
    205 		return err
    206 	}
    207 	if err = addInterceptAfterSigning(stack, options); err != nil {
    208 		return err
    209 	}
    210 	if err = addInterceptTransmit(stack, options); err != nil {
    211 		return err
    212 	}
    213 	if err = addInterceptBeforeDeserialization(stack, options); err != nil {
    214 		return err
    215 	}
    216 	if err = addInterceptAfterDeserialization(stack, options); err != nil {
    217 		return err
    218 	}
    219 	if err = addSpanInitializeStart(stack); err != nil {
    220 		return err
    221 	}
    222 	if err = addSpanInitializeEnd(stack); err != nil {
    223 		return err
    224 	}
    225 	if err = addSpanBuildRequestStart(stack); err != nil {
    226 		return err
    227 	}
    228 	if err = addSpanBuildRequestEnd(stack); err != nil {
    229 		return err
    230 	}
    231 	return nil
    232 }
    233 
    234 // ListQueryLoggingConfigsPaginatorOptions is the paginator options for
    235 // ListQueryLoggingConfigs
    236 type ListQueryLoggingConfigsPaginatorOptions struct {
    237 	// (Optional) The maximum number of query logging configurations that you want
    238 	// Amazon Route 53 to return in response to the current request. If the current
    239 	// Amazon Web Services account has more than MaxResults configurations, use the
    240 	// value of [NextToken]in the response to get the next page of results.
    241 	//
    242 	// If you don't specify a value for MaxResults , Route 53 returns up to 100
    243 	// configurations.
    244 	//
    245 	// [NextToken]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ListQueryLoggingConfigs.html#API_ListQueryLoggingConfigs_RequestSyntax
    246 	Limit int32
    247 
    248 	// Set to true if pagination should stop if the service returns a pagination token
    249 	// that matches the most recent token provided to the service.
    250 	StopOnDuplicateToken bool
    251 }
    252 
    253 // ListQueryLoggingConfigsPaginator is a paginator for ListQueryLoggingConfigs
    254 type ListQueryLoggingConfigsPaginator struct {
    255 	options   ListQueryLoggingConfigsPaginatorOptions
    256 	client    ListQueryLoggingConfigsAPIClient
    257 	params    *ListQueryLoggingConfigsInput
    258 	nextToken *string
    259 	firstPage bool
    260 }
    261 
    262 // NewListQueryLoggingConfigsPaginator returns a new
    263 // ListQueryLoggingConfigsPaginator
    264 func NewListQueryLoggingConfigsPaginator(client ListQueryLoggingConfigsAPIClient, params *ListQueryLoggingConfigsInput, optFns ...func(*ListQueryLoggingConfigsPaginatorOptions)) *ListQueryLoggingConfigsPaginator {
    265 	if params == nil {
    266 		params = &ListQueryLoggingConfigsInput{}
    267 	}
    268 
    269 	options := ListQueryLoggingConfigsPaginatorOptions{}
    270 	if params.MaxResults != nil {
    271 		options.Limit = *params.MaxResults
    272 	}
    273 
    274 	for _, fn := range optFns {
    275 		fn(&options)
    276 	}
    277 
    278 	return &ListQueryLoggingConfigsPaginator{
    279 		options:   options,
    280 		client:    client,
    281 		params:    params,
    282 		firstPage: true,
    283 		nextToken: params.NextToken,
    284 	}
    285 }
    286 
    287 // HasMorePages returns a boolean indicating whether more pages are available
    288 func (p *ListQueryLoggingConfigsPaginator) HasMorePages() bool {
    289 	return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
    290 }
    291 
    292 // NextPage retrieves the next ListQueryLoggingConfigs page.
    293 func (p *ListQueryLoggingConfigsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListQueryLoggingConfigsOutput, error) {
    294 	if !p.HasMorePages() {
    295 		return nil, fmt.Errorf("no more pages available")
    296 	}
    297 
    298 	params := *p.params
    299 	params.NextToken = p.nextToken
    300 
    301 	var limit *int32
    302 	if p.options.Limit > 0 {
    303 		limit = &p.options.Limit
    304 	}
    305 	params.MaxResults = limit
    306 
    307 	optFns = append([]func(*Options){
    308 		addIsPaginatorUserAgent,
    309 	}, optFns...)
    310 	result, err := p.client.ListQueryLoggingConfigs(ctx, &params, optFns...)
    311 	if err != nil {
    312 		return nil, err
    313 	}
    314 	p.firstPage = false
    315 
    316 	prevToken := p.nextToken
    317 	p.nextToken = result.NextToken
    318 
    319 	if p.options.StopOnDuplicateToken &&
    320 		prevToken != nil &&
    321 		p.nextToken != nil &&
    322 		*prevToken == *p.nextToken {
    323 		p.nextToken = nil
    324 	}
    325 
    326 	return result, nil
    327 }
    328 
    329 // ListQueryLoggingConfigsAPIClient is a client that implements the
    330 // ListQueryLoggingConfigs operation.
    331 type ListQueryLoggingConfigsAPIClient interface {
    332 	ListQueryLoggingConfigs(context.Context, *ListQueryLoggingConfigsInput, ...func(*Options)) (*ListQueryLoggingConfigsOutput, error)
    333 }
    334 
    335 var _ ListQueryLoggingConfigsAPIClient = (*Client)(nil)
    336 
    337 func newServiceMetadataMiddleware_opListQueryLoggingConfigs(region string) *awsmiddleware.RegisterServiceMetadata {
    338 	return &awsmiddleware.RegisterServiceMetadata{
    339 		Region:        region,
    340 		ServiceID:     ServiceID,
    341 		OperationName: "ListQueryLoggingConfigs",
    342 	}
    343 }