Skip to content

Commit f49c1be

Browse files
Update spec to latest and revise generation instructions (#106)
* Update spec to 895e08a * Update generation instructions
1 parent 1a0f4d7 commit f49c1be

File tree

9 files changed

+699
-128
lines changed

9 files changed

+699
-128
lines changed

generator/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ used to programmatically generate the [Dropbox Go SDK](https://github.com/dropbo
66
## Requirements
77

88
* While not a hard requirement, this repo currently assumes `python3` in the path.
9-
* Assumes you have already installed [Stone](https://github.com/dropbox/stone)
10-
* Requires [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports) to fix up imports in the auto-generated code
9+
* Assumes you have already installed [Stone](https://github.com/dropbox/stone) and have `stone` in the path.
10+
* Requires [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports) in the path to fix up imports in the auto-generated code.
1111

1212
## Basic Setup
1313

14-
. Clone this repo
15-
. Run `git submodule init` followed by `git submodule update`
16-
. Run `./generate-sdk.sh` to generate code under `../dropbox`
14+
* Clone this repo
15+
* Run `git submodule init` followed by `git submodule update`. To fetch the latest API spec, use `git submodule update --remote`
16+
* Run `./generate-sdk.sh X.Y.Z`, where `X.Y.Z` is the desired version number, to generate code under `../vX/dropbox`
1717

1818
## Generated Code
1919

generator/generate-sdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -euo pipefail
33

44
if [[ $# -ne 1 ]]; then
5-
echo "$0: Not expecting more than one command-line argument, got $#." 1>&2
5+
echo "$0: Expecting exactly one command-line argument, got $#." 1>&2
66
exit 1
77
fi
88

v6/dropbox/files/client.go

Lines changed: 131 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ type Client interface {
3939
// Deprecated: Use `GetMetadata` instead
4040
AlphaGetMetadata(arg *AlphaGetMetadataArg) (res IsMetadata, err error)
4141
// AlphaUpload : Create a new file with the contents provided in the
42-
// request. Note that this endpoint is part of the properties API alpha and
43-
// is slightly different from `upload`. Do not use this to upload a file
44-
// larger than 150 MB. Instead, create an upload session with
45-
// `uploadSessionStart`.
46-
// Deprecated: Use `AlphaUpload` instead
47-
AlphaUpload(arg *CommitInfoWithProperties, content io.Reader) (res *FileMetadata, err error)
42+
// request. Note that the behavior of this alpha endpoint is unstable and
43+
// subject to change. Do not use this to upload a file larger than 150 MB.
44+
// Instead, create an upload session with `uploadSessionStart`.
45+
// Deprecated: Use `Upload` instead
46+
AlphaUpload(arg *UploadArg, content io.Reader) (res *FileMetadata, err error)
4847
// Copy : Copy a file or folder to a different location in the user's
4948
// Dropbox. If the source path is a folder all its contents will be copied.
5049
CopyV2(arg *RelocationArg) (res *RelocationResult, err error)
@@ -332,6 +331,13 @@ type Client interface {
332331
// Duplicate results may be returned across pages. Some results may not be
333332
// returned.
334333
SearchContinueV2(arg *SearchV2ContinueArg) (res *SearchV2Result, err error)
334+
// TagsAdd : Add a tag to an item. A tag is a string. No more than 20 tags
335+
// can be added to a given item.
336+
TagsAdd(arg *AddTagArg) (err error)
337+
// TagsGet : Get list of tags assigned to items.
338+
TagsGet(arg *GetTagsArg) (res *GetTagsResult, err error)
339+
// TagsRemove : Remove a tag from an item.
340+
TagsRemove(arg *RemoveTagArg) (err error)
335341
// UnlockFileBatch : Unlock the files at the given paths. A locked file can
336342
// only be unlocked by the lock holder or, if a business account, a team
337343
// admin. A successful response indicates that the file has been unlocked.
@@ -345,7 +351,7 @@ type Client interface {
345351
// on the number of data transport calls allowed per month. For more
346352
// information, see the `Data transport limit page`
347353
// <https://www.dropbox.com/developers/reference/data-transport-limit>.
348-
Upload(arg *CommitInfo, content io.Reader) (res *FileMetadata, err error)
354+
Upload(arg *UploadArg, content io.Reader) (res *FileMetadata, err error)
349355
// UploadSessionAppend : Append more data to an upload session. When the
350356
// parameter close is set, this call will close the session. A single
351357
// request should not upload more than 150 MB. The maximum size of a file
@@ -391,6 +397,7 @@ type Client interface {
391397
// of data transport calls allowed per month. For more information, see the
392398
// `Data transport limit page`
393399
// <https://www.dropbox.com/developers/reference/data-transport-limit>.
400+
// Deprecated: Use `UploadSessionFinishBatchV2` instead
394401
UploadSessionFinishBatch(arg *UploadSessionFinishBatchArg) (res *UploadSessionFinishBatchLaunch, err error)
395402
// UploadSessionFinishBatch : This route helps you commit many files at once
396403
// into a user's Dropbox. Use `uploadSessionStart` and `uploadSessionAppend`
@@ -501,12 +508,12 @@ func (dbx *apiImpl) AlphaGetMetadata(arg *AlphaGetMetadataArg) (res IsMetadata,
501508
//AlphaUploadAPIError is an error-wrapper for the alpha/upload route
502509
type AlphaUploadAPIError struct {
503510
dropbox.APIError
504-
EndpointError *UploadErrorWithProperties `json:"error"`
511+
EndpointError *UploadError `json:"error"`
505512
}
506513

507-
func (dbx *apiImpl) AlphaUpload(arg *CommitInfoWithProperties, content io.Reader) (res *FileMetadata, err error) {
514+
func (dbx *apiImpl) AlphaUpload(arg *UploadArg, content io.Reader) (res *FileMetadata, err error) {
508515
log.Printf("WARNING: API `AlphaUpload` is deprecated")
509-
log.Printf("Use API `AlphaUpload` instead")
516+
log.Printf("Use API `Upload` instead")
510517

511518
req := dropbox.Request{
512519
Host: "content",
@@ -1624,7 +1631,7 @@ func (dbx *apiImpl) ListFolder(arg *ListFolderArg) (res *ListFolderResult, err e
16241631
Host: "api",
16251632
Namespace: "files",
16261633
Route: "list_folder",
1627-
Auth: "user",
1634+
Auth: "app, user",
16281635
Style: "rpc",
16291636
Arg: arg,
16301637
ExtraHeaders: nil,
@@ -1662,7 +1669,7 @@ func (dbx *apiImpl) ListFolderContinue(arg *ListFolderContinueArg) (res *ListFol
16621669
Host: "api",
16631670
Namespace: "files",
16641671
Route: "list_folder/continue",
1665-
Auth: "user",
1672+
Auth: "app, user",
16661673
Style: "rpc",
16671674
Arg: arg,
16681675
ExtraHeaders: nil,
@@ -2654,6 +2661,112 @@ func (dbx *apiImpl) SearchContinueV2(arg *SearchV2ContinueArg) (res *SearchV2Res
26542661
return
26552662
}
26562663

2664+
//TagsAddAPIError is an error-wrapper for the tags/add route
2665+
type TagsAddAPIError struct {
2666+
dropbox.APIError
2667+
EndpointError *AddTagError `json:"error"`
2668+
}
2669+
2670+
func (dbx *apiImpl) TagsAdd(arg *AddTagArg) (err error) {
2671+
req := dropbox.Request{
2672+
Host: "api",
2673+
Namespace: "files",
2674+
Route: "tags/add",
2675+
Auth: "user",
2676+
Style: "rpc",
2677+
Arg: arg,
2678+
ExtraHeaders: nil,
2679+
}
2680+
2681+
var resp []byte
2682+
var respBody io.ReadCloser
2683+
resp, respBody, err = (*dropbox.Context)(dbx).Execute(req, nil)
2684+
if err != nil {
2685+
var appErr TagsAddAPIError
2686+
err = auth.ParseError(err, &appErr)
2687+
if err == &appErr {
2688+
err = appErr
2689+
}
2690+
return
2691+
}
2692+
2693+
_ = resp
2694+
_ = respBody
2695+
return
2696+
}
2697+
2698+
//TagsGetAPIError is an error-wrapper for the tags/get route
2699+
type TagsGetAPIError struct {
2700+
dropbox.APIError
2701+
EndpointError *BaseTagError `json:"error"`
2702+
}
2703+
2704+
func (dbx *apiImpl) TagsGet(arg *GetTagsArg) (res *GetTagsResult, err error) {
2705+
req := dropbox.Request{
2706+
Host: "api",
2707+
Namespace: "files",
2708+
Route: "tags/get",
2709+
Auth: "user",
2710+
Style: "rpc",
2711+
Arg: arg,
2712+
ExtraHeaders: nil,
2713+
}
2714+
2715+
var resp []byte
2716+
var respBody io.ReadCloser
2717+
resp, respBody, err = (*dropbox.Context)(dbx).Execute(req, nil)
2718+
if err != nil {
2719+
var appErr TagsGetAPIError
2720+
err = auth.ParseError(err, &appErr)
2721+
if err == &appErr {
2722+
err = appErr
2723+
}
2724+
return
2725+
}
2726+
2727+
err = json.Unmarshal(resp, &res)
2728+
if err != nil {
2729+
return
2730+
}
2731+
2732+
_ = respBody
2733+
return
2734+
}
2735+
2736+
//TagsRemoveAPIError is an error-wrapper for the tags/remove route
2737+
type TagsRemoveAPIError struct {
2738+
dropbox.APIError
2739+
EndpointError *RemoveTagError `json:"error"`
2740+
}
2741+
2742+
func (dbx *apiImpl) TagsRemove(arg *RemoveTagArg) (err error) {
2743+
req := dropbox.Request{
2744+
Host: "api",
2745+
Namespace: "files",
2746+
Route: "tags/remove",
2747+
Auth: "user",
2748+
Style: "rpc",
2749+
Arg: arg,
2750+
ExtraHeaders: nil,
2751+
}
2752+
2753+
var resp []byte
2754+
var respBody io.ReadCloser
2755+
resp, respBody, err = (*dropbox.Context)(dbx).Execute(req, nil)
2756+
if err != nil {
2757+
var appErr TagsRemoveAPIError
2758+
err = auth.ParseError(err, &appErr)
2759+
if err == &appErr {
2760+
err = appErr
2761+
}
2762+
return
2763+
}
2764+
2765+
_ = resp
2766+
_ = respBody
2767+
return
2768+
}
2769+
26572770
//UnlockFileBatchAPIError is an error-wrapper for the unlock_file_batch route
26582771
type UnlockFileBatchAPIError struct {
26592772
dropbox.APIError
@@ -2698,7 +2811,7 @@ type UploadAPIError struct {
26982811
EndpointError *UploadError `json:"error"`
26992812
}
27002813

2701-
func (dbx *apiImpl) Upload(arg *CommitInfo, content io.Reader) (res *FileMetadata, err error) {
2814+
func (dbx *apiImpl) Upload(arg *UploadArg, content io.Reader) (res *FileMetadata, err error) {
27022815
req := dropbox.Request{
27032816
Host: "content",
27042817
Namespace: "files",
@@ -2733,7 +2846,7 @@ func (dbx *apiImpl) Upload(arg *CommitInfo, content io.Reader) (res *FileMetadat
27332846
//UploadSessionAppendV2APIError is an error-wrapper for the upload_session/append_v2 route
27342847
type UploadSessionAppendV2APIError struct {
27352848
dropbox.APIError
2736-
EndpointError *UploadSessionLookupError `json:"error"`
2849+
EndpointError *UploadSessionAppendError `json:"error"`
27372850
}
27382851

27392852
func (dbx *apiImpl) UploadSessionAppendV2(arg *UploadSessionAppendArg, content io.Reader) (err error) {
@@ -2767,7 +2880,7 @@ func (dbx *apiImpl) UploadSessionAppendV2(arg *UploadSessionAppendArg, content i
27672880
//UploadSessionAppendAPIError is an error-wrapper for the upload_session/append route
27682881
type UploadSessionAppendAPIError struct {
27692882
dropbox.APIError
2770-
EndpointError *UploadSessionLookupError `json:"error"`
2883+
EndpointError *UploadSessionAppendError `json:"error"`
27712884
}
27722885

27732886
func (dbx *apiImpl) UploadSessionAppend(arg *UploadSessionCursor, content io.Reader) (err error) {
@@ -2846,6 +2959,9 @@ type UploadSessionFinishBatchAPIError struct {
28462959
}
28472960

28482961
func (dbx *apiImpl) UploadSessionFinishBatch(arg *UploadSessionFinishBatchArg) (res *UploadSessionFinishBatchLaunch, err error) {
2962+
log.Printf("WARNING: API `UploadSessionFinishBatch` is deprecated")
2963+
log.Printf("Use API `UploadSessionFinishBatchV2` instead")
2964+
28492965
req := dropbox.Request{
28502966
Host: "api",
28512967
Namespace: "files",

0 commit comments

Comments
 (0)