1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package rds 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/rds/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Describes the available option groups. 16func (c *Client) DescribeOptionGroups(ctx context.Context, params *DescribeOptionGroupsInput, optFns ...func(*Options)) (*DescribeOptionGroupsOutput, error) { 17 if params == nil { 18 params = &DescribeOptionGroupsInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "DescribeOptionGroups", params, optFns, addOperationDescribeOptionGroupsMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*DescribeOptionGroupsOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31// 32type DescribeOptionGroupsInput struct { 33 34 // Filters the list of option groups to only include groups associated with a 35 // specific database engine. Valid Values: 36 // 37 // * mariadb 38 // 39 // * mysql 40 // 41 // * oracle-ee 42 // 43 // * 44 // oracle-se2 45 // 46 // * oracle-se1 47 // 48 // * oracle-se 49 // 50 // * postgres 51 // 52 // * sqlserver-ee 53 // 54 // * 55 // sqlserver-se 56 // 57 // * sqlserver-ex 58 // 59 // * sqlserver-web 60 EngineName *string 61 62 // This parameter isn't currently supported. 63 Filters []types.Filter 64 65 // Filters the list of option groups to only include groups associated with a 66 // specific database engine version. If specified, then EngineName must also be 67 // specified. 68 MajorEngineVersion *string 69 70 // An optional pagination token provided by a previous DescribeOptionGroups 71 // request. If this parameter is specified, the response includes only records 72 // beyond the marker, up to the value specified by MaxRecords. 73 Marker *string 74 75 // The maximum number of records to include in the response. If more records exist 76 // than the specified MaxRecords value, a pagination token called a marker is 77 // included in the response so that you can retrieve the remaining results. 78 // Default: 100 Constraints: Minimum 20, maximum 100. 79 MaxRecords *int32 80 81 // The name of the option group to describe. Can't be supplied together with 82 // EngineName or MajorEngineVersion. 83 OptionGroupName *string 84} 85 86// List of option groups. 87type DescribeOptionGroupsOutput struct { 88 89 // An optional pagination token provided by a previous request. If this parameter 90 // is specified, the response includes only records beyond the marker, up to the 91 // value specified by MaxRecords. 92 Marker *string 93 94 // List of option groups. 95 OptionGroupsList []types.OptionGroup 96 97 // Metadata pertaining to the operation's result. 98 ResultMetadata middleware.Metadata 99} 100 101func addOperationDescribeOptionGroupsMiddlewares(stack *middleware.Stack, options Options) (err error) { 102 err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeOptionGroups{}, middleware.After) 103 if err != nil { 104 return err 105 } 106 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeOptionGroups{}, middleware.After) 107 if err != nil { 108 return err 109 } 110 if err = addSetLoggerMiddleware(stack, options); err != nil { 111 return err 112 } 113 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 114 return err 115 } 116 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 117 return err 118 } 119 if err = addResolveEndpointMiddleware(stack, options); err != nil { 120 return err 121 } 122 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 123 return err 124 } 125 if err = addRetryMiddlewares(stack, options); err != nil { 126 return err 127 } 128 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 129 return err 130 } 131 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 132 return err 133 } 134 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 135 return err 136 } 137 if err = addClientUserAgent(stack); err != nil { 138 return err 139 } 140 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 141 return err 142 } 143 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 144 return err 145 } 146 if err = addOpDescribeOptionGroupsValidationMiddleware(stack); err != nil { 147 return err 148 } 149 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeOptionGroups(options.Region), middleware.Before); err != nil { 150 return err 151 } 152 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 153 return err 154 } 155 if err = addResponseErrorMiddleware(stack); err != nil { 156 return err 157 } 158 if err = addRequestResponseLogging(stack, options); err != nil { 159 return err 160 } 161 return nil 162} 163 164// DescribeOptionGroupsAPIClient is a client that implements the 165// DescribeOptionGroups operation. 166type DescribeOptionGroupsAPIClient interface { 167 DescribeOptionGroups(context.Context, *DescribeOptionGroupsInput, ...func(*Options)) (*DescribeOptionGroupsOutput, error) 168} 169 170var _ DescribeOptionGroupsAPIClient = (*Client)(nil) 171 172// DescribeOptionGroupsPaginatorOptions is the paginator options for 173// DescribeOptionGroups 174type DescribeOptionGroupsPaginatorOptions struct { 175 // The maximum number of records to include in the response. If more records exist 176 // than the specified MaxRecords value, a pagination token called a marker is 177 // included in the response so that you can retrieve the remaining results. 178 // Default: 100 Constraints: Minimum 20, maximum 100. 179 Limit int32 180 181 // Set to true if pagination should stop if the service returns a pagination token 182 // that matches the most recent token provided to the service. 183 StopOnDuplicateToken bool 184} 185 186// DescribeOptionGroupsPaginator is a paginator for DescribeOptionGroups 187type DescribeOptionGroupsPaginator struct { 188 options DescribeOptionGroupsPaginatorOptions 189 client DescribeOptionGroupsAPIClient 190 params *DescribeOptionGroupsInput 191 nextToken *string 192 firstPage bool 193} 194 195// NewDescribeOptionGroupsPaginator returns a new DescribeOptionGroupsPaginator 196func NewDescribeOptionGroupsPaginator(client DescribeOptionGroupsAPIClient, params *DescribeOptionGroupsInput, optFns ...func(*DescribeOptionGroupsPaginatorOptions)) *DescribeOptionGroupsPaginator { 197 if params == nil { 198 params = &DescribeOptionGroupsInput{} 199 } 200 201 options := DescribeOptionGroupsPaginatorOptions{} 202 if params.MaxRecords != nil { 203 options.Limit = *params.MaxRecords 204 } 205 206 for _, fn := range optFns { 207 fn(&options) 208 } 209 210 return &DescribeOptionGroupsPaginator{ 211 options: options, 212 client: client, 213 params: params, 214 firstPage: true, 215 } 216} 217 218// HasMorePages returns a boolean indicating whether more pages are available 219func (p *DescribeOptionGroupsPaginator) HasMorePages() bool { 220 return p.firstPage || p.nextToken != nil 221} 222 223// NextPage retrieves the next DescribeOptionGroups page. 224func (p *DescribeOptionGroupsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeOptionGroupsOutput, error) { 225 if !p.HasMorePages() { 226 return nil, fmt.Errorf("no more pages available") 227 } 228 229 params := *p.params 230 params.Marker = p.nextToken 231 232 var limit *int32 233 if p.options.Limit > 0 { 234 limit = &p.options.Limit 235 } 236 params.MaxRecords = limit 237 238 result, err := p.client.DescribeOptionGroups(ctx, ¶ms, optFns...) 239 if err != nil { 240 return nil, err 241 } 242 p.firstPage = false 243 244 prevToken := p.nextToken 245 p.nextToken = result.Marker 246 247 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 248 p.nextToken = nil 249 } 250 251 return result, nil 252} 253 254func newServiceMetadataMiddleware_opDescribeOptionGroups(region string) *awsmiddleware.RegisterServiceMetadata { 255 return &awsmiddleware.RegisterServiceMetadata{ 256 Region: region, 257 ServiceID: ServiceID, 258 SigningName: "rds", 259 OperationName: "DescribeOptionGroups", 260 } 261} 262