1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package elasticsearchservice 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/elasticsearchservice/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Retrieves the complete history of the last 10 upgrades that were performed on 16// the domain. 17func (c *Client) GetUpgradeHistory(ctx context.Context, params *GetUpgradeHistoryInput, optFns ...func(*Options)) (*GetUpgradeHistoryOutput, error) { 18 if params == nil { 19 params = &GetUpgradeHistoryInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "GetUpgradeHistory", params, optFns, addOperationGetUpgradeHistoryMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*GetUpgradeHistoryOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32// Container for request parameters to GetUpgradeHistory operation. 33type GetUpgradeHistoryInput struct { 34 35 // The name of an Elasticsearch domain. Domain names are unique across the domains 36 // owned by an account within an AWS region. Domain names start with a letter or 37 // number and can contain the following characters: a-z (lowercase), 0-9, and - 38 // (hyphen). 39 // 40 // This member is required. 41 DomainName *string 42 43 // Set this value to limit the number of results returned. 44 MaxResults int32 45 46 // Paginated APIs accepts NextToken input to returns next page results and provides 47 // a NextToken output in the response which can be used by the client to retrieve 48 // more results. 49 NextToken *string 50} 51 52// Container for response returned by GetUpgradeHistory operation. 53type GetUpgradeHistoryOutput struct { 54 55 // Pagination token that needs to be supplied to the next call to get the next page 56 // of results 57 NextToken *string 58 59 // A list of UpgradeHistory objects corresponding to each Upgrade or Upgrade 60 // Eligibility Check performed on a domain returned as part of 61 // GetUpgradeHistoryResponse object. 62 UpgradeHistories []types.UpgradeHistory 63 64 // Metadata pertaining to the operation's result. 65 ResultMetadata middleware.Metadata 66} 67 68func addOperationGetUpgradeHistoryMiddlewares(stack *middleware.Stack, options Options) (err error) { 69 err = stack.Serialize.Add(&awsRestjson1_serializeOpGetUpgradeHistory{}, middleware.After) 70 if err != nil { 71 return err 72 } 73 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpGetUpgradeHistory{}, middleware.After) 74 if err != nil { 75 return err 76 } 77 if err = addSetLoggerMiddleware(stack, options); err != nil { 78 return err 79 } 80 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 81 return err 82 } 83 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 84 return err 85 } 86 if err = addResolveEndpointMiddleware(stack, options); err != nil { 87 return err 88 } 89 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 90 return err 91 } 92 if err = addRetryMiddlewares(stack, options); err != nil { 93 return err 94 } 95 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 96 return err 97 } 98 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 99 return err 100 } 101 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 102 return err 103 } 104 if err = addClientUserAgent(stack); err != nil { 105 return err 106 } 107 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 108 return err 109 } 110 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 111 return err 112 } 113 if err = addOpGetUpgradeHistoryValidationMiddleware(stack); err != nil { 114 return err 115 } 116 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetUpgradeHistory(options.Region), middleware.Before); err != nil { 117 return err 118 } 119 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 120 return err 121 } 122 if err = addResponseErrorMiddleware(stack); err != nil { 123 return err 124 } 125 if err = addRequestResponseLogging(stack, options); err != nil { 126 return err 127 } 128 return nil 129} 130 131// GetUpgradeHistoryAPIClient is a client that implements the GetUpgradeHistory 132// operation. 133type GetUpgradeHistoryAPIClient interface { 134 GetUpgradeHistory(context.Context, *GetUpgradeHistoryInput, ...func(*Options)) (*GetUpgradeHistoryOutput, error) 135} 136 137var _ GetUpgradeHistoryAPIClient = (*Client)(nil) 138 139// GetUpgradeHistoryPaginatorOptions is the paginator options for GetUpgradeHistory 140type GetUpgradeHistoryPaginatorOptions struct { 141 // Set this value to limit the number of results returned. 142 Limit int32 143 144 // Set to true if pagination should stop if the service returns a pagination token 145 // that matches the most recent token provided to the service. 146 StopOnDuplicateToken bool 147} 148 149// GetUpgradeHistoryPaginator is a paginator for GetUpgradeHistory 150type GetUpgradeHistoryPaginator struct { 151 options GetUpgradeHistoryPaginatorOptions 152 client GetUpgradeHistoryAPIClient 153 params *GetUpgradeHistoryInput 154 nextToken *string 155 firstPage bool 156} 157 158// NewGetUpgradeHistoryPaginator returns a new GetUpgradeHistoryPaginator 159func NewGetUpgradeHistoryPaginator(client GetUpgradeHistoryAPIClient, params *GetUpgradeHistoryInput, optFns ...func(*GetUpgradeHistoryPaginatorOptions)) *GetUpgradeHistoryPaginator { 160 if params == nil { 161 params = &GetUpgradeHistoryInput{} 162 } 163 164 options := GetUpgradeHistoryPaginatorOptions{} 165 if params.MaxResults != 0 { 166 options.Limit = params.MaxResults 167 } 168 169 for _, fn := range optFns { 170 fn(&options) 171 } 172 173 return &GetUpgradeHistoryPaginator{ 174 options: options, 175 client: client, 176 params: params, 177 firstPage: true, 178 } 179} 180 181// HasMorePages returns a boolean indicating whether more pages are available 182func (p *GetUpgradeHistoryPaginator) HasMorePages() bool { 183 return p.firstPage || p.nextToken != nil 184} 185 186// NextPage retrieves the next GetUpgradeHistory page. 187func (p *GetUpgradeHistoryPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetUpgradeHistoryOutput, error) { 188 if !p.HasMorePages() { 189 return nil, fmt.Errorf("no more pages available") 190 } 191 192 params := *p.params 193 params.NextToken = p.nextToken 194 195 params.MaxResults = p.options.Limit 196 197 result, err := p.client.GetUpgradeHistory(ctx, ¶ms, optFns...) 198 if err != nil { 199 return nil, err 200 } 201 p.firstPage = false 202 203 prevToken := p.nextToken 204 p.nextToken = result.NextToken 205 206 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 207 p.nextToken = nil 208 } 209 210 return result, nil 211} 212 213func newServiceMetadataMiddleware_opGetUpgradeHistory(region string) *awsmiddleware.RegisterServiceMetadata { 214 return &awsmiddleware.RegisterServiceMetadata{ 215 Region: region, 216 ServiceID: ServiceID, 217 SigningName: "es", 218 OperationName: "GetUpgradeHistory", 219 } 220} 221