forked from dugancathal/dynago
-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_table.go
69 lines (58 loc) · 1.76 KB
/
request_table.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package dynago
import (
"github.com/bemobi/dynago/schema"
)
type awsSchemaExecutor struct {
*AwsExecutor
}
func (e awsSchemaExecutor) CreateTable(req *schema.CreateRequest) (resp *schema.CreateResult, err error) {
err = e.MakeRequestUnmarshal("CreateTable", req, &resp)
return
}
func (e awsSchemaExecutor) DeleteTable(req *schema.DeleteRequest) (resp *schema.DeleteResult, err error) {
err = e.MakeRequestUnmarshal("DeleteTable", req, &resp)
return
}
func (e awsSchemaExecutor) DescribeTable(req *schema.DescribeRequest) (resp *schema.DescribeResponse, err error) {
err = e.MakeRequestUnmarshal("DescribeTable", req, &resp)
return
}
// ListTables lists tables in your account.
type ListTables struct {
client *Client
req schema.ListRequest
}
// Limit the number of results returned.
func (l ListTables) Limit(limit uint) *ListTables {
l.req.Limit = limit
return &l
}
// Execute this ListTables request
func (l *ListTables) Execute() (result *ListTablesResult, err error) {
resp, err := l.client.schemaExecutor.ListTables(l)
if err == nil {
result = &ListTablesResult{resp.TableNames, resp.LastEvaluatedTableName, l}
}
return
}
func (e awsSchemaExecutor) ListTables(list *ListTables) (resp *schema.ListResponse, err error) {
err = e.MakeRequestUnmarshal("ListTables", list.req, &resp)
return resp, err
}
// ListTablesResult is a helper for paginating.
type ListTablesResult struct {
TableNames []string
cursor *string
req *ListTables
}
// Next will get the ListTables for the next page of listings.
// If there is not a next page, returns nil.
func (r ListTablesResult) Next() *ListTables {
if r.cursor == nil {
return nil
}
return &ListTables{r.req.client, schema.ListRequest{
ExclusiveStartTableName: *r.cursor,
Limit: r.req.req.Limit,
}}
}