1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ssm 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/ssm/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Retrieves the history of all changes to a parameter. 16func (c *Client) GetParameterHistory(ctx context.Context, params *GetParameterHistoryInput, optFns ...func(*Options)) (*GetParameterHistoryOutput, error) { 17 if params == nil { 18 params = &GetParameterHistoryInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "GetParameterHistory", params, optFns, addOperationGetParameterHistoryMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*GetParameterHistoryOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type GetParameterHistoryInput struct { 32 33 // The name of the parameter for which you want to review history. 34 // 35 // This member is required. 36 Name *string 37 38 // The maximum number of items to return for this call. The call also returns a 39 // token that you can specify in a subsequent call to get the next set of results. 40 MaxResults int32 41 42 // The token for the next set of items to return. (You received this token from a 43 // previous call.) 44 NextToken *string 45 46 // Return decrypted values for secure string parameters. This flag is ignored for 47 // String and StringList parameter types. 48 WithDecryption bool 49} 50 51type GetParameterHistoryOutput struct { 52 53 // The token to use when requesting the next set of items. If there are no 54 // additional items to return, the string is empty. 55 NextToken *string 56 57 // A list of parameters returned by the request. 58 Parameters []types.ParameterHistory 59 60 // Metadata pertaining to the operation's result. 61 ResultMetadata middleware.Metadata 62} 63 64func addOperationGetParameterHistoryMiddlewares(stack *middleware.Stack, options Options) (err error) { 65 err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetParameterHistory{}, middleware.After) 66 if err != nil { 67 return err 68 } 69 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetParameterHistory{}, middleware.After) 70 if err != nil { 71 return err 72 } 73 if err = addSetLoggerMiddleware(stack, options); err != nil { 74 return err 75 } 76 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 77 return err 78 } 79 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 80 return err 81 } 82 if err = addResolveEndpointMiddleware(stack, options); err != nil { 83 return err 84 } 85 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 86 return err 87 } 88 if err = addRetryMiddlewares(stack, options); err != nil { 89 return err 90 } 91 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 92 return err 93 } 94 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 95 return err 96 } 97 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 98 return err 99 } 100 if err = addClientUserAgent(stack); err != nil { 101 return err 102 } 103 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 104 return err 105 } 106 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 107 return err 108 } 109 if err = addOpGetParameterHistoryValidationMiddleware(stack); err != nil { 110 return err 111 } 112 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetParameterHistory(options.Region), middleware.Before); err != nil { 113 return err 114 } 115 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 116 return err 117 } 118 if err = addResponseErrorMiddleware(stack); err != nil { 119 return err 120 } 121 if err = addRequestResponseLogging(stack, options); err != nil { 122 return err 123 } 124 return nil 125} 126 127// GetParameterHistoryAPIClient is a client that implements the GetParameterHistory 128// operation. 129type GetParameterHistoryAPIClient interface { 130 GetParameterHistory(context.Context, *GetParameterHistoryInput, ...func(*Options)) (*GetParameterHistoryOutput, error) 131} 132 133var _ GetParameterHistoryAPIClient = (*Client)(nil) 134 135// GetParameterHistoryPaginatorOptions is the paginator options for 136// GetParameterHistory 137type GetParameterHistoryPaginatorOptions struct { 138 // The maximum number of items to return for this call. The call also returns a 139 // token that you can specify in a subsequent call to get the next set of results. 140 Limit int32 141 142 // Set to true if pagination should stop if the service returns a pagination token 143 // that matches the most recent token provided to the service. 144 StopOnDuplicateToken bool 145} 146 147// GetParameterHistoryPaginator is a paginator for GetParameterHistory 148type GetParameterHistoryPaginator struct { 149 options GetParameterHistoryPaginatorOptions 150 client GetParameterHistoryAPIClient 151 params *GetParameterHistoryInput 152 nextToken *string 153 firstPage bool 154} 155 156// NewGetParameterHistoryPaginator returns a new GetParameterHistoryPaginator 157func NewGetParameterHistoryPaginator(client GetParameterHistoryAPIClient, params *GetParameterHistoryInput, optFns ...func(*GetParameterHistoryPaginatorOptions)) *GetParameterHistoryPaginator { 158 options := GetParameterHistoryPaginatorOptions{} 159 if params.MaxResults != 0 { 160 options.Limit = params.MaxResults 161 } 162 163 for _, fn := range optFns { 164 fn(&options) 165 } 166 167 if params == nil { 168 params = &GetParameterHistoryInput{} 169 } 170 171 return &GetParameterHistoryPaginator{ 172 options: options, 173 client: client, 174 params: params, 175 firstPage: true, 176 } 177} 178 179// HasMorePages returns a boolean indicating whether more pages are available 180func (p *GetParameterHistoryPaginator) HasMorePages() bool { 181 return p.firstPage || p.nextToken != nil 182} 183 184// NextPage retrieves the next GetParameterHistory page. 185func (p *GetParameterHistoryPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetParameterHistoryOutput, error) { 186 if !p.HasMorePages() { 187 return nil, fmt.Errorf("no more pages available") 188 } 189 190 params := *p.params 191 params.NextToken = p.nextToken 192 193 params.MaxResults = p.options.Limit 194 195 result, err := p.client.GetParameterHistory(ctx, ¶ms, optFns...) 196 if err != nil { 197 return nil, err 198 } 199 p.firstPage = false 200 201 prevToken := p.nextToken 202 p.nextToken = result.NextToken 203 204 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 205 p.nextToken = nil 206 } 207 208 return result, nil 209} 210 211func newServiceMetadataMiddleware_opGetParameterHistory(region string) *awsmiddleware.RegisterServiceMetadata { 212 return &awsmiddleware.RegisterServiceMetadata{ 213 Region: region, 214 ServiceID: ServiceID, 215 SigningName: "ssm", 216 OperationName: "GetParameterHistory", 217 } 218} 219