1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package servicediscovery 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/servicediscovery/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Lists operations that match the criteria that you specify. 16func (c *Client) ListOperations(ctx context.Context, params *ListOperationsInput, optFns ...func(*Options)) (*ListOperationsOutput, error) { 17 if params == nil { 18 params = &ListOperationsInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "ListOperations", params, optFns, addOperationListOperationsMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*ListOperationsOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type ListOperationsInput struct { 32 33 // A complex type that contains specifications for the operations that you want to 34 // list, for example, operations that you started between a specified start date 35 // and end date. If you specify more than one filter, an operation must match all 36 // filters to be returned by ListOperations. 37 Filters []types.OperationFilter 38 39 // The maximum number of items that you want AWS Cloud Map to return in the 40 // response to a ListOperations request. If you don't specify a value for 41 // MaxResults, AWS Cloud Map returns up to 100 operations. 42 MaxResults *int32 43 44 // For the first ListOperations request, omit this value. If the response contains 45 // NextToken, submit another ListOperations request to get the next group of 46 // results. Specify the value of NextToken from the previous response in the next 47 // request. AWS Cloud Map gets MaxResults operations and then filters them based on 48 // the specified criteria. It's possible that no operations in the first MaxResults 49 // operations matched the specified criteria but that subsequent groups of 50 // MaxResults operations do contain operations that match the criteria. 51 NextToken *string 52} 53 54type ListOperationsOutput struct { 55 56 // If the response contains NextToken, submit another ListOperations request to get 57 // the next group of results. Specify the value of NextToken from the previous 58 // response in the next request. AWS Cloud Map gets MaxResults operations and then 59 // filters them based on the specified criteria. It's possible that no operations 60 // in the first MaxResults operations matched the specified criteria but that 61 // subsequent groups of MaxResults operations do contain operations that match the 62 // criteria. 63 NextToken *string 64 65 // Summary information about the operations that match the specified criteria. 66 Operations []types.OperationSummary 67 68 // Metadata pertaining to the operation's result. 69 ResultMetadata middleware.Metadata 70} 71 72func addOperationListOperationsMiddlewares(stack *middleware.Stack, options Options) (err error) { 73 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListOperations{}, middleware.After) 74 if err != nil { 75 return err 76 } 77 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListOperations{}, middleware.After) 78 if err != nil { 79 return err 80 } 81 if err = addSetLoggerMiddleware(stack, options); err != nil { 82 return err 83 } 84 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 85 return err 86 } 87 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 88 return err 89 } 90 if err = addResolveEndpointMiddleware(stack, options); err != nil { 91 return err 92 } 93 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 94 return err 95 } 96 if err = addRetryMiddlewares(stack, options); err != nil { 97 return err 98 } 99 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 100 return err 101 } 102 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 103 return err 104 } 105 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 106 return err 107 } 108 if err = addClientUserAgent(stack); err != nil { 109 return err 110 } 111 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 112 return err 113 } 114 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 115 return err 116 } 117 if err = addOpListOperationsValidationMiddleware(stack); err != nil { 118 return err 119 } 120 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListOperations(options.Region), middleware.Before); err != nil { 121 return err 122 } 123 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 124 return err 125 } 126 if err = addResponseErrorMiddleware(stack); err != nil { 127 return err 128 } 129 if err = addRequestResponseLogging(stack, options); err != nil { 130 return err 131 } 132 return nil 133} 134 135// ListOperationsAPIClient is a client that implements the ListOperations 136// operation. 137type ListOperationsAPIClient interface { 138 ListOperations(context.Context, *ListOperationsInput, ...func(*Options)) (*ListOperationsOutput, error) 139} 140 141var _ ListOperationsAPIClient = (*Client)(nil) 142 143// ListOperationsPaginatorOptions is the paginator options for ListOperations 144type ListOperationsPaginatorOptions struct { 145 // The maximum number of items that you want AWS Cloud Map to return in the 146 // response to a ListOperations request. If you don't specify a value for 147 // MaxResults, AWS Cloud Map returns up to 100 operations. 148 Limit int32 149 150 // Set to true if pagination should stop if the service returns a pagination token 151 // that matches the most recent token provided to the service. 152 StopOnDuplicateToken bool 153} 154 155// ListOperationsPaginator is a paginator for ListOperations 156type ListOperationsPaginator struct { 157 options ListOperationsPaginatorOptions 158 client ListOperationsAPIClient 159 params *ListOperationsInput 160 nextToken *string 161 firstPage bool 162} 163 164// NewListOperationsPaginator returns a new ListOperationsPaginator 165func NewListOperationsPaginator(client ListOperationsAPIClient, params *ListOperationsInput, optFns ...func(*ListOperationsPaginatorOptions)) *ListOperationsPaginator { 166 if params == nil { 167 params = &ListOperationsInput{} 168 } 169 170 options := ListOperationsPaginatorOptions{} 171 if params.MaxResults != nil { 172 options.Limit = *params.MaxResults 173 } 174 175 for _, fn := range optFns { 176 fn(&options) 177 } 178 179 return &ListOperationsPaginator{ 180 options: options, 181 client: client, 182 params: params, 183 firstPage: true, 184 } 185} 186 187// HasMorePages returns a boolean indicating whether more pages are available 188func (p *ListOperationsPaginator) HasMorePages() bool { 189 return p.firstPage || p.nextToken != nil 190} 191 192// NextPage retrieves the next ListOperations page. 193func (p *ListOperationsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListOperationsOutput, error) { 194 if !p.HasMorePages() { 195 return nil, fmt.Errorf("no more pages available") 196 } 197 198 params := *p.params 199 params.NextToken = p.nextToken 200 201 var limit *int32 202 if p.options.Limit > 0 { 203 limit = &p.options.Limit 204 } 205 params.MaxResults = limit 206 207 result, err := p.client.ListOperations(ctx, ¶ms, optFns...) 208 if err != nil { 209 return nil, err 210 } 211 p.firstPage = false 212 213 prevToken := p.nextToken 214 p.nextToken = result.NextToken 215 216 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 217 p.nextToken = nil 218 } 219 220 return result, nil 221} 222 223func newServiceMetadataMiddleware_opListOperations(region string) *awsmiddleware.RegisterServiceMetadata { 224 return &awsmiddleware.RegisterServiceMetadata{ 225 Region: region, 226 ServiceID: ServiceID, 227 SigningName: "servicediscovery", 228 OperationName: "ListOperations", 229 } 230} 231