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) 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" "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 { var res struct {
Links []Link Links []Link
} }
@@ -22,6 +22,7 @@ func (c *Client) ListChildren(ctx context.Context, shareID, linkID string) ([]Li
SetQueryParams(map[string]string{ SetQueryParams(map[string]string{
"Page": strconv.Itoa(page), "Page": strconv.Itoa(page),
"PageSize": strconv.Itoa(maxPageSize), "PageSize": strconv.Itoa(maxPageSize),
"ShowAll": Bool(all).FormatURL(),
}). }).
SetResult(&res). SetResult(&res).
Get("/drive/shares/" + shareID + "/folders/" + linkID + "/children") Get("/drive/shares/" + shareID + "/folders/" + linkID + "/children")

View File

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