1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ec2 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/ec2/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Describes one or more of your DHCP options sets. For more information, see DHCP 16// Options Sets 17// (https://docs.aws.amazon.com/vpc/latest/userguide/VPC_DHCP_Options.html) in the 18// Amazon Virtual Private Cloud User Guide. 19func (c *Client) DescribeDhcpOptions(ctx context.Context, params *DescribeDhcpOptionsInput, optFns ...func(*Options)) (*DescribeDhcpOptionsOutput, error) { 20 if params == nil { 21 params = &DescribeDhcpOptionsInput{} 22 } 23 24 result, metadata, err := c.invokeOperation(ctx, "DescribeDhcpOptions", params, optFns, addOperationDescribeDhcpOptionsMiddlewares) 25 if err != nil { 26 return nil, err 27 } 28 29 out := result.(*DescribeDhcpOptionsOutput) 30 out.ResultMetadata = metadata 31 return out, nil 32} 33 34type DescribeDhcpOptionsInput struct { 35 36 // The IDs of one or more DHCP options sets. Default: Describes all your DHCP 37 // options sets. 38 DhcpOptionsIds []string 39 40 // Checks whether you have the required permissions for the action, without 41 // actually making the request, and provides an error response. If you have the 42 // required permissions, the error response is DryRunOperation. Otherwise, it is 43 // UnauthorizedOperation. 44 DryRun bool 45 46 // One or more filters. 47 // 48 // * dhcp-options-id - The ID of a DHCP options set. 49 // 50 // * key - 51 // The key for one of the options (for example, domain-name). 52 // 53 // * value - The value 54 // for one of the options. 55 // 56 // * owner-id - The ID of the AWS account that owns the 57 // DHCP options set. 58 // 59 // * tag: - The key/value combination of a tag assigned to the 60 // resource. Use the tag key in the filter name and the tag value as the filter 61 // value. For example, to find all resources that have a tag with the key Owner and 62 // the value TeamA, specify tag:Owner for the filter name and TeamA for the filter 63 // value. 64 // 65 // * tag-key - The key of a tag assigned to the resource. Use this filter 66 // to find all resources assigned a tag with a specific key, regardless of the tag 67 // value. 68 Filters []types.Filter 69 70 // The maximum number of results to return with a single call. To retrieve the 71 // remaining results, make another call with the returned nextToken value. 72 MaxResults int32 73 74 // The token for the next page of results. 75 NextToken *string 76} 77 78type DescribeDhcpOptionsOutput struct { 79 80 // Information about one or more DHCP options sets. 81 DhcpOptions []types.DhcpOptions 82 83 // The token to use to retrieve the next page of results. This value is null when 84 // there are no more results to return. 85 NextToken *string 86 87 // Metadata pertaining to the operation's result. 88 ResultMetadata middleware.Metadata 89} 90 91func addOperationDescribeDhcpOptionsMiddlewares(stack *middleware.Stack, options Options) (err error) { 92 err = stack.Serialize.Add(&awsEc2query_serializeOpDescribeDhcpOptions{}, middleware.After) 93 if err != nil { 94 return err 95 } 96 err = stack.Deserialize.Add(&awsEc2query_deserializeOpDescribeDhcpOptions{}, middleware.After) 97 if err != nil { 98 return err 99 } 100 if err = addSetLoggerMiddleware(stack, options); err != nil { 101 return err 102 } 103 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 104 return err 105 } 106 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 107 return err 108 } 109 if err = addResolveEndpointMiddleware(stack, options); err != nil { 110 return err 111 } 112 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 113 return err 114 } 115 if err = addRetryMiddlewares(stack, options); err != nil { 116 return err 117 } 118 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 119 return err 120 } 121 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 122 return err 123 } 124 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 125 return err 126 } 127 if err = addClientUserAgent(stack); err != nil { 128 return err 129 } 130 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 131 return err 132 } 133 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 134 return err 135 } 136 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeDhcpOptions(options.Region), middleware.Before); err != nil { 137 return err 138 } 139 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 140 return err 141 } 142 if err = addResponseErrorMiddleware(stack); err != nil { 143 return err 144 } 145 if err = addRequestResponseLogging(stack, options); err != nil { 146 return err 147 } 148 return nil 149} 150 151// DescribeDhcpOptionsAPIClient is a client that implements the DescribeDhcpOptions 152// operation. 153type DescribeDhcpOptionsAPIClient interface { 154 DescribeDhcpOptions(context.Context, *DescribeDhcpOptionsInput, ...func(*Options)) (*DescribeDhcpOptionsOutput, error) 155} 156 157var _ DescribeDhcpOptionsAPIClient = (*Client)(nil) 158 159// DescribeDhcpOptionsPaginatorOptions is the paginator options for 160// DescribeDhcpOptions 161type DescribeDhcpOptionsPaginatorOptions struct { 162 // The maximum number of results to return with a single call. To retrieve the 163 // remaining results, make another call with the returned nextToken value. 164 Limit int32 165 166 // Set to true if pagination should stop if the service returns a pagination token 167 // that matches the most recent token provided to the service. 168 StopOnDuplicateToken bool 169} 170 171// DescribeDhcpOptionsPaginator is a paginator for DescribeDhcpOptions 172type DescribeDhcpOptionsPaginator struct { 173 options DescribeDhcpOptionsPaginatorOptions 174 client DescribeDhcpOptionsAPIClient 175 params *DescribeDhcpOptionsInput 176 nextToken *string 177 firstPage bool 178} 179 180// NewDescribeDhcpOptionsPaginator returns a new DescribeDhcpOptionsPaginator 181func NewDescribeDhcpOptionsPaginator(client DescribeDhcpOptionsAPIClient, params *DescribeDhcpOptionsInput, optFns ...func(*DescribeDhcpOptionsPaginatorOptions)) *DescribeDhcpOptionsPaginator { 182 options := DescribeDhcpOptionsPaginatorOptions{} 183 if params.MaxResults != 0 { 184 options.Limit = params.MaxResults 185 } 186 187 for _, fn := range optFns { 188 fn(&options) 189 } 190 191 if params == nil { 192 params = &DescribeDhcpOptionsInput{} 193 } 194 195 return &DescribeDhcpOptionsPaginator{ 196 options: options, 197 client: client, 198 params: params, 199 firstPage: true, 200 } 201} 202 203// HasMorePages returns a boolean indicating whether more pages are available 204func (p *DescribeDhcpOptionsPaginator) HasMorePages() bool { 205 return p.firstPage || p.nextToken != nil 206} 207 208// NextPage retrieves the next DescribeDhcpOptions page. 209func (p *DescribeDhcpOptionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeDhcpOptionsOutput, error) { 210 if !p.HasMorePages() { 211 return nil, fmt.Errorf("no more pages available") 212 } 213 214 params := *p.params 215 params.NextToken = p.nextToken 216 217 params.MaxResults = p.options.Limit 218 219 result, err := p.client.DescribeDhcpOptions(ctx, ¶ms, optFns...) 220 if err != nil { 221 return nil, err 222 } 223 p.firstPage = false 224 225 prevToken := p.nextToken 226 p.nextToken = result.NextToken 227 228 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 229 p.nextToken = nil 230 } 231 232 return result, nil 233} 234 235func newServiceMetadataMiddleware_opDescribeDhcpOptions(region string) *awsmiddleware.RegisterServiceMetadata { 236 return &awsmiddleware.RegisterServiceMetadata{ 237 Region: region, 238 ServiceID: ServiceID, 239 SigningName: "ec2", 240 OperationName: "DescribeDhcpOptions", 241 } 242} 243