feat: ListChildren ShowAll query parameter

This commit is contained in:
James Houlahan
2023-02-26 16:27:54 +01:00
committed by James
parent fdedd64a6f
commit 3a58a3817e
3 changed files with 29 additions and 1 deletions

View File

@@ -36,3 +36,19 @@ func (b Bool) MarshalJSON() ([]byte, error) {
return json.Marshal(v)
}
func (b Bool) String() string {
if b {
return "true"
}
return "false"
}
func (b Bool) FormatURL() string {
if b {
return "1"
}
return "0"
}

View File

@@ -9,7 +9,7 @@ import (
"github.com/go-resty/resty/v2"
)
func (c *Client) ListChildren(ctx context.Context, shareID, linkID string) ([]Link, error) {
func (c *Client) ListChildren(ctx context.Context, shareID, linkID string, all bool) ([]Link, error) {
var res struct {
Links []Link
}
@@ -22,6 +22,7 @@ func (c *Client) ListChildren(ctx context.Context, shareID, linkID string) ([]Li
SetQueryParams(map[string]string{
"Page": strconv.Itoa(page),
"PageSize": strconv.Itoa(maxPageSize),
"ShowAll": Bool(all).FormatURL(),
}).
SetResult(&res).
Get("/drive/shares/" + shareID + "/folders/" + linkID + "/children")

View File

@@ -21,6 +21,7 @@ type Link struct {
Name string // Encrypted file name
Hash string // HMAC of name encrypted with parent hash key
Size int64
State LinkState
MIMEType string
CreateTime int64 // Link creation time
@@ -35,6 +36,16 @@ type Link struct {
FolderProperties *FolderProperties
}
type LinkState int
const (
LinkStateDraft LinkState = iota
LinkStateActive
LinkStateTrashed
LinkStateDeleted
LinkStateRestoring
)
func (l Link) GetName(parentNodeKR, addrKR *crypto.KeyRing) (string, error) {
encName, err := crypto.NewPGPMessageFromArmored(l.Name)
if err != nil {