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/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Downloads all or a portion of the specified log file, up to 1 MB in size. 15func (c *Client) DownloadDBLogFilePortion(ctx context.Context, params *DownloadDBLogFilePortionInput, optFns ...func(*Options)) (*DownloadDBLogFilePortionOutput, error) { 16 if params == nil { 17 params = &DownloadDBLogFilePortionInput{} 18 } 19 20 result, metadata, err := c.invokeOperation(ctx, "DownloadDBLogFilePortion", params, optFns, addOperationDownloadDBLogFilePortionMiddlewares) 21 if err != nil { 22 return nil, err 23 } 24 25 out := result.(*DownloadDBLogFilePortionOutput) 26 out.ResultMetadata = metadata 27 return out, nil 28} 29 30// 31type DownloadDBLogFilePortionInput struct { 32 33 // The customer-assigned name of the DB instance that contains the log files you 34 // want to list. Constraints: 35 // 36 // * Must match the identifier of an existing 37 // DBInstance. 38 // 39 // This member is required. 40 DBInstanceIdentifier *string 41 42 // The name of the log file to be downloaded. 43 // 44 // This member is required. 45 LogFileName *string 46 47 // The pagination token provided in the previous request or "0". If the Marker 48 // parameter is specified the response includes only records beyond the marker 49 // until the end of the file or up to NumberOfLines. 50 Marker *string 51 52 // The number of lines to download. If the number of lines specified results in a 53 // file over 1 MB in size, the file is truncated at 1 MB in size. If the 54 // NumberOfLines parameter is specified, then the block of lines returned can be 55 // from the beginning or the end of the log file, depending on the value of the 56 // Marker parameter. 57 // 58 // * If neither Marker or NumberOfLines are specified, the 59 // entire log file is returned up to a maximum of 10000 lines, starting with the 60 // most recent log entries first. 61 // 62 // * If NumberOfLines is specified and Marker isn't 63 // specified, then the most recent lines from the end of the log file are 64 // returned. 65 // 66 // * If Marker is specified as "0", then the specified number of lines 67 // from the beginning of the log file are returned. 68 // 69 // * You can download the log 70 // file in blocks of lines by specifying the size of the block using the 71 // NumberOfLines parameter, and by specifying a value of "0" for the Marker 72 // parameter in your first request. Include the Marker value returned in the 73 // response as the Marker value for the next request, continuing until the 74 // AdditionalDataPending response element returns false. 75 NumberOfLines int32 76} 77 78// This data type is used as a response element to DownloadDBLogFilePortion. 79type DownloadDBLogFilePortionOutput struct { 80 81 // Boolean value that if true, indicates there is more data to be downloaded. 82 AdditionalDataPending bool 83 84 // Entries from the specified log file. 85 LogFileData *string 86 87 // A pagination token that can be used in a later DownloadDBLogFilePortion request. 88 Marker *string 89 90 // Metadata pertaining to the operation's result. 91 ResultMetadata middleware.Metadata 92} 93 94func addOperationDownloadDBLogFilePortionMiddlewares(stack *middleware.Stack, options Options) (err error) { 95 err = stack.Serialize.Add(&awsAwsquery_serializeOpDownloadDBLogFilePortion{}, middleware.After) 96 if err != nil { 97 return err 98 } 99 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDownloadDBLogFilePortion{}, middleware.After) 100 if err != nil { 101 return err 102 } 103 if err = addSetLoggerMiddleware(stack, options); err != nil { 104 return err 105 } 106 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 107 return err 108 } 109 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 110 return err 111 } 112 if err = addResolveEndpointMiddleware(stack, options); err != nil { 113 return err 114 } 115 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 116 return err 117 } 118 if err = addRetryMiddlewares(stack, options); err != nil { 119 return err 120 } 121 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 122 return err 123 } 124 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 125 return err 126 } 127 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 128 return err 129 } 130 if err = addClientUserAgent(stack); err != nil { 131 return err 132 } 133 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 134 return err 135 } 136 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 137 return err 138 } 139 if err = addOpDownloadDBLogFilePortionValidationMiddleware(stack); err != nil { 140 return err 141 } 142 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDownloadDBLogFilePortion(options.Region), middleware.Before); err != nil { 143 return err 144 } 145 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 146 return err 147 } 148 if err = addResponseErrorMiddleware(stack); err != nil { 149 return err 150 } 151 if err = addRequestResponseLogging(stack, options); err != nil { 152 return err 153 } 154 return nil 155} 156 157// DownloadDBLogFilePortionAPIClient is a client that implements the 158// DownloadDBLogFilePortion operation. 159type DownloadDBLogFilePortionAPIClient interface { 160 DownloadDBLogFilePortion(context.Context, *DownloadDBLogFilePortionInput, ...func(*Options)) (*DownloadDBLogFilePortionOutput, error) 161} 162 163var _ DownloadDBLogFilePortionAPIClient = (*Client)(nil) 164 165// DownloadDBLogFilePortionPaginatorOptions is the paginator options for 166// DownloadDBLogFilePortion 167type DownloadDBLogFilePortionPaginatorOptions struct { 168 // The number of lines to download. If the number of lines specified results in a 169 // file over 1 MB in size, the file is truncated at 1 MB in size. If the 170 // NumberOfLines parameter is specified, then the block of lines returned can be 171 // from the beginning or the end of the log file, depending on the value of the 172 // Marker parameter. 173 // 174 // * If neither Marker or NumberOfLines are specified, the 175 // entire log file is returned up to a maximum of 10000 lines, starting with the 176 // most recent log entries first. 177 // 178 // * If NumberOfLines is specified and Marker isn't 179 // specified, then the most recent lines from the end of the log file are 180 // returned. 181 // 182 // * If Marker is specified as "0", then the specified number of lines 183 // from the beginning of the log file are returned. 184 // 185 // * You can download the log 186 // file in blocks of lines by specifying the size of the block using the 187 // NumberOfLines parameter, and by specifying a value of "0" for the Marker 188 // parameter in your first request. Include the Marker value returned in the 189 // response as the Marker value for the next request, continuing until the 190 // AdditionalDataPending response element returns false. 191 Limit int32 192 193 // Set to true if pagination should stop if the service returns a pagination token 194 // that matches the most recent token provided to the service. 195 StopOnDuplicateToken bool 196} 197 198// DownloadDBLogFilePortionPaginator is a paginator for DownloadDBLogFilePortion 199type DownloadDBLogFilePortionPaginator struct { 200 options DownloadDBLogFilePortionPaginatorOptions 201 client DownloadDBLogFilePortionAPIClient 202 params *DownloadDBLogFilePortionInput 203 nextToken *string 204 firstPage bool 205} 206 207// NewDownloadDBLogFilePortionPaginator returns a new 208// DownloadDBLogFilePortionPaginator 209func NewDownloadDBLogFilePortionPaginator(client DownloadDBLogFilePortionAPIClient, params *DownloadDBLogFilePortionInput, optFns ...func(*DownloadDBLogFilePortionPaginatorOptions)) *DownloadDBLogFilePortionPaginator { 210 if params == nil { 211 params = &DownloadDBLogFilePortionInput{} 212 } 213 214 options := DownloadDBLogFilePortionPaginatorOptions{} 215 if params.NumberOfLines != 0 { 216 options.Limit = params.NumberOfLines 217 } 218 219 for _, fn := range optFns { 220 fn(&options) 221 } 222 223 return &DownloadDBLogFilePortionPaginator{ 224 options: options, 225 client: client, 226 params: params, 227 firstPage: true, 228 } 229} 230 231// HasMorePages returns a boolean indicating whether more pages are available 232func (p *DownloadDBLogFilePortionPaginator) HasMorePages() bool { 233 return p.firstPage || p.nextToken != nil 234} 235 236// NextPage retrieves the next DownloadDBLogFilePortion page. 237func (p *DownloadDBLogFilePortionPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DownloadDBLogFilePortionOutput, error) { 238 if !p.HasMorePages() { 239 return nil, fmt.Errorf("no more pages available") 240 } 241 242 params := *p.params 243 params.Marker = p.nextToken 244 245 params.NumberOfLines = p.options.Limit 246 247 result, err := p.client.DownloadDBLogFilePortion(ctx, ¶ms, optFns...) 248 if err != nil { 249 return nil, err 250 } 251 p.firstPage = false 252 253 prevToken := p.nextToken 254 p.nextToken = result.Marker 255 256 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 257 p.nextToken = nil 258 } 259 260 return result, nil 261} 262 263func newServiceMetadataMiddleware_opDownloadDBLogFilePortion(region string) *awsmiddleware.RegisterServiceMetadata { 264 return &awsmiddleware.RegisterServiceMetadata{ 265 Region: region, 266 ServiceID: ServiceID, 267 SigningName: "rds", 268 OperationName: "DownloadDBLogFilePortion", 269 } 270} 271