vendor: update github.com/dropbox/dropbox-sdk-go-unofficial #2158

This commit is contained in:
Nick Craig-Wood 2018-05-25 19:08:10 +01:00
parent 3d8e529441
commit 500085d244
32 changed files with 12925 additions and 3262 deletions

5
Gopkg.lock generated
View File

@ -141,14 +141,15 @@
"dropbox/common",
"dropbox/file_properties",
"dropbox/files",
"dropbox/seen_state",
"dropbox/sharing",
"dropbox/team_common",
"dropbox/team_policies",
"dropbox/users",
"dropbox/users_common"
]
revision = "81ac5b288ffc03b166174f520cdc0b227461450e"
version = "v4.0.0"
revision = "7afa861bfde5a348d765522b303b6fbd9d250155"
version = "v4.1.0"
[[projects]]
name = "github.com/go-ini/ini"

View File

@ -1,16 +1,22 @@
language: go
go:
- 1.6.x
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
install:
- go get -u golang.org/x/oauth2
before_script:
- go get -u github.com/mitchellh/gox
install: go get -u golang.org/x/oauth2
script:
- gox -osarch="darwin/amd64 linux/amd64 windows/amd64" ./dropbox/...
- set -e
- GOOS=linux GOARCH=amd64 go install ./dropbox/...
- GOOS=darwin GOARCH=amd64 go install ./dropbox/...
- GOOS=windows GOARCH=amd64 go install ./dropbox/...
- set +e
jobs:
include:
- stage: run tests
go: 1.9.x
install: go get -u golang.org/x/oauth2
script: go test ./dropbox/...

View File

@ -1,4 +1,4 @@
# Dropbox SDK for Go [UNOFFICIAL] [![GoDoc](https://godoc.org/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox?status.svg)](https://godoc.org/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox) [![Build Status](https://travis-ci.org/dropbox/dropbox-sdk-go-unofficial.svg?branch=master)](https://travis-ci.org/dropbox/dropbox-sdk-go-unofficial)
# Dropbox SDK for Go [UNOFFICIAL] [![GoDoc](https://godoc.org/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox?status.svg)](https://godoc.org/github.com/dropbox/dropbox-sdk-go-unofficial/dropbox) [![Build Status](https://travis-ci.org/dropbox/dropbox-sdk-go-unofficial.svg?branch=master)](https://travis-ci.org/dropbox/dropbox-sdk-go-unofficial) [![Go Report Card](https://goreportcard.com/badge/github.com/dropbox/dropbox-sdk-go-unofficial)](https://goreportcard.com/report/github.com/dropbox/dropbox-sdk-go-unofficial)
An **UNOFFICIAL** Go SDK for integrating with the Dropbox API v2. Tested with Go 1.5+

View File

@ -99,7 +99,7 @@ func (dbx *apiImpl) TokenFromOauth1(arg *TokenFromOAuth1Arg) (res *TokenFromOAut
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -158,7 +158,7 @@ func (dbx *apiImpl) TokenRevoke() (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return

View File

@ -118,11 +118,12 @@ func (u *PathRootError) UnmarshalJSON(body []byte) error {
// RootInfo : Information about current user's root.
type RootInfo struct {
// RootNamespaceId : The namespace id for user's root namespace. It will be
// the namespace id of the shared team root if the user is member of a CDM
// team. Otherwise it will be same as `RootInfo.home_namespace_id`.
// RootNamespaceId : The namespace ID for user's root namespace. It will be
// the namespace ID of the shared team root if the user is member of a team
// with a separate team root. Otherwise it will be same as
// `RootInfo.home_namespace_id`.
RootNamespaceId string `json:"root_namespace_id"`
// HomeNamespaceId : The namespace id for user's home namespace.
// HomeNamespaceId : The namespace ID for user's home namespace.
HomeNamespaceId string `json:"home_namespace_id"`
}
@ -205,7 +206,8 @@ func IsRootInfoFromJSON(data []byte) (IsRootInfo, error) {
return nil, nil
}
// TeamRootInfo : Root info when user is member of a CDM team.
// TeamRootInfo : Root info when user is member of a team with a separate root
// namespace ID.
type TeamRootInfo struct {
RootInfo
// HomePath : The path for user's home directory under the shared team root.
@ -221,7 +223,8 @@ func NewTeamRootInfo(RootNamespaceId string, HomeNamespaceId string, HomePath st
return s
}
// UserRootInfo : Root info when user is not member of a CDM team.
// UserRootInfo : Root info when user is not member of a team or the user is a
// member of a team and the team does not have a separate root namespace.
type UserRootInfo struct {
RootInfo
}

View File

@ -44,7 +44,8 @@ type Client interface {
// PropertiesRemove : Permanently removes the specified property group from
// the file. To remove specific property field key value pairs, see
// `propertiesUpdate`. To update a template, see `templatesUpdateForUser` or
// `templatesUpdateForTeam`. Templates can't be removed once created.
// `templatesUpdateForTeam`. To remove a template, see
// `templatesRemoveForUser` or `templatesRemoveForTeam`.
PropertiesRemove(arg *RemovePropertiesArg) (err error)
// PropertiesSearch : Search across property templates for particular
// property field values.
@ -155,7 +156,7 @@ func (dbx *apiImpl) PropertiesAdd(arg *AddPropertiesArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -222,7 +223,7 @@ func (dbx *apiImpl) PropertiesOverwrite(arg *OverwritePropertyGroupArg) (err err
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -289,7 +290,7 @@ func (dbx *apiImpl) PropertiesRemove(arg *RemovePropertiesArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -361,7 +362,7 @@ func (dbx *apiImpl) PropertiesSearch(arg *PropertiesSearchArg) (res *PropertiesS
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -433,7 +434,7 @@ func (dbx *apiImpl) PropertiesSearchContinue(arg *PropertiesSearchContinueArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -500,7 +501,7 @@ func (dbx *apiImpl) PropertiesUpdate(arg *UpdatePropertiesArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -569,7 +570,7 @@ func (dbx *apiImpl) TemplatesAddForTeam(arg *AddTemplateArg) (res *AddTemplateRe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -641,7 +642,7 @@ func (dbx *apiImpl) TemplatesAddForUser(arg *AddTemplateArg) (res *AddTemplateRe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -710,7 +711,7 @@ func (dbx *apiImpl) TemplatesGetForTeam(arg *GetTemplateArg) (res *GetTemplateRe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -782,7 +783,7 @@ func (dbx *apiImpl) TemplatesGetForUser(arg *GetTemplateArg) (res *GetTemplateRe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -843,7 +844,7 @@ func (dbx *apiImpl) TemplatesListForTeam() (res *ListTemplateResult, err error)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -907,7 +908,7 @@ func (dbx *apiImpl) TemplatesListForUser() (res *ListTemplateResult, err error)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -971,7 +972,7 @@ func (dbx *apiImpl) TemplatesRemoveForTeam(arg *RemoveTemplateArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1038,7 +1039,7 @@ func (dbx *apiImpl) TemplatesRemoveForUser(arg *RemoveTemplateArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1107,7 +1108,7 @@ func (dbx *apiImpl) TemplatesUpdateForTeam(arg *UpdateTemplateArg) (res *UpdateT
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1179,7 +1180,7 @@ func (dbx *apiImpl) TemplatesUpdateForUser(arg *UpdateTemplateArg) (res *UpdateT
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return

View File

@ -35,11 +35,12 @@
// associated properties can't be accessed by any app other than the app that
// created them, and even then, only when the app is linked with the owner of
// the template (either a user or team). User-owned templates are accessed via
// the user-auth template/*_for_user endpoints, while team-owned templates are
// accessed via the team-auth template/*_for_team endpoints. Properties
// associated with either type of template can be accessed via the user-auth
// properties/* endpoints. Finally, properties can be accessed from a number of
// endpoints that return metadata, including `files/get_metadata`, and
// the user-auth file_properties/templates/*_for_user endpoints, while
// team-owned templates are accessed via the team-auth
// file_properties/templates/*_for_team endpoints. Properties associated with
// either type of template can be accessed via the user-auth properties/*
// endpoints. Finally, properties can be accessed from a number of endpoints
// that return metadata, including `files/get_metadata`, and
// `files/list_folder`. Properties can also be added during upload, using
// `files/upload`.
package file_properties

View File

@ -104,7 +104,7 @@ func (dbx *apiImpl) Create(arg *CreateFileRequestArgs) (res *FileRequest, err er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -176,7 +176,7 @@ func (dbx *apiImpl) Get(arg *GetFileRequestArgs) (res *FileRequest, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -240,7 +240,7 @@ func (dbx *apiImpl) List() (res *ListFileRequestsResult, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -312,7 +312,7 @@ func (dbx *apiImpl) Update(arg *UpdateFileRequestArgs) (res *FileRequest, err er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return

View File

@ -145,7 +145,7 @@ type FileRequestDeadline struct {
// Deadline : The deadline for this file request.
Deadline time.Time `json:"deadline"`
// AllowLateUploads : If set, allow uploads after the deadline has passed.
// These uploads will be marked overdue.
// These uploads will be marked overdue.
AllowLateUploads *GracePeriod `json:"allow_late_uploads,omitempty"`
}

View File

@ -76,6 +76,18 @@ type Client interface {
// CreateFolder : Create a folder at a given path.
// Deprecated: Use `CreateFolderV2` instead
CreateFolder(arg *CreateFolderArg) (res *FolderMetadata, err error)
// CreateFolderBatch : Create multiple folders at once. This route is
// asynchronous for large batches, which returns a job ID immediately and
// runs the create folder batch asynchronously. Otherwise, creates the
// folders and returns the result synchronously for smaller inputs. You can
// force asynchronous behaviour by using the
// `CreateFolderBatchArg.force_async` flag. Use `createFolderBatchCheck` to
// check the job status.
CreateFolderBatch(arg *CreateFolderBatchArg) (res *CreateFolderBatchLaunch, err error)
// CreateFolderBatchCheck : Returns the status of an asynchronous job for
// `createFolderBatch`. If success, it returns list of result for each
// entry.
CreateFolderBatchCheck(arg *async.PollArg) (res *CreateFolderBatchJobStatus, err error)
// CreateFolderV2 : Create a folder at a given path.
CreateFolderV2(arg *CreateFolderArg) (res *CreateFolderResult, err error)
// Delete : Delete the file or folder at a given path. If the path is a
@ -100,6 +112,10 @@ type Client interface {
DeleteV2(arg *DeleteArg) (res *DeleteResult, err error)
// Download : Download a file from a user's Dropbox.
Download(arg *DownloadArg) (res *FileMetadata, content io.ReadCloser, err error)
// DownloadZip : Download a folder from the user's Dropbox, as a zip file.
// The folder must be less than 1 GB in size and have fewer than 10,000
// total files. The input cannot be a single file.
DownloadZip(arg *DownloadZipArg) (res *DownloadZipResult, content io.ReadCloser, err error)
// GetMetadata : Returns the metadata for a file or folder. Note: Metadata
// for the root folder is unsupported.
GetMetadata(arg *GetMetadataArg) (res IsMetadata, err error)
@ -231,16 +247,19 @@ type Client interface {
// upload session with `uploadSessionStart`.
Upload(arg *CommitInfo, content io.Reader) (res *FileMetadata, err error)
// UploadSessionAppend : Append more data to an upload session. A single
// request should not upload more than 150 MB.
// request should not upload more than 150 MB. The maximum size of a file
// one can upload to an upload session is 350 GB.
// Deprecated: Use `UploadSessionAppendV2` instead
UploadSessionAppend(arg *UploadSessionCursor, content io.Reader) (err error)
// UploadSessionAppendV2 : Append more data to an upload session. When the
// parameter close is set, this call will close the session. A single
// request should not upload more than 150 MB.
// request should not upload more than 150 MB. The maximum size of a file
// one can upload to an upload session is 350 GB.
UploadSessionAppendV2(arg *UploadSessionAppendArg, content io.Reader) (err error)
// UploadSessionFinish : Finish an upload session and save the uploaded data
// to the given file path. A single request should not upload more than 150
// MB.
// MB. The maximum size of a file one can upload to an upload session is 350
// GB.
UploadSessionFinish(arg *UploadSessionFinishArg, content io.Reader) (res *FileMetadata, err error)
// UploadSessionFinishBatch : This route helps you commit many files at once
// into a user's Dropbox. Use `uploadSessionStart` and
@ -250,11 +269,12 @@ type Client interface {
// route to finish all your upload sessions in a single request.
// `UploadSessionStartArg.close` or `UploadSessionAppendArg.close` needs to
// be true for the last `uploadSessionStart` or `uploadSessionAppendV2`
// call. This route will return a job_id immediately and do the async commit
// job in background. Use `uploadSessionFinishBatchCheck` to check the job
// status. For the same account, this route should be executed serially.
// That means you should not start the next job before current job finishes.
// We allow up to 1000 entries in a single request.
// call. The maximum size of a file one can upload to an upload session is
// 350 GB. This route will return a job_id immediately and do the async
// commit job in background. Use `uploadSessionFinishBatchCheck` to check
// the job status. For the same account, this route should be executed
// serially. That means you should not start the next job before current job
// finishes. We allow up to 1000 entries in a single request.
UploadSessionFinishBatch(arg *UploadSessionFinishBatchArg) (res *UploadSessionFinishBatchLaunch, err error)
// UploadSessionFinishBatchCheck : Returns the status of an asynchronous job
// for `uploadSessionFinishBatch`. If success, it returns list of result for
@ -265,8 +285,9 @@ type Client interface {
// than 150 MB. This call starts a new upload session with the given data.
// You can then use `uploadSessionAppendV2` to add more data and
// `uploadSessionFinish` to save all the data to a file in Dropbox. A single
// request should not upload more than 150 MB. An upload session can be used
// for a maximum of 48 hours. Attempting to use an
// request should not upload more than 150 MB. The maximum size of a file
// one can upload to an upload session is 350 GB. An upload session can be
// used for a maximum of 48 hours. Attempting to use an
// `UploadSessionStartResult.session_id` with `uploadSessionAppendV2` or
// `uploadSessionFinish` more than 48 hours after its creation will return a
// `UploadSessionLookupError.not_found`.
@ -348,7 +369,7 @@ func (dbx *apiImpl) AlphaGetMetadata(arg *AlphaGetMetadataArg) (res IsMetadata,
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -424,7 +445,7 @@ func (dbx *apiImpl) AlphaUpload(arg *CommitInfoWithProperties, content io.Reader
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -510,7 +531,7 @@ func (dbx *apiImpl) Copy(arg *RelocationArg) (res IsMetadata, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -582,7 +603,7 @@ func (dbx *apiImpl) CopyBatch(arg *RelocationBatchArg) (res *RelocationBatchLaun
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -654,7 +675,7 @@ func (dbx *apiImpl) CopyBatchCheck(arg *async.PollArg) (res *RelocationBatchJobS
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -726,7 +747,7 @@ func (dbx *apiImpl) CopyReferenceGet(arg *GetCopyReferenceArg) (res *GetCopyRefe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -798,7 +819,7 @@ func (dbx *apiImpl) CopyReferenceSave(arg *SaveCopyReferenceArg) (res *SaveCopyR
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -870,7 +891,7 @@ func (dbx *apiImpl) CopyV2(arg *RelocationArg) (res *RelocationResult, err error
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -945,7 +966,151 @@ func (dbx *apiImpl) CreateFolder(arg *CreateFolderArg) (res *FolderMetadata, err
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//CreateFolderBatchAPIError is an error-wrapper for the create_folder_batch route
type CreateFolderBatchAPIError struct {
dropbox.APIError
EndpointError struct{} `json:"error"`
}
func (dbx *apiImpl) CreateFolderBatch(arg *CreateFolderBatchArg) (res *CreateFolderBatchLaunch, err error) {
cli := dbx.Client
dbx.Config.LogDebug("arg: %v", arg)
b, err := json.Marshal(arg)
if err != nil {
return
}
headers := map[string]string{
"Content-Type": "application/json",
}
if dbx.Config.AsMemberID != "" {
headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID
}
req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "create_folder_batch", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.LogInfo("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.LogInfo("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.LogDebug("body: %v", body)
if resp.StatusCode == http.StatusOK {
err = json.Unmarshal(body, &res)
if err != nil {
return
}
return
}
if resp.StatusCode == http.StatusConflict {
var apiError CreateFolderBatchAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//CreateFolderBatchCheckAPIError is an error-wrapper for the create_folder_batch/check route
type CreateFolderBatchCheckAPIError struct {
dropbox.APIError
EndpointError *async.PollError `json:"error"`
}
func (dbx *apiImpl) CreateFolderBatchCheck(arg *async.PollArg) (res *CreateFolderBatchJobStatus, err error) {
cli := dbx.Client
dbx.Config.LogDebug("arg: %v", arg)
b, err := json.Marshal(arg)
if err != nil {
return
}
headers := map[string]string{
"Content-Type": "application/json",
}
if dbx.Config.AsMemberID != "" {
headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID
}
req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "create_folder_batch/check", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.LogInfo("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.LogInfo("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.LogDebug("body: %v", body)
if resp.StatusCode == http.StatusOK {
err = json.Unmarshal(body, &res)
if err != nil {
return
}
return
}
if resp.StatusCode == http.StatusConflict {
var apiError CreateFolderBatchCheckAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1017,7 +1182,7 @@ func (dbx *apiImpl) CreateFolderV2(arg *CreateFolderArg) (res *CreateFolderResul
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1103,7 +1268,7 @@ func (dbx *apiImpl) Delete(arg *DeleteArg) (res IsMetadata, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1175,7 +1340,7 @@ func (dbx *apiImpl) DeleteBatch(arg *DeleteBatchArg) (res *DeleteBatchLaunch, er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1247,7 +1412,7 @@ func (dbx *apiImpl) DeleteBatchCheck(arg *async.PollArg) (res *DeleteBatchJobSta
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1319,7 +1484,7 @@ func (dbx *apiImpl) DeleteV2(arg *DeleteArg) (res *DeleteResult, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1395,7 +1560,80 @@ func (dbx *apiImpl) Download(arg *DownloadArg) (res *FileMetadata, content io.Re
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//DownloadZipAPIError is an error-wrapper for the download_zip route
type DownloadZipAPIError struct {
dropbox.APIError
EndpointError *DownloadZipError `json:"error"`
}
func (dbx *apiImpl) DownloadZip(arg *DownloadZipArg) (res *DownloadZipResult, content io.ReadCloser, err error) {
cli := dbx.Client
dbx.Config.LogDebug("arg: %v", arg)
b, err := json.Marshal(arg)
if err != nil {
return
}
headers := map[string]string{
"Dropbox-API-Arg": string(b),
}
if dbx.Config.AsMemberID != "" {
headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID
}
req, err := (*dropbox.Context)(dbx).NewRequest("content", "download", true, "files", "download_zip", headers, nil)
if err != nil {
return
}
dbx.Config.LogInfo("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.LogInfo("resp: %v", resp)
body := []byte(resp.Header.Get("Dropbox-API-Result"))
content = resp.Body
dbx.Config.LogDebug("body: %v", body)
if resp.StatusCode == http.StatusOK {
err = json.Unmarshal(body, &res)
if err != nil {
return
}
return
}
if resp.StatusCode == http.StatusConflict {
defer resp.Body.Close()
body, err = ioutil.ReadAll(resp.Body)
if err != nil {
return
}
var apiError DownloadZipAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1478,7 +1716,7 @@ func (dbx *apiImpl) GetMetadata(arg *GetMetadataArg) (res IsMetadata, err error)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1551,7 +1789,7 @@ func (dbx *apiImpl) GetPreview(arg *PreviewArg) (res *FileMetadata, content io.R
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1623,7 +1861,7 @@ func (dbx *apiImpl) GetTemporaryLink(arg *GetTemporaryLinkArg) (res *GetTemporar
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1696,7 +1934,7 @@ func (dbx *apiImpl) GetThumbnail(arg *ThumbnailArg) (res *FileMetadata, content
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1768,7 +2006,7 @@ func (dbx *apiImpl) GetThumbnailBatch(arg *GetThumbnailBatchArg) (res *GetThumbn
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1840,7 +2078,7 @@ func (dbx *apiImpl) ListFolder(arg *ListFolderArg) (res *ListFolderResult, err e
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1912,7 +2150,7 @@ func (dbx *apiImpl) ListFolderContinue(arg *ListFolderContinueArg) (res *ListFol
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1984,7 +2222,7 @@ func (dbx *apiImpl) ListFolderGetLatestCursor(arg *ListFolderArg) (res *ListFold
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2053,7 +2291,7 @@ func (dbx *apiImpl) ListFolderLongpoll(arg *ListFolderLongpollArg) (res *ListFol
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2125,7 +2363,7 @@ func (dbx *apiImpl) ListRevisions(arg *ListRevisionsArg) (res *ListRevisionsResu
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2211,7 +2449,7 @@ func (dbx *apiImpl) Move(arg *RelocationArg) (res IsMetadata, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2283,7 +2521,7 @@ func (dbx *apiImpl) MoveBatch(arg *RelocationBatchArg) (res *RelocationBatchLaun
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2355,7 +2593,7 @@ func (dbx *apiImpl) MoveBatchCheck(arg *async.PollArg) (res *RelocationBatchJobS
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2427,7 +2665,7 @@ func (dbx *apiImpl) MoveV2(arg *RelocationArg) (res *RelocationResult, err error
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2494,7 +2732,7 @@ func (dbx *apiImpl) PermanentlyDelete(arg *DeleteArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2563,7 +2801,7 @@ func (dbx *apiImpl) PropertiesAdd(arg *file_properties.AddPropertiesArg) (err er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2632,7 +2870,7 @@ func (dbx *apiImpl) PropertiesOverwrite(arg *file_properties.OverwritePropertyGr
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2701,7 +2939,7 @@ func (dbx *apiImpl) PropertiesRemove(arg *file_properties.RemovePropertiesArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2775,7 +3013,7 @@ func (dbx *apiImpl) PropertiesTemplateGet(arg *file_properties.GetTemplateArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2841,7 +3079,7 @@ func (dbx *apiImpl) PropertiesTemplateList() (res *file_properties.ListTemplateR
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2910,7 +3148,7 @@ func (dbx *apiImpl) PropertiesUpdate(arg *file_properties.UpdatePropertiesArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2982,7 +3220,7 @@ func (dbx *apiImpl) Restore(arg *RestoreArg) (res *FileMetadata, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3054,7 +3292,7 @@ func (dbx *apiImpl) SaveUrl(arg *SaveUrlArg) (res *SaveUrlResult, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3126,7 +3364,7 @@ func (dbx *apiImpl) SaveUrlCheckJobStatus(arg *async.PollArg) (res *SaveUrlJobSt
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3198,7 +3436,7 @@ func (dbx *apiImpl) Search(arg *SearchArg) (res *SearchResult, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3271,7 +3509,7 @@ func (dbx *apiImpl) Upload(arg *CommitInfo, content io.Reader) (res *FileMetadat
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3342,7 +3580,7 @@ func (dbx *apiImpl) UploadSessionAppend(arg *UploadSessionCursor, content io.Rea
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3410,7 +3648,7 @@ func (dbx *apiImpl) UploadSessionAppendV2(arg *UploadSessionAppendArg, content i
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3483,7 +3721,7 @@ func (dbx *apiImpl) UploadSessionFinish(arg *UploadSessionFinishArg, content io.
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3555,7 +3793,7 @@ func (dbx *apiImpl) UploadSessionFinishBatch(arg *UploadSessionFinishBatchArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3627,7 +3865,7 @@ func (dbx *apiImpl) UploadSessionFinishBatchCheck(arg *async.PollArg) (res *Uplo
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3700,7 +3938,7 @@ func (dbx *apiImpl) UploadSessionStart(arg *UploadSessionStartArg, content io.Re
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return

View File

@ -1,109 +0,0 @@
// Copyright (c) Dropbox, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package files
import "encoding/json"
type listFolderResult struct {
Entries []json.RawMessage `json:"entries"`
Cursor string `json:"cursor"`
HasMore bool `json:"has_more"`
}
// UnmarshalJSON deserializes into a ListFolderResult instance
func (r *ListFolderResult) UnmarshalJSON(b []byte) error {
var l listFolderResult
if err := json.Unmarshal(b, &l); err != nil {
return err
}
r.Cursor = l.Cursor
r.HasMore = l.HasMore
r.Entries = make([]IsMetadata, len(l.Entries))
for i, e := range l.Entries {
metadata, err := IsMetadataFromJSON(e)
if err != nil {
return err
}
r.Entries[i] = metadata
}
return nil
}
type searchMatch struct {
MatchType *SearchMatchType `json:"match_type"`
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a SearchMatch instance
func (s *SearchMatch) UnmarshalJSON(b []byte) error {
var m searchMatch
if err := json.Unmarshal(b, &m); err != nil {
return err
}
s.MatchType = m.MatchType
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}
type deleteResult struct {
FileOpsResult
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a DeleteResult instance
func (s *DeleteResult) UnmarshalJSON(b []byte) error {
var m deleteResult
if err := json.Unmarshal(b, &m); err != nil {
return err
}
s.FileOpsResult = m.FileOpsResult
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}
type relocationResult struct {
FileOpsResult
// Metadata : Metadata of the relocated object.
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a RelocationResult instance
func (s *RelocationResult) UnmarshalJSON(b []byte) error {
var m relocationResult
if err := json.Unmarshal(b, &m); err != nil {
return err
}
s.FileOpsResult = m.FileOpsResult
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}

View File

@ -210,6 +210,38 @@ func NewCommitInfoWithProperties(Path string) *CommitInfoWithProperties {
return s
}
// ContentSyncSetting : has no documentation (yet)
type ContentSyncSetting struct {
// Id : Id of the item this setting is applied to.
Id string `json:"id"`
// SyncSetting : Setting for this item.
SyncSetting *SyncSetting `json:"sync_setting"`
}
// NewContentSyncSetting returns a new ContentSyncSetting instance
func NewContentSyncSetting(Id string, SyncSetting *SyncSetting) *ContentSyncSetting {
s := new(ContentSyncSetting)
s.Id = Id
s.SyncSetting = SyncSetting
return s
}
// ContentSyncSettingArg : has no documentation (yet)
type ContentSyncSettingArg struct {
// Id : Id of the item this setting is applied to.
Id string `json:"id"`
// SyncSetting : Setting for this item.
SyncSetting *SyncSettingArg `json:"sync_setting"`
}
// NewContentSyncSettingArg returns a new ContentSyncSettingArg instance
func NewContentSyncSettingArg(Id string, SyncSetting *SyncSettingArg) *ContentSyncSettingArg {
s := new(ContentSyncSettingArg)
s.Id = Id
s.SyncSetting = SyncSetting
return s
}
// CreateFolderArg : has no documentation (yet)
type CreateFolderArg struct {
// Path : Path in the user's Dropbox to create.
@ -227,6 +259,257 @@ func NewCreateFolderArg(Path string) *CreateFolderArg {
return s
}
// CreateFolderBatchArg : has no documentation (yet)
type CreateFolderBatchArg struct {
// Paths : List of paths to be created in the user's Dropbox. Duplicate path
// arguments in the batch are considered only once.
Paths []string `json:"paths"`
// Autorename : If there's a conflict, have the Dropbox server try to
// autorename the folder to avoid the conflict.
Autorename bool `json:"autorename"`
// ForceAsync : Whether to force the create to happen asynchronously.
ForceAsync bool `json:"force_async"`
}
// NewCreateFolderBatchArg returns a new CreateFolderBatchArg instance
func NewCreateFolderBatchArg(Paths []string) *CreateFolderBatchArg {
s := new(CreateFolderBatchArg)
s.Paths = Paths
s.Autorename = false
s.ForceAsync = false
return s
}
// CreateFolderBatchError : has no documentation (yet)
type CreateFolderBatchError struct {
dropbox.Tagged
}
// Valid tag values for CreateFolderBatchError
const (
CreateFolderBatchErrorTooManyFiles = "too_many_files"
CreateFolderBatchErrorOther = "other"
)
// CreateFolderBatchJobStatus : has no documentation (yet)
type CreateFolderBatchJobStatus struct {
dropbox.Tagged
// Complete : The batch create folder has finished.
Complete *CreateFolderBatchResult `json:"complete,omitempty"`
// Failed : The batch create folder has failed.
Failed *CreateFolderBatchError `json:"failed,omitempty"`
}
// Valid tag values for CreateFolderBatchJobStatus
const (
CreateFolderBatchJobStatusInProgress = "in_progress"
CreateFolderBatchJobStatusComplete = "complete"
CreateFolderBatchJobStatusFailed = "failed"
CreateFolderBatchJobStatusOther = "other"
)
// UnmarshalJSON deserializes into a CreateFolderBatchJobStatus instance
func (u *CreateFolderBatchJobStatus) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Complete : The batch create folder has finished.
Complete json.RawMessage `json:"complete,omitempty"`
// Failed : The batch create folder has failed.
Failed json.RawMessage `json:"failed,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "complete":
err = json.Unmarshal(body, &u.Complete)
if err != nil {
return err
}
case "failed":
err = json.Unmarshal(w.Failed, &u.Failed)
if err != nil {
return err
}
}
return nil
}
// CreateFolderBatchLaunch : Result returned by `createFolderBatch` that may
// either launch an asynchronous job or complete synchronously.
type CreateFolderBatchLaunch struct {
dropbox.Tagged
// AsyncJobId : This response indicates that the processing is asynchronous.
// The string is an id that can be used to obtain the status of the
// asynchronous job.
AsyncJobId string `json:"async_job_id,omitempty"`
// Complete : has no documentation (yet)
Complete *CreateFolderBatchResult `json:"complete,omitempty"`
}
// Valid tag values for CreateFolderBatchLaunch
const (
CreateFolderBatchLaunchAsyncJobId = "async_job_id"
CreateFolderBatchLaunchComplete = "complete"
CreateFolderBatchLaunchOther = "other"
)
// UnmarshalJSON deserializes into a CreateFolderBatchLaunch instance
func (u *CreateFolderBatchLaunch) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Complete : has no documentation (yet)
Complete json.RawMessage `json:"complete,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "async_job_id":
err = json.Unmarshal(body, &u.AsyncJobId)
if err != nil {
return err
}
case "complete":
err = json.Unmarshal(body, &u.Complete)
if err != nil {
return err
}
}
return nil
}
// FileOpsResult : has no documentation (yet)
type FileOpsResult struct {
}
// NewFileOpsResult returns a new FileOpsResult instance
func NewFileOpsResult() *FileOpsResult {
s := new(FileOpsResult)
return s
}
// CreateFolderBatchResult : has no documentation (yet)
type CreateFolderBatchResult struct {
FileOpsResult
// Entries : has no documentation (yet)
Entries []*CreateFolderBatchResultEntry `json:"entries"`
}
// NewCreateFolderBatchResult returns a new CreateFolderBatchResult instance
func NewCreateFolderBatchResult(Entries []*CreateFolderBatchResultEntry) *CreateFolderBatchResult {
s := new(CreateFolderBatchResult)
s.Entries = Entries
return s
}
// CreateFolderBatchResultEntry : has no documentation (yet)
type CreateFolderBatchResultEntry struct {
dropbox.Tagged
// Success : has no documentation (yet)
Success *CreateFolderEntryResult `json:"success,omitempty"`
// Failure : has no documentation (yet)
Failure *CreateFolderEntryError `json:"failure,omitempty"`
}
// Valid tag values for CreateFolderBatchResultEntry
const (
CreateFolderBatchResultEntrySuccess = "success"
CreateFolderBatchResultEntryFailure = "failure"
)
// UnmarshalJSON deserializes into a CreateFolderBatchResultEntry instance
func (u *CreateFolderBatchResultEntry) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Success : has no documentation (yet)
Success json.RawMessage `json:"success,omitempty"`
// Failure : has no documentation (yet)
Failure json.RawMessage `json:"failure,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "success":
err = json.Unmarshal(body, &u.Success)
if err != nil {
return err
}
case "failure":
err = json.Unmarshal(w.Failure, &u.Failure)
if err != nil {
return err
}
}
return nil
}
// CreateFolderEntryError : has no documentation (yet)
type CreateFolderEntryError struct {
dropbox.Tagged
// Path : has no documentation (yet)
Path *WriteError `json:"path,omitempty"`
}
// Valid tag values for CreateFolderEntryError
const (
CreateFolderEntryErrorPath = "path"
CreateFolderEntryErrorOther = "other"
)
// UnmarshalJSON deserializes into a CreateFolderEntryError instance
func (u *CreateFolderEntryError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Path : has no documentation (yet)
Path json.RawMessage `json:"path,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "path":
err = json.Unmarshal(w.Path, &u.Path)
if err != nil {
return err
}
}
return nil
}
// CreateFolderEntryResult : has no documentation (yet)
type CreateFolderEntryResult struct {
// Metadata : Metadata of the created folder.
Metadata *FolderMetadata `json:"metadata"`
}
// NewCreateFolderEntryResult returns a new CreateFolderEntryResult instance
func NewCreateFolderEntryResult(Metadata *FolderMetadata) *CreateFolderEntryResult {
s := new(CreateFolderEntryResult)
s.Metadata = Metadata
return s
}
// CreateFolderError : has no documentation (yet)
type CreateFolderError struct {
dropbox.Tagged
@ -263,16 +546,6 @@ func (u *CreateFolderError) UnmarshalJSON(body []byte) error {
return nil
}
// FileOpsResult : has no documentation (yet)
type FileOpsResult struct {
}
// NewFileOpsResult returns a new FileOpsResult instance
func NewFileOpsResult() *FileOpsResult {
s := new(FileOpsResult)
return s
}
// CreateFolderResult : has no documentation (yet)
type CreateFolderResult struct {
FileOpsResult
@ -291,6 +564,9 @@ func NewCreateFolderResult(Metadata *FolderMetadata) *CreateFolderResult {
type DeleteArg struct {
// Path : Path in the user's Dropbox to delete.
Path string `json:"path"`
// ParentRev : Perform delete if given "rev" matches the existing file's
// latest "rev". This field does not support deleting a folder.
ParentRev string `json:"parent_rev,omitempty"`
}
// NewDeleteArg returns a new DeleteArg instance
@ -449,6 +725,24 @@ func NewDeleteBatchResultData(Metadata IsMetadata) *DeleteBatchResultData {
return s
}
// UnmarshalJSON deserializes into a DeleteBatchResultData instance
func (u *DeleteBatchResultData) UnmarshalJSON(b []byte) error {
type wrap struct {
// Metadata : Metadata of the deleted object.
Metadata json.RawMessage `json:"metadata"`
}
var w wrap
if err := json.Unmarshal(b, &w); err != nil {
return err
}
Metadata, err := IsMetadataFromJSON(w.Metadata)
if err != nil {
return err
}
u.Metadata = Metadata
return nil
}
// DeleteBatchResultEntry : has no documentation (yet)
type DeleteBatchResultEntry struct {
dropbox.Tagged
@ -560,6 +854,24 @@ func NewDeleteResult(Metadata IsMetadata) *DeleteResult {
return s
}
// UnmarshalJSON deserializes into a DeleteResult instance
func (u *DeleteResult) UnmarshalJSON(b []byte) error {
type wrap struct {
// Metadata : Metadata of the deleted object.
Metadata json.RawMessage `json:"metadata"`
}
var w wrap
if err := json.Unmarshal(b, &w); err != nil {
return err
}
Metadata, err := IsMetadataFromJSON(w.Metadata)
if err != nil {
return err
}
u.Metadata = Metadata
return nil
}
// Metadata : Metadata for a file or folder.
type Metadata struct {
// Name : The last component of the path (including extension). This never
@ -757,6 +1069,71 @@ func (u *DownloadError) UnmarshalJSON(body []byte) error {
return nil
}
// DownloadZipArg : has no documentation (yet)
type DownloadZipArg struct {
// Path : The path of the folder to download.
Path string `json:"path"`
}
// NewDownloadZipArg returns a new DownloadZipArg instance
func NewDownloadZipArg(Path string) *DownloadZipArg {
s := new(DownloadZipArg)
s.Path = Path
return s
}
// DownloadZipError : has no documentation (yet)
type DownloadZipError struct {
dropbox.Tagged
// Path : has no documentation (yet)
Path *LookupError `json:"path,omitempty"`
}
// Valid tag values for DownloadZipError
const (
DownloadZipErrorPath = "path"
DownloadZipErrorTooLarge = "too_large"
DownloadZipErrorTooManyFiles = "too_many_files"
DownloadZipErrorOther = "other"
)
// UnmarshalJSON deserializes into a DownloadZipError instance
func (u *DownloadZipError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Path : has no documentation (yet)
Path json.RawMessage `json:"path,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "path":
err = json.Unmarshal(w.Path, &u.Path)
if err != nil {
return err
}
}
return nil
}
// DownloadZipResult : has no documentation (yet)
type DownloadZipResult struct {
// Metadata : has no documentation (yet)
Metadata *FolderMetadata `json:"metadata"`
}
// NewDownloadZipResult returns a new DownloadZipResult instance
func NewDownloadZipResult(Metadata *FolderMetadata) *DownloadZipResult {
s := new(DownloadZipResult)
s.Metadata = Metadata
return s
}
// FileMetadata : has no documentation (yet)
type FileMetadata struct {
Metadata
@ -778,6 +1155,8 @@ type FileMetadata struct {
Size uint64 `json:"size"`
// MediaInfo : Additional information if the file is a photo or video.
MediaInfo *MediaInfo `json:"media_info,omitempty"`
// SymlinkInfo : Set if this file is a symlink.
SymlinkInfo *SymlinkInfo `json:"symlink_info,omitempty"`
// SharingInfo : Set if this file is contained in a shared folder.
SharingInfo *FileSharingInfo `json:"sharing_info,omitempty"`
// PropertyGroups : Additional information if the file has custom properties
@ -965,6 +1344,32 @@ func NewGetCopyReferenceResult(Metadata IsMetadata, CopyReference string, Expire
return s
}
// UnmarshalJSON deserializes into a GetCopyReferenceResult instance
func (u *GetCopyReferenceResult) UnmarshalJSON(b []byte) error {
type wrap struct {
// Metadata : Metadata of the file or folder.
Metadata json.RawMessage `json:"metadata"`
// CopyReference : A copy reference to the file or folder.
CopyReference string `json:"copy_reference"`
// Expires : The expiration date of the copy reference. This value is
// currently set to be far enough in the future so that expiration is
// effectively not an issue.
Expires time.Time `json:"expires"`
}
var w wrap
if err := json.Unmarshal(b, &w); err != nil {
return err
}
Metadata, err := IsMetadataFromJSON(w.Metadata)
if err != nil {
return err
}
u.Metadata = Metadata
u.CopyReference = w.CopyReference
u.Expires = w.Expires
return nil
}
// GetTemporaryLinkArg : has no documentation (yet)
type GetTemporaryLinkArg struct {
// Path : The path to the file you want a temporary link to.
@ -1369,6 +1774,35 @@ func NewListFolderResult(Entries []IsMetadata, Cursor string, HasMore bool) *Lis
return s
}
// UnmarshalJSON deserializes into a ListFolderResult instance
func (u *ListFolderResult) UnmarshalJSON(b []byte) error {
type wrap struct {
// Entries : The files and (direct) subfolders in the folder.
Entries []json.RawMessage `json:"entries"`
// Cursor : Pass the cursor into `listFolderContinue` to see what's
// changed in the folder since your previous query.
Cursor string `json:"cursor"`
// HasMore : If true, then there are more entries available. Pass the
// cursor to `listFolderContinue` to retrieve the rest.
HasMore bool `json:"has_more"`
}
var w wrap
if err := json.Unmarshal(b, &w); err != nil {
return err
}
u.Entries = make([]IsMetadata, len(w.Entries))
for i, e := range w.Entries {
v, err := IsMetadataFromJSON(e)
if err != nil {
return err
}
u.Entries[i] = v
}
u.Cursor = w.Cursor
u.HasMore = w.HasMore
return nil
}
// ListRevisionsArg : has no documentation (yet)
type ListRevisionsArg struct {
// Path : The path to the file you want to see the revisions of.
@ -2017,6 +2451,24 @@ func NewRelocationBatchResultData(Metadata IsMetadata) *RelocationBatchResultDat
return s
}
// UnmarshalJSON deserializes into a RelocationBatchResultData instance
func (u *RelocationBatchResultData) UnmarshalJSON(b []byte) error {
type wrap struct {
// Metadata : Metadata of the relocated object.
Metadata json.RawMessage `json:"metadata"`
}
var w wrap
if err := json.Unmarshal(b, &w); err != nil {
return err
}
Metadata, err := IsMetadataFromJSON(w.Metadata)
if err != nil {
return err
}
u.Metadata = Metadata
return nil
}
// RelocationResult : has no documentation (yet)
type RelocationResult struct {
FileOpsResult
@ -2031,6 +2483,24 @@ func NewRelocationResult(Metadata IsMetadata) *RelocationResult {
return s
}
// UnmarshalJSON deserializes into a RelocationResult instance
func (u *RelocationResult) UnmarshalJSON(b []byte) error {
type wrap struct {
// Metadata : Metadata of the relocated object.
Metadata json.RawMessage `json:"metadata"`
}
var w wrap
if err := json.Unmarshal(b, &w); err != nil {
return err
}
Metadata, err := IsMetadataFromJSON(w.Metadata)
if err != nil {
return err
}
u.Metadata = Metadata
return nil
}
// RestoreArg : has no documentation (yet)
type RestoreArg struct {
// Path : The path to the file you want to restore.
@ -2168,6 +2638,25 @@ func NewSaveCopyReferenceResult(Metadata IsMetadata) *SaveCopyReferenceResult {
return s
}
// UnmarshalJSON deserializes into a SaveCopyReferenceResult instance
func (u *SaveCopyReferenceResult) UnmarshalJSON(b []byte) error {
type wrap struct {
// Metadata : The metadata of the saved file or folder in the user's
// Dropbox.
Metadata json.RawMessage `json:"metadata"`
}
var w wrap
if err := json.Unmarshal(b, &w); err != nil {
return err
}
Metadata, err := IsMetadataFromJSON(w.Metadata)
if err != nil {
return err
}
u.Metadata = Metadata
return nil
}
// SaveUrlArg : has no documentation (yet)
type SaveUrlArg struct {
// Path : The path in Dropbox where the URL will be saved to.
@ -2402,6 +2891,27 @@ func NewSearchMatch(MatchType *SearchMatchType, Metadata IsMetadata) *SearchMatc
return s
}
// UnmarshalJSON deserializes into a SearchMatch instance
func (u *SearchMatch) UnmarshalJSON(b []byte) error {
type wrap struct {
// MatchType : The type of the match.
MatchType *SearchMatchType `json:"match_type"`
// Metadata : The metadata for the matched file or folder.
Metadata json.RawMessage `json:"metadata"`
}
var w wrap
if err := json.Unmarshal(b, &w); err != nil {
return err
}
u.MatchType = w.MatchType
Metadata, err := IsMetadataFromJSON(w.Metadata)
if err != nil {
return err
}
u.Metadata = Metadata
return nil
}
// SearchMatchType : Indicates what type of match was found for a given item.
type SearchMatchType struct {
dropbox.Tagged
@ -2462,6 +2972,83 @@ func NewSharedLink(Url string) *SharedLink {
return s
}
// SymlinkInfo : has no documentation (yet)
type SymlinkInfo struct {
// Target : The target this symlink points to.
Target string `json:"target"`
}
// NewSymlinkInfo returns a new SymlinkInfo instance
func NewSymlinkInfo(Target string) *SymlinkInfo {
s := new(SymlinkInfo)
s.Target = Target
return s
}
// SyncSetting : has no documentation (yet)
type SyncSetting struct {
dropbox.Tagged
}
// Valid tag values for SyncSetting
const (
SyncSettingDefault = "default"
SyncSettingNotSynced = "not_synced"
SyncSettingNotSyncedInactive = "not_synced_inactive"
SyncSettingOther = "other"
)
// SyncSettingArg : has no documentation (yet)
type SyncSettingArg struct {
dropbox.Tagged
}
// Valid tag values for SyncSettingArg
const (
SyncSettingArgDefault = "default"
SyncSettingArgNotSynced = "not_synced"
SyncSettingArgOther = "other"
)
// SyncSettingsError : has no documentation (yet)
type SyncSettingsError struct {
dropbox.Tagged
// Path : has no documentation (yet)
Path *LookupError `json:"path,omitempty"`
}
// Valid tag values for SyncSettingsError
const (
SyncSettingsErrorPath = "path"
SyncSettingsErrorUnsupportedCombination = "unsupported_combination"
SyncSettingsErrorUnsupportedConfiguration = "unsupported_configuration"
SyncSettingsErrorOther = "other"
)
// UnmarshalJSON deserializes into a SyncSettingsError instance
func (u *SyncSettingsError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Path : has no documentation (yet)
Path json.RawMessage `json:"path,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "path":
err = json.Unmarshal(w.Path, &u.Path)
if err != nil {
return err
}
}
return nil
}
// ThumbnailArg : has no documentation (yet)
type ThumbnailArg struct {
// Path : The path to the image file you want to thumbnail.
@ -2472,6 +3059,8 @@ type ThumbnailArg struct {
Format *ThumbnailFormat `json:"format"`
// Size : The size for the thumbnail image.
Size *ThumbnailSize `json:"size"`
// Mode : How to resize and crop the image to achieve the desired size.
Mode *ThumbnailMode `json:"mode"`
}
// NewThumbnailArg returns a new ThumbnailArg instance
@ -2480,6 +3069,7 @@ func NewThumbnailArg(Path string) *ThumbnailArg {
s.Path = Path
s.Format = &ThumbnailFormat{Tagged: dropbox.Tagged{"jpeg"}}
s.Size = &ThumbnailSize{Tagged: dropbox.Tagged{"w64h64"}}
s.Mode = &ThumbnailMode{Tagged: dropbox.Tagged{"strict"}}
return s
}
@ -2533,6 +3123,18 @@ const (
ThumbnailFormatPng = "png"
)
// ThumbnailMode : has no documentation (yet)
type ThumbnailMode struct {
dropbox.Tagged
}
// Valid tag values for ThumbnailMode
const (
ThumbnailModeStrict = "strict"
ThumbnailModeBestfit = "bestfit"
ThumbnailModeFitoneBestfit = "fitone_bestfit"
)
// ThumbnailSize : has no documentation (yet)
type ThumbnailSize struct {
dropbox.Tagged
@ -2540,11 +3142,15 @@ type ThumbnailSize struct {
// Valid tag values for ThumbnailSize
const (
ThumbnailSizeW32h32 = "w32h32"
ThumbnailSizeW64h64 = "w64h64"
ThumbnailSizeW128h128 = "w128h128"
ThumbnailSizeW640h480 = "w640h480"
ThumbnailSizeW1024h768 = "w1024h768"
ThumbnailSizeW32h32 = "w32h32"
ThumbnailSizeW64h64 = "w64h64"
ThumbnailSizeW128h128 = "w128h128"
ThumbnailSizeW256h256 = "w256h256"
ThumbnailSizeW480h320 = "w480h320"
ThumbnailSizeW640h480 = "w640h480"
ThumbnailSizeW960h640 = "w960h640"
ThumbnailSizeW1024h768 = "w1024h768"
ThumbnailSizeW2048h1536 = "w2048h1536"
)
// UploadError : has no documentation (yet)
@ -2552,12 +3158,16 @@ type UploadError struct {
dropbox.Tagged
// Path : Unable to save the uploaded contents to a file.
Path *UploadWriteFailed `json:"path,omitempty"`
// PropertiesError : The supplied property group is invalid. The file has
// uploaded without property groups.
PropertiesError *file_properties.InvalidPropertyGroupError `json:"properties_error,omitempty"`
}
// Valid tag values for UploadError
const (
UploadErrorPath = "path"
UploadErrorOther = "other"
UploadErrorPath = "path"
UploadErrorPropertiesError = "properties_error"
UploadErrorOther = "other"
)
// UnmarshalJSON deserializes into a UploadError instance
@ -2566,6 +3176,9 @@ func (u *UploadError) UnmarshalJSON(body []byte) error {
dropbox.Tagged
// Path : Unable to save the uploaded contents to a file.
Path json.RawMessage `json:"path,omitempty"`
// PropertiesError : The supplied property group is invalid. The file
// has uploaded without property groups.
PropertiesError json.RawMessage `json:"properties_error,omitempty"`
}
var w wrap
var err error
@ -2577,6 +3190,12 @@ func (u *UploadError) UnmarshalJSON(body []byte) error {
case "path":
err = json.Unmarshal(body, &u.Path)
if err != nil {
return err
}
case "properties_error":
err = json.Unmarshal(w.PropertiesError, &u.PropertiesError)
if err != nil {
return err
}
@ -2589,15 +3208,16 @@ type UploadErrorWithProperties struct {
dropbox.Tagged
// Path : Unable to save the uploaded contents to a file.
Path *UploadWriteFailed `json:"path,omitempty"`
// PropertiesError : has no documentation (yet)
// PropertiesError : The supplied property group is invalid. The file has
// uploaded without property groups.
PropertiesError *file_properties.InvalidPropertyGroupError `json:"properties_error,omitempty"`
}
// Valid tag values for UploadErrorWithProperties
const (
UploadErrorWithPropertiesPath = "path"
UploadErrorWithPropertiesOther = "other"
UploadErrorWithPropertiesPropertiesError = "properties_error"
UploadErrorWithPropertiesOther = "other"
)
// UnmarshalJSON deserializes into a UploadErrorWithProperties instance
@ -2606,7 +3226,8 @@ func (u *UploadErrorWithProperties) UnmarshalJSON(body []byte) error {
dropbox.Tagged
// Path : Unable to save the uploaded contents to a file.
Path json.RawMessage `json:"path,omitempty"`
// PropertiesError : has no documentation (yet)
// PropertiesError : The supplied property group is invalid. The file
// has uploaded without property groups.
PropertiesError json.RawMessage `json:"properties_error,omitempty"`
}
var w wrap
@ -2850,14 +3471,20 @@ type UploadSessionFinishError struct {
// LookupFailed : The session arguments are incorrect; the value explains
// the reason.
LookupFailed *UploadSessionLookupError `json:"lookup_failed,omitempty"`
// Path : Unable to save the uploaded contents to a file.
// Path : Unable to save the uploaded contents to a file. Data has already
// been appended to the upload session. Please retry with empty data body
// and updated offset.
Path *WriteError `json:"path,omitempty"`
// PropertiesError : The supplied property group is invalid. The file has
// uploaded without property groups.
PropertiesError *file_properties.InvalidPropertyGroupError `json:"properties_error,omitempty"`
}
// Valid tag values for UploadSessionFinishError
const (
UploadSessionFinishErrorLookupFailed = "lookup_failed"
UploadSessionFinishErrorPath = "path"
UploadSessionFinishErrorPropertiesError = "properties_error"
UploadSessionFinishErrorTooManySharedFolderTargets = "too_many_shared_folder_targets"
UploadSessionFinishErrorTooManyWriteOperations = "too_many_write_operations"
UploadSessionFinishErrorOther = "other"
@ -2870,8 +3497,13 @@ func (u *UploadSessionFinishError) UnmarshalJSON(body []byte) error {
// LookupFailed : The session arguments are incorrect; the value
// explains the reason.
LookupFailed json.RawMessage `json:"lookup_failed,omitempty"`
// Path : Unable to save the uploaded contents to a file.
// Path : Unable to save the uploaded contents to a file. Data has
// already been appended to the upload session. Please retry with empty
// data body and updated offset.
Path json.RawMessage `json:"path,omitempty"`
// PropertiesError : The supplied property group is invalid. The file
// has uploaded without property groups.
PropertiesError json.RawMessage `json:"properties_error,omitempty"`
}
var w wrap
var err error
@ -2889,6 +3521,12 @@ func (u *UploadSessionFinishError) UnmarshalJSON(body []byte) error {
case "path":
err = json.Unmarshal(w.Path, &u.Path)
if err != nil {
return err
}
case "properties_error":
err = json.Unmarshal(w.PropertiesError, &u.PropertiesError)
if err != nil {
return err
}
@ -2912,6 +3550,7 @@ const (
UploadSessionLookupErrorIncorrectOffset = "incorrect_offset"
UploadSessionLookupErrorClosed = "closed"
UploadSessionLookupErrorNotClosed = "not_closed"
UploadSessionLookupErrorTooLarge = "too_large"
UploadSessionLookupErrorOther = "other"
)
@ -2988,8 +3627,9 @@ func NewUploadSessionStartResult(SessionId string) *UploadSessionStartResult {
type UploadWriteFailed struct {
// Reason : The reason why the file couldn't be saved.
Reason *WriteError `json:"reason"`
// UploadSessionId : The upload session ID; this may be used to retry the
// commit.
// UploadSessionId : The upload session ID; data has already been uploaded
// to the corresponding upload session and this ID may be used to retry the
// commit with `uploadSessionFinish`.
UploadSessionId string `json:"upload_session_id"`
}
@ -3039,13 +3679,14 @@ type WriteError struct {
// Valid tag values for WriteError
const (
WriteErrorMalformedPath = "malformed_path"
WriteErrorConflict = "conflict"
WriteErrorNoWritePermission = "no_write_permission"
WriteErrorInsufficientSpace = "insufficient_space"
WriteErrorDisallowedName = "disallowed_name"
WriteErrorTeamFolder = "team_folder"
WriteErrorOther = "other"
WriteErrorMalformedPath = "malformed_path"
WriteErrorConflict = "conflict"
WriteErrorNoWritePermission = "no_write_permission"
WriteErrorInsufficientSpace = "insufficient_space"
WriteErrorDisallowedName = "disallowed_name"
WriteErrorTeamFolder = "team_folder"
WriteErrorTooManyWriteOperations = "too_many_write_operations"
WriteErrorOther = "other"
)
// UnmarshalJSON deserializes into a WriteError instance

View File

@ -52,9 +52,9 @@ type Client interface {
// DocsGetFolderInfo : Retrieves folder information for the given Paper doc.
// This includes: - folder sharing policy; permissions for subfolders are
// set by the top-level folder. - full 'filepath', i.e. the list of
// folders (both folderId and folderName) from the root folder to the folder
// directly containing the Paper doc. Note: If the Paper doc is not in any
// folder (aka unfiled) the response will be empty.
// folders (both folderId and folderName) from the root folder to the
// folder directly containing the Paper doc. Note: If the Paper doc is not
// in any folder (aka unfiled) the response will be empty.
DocsGetFolderInfo(arg *RefPaperDoc) (res *FoldersContainingPaperDoc, err error)
// DocsList : Return the list of all Paper docs according to the argument
// specifications. To iterate over through the full pagination, pass the
@ -153,7 +153,7 @@ func (dbx *apiImpl) DocsArchive(arg *RefPaperDoc) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -226,7 +226,7 @@ func (dbx *apiImpl) DocsCreate(arg *PaperDocCreateArgs, content io.Reader) (res
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -299,7 +299,7 @@ func (dbx *apiImpl) DocsDownload(arg *PaperDocExport) (res *PaperDocExportResult
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -371,7 +371,7 @@ func (dbx *apiImpl) DocsFolderUsersList(arg *ListUsersOnFolderArgs) (res *ListUs
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -443,7 +443,7 @@ func (dbx *apiImpl) DocsFolderUsersListContinue(arg *ListUsersOnFolderContinueAr
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -515,7 +515,7 @@ func (dbx *apiImpl) DocsGetFolderInfo(arg *RefPaperDoc) (res *FoldersContainingP
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -587,7 +587,7 @@ func (dbx *apiImpl) DocsList(arg *ListPaperDocsArgs) (res *ListPaperDocsResponse
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -659,7 +659,7 @@ func (dbx *apiImpl) DocsListContinue(arg *ListPaperDocsContinueArgs) (res *ListP
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -726,7 +726,7 @@ func (dbx *apiImpl) DocsPermanentlyDelete(arg *RefPaperDoc) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -798,7 +798,7 @@ func (dbx *apiImpl) DocsSharingPolicyGet(arg *RefPaperDoc) (res *SharingPolicy,
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -865,7 +865,7 @@ func (dbx *apiImpl) DocsSharingPolicySet(arg *PaperDocSharingPolicy) (err error)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -938,7 +938,7 @@ func (dbx *apiImpl) DocsUpdate(arg *PaperDocUpdateArgs, content io.Reader) (res
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1010,7 +1010,7 @@ func (dbx *apiImpl) DocsUsersAdd(arg *AddPaperDocUser) (res []*AddPaperDocUserMe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1082,7 +1082,7 @@ func (dbx *apiImpl) DocsUsersList(arg *ListUsersOnPaperDocArgs) (res *ListUsersO
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1154,7 +1154,7 @@ func (dbx *apiImpl) DocsUsersListContinue(arg *ListUsersOnPaperDocContinueArgs)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1221,7 +1221,7 @@ func (dbx *apiImpl) DocsUsersRemove(arg *RemovePaperDocUser) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return

View File

@ -26,6 +26,7 @@ import (
"log"
"net/http"
"golang.org/x/net/context"
"golang.org/x/oauth2"
)
@ -35,8 +36,8 @@ const (
hostAPI = "api"
hostContent = "content"
hostNotify = "notify"
sdkVersion = "4.0.0"
specVersion = "5389e5b"
sdkVersion = "4.2.0"
specVersion = "222ba8c"
)
// Version returns the current SDK version and API Spec version
@ -77,12 +78,12 @@ const (
LogInfo
)
func (l LogLevel) ShouldLog(v LogLevel) bool {
func (l LogLevel) shouldLog(v LogLevel) bool {
return l > v || l&v == v
}
func (c *Config) doLog(l LogLevel, format string, v ...interface{}) {
if !c.LogLevel.ShouldLog(l) {
if !c.LogLevel.shouldLog(l) {
return
}
@ -152,7 +153,7 @@ func NewContext(c Config) Context {
if client == nil {
var conf = &oauth2.Config{Endpoint: OAuthEndpoint(domain)}
tok := &oauth2.Token{AccessToken: c.Token}
client = conf.Client(oauth2.NoContext, tok)
client = conf.Client(context.Background(), tok)
}
headerGenerator := c.HeaderGenerator

View File

@ -18,32 +18,38 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package sharing
package dropbox_test
import "encoding/json"
import (
"fmt"
"net/http"
"net/http/httptest"
"strings"
"testing"
type listSharedLinksResult struct {
Links []sharedLinkMetadataUnion `json:"links"`
HasMore bool `json:"has_more"`
Cursor string `json:"cursor,omitempty"`
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users"
)
func generateURL(base string, namespace string, route string) string {
return fmt.Sprintf("%s/%s/%s", base, namespace, route)
}
// UnmarshalJSON deserializes into a ListSharedLinksResult instance
func (r *ListSharedLinksResult) UnmarshalJSON(b []byte) error {
var l listSharedLinksResult
if err := json.Unmarshal(b, &l); err != nil {
return err
func TestInternalError(t *testing.T) {
eString := "internal server error"
ts := httptest.NewServer(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
http.Error(w, eString, http.StatusInternalServerError)
}))
defer ts.Close()
config := dropbox.Config{Client: ts.Client(), LogLevel: dropbox.LogDebug,
URLGenerator: func(hostType string, style string, namespace string, route string) string {
return generateURL(ts.URL, namespace, route)
}}
client := users.New(config)
v, e := client.GetCurrentAccount()
if v != nil || strings.Trim(e.Error(), "\n") != eString {
t.Errorf("v: %v e: '%s'\n", v, e.Error())
}
r.Cursor = l.Cursor
r.HasMore = l.HasMore
r.Links = make([]IsSharedLinkMetadata, len(l.Links))
for i, e := range l.Links {
switch e.Tag {
case "file":
r.Links[i] = e.File
case "folder":
r.Links[i] = e.Folder
}
}
return nil
}

View File

@ -18,32 +18,21 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package sharing
// Package seen_state : has no documentation (yet)
package seen_state
import "encoding/json"
import "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
type listSharedLinksResult struct {
Links []sharedLinkMetadataUnion `json:"links"`
HasMore bool `json:"has_more"`
Cursor string `json:"cursor,omitempty"`
// PlatformType : Possible platforms on which a user may view content.
type PlatformType struct {
dropbox.Tagged
}
// UnmarshalJSON deserializes into a ListSharedLinksResult instance
func (r *ListSharedLinksResult) UnmarshalJSON(b []byte) error {
var l listSharedLinksResult
if err := json.Unmarshal(b, &l); err != nil {
return err
}
r.Cursor = l.Cursor
r.HasMore = l.HasMore
r.Links = make([]IsSharedLinkMetadata, len(l.Links))
for i, e := range l.Links {
switch e.Tag {
case "file":
r.Links[i] = e.File
case "folder":
r.Links[i] = e.Folder
}
}
return nil
}
// Valid tag values for PlatformType
const (
PlatformTypeWeb = "web"
PlatformTypeMobile = "mobile"
PlatformTypeDesktop = "desktop"
PlatformTypeUnknown = "unknown"
PlatformTypeOther = "other"
)

View File

@ -187,6 +187,12 @@ type Client interface {
// that enable access to a specific file, you can use the `listSharedLinks`
// with the file as the `ListSharedLinksArg.path` argument.
RevokeSharedLink(arg *RevokeSharedLinkArg) (err error)
// SetAccessInheritance : Change the inheritance policy of an existing
// Shared Folder. Only permitted for shared folders in a shared team root.
// If a `ShareFolderLaunch.async_job_id` is returned, you'll need to call
// `checkShareJobStatus` until the action completes to get the metadata for
// the folder.
SetAccessInheritance(arg *SetAccessInheritanceArg) (res *ShareFolderLaunch, err error)
// ShareFolder : Share a folder with collaborators. Most sharing will be
// completed synchronously. Large folders will be completed asynchronously.
// To make testing the async case repeatable, set
@ -285,7 +291,7 @@ func (dbx *apiImpl) AddFileMember(arg *AddFileMemberArgs) (res []*FileMemberActi
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -352,7 +358,7 @@ func (dbx *apiImpl) AddFolderMember(arg *AddFolderMemberArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -427,7 +433,7 @@ func (dbx *apiImpl) ChangeFileMemberAccess(arg *ChangeFileMemberAccessArgs) (res
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -499,7 +505,7 @@ func (dbx *apiImpl) CheckJobStatus(arg *async.PollArg) (res *JobStatus, err erro
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -571,7 +577,7 @@ func (dbx *apiImpl) CheckRemoveMemberJobStatus(arg *async.PollArg) (res *RemoveM
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -643,7 +649,7 @@ func (dbx *apiImpl) CheckShareJobStatus(arg *async.PollArg) (res *ShareFolderJob
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -718,7 +724,7 @@ func (dbx *apiImpl) CreateSharedLink(arg *CreateSharedLinkArg) (res *PathLinkMet
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -798,7 +804,7 @@ func (dbx *apiImpl) CreateSharedLinkWithSettings(arg *CreateSharedLinkWithSettin
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -870,7 +876,7 @@ func (dbx *apiImpl) GetFileMetadata(arg *GetFileMetadataArg) (res *SharedFileMet
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -942,7 +948,7 @@ func (dbx *apiImpl) GetFileMetadataBatch(arg *GetFileMetadataBatchArg) (res []*G
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1014,7 +1020,7 @@ func (dbx *apiImpl) GetFolderMetadata(arg *GetMetadataArgs) (res *SharedFolderMe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1095,7 +1101,7 @@ func (dbx *apiImpl) GetSharedLinkFile(arg *GetSharedLinkMetadataArg) (res IsShar
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1175,7 +1181,7 @@ func (dbx *apiImpl) GetSharedLinkMetadata(arg *GetSharedLinkMetadataArg) (res Is
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1250,7 +1256,7 @@ func (dbx *apiImpl) GetSharedLinks(arg *GetSharedLinksArg) (res *GetSharedLinksR
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1322,7 +1328,7 @@ func (dbx *apiImpl) ListFileMembers(arg *ListFileMembersArg) (res *SharedFileMem
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1394,7 +1400,7 @@ func (dbx *apiImpl) ListFileMembersBatch(arg *ListFileMembersBatchArg) (res []*L
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1466,7 +1472,7 @@ func (dbx *apiImpl) ListFileMembersContinue(arg *ListFileMembersContinueArg) (re
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1538,7 +1544,7 @@ func (dbx *apiImpl) ListFolderMembers(arg *ListFolderMembersArgs) (res *SharedFo
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1610,7 +1616,7 @@ func (dbx *apiImpl) ListFolderMembersContinue(arg *ListFolderMembersContinueArg)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1682,7 +1688,7 @@ func (dbx *apiImpl) ListFolders(arg *ListFoldersArgs) (res *ListFoldersResult, e
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1754,7 +1760,7 @@ func (dbx *apiImpl) ListFoldersContinue(arg *ListFoldersContinueArg) (res *ListF
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1826,7 +1832,7 @@ func (dbx *apiImpl) ListMountableFolders(arg *ListFoldersArgs) (res *ListFolders
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1898,7 +1904,7 @@ func (dbx *apiImpl) ListMountableFoldersContinue(arg *ListFoldersContinueArg) (r
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1970,7 +1976,7 @@ func (dbx *apiImpl) ListReceivedFiles(arg *ListFilesArg) (res *ListFilesResult,
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2042,7 +2048,7 @@ func (dbx *apiImpl) ListReceivedFilesContinue(arg *ListFilesContinueArg) (res *L
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2114,7 +2120,7 @@ func (dbx *apiImpl) ListSharedLinks(arg *ListSharedLinksArg) (res *ListSharedLin
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2194,7 +2200,7 @@ func (dbx *apiImpl) ModifySharedLinkSettings(arg *ModifySharedLinkSettingsArgs)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2266,7 +2272,7 @@ func (dbx *apiImpl) MountFolder(arg *MountFolderArg) (res *SharedFolderMetadata,
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2333,7 +2339,7 @@ func (dbx *apiImpl) RelinquishFileMembership(arg *RelinquishFileMembershipArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2405,7 +2411,7 @@ func (dbx *apiImpl) RelinquishFolderMembership(arg *RelinquishFolderMembershipAr
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2480,7 +2486,7 @@ func (dbx *apiImpl) RemoveFileMember(arg *RemoveFileMemberArg) (res *FileMemberA
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2552,7 +2558,7 @@ func (dbx *apiImpl) RemoveFileMember2(arg *RemoveFileMemberArg) (res *FileMember
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2624,7 +2630,7 @@ func (dbx *apiImpl) RemoveFolderMember(arg *RemoveFolderMemberArg) (res *async.L
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2691,7 +2697,79 @@ func (dbx *apiImpl) RevokeSharedLink(arg *RevokeSharedLinkArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//SetAccessInheritanceAPIError is an error-wrapper for the set_access_inheritance route
type SetAccessInheritanceAPIError struct {
dropbox.APIError
EndpointError *SetAccessInheritanceError `json:"error"`
}
func (dbx *apiImpl) SetAccessInheritance(arg *SetAccessInheritanceArg) (res *ShareFolderLaunch, err error) {
cli := dbx.Client
dbx.Config.LogDebug("arg: %v", arg)
b, err := json.Marshal(arg)
if err != nil {
return
}
headers := map[string]string{
"Content-Type": "application/json",
}
if dbx.Config.AsMemberID != "" {
headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID
}
req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "sharing", "set_access_inheritance", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.LogInfo("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.LogInfo("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.LogDebug("body: %v", body)
if resp.StatusCode == http.StatusOK {
err = json.Unmarshal(body, &res)
if err != nil {
return
}
return
}
if resp.StatusCode == http.StatusConflict {
var apiError SetAccessInheritanceAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2763,7 +2841,7 @@ func (dbx *apiImpl) ShareFolder(arg *ShareFolderArg) (res *ShareFolderLaunch, er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2830,7 +2908,7 @@ func (dbx *apiImpl) TransferFolder(arg *TransferFolderArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2897,7 +2975,7 @@ func (dbx *apiImpl) UnmountFolder(arg *UnmountFolderArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2964,7 +3042,7 @@ func (dbx *apiImpl) UnshareFile(arg *UnshareFileArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3036,7 +3114,7 @@ func (dbx *apiImpl) UnshareFolder(arg *UnshareFolderArg) (res *async.LaunchEmpty
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3108,7 +3186,7 @@ func (dbx *apiImpl) UpdateFileMember(arg *UpdateFileMemberArgs) (res *MemberAcce
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3180,7 +3258,7 @@ func (dbx *apiImpl) UpdateFolderMember(arg *UpdateFolderMemberArg) (res *MemberA
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3252,7 +3330,7 @@ func (dbx *apiImpl) UpdateFolderPolicy(arg *UpdateFolderPolicyArg) (res *SharedF
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return

View File

@ -28,10 +28,24 @@ import (
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/seen_state"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_common"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users"
)
// AccessInheritance : Information about the inheritance policy of a shared
// folder.
type AccessInheritance struct {
dropbox.Tagged
}
// Valid tag values for AccessInheritance
const (
AccessInheritanceInherit = "inherit"
AccessInheritanceNoInherit = "no_inherit"
AccessInheritanceOther = "other"
)
// AccessLevel : Defines the access levels for collaborators.
type AccessLevel struct {
dropbox.Tagged
@ -1089,6 +1103,7 @@ const (
FolderActionLeaveACopy = "leave_a_copy"
FolderActionShareLink = "share_link"
FolderActionCreateLink = "create_link"
FolderActionSetAccessInheritance = "set_access_inheritance"
FolderActionOther = "other"
)
@ -1431,6 +1446,27 @@ func NewGetSharedLinksResult(Links []IsLinkMetadata) *GetSharedLinksResult {
return s
}
// UnmarshalJSON deserializes into a GetSharedLinksResult instance
func (u *GetSharedLinksResult) UnmarshalJSON(b []byte) error {
type wrap struct {
// Links : Shared links applicable to the path argument.
Links []json.RawMessage `json:"links"`
}
var w wrap
if err := json.Unmarshal(b, &w); err != nil {
return err
}
u.Links = make([]IsLinkMetadata, len(w.Links))
for i, e := range w.Links {
v, err := IsLinkMetadataFromJSON(e)
if err != nil {
return err
}
u.Links[i] = v
}
return nil
}
// GroupInfo : The information about a group. Groups is a way to manage a list
// of users who need same access permission to the shared folder.
type GroupInfo struct {
@ -1465,7 +1501,7 @@ type MembershipInfo struct {
// Permissions : The permissions that requesting user has on this member.
// The set of permissions corresponds to the MemberActions in the request.
Permissions []*MemberPermission `json:"permissions,omitempty"`
// Initials : Suggested name initials for a member.
// Initials : Never set.
Initials string `json:"initials,omitempty"`
// IsInherited : True if the member has access from a parent folder.
IsInherited bool `json:"is_inherited"`
@ -2398,6 +2434,36 @@ func NewListSharedLinksResult(Links []IsSharedLinkMetadata, HasMore bool) *ListS
return s
}
// UnmarshalJSON deserializes into a ListSharedLinksResult instance
func (u *ListSharedLinksResult) UnmarshalJSON(b []byte) error {
type wrap struct {
// Links : Shared links applicable to the path argument.
Links []json.RawMessage `json:"links"`
// HasMore : Is true if there are additional shared links that have not
// been returned yet. Pass the cursor into `listSharedLinks` to retrieve
// them.
HasMore bool `json:"has_more"`
// Cursor : Pass the cursor into `listSharedLinks` to obtain the
// additional links. Cursor is returned only if no path is given.
Cursor string `json:"cursor,omitempty"`
}
var w wrap
if err := json.Unmarshal(b, &w); err != nil {
return err
}
u.Links = make([]IsSharedLinkMetadata, len(w.Links))
for i, e := range w.Links {
v, err := IsSharedLinkMetadataFromJSON(e)
if err != nil {
return err
}
u.Links[i] = v
}
u.HasMore = w.HasMore
u.Cursor = w.Cursor
return nil
}
// MemberAccessLevelResult : Contains information about a member's access level
// to content after an operation.
type MemberAccessLevelResult struct {
@ -3123,6 +3189,60 @@ const (
RevokeSharedLinkErrorSharedLinkMalformed = "shared_link_malformed"
)
// SetAccessInheritanceArg : has no documentation (yet)
type SetAccessInheritanceArg struct {
// AccessInheritance : The access inheritance settings for the folder.
AccessInheritance *AccessInheritance `json:"access_inheritance"`
// SharedFolderId : The ID for the shared folder.
SharedFolderId string `json:"shared_folder_id"`
}
// NewSetAccessInheritanceArg returns a new SetAccessInheritanceArg instance
func NewSetAccessInheritanceArg(SharedFolderId string) *SetAccessInheritanceArg {
s := new(SetAccessInheritanceArg)
s.SharedFolderId = SharedFolderId
s.AccessInheritance = &AccessInheritance{Tagged: dropbox.Tagged{"inherit"}}
return s
}
// SetAccessInheritanceError : has no documentation (yet)
type SetAccessInheritanceError struct {
dropbox.Tagged
// AccessError : Unable to access shared folder.
AccessError *SharedFolderAccessError `json:"access_error,omitempty"`
}
// Valid tag values for SetAccessInheritanceError
const (
SetAccessInheritanceErrorAccessError = "access_error"
SetAccessInheritanceErrorNoPermission = "no_permission"
SetAccessInheritanceErrorOther = "other"
)
// UnmarshalJSON deserializes into a SetAccessInheritanceError instance
func (u *SetAccessInheritanceError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// AccessError : Unable to access shared folder.
AccessError json.RawMessage `json:"access_error,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "access_error":
err = json.Unmarshal(w.AccessError, &u.AccessError)
if err != nil {
return err
}
}
return nil
}
// ShareFolderArgBase : has no documentation (yet)
type ShareFolderArgBase struct {
// AclUpdatePolicy : Who can add and remove members of this shared folder.
@ -3643,6 +3763,9 @@ type SharedFolderMetadata struct {
// TimeInvited : Timestamp indicating when the current user was invited to
// this shared folder.
TimeInvited time.Time `json:"time_invited"`
// AccessInheritance : Whether the folder inherits its members from its
// parent.
AccessInheritance *AccessInheritance `json:"access_inheritance"`
}
// NewSharedFolderMetadata returns a new SharedFolderMetadata instance
@ -3656,6 +3779,7 @@ func NewSharedFolderMetadata(AccessType *AccessLevel, IsInsideTeamFolder bool, I
s.PreviewUrl = PreviewUrl
s.SharedFolderId = SharedFolderId
s.TimeInvited = TimeInvited
s.AccessInheritance = &AccessInheritance{Tagged: dropbox.Tagged{"inherit"}}
return s
}
@ -4191,6 +4315,9 @@ type UserFileMembershipInfo struct {
// TimeLastSeen : The UTC timestamp of when the user has last seen the
// content, if they have.
TimeLastSeen time.Time `json:"time_last_seen,omitempty"`
// PlatformType : The platform on which the user has last seen the content,
// or unknown.
PlatformType *seen_state.PlatformType `json:"platform_type,omitempty"`
}
// NewUserFileMembershipInfo returns a new UserFileMembershipInfo instance
@ -4207,6 +4334,10 @@ func NewUserFileMembershipInfo(AccessType *AccessLevel, User *UserInfo) *UserFil
type UserInfo struct {
// AccountId : The account ID of the user.
AccountId string `json:"account_id"`
// Email : Email address of user.
Email string `json:"email"`
// DisplayName : The display name of the user.
DisplayName string `json:"display_name"`
// SameTeam : If the user is in the same team as current user.
SameTeam bool `json:"same_team"`
// TeamMemberId : The team member ID of the shared folder member. Only
@ -4215,9 +4346,11 @@ type UserInfo struct {
}
// NewUserInfo returns a new UserInfo instance
func NewUserInfo(AccountId string, SameTeam bool) *UserInfo {
func NewUserInfo(AccountId string, Email string, DisplayName string, SameTeam bool) *UserInfo {
s := new(UserInfo)
s.AccountId = AccountId
s.Email = Email
s.DisplayName = DisplayName
s.SameTeam = SameTeam
return s
}

View File

@ -272,6 +272,10 @@ type Client interface {
// TeamFolderRename : Changes an active team folder's name. Permission :
// Team member file access.
TeamFolderRename(arg *TeamFolderRenameArg) (res *TeamFolderMetadata, err error)
// TeamFolderUpdateSyncSettings : Updates the sync settings on a team folder
// or its contents. Use of this endpoint requires that the team has team
// selective sync enabled.
TeamFolderUpdateSyncSettings(arg *TeamFolderUpdateSyncSettingsArg) (res *TeamFolderMetadata, err error)
// TokenGetAuthenticatedAdmin : Returns the member profile of the admin who
// generated the team access token used to make the call.
TokenGetAuthenticatedAdmin() (res *TokenGetAuthenticatedAdminResult, err error)
@ -335,7 +339,7 @@ func (dbx *apiImpl) DevicesListMemberDevices(arg *ListMemberDevicesArg) (res *Li
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -404,7 +408,7 @@ func (dbx *apiImpl) DevicesListMembersDevices(arg *ListMembersDevicesArg) (res *
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -476,7 +480,7 @@ func (dbx *apiImpl) DevicesListTeamDevices(arg *ListTeamDevicesArg) (res *ListTe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -540,7 +544,7 @@ func (dbx *apiImpl) DevicesRevokeDeviceSession(arg *RevokeDeviceSessionArg) (err
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -609,7 +613,7 @@ func (dbx *apiImpl) DevicesRevokeDeviceSessionBatch(arg *RevokeDeviceSessionBatc
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -678,7 +682,7 @@ func (dbx *apiImpl) FeaturesGetValues(arg *FeaturesGetValuesBatchArg) (res *Feat
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -739,7 +743,7 @@ func (dbx *apiImpl) GetInfo() (res *TeamGetInfoResult, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -808,7 +812,7 @@ func (dbx *apiImpl) GroupsCreate(arg *GroupCreateArg) (res *GroupFullInfo, err e
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -877,7 +881,7 @@ func (dbx *apiImpl) GroupsDelete(arg *GroupSelector) (res *async.LaunchEmptyResu
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -946,7 +950,7 @@ func (dbx *apiImpl) GroupsGetInfo(arg *GroupsSelector) (res []*GroupsGetInfoItem
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1015,7 +1019,7 @@ func (dbx *apiImpl) GroupsJobStatusGet(arg *async.PollArg) (res *async.PollEmpty
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1084,7 +1088,7 @@ func (dbx *apiImpl) GroupsList(arg *GroupsListArg) (res *GroupsListResult, err e
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1153,7 +1157,7 @@ func (dbx *apiImpl) GroupsListContinue(arg *GroupsListContinueArg) (res *GroupsL
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1222,7 +1226,7 @@ func (dbx *apiImpl) GroupsMembersAdd(arg *GroupMembersAddArg) (res *GroupMembers
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1291,7 +1295,7 @@ func (dbx *apiImpl) GroupsMembersList(arg *GroupsMembersListArg) (res *GroupsMem
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1360,7 +1364,7 @@ func (dbx *apiImpl) GroupsMembersListContinue(arg *GroupsMembersListContinueArg)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1429,7 +1433,7 @@ func (dbx *apiImpl) GroupsMembersRemove(arg *GroupMembersRemoveArg) (res *GroupM
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1498,7 +1502,7 @@ func (dbx *apiImpl) GroupsMembersSetAccessType(arg *GroupMembersSetAccessTypeArg
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1567,7 +1571,7 @@ func (dbx *apiImpl) GroupsUpdate(arg *GroupUpdateArgs) (res *GroupFullInfo, err
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1636,7 +1640,7 @@ func (dbx *apiImpl) LinkedAppsListMemberLinkedApps(arg *ListMemberAppsArg) (res
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1705,7 +1709,7 @@ func (dbx *apiImpl) LinkedAppsListMembersLinkedApps(arg *ListMembersAppsArg) (re
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1777,7 +1781,7 @@ func (dbx *apiImpl) LinkedAppsListTeamLinkedApps(arg *ListTeamAppsArg) (res *Lis
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1841,7 +1845,7 @@ func (dbx *apiImpl) LinkedAppsRevokeLinkedApp(arg *RevokeLinkedApiAppArg) (err e
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1910,7 +1914,7 @@ func (dbx *apiImpl) LinkedAppsRevokeLinkedAppBatch(arg *RevokeLinkedApiAppBatchA
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1979,7 +1983,7 @@ func (dbx *apiImpl) MemberSpaceLimitsExcludedUsersAdd(arg *ExcludedUsersUpdateAr
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2048,7 +2052,7 @@ func (dbx *apiImpl) MemberSpaceLimitsExcludedUsersList(arg *ExcludedUsersListArg
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2117,7 +2121,7 @@ func (dbx *apiImpl) MemberSpaceLimitsExcludedUsersListContinue(arg *ExcludedUser
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2186,7 +2190,7 @@ func (dbx *apiImpl) MemberSpaceLimitsExcludedUsersRemove(arg *ExcludedUsersUpdat
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2255,7 +2259,7 @@ func (dbx *apiImpl) MemberSpaceLimitsGetCustomQuota(arg *CustomQuotaUsersArg) (r
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2324,7 +2328,7 @@ func (dbx *apiImpl) MemberSpaceLimitsRemoveCustomQuota(arg *CustomQuotaUsersArg)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2393,7 +2397,7 @@ func (dbx *apiImpl) MemberSpaceLimitsSetCustomQuota(arg *SetCustomQuotaArg) (res
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2462,7 +2466,7 @@ func (dbx *apiImpl) MembersAdd(arg *MembersAddArg) (res *MembersAddLaunch, err e
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2531,7 +2535,7 @@ func (dbx *apiImpl) MembersAddJobStatusGet(arg *async.PollArg) (res *MembersAddJ
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2600,7 +2604,7 @@ func (dbx *apiImpl) MembersGetInfo(arg *MembersGetInfoArgs) (res []*MembersGetIn
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2669,7 +2673,7 @@ func (dbx *apiImpl) MembersList(arg *MembersListArg) (res *MembersListResult, er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2738,7 +2742,7 @@ func (dbx *apiImpl) MembersListContinue(arg *MembersListContinueArg) (res *Membe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2802,7 +2806,7 @@ func (dbx *apiImpl) MembersRecover(arg *MembersRecoverArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2871,7 +2875,7 @@ func (dbx *apiImpl) MembersRemove(arg *MembersRemoveArg) (res *async.LaunchEmpty
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2940,7 +2944,7 @@ func (dbx *apiImpl) MembersRemoveJobStatusGet(arg *async.PollArg) (res *async.Po
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3004,7 +3008,7 @@ func (dbx *apiImpl) MembersSendWelcomeEmail(arg *UserSelectorArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3073,7 +3077,7 @@ func (dbx *apiImpl) MembersSetAdminPermissions(arg *MembersSetPermissionsArg) (r
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3142,7 +3146,7 @@ func (dbx *apiImpl) MembersSetProfile(arg *MembersSetProfileArg) (res *TeamMembe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3206,7 +3210,7 @@ func (dbx *apiImpl) MembersSuspend(arg *MembersDeactivateArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3270,7 +3274,7 @@ func (dbx *apiImpl) MembersUnsuspend(arg *MembersUnsuspendArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3339,7 +3343,7 @@ func (dbx *apiImpl) NamespacesList(arg *TeamNamespacesListArg) (res *TeamNamespa
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3408,7 +3412,7 @@ func (dbx *apiImpl) NamespacesListContinue(arg *TeamNamespacesListContinueArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3479,7 +3483,7 @@ func (dbx *apiImpl) PropertiesTemplateAdd(arg *file_properties.AddTemplateArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3550,7 +3554,7 @@ func (dbx *apiImpl) PropertiesTemplateGet(arg *file_properties.GetTemplateArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3613,7 +3617,7 @@ func (dbx *apiImpl) PropertiesTemplateList() (res *file_properties.ListTemplateR
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3684,7 +3688,7 @@ func (dbx *apiImpl) PropertiesTemplateUpdate(arg *file_properties.UpdateTemplate
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3753,7 +3757,7 @@ func (dbx *apiImpl) ReportsGetActivity(arg *DateRange) (res *GetActivityReport,
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3822,7 +3826,7 @@ func (dbx *apiImpl) ReportsGetDevices(arg *DateRange) (res *GetDevicesReport, er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3891,7 +3895,7 @@ func (dbx *apiImpl) ReportsGetMembership(arg *DateRange) (res *GetMembershipRepo
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3960,7 +3964,7 @@ func (dbx *apiImpl) ReportsGetStorage(arg *DateRange) (res *GetStorageReport, er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4029,7 +4033,7 @@ func (dbx *apiImpl) TeamFolderActivate(arg *TeamFolderIdArg) (res *TeamFolderMet
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4098,7 +4102,7 @@ func (dbx *apiImpl) TeamFolderArchive(arg *TeamFolderArchiveArg) (res *TeamFolde
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4167,7 +4171,7 @@ func (dbx *apiImpl) TeamFolderArchiveCheck(arg *async.PollArg) (res *TeamFolderA
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4236,7 +4240,7 @@ func (dbx *apiImpl) TeamFolderCreate(arg *TeamFolderCreateArg) (res *TeamFolderM
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4305,7 +4309,7 @@ func (dbx *apiImpl) TeamFolderGetInfo(arg *TeamFolderIdListArg) (res []*TeamFold
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4374,7 +4378,7 @@ func (dbx *apiImpl) TeamFolderList(arg *TeamFolderListArg) (res *TeamFolderListR
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4443,7 +4447,7 @@ func (dbx *apiImpl) TeamFolderListContinue(arg *TeamFolderListContinueArg) (res
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4507,7 +4511,7 @@ func (dbx *apiImpl) TeamFolderPermanentlyDelete(arg *TeamFolderIdArg) (err error
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4576,7 +4580,76 @@ func (dbx *apiImpl) TeamFolderRename(arg *TeamFolderRenameArg) (res *TeamFolderM
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//TeamFolderUpdateSyncSettingsAPIError is an error-wrapper for the team_folder/update_sync_settings route
type TeamFolderUpdateSyncSettingsAPIError struct {
dropbox.APIError
EndpointError *TeamFolderUpdateSyncSettingsError `json:"error"`
}
func (dbx *apiImpl) TeamFolderUpdateSyncSettings(arg *TeamFolderUpdateSyncSettingsArg) (res *TeamFolderMetadata, err error) {
cli := dbx.Client
dbx.Config.LogDebug("arg: %v", arg)
b, err := json.Marshal(arg)
if err != nil {
return
}
headers := map[string]string{
"Content-Type": "application/json",
}
req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "team", "team_folder/update_sync_settings", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.LogInfo("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.LogInfo("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.LogDebug("body: %v", body)
if resp.StatusCode == http.StatusOK {
err = json.Unmarshal(body, &res)
if err != nil {
return
}
return
}
if resp.StatusCode == http.StatusConflict {
var apiError TeamFolderUpdateSyncSettingsAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4637,7 +4710,7 @@ func (dbx *apiImpl) TokenGetAuthenticatedAdmin() (res *TokenGetAuthenticatedAdmi
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return

View File

@ -26,6 +26,7 @@ import (
"time"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_common"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_policies"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users"
@ -497,7 +498,7 @@ const (
ExcludedUsersUpdateStatusOther = "other"
)
// Feature : A set of features that Dropbox for Business account support.
// Feature : A set of features that a Dropbox Business account may support.
type Feature struct {
dropbox.Tagged
}
@ -507,11 +508,12 @@ const (
FeatureUploadApiRateLimit = "upload_api_rate_limit"
FeatureHasTeamSharedDropbox = "has_team_shared_dropbox"
FeatureHasTeamFileEvents = "has_team_file_events"
FeatureHasTeamSelectiveSync = "has_team_selective_sync"
FeatureOther = "other"
)
// FeatureValue : The values correspond to entries in `Feature`. You may get
// different value according to your Dropbox for Business plan.
// different value according to your Dropbox Business plan.
type FeatureValue struct {
dropbox.Tagged
// UploadApiRateLimit : has no documentation (yet)
@ -520,6 +522,8 @@ type FeatureValue struct {
HasTeamSharedDropbox *HasTeamSharedDropboxValue `json:"has_team_shared_dropbox,omitempty"`
// HasTeamFileEvents : has no documentation (yet)
HasTeamFileEvents *HasTeamFileEventsValue `json:"has_team_file_events,omitempty"`
// HasTeamSelectiveSync : has no documentation (yet)
HasTeamSelectiveSync *HasTeamSelectiveSyncValue `json:"has_team_selective_sync,omitempty"`
}
// Valid tag values for FeatureValue
@ -527,6 +531,7 @@ const (
FeatureValueUploadApiRateLimit = "upload_api_rate_limit"
FeatureValueHasTeamSharedDropbox = "has_team_shared_dropbox"
FeatureValueHasTeamFileEvents = "has_team_file_events"
FeatureValueHasTeamSelectiveSync = "has_team_selective_sync"
FeatureValueOther = "other"
)
@ -540,6 +545,8 @@ func (u *FeatureValue) UnmarshalJSON(body []byte) error {
HasTeamSharedDropbox json.RawMessage `json:"has_team_shared_dropbox,omitempty"`
// HasTeamFileEvents : has no documentation (yet)
HasTeamFileEvents json.RawMessage `json:"has_team_file_events,omitempty"`
// HasTeamSelectiveSync : has no documentation (yet)
HasTeamSelectiveSync json.RawMessage `json:"has_team_selective_sync,omitempty"`
}
var w wrap
var err error
@ -563,6 +570,12 @@ func (u *FeatureValue) UnmarshalJSON(body []byte) error {
case "has_team_file_events":
err = json.Unmarshal(w.HasTeamFileEvents, &u.HasTeamFileEvents)
if err != nil {
return err
}
case "has_team_selective_sync":
err = json.Unmarshal(w.HasTeamSelectiveSync, &u.HasTeamSelectiveSync)
if err != nil {
return err
}
@ -1531,10 +1544,45 @@ func (u *HasTeamFileEventsValue) UnmarshalJSON(body []byte) error {
return nil
}
// HasTeamSelectiveSyncValue : The value for `Feature.has_team_selective_sync`.
type HasTeamSelectiveSyncValue struct {
dropbox.Tagged
// HasTeamSelectiveSync : Does this team have team selective sync enabled.
HasTeamSelectiveSync bool `json:"has_team_selective_sync,omitempty"`
}
// Valid tag values for HasTeamSelectiveSyncValue
const (
HasTeamSelectiveSyncValueHasTeamSelectiveSync = "has_team_selective_sync"
HasTeamSelectiveSyncValueOther = "other"
)
// UnmarshalJSON deserializes into a HasTeamSelectiveSyncValue instance
func (u *HasTeamSelectiveSyncValue) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "has_team_selective_sync":
err = json.Unmarshal(body, &u.HasTeamSelectiveSync)
if err != nil {
return err
}
}
return nil
}
// HasTeamSharedDropboxValue : The value for `Feature.has_team_shared_dropbox`.
type HasTeamSharedDropboxValue struct {
dropbox.Tagged
// HasTeamSharedDropbox : Does this team have a team shared dropbox.
// HasTeamSharedDropbox : Does this team have a shared team root.
HasTeamSharedDropbox bool `json:"has_team_shared_dropbox,omitempty"`
}
@ -1899,6 +1947,8 @@ type MemberAddArg struct {
SendWelcomeEmail bool `json:"send_welcome_email"`
// Role : has no documentation (yet)
Role *AdminTier `json:"role"`
// IsDirectoryRestricted : Whether a user is directory restricted.
IsDirectoryRestricted bool `json:"is_directory_restricted,omitempty"`
}
// NewMemberAddArg returns a new MemberAddArg instance
@ -2113,6 +2163,8 @@ type MemberProfile struct {
// PersistentId : Persistent ID that a team can attach to the user. The
// persistent ID is unique ID to be used for SAML authentication.
PersistentId string `json:"persistent_id,omitempty"`
// IsDirectoryRestricted : Whether the user is a directory restricted user.
IsDirectoryRestricted bool `json:"is_directory_restricted,omitempty"`
}
// NewMemberProfile returns a new MemberProfile instance
@ -2191,7 +2243,7 @@ func (u *MembersAddJobStatus) UnmarshalJSON(body []byte) error {
// Complete : The asynchronous job has finished. For each member that
// was specified in the parameter `MembersAddArg` that was provided to
// `membersAdd`, a corresponding item is returned in this list.
Complete json.RawMessage `json:"complete,omitempty"`
Complete []json.RawMessage `json:"complete,omitempty"`
}
var w wrap
var err error
@ -2238,7 +2290,7 @@ func (u *MembersAddLaunch) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Complete : has no documentation (yet)
Complete json.RawMessage `json:"complete,omitempty"`
Complete []json.RawMessage `json:"complete,omitempty"`
}
var w wrap
var err error
@ -2512,6 +2564,7 @@ const (
MembersRemoveErrorCannotKeepAccountAndTransfer = "cannot_keep_account_and_transfer"
MembersRemoveErrorCannotKeepAccountAndDeleteData = "cannot_keep_account_and_delete_data"
MembersRemoveErrorEmailAddressTooLongToBeDisabled = "email_address_too_long_to_be_disabled"
MembersRemoveErrorCannotKeepInvitedUserAccount = "cannot_keep_invited_user_account"
)
// MembersSendWelcomeError :
@ -2591,6 +2644,9 @@ type MembersSetProfileArg struct {
// NewPersistentId : New persistent ID. This field only available to teams
// using persistent ID SAML configuration.
NewPersistentId string `json:"new_persistent_id,omitempty"`
// NewIsDirectoryRestricted : New value for whether the user is a directory
// restricted user.
NewIsDirectoryRestricted bool `json:"new_is_directory_restricted,omitempty"`
}
// NewMembersSetProfileArg returns a new MembersSetProfileArg instance
@ -2617,6 +2673,7 @@ const (
MembersSetProfileErrorParamCannotBeEmpty = "param_cannot_be_empty"
MembersSetProfileErrorPersistentIdDisabled = "persistent_id_disabled"
MembersSetProfileErrorPersistentIdUsedByOtherUser = "persistent_id_used_by_other_user"
MembersSetProfileErrorDirectoryRestrictedOff = "directory_restricted_off"
MembersSetProfileErrorOther = "other"
)
@ -2711,8 +2768,8 @@ type NamespaceMetadata struct {
NamespaceId string `json:"namespace_id"`
// NamespaceType : The type of this namespace.
NamespaceType *NamespaceType `json:"namespace_type"`
// TeamMemberId : If this is a team member folder, the ID of the team
// member. Otherwise, this field is not present.
// TeamMemberId : If this is a team member or app folder, the ID of the
// owning team member. Otherwise, this field is not present.
TeamMemberId string `json:"team_member_id,omitempty"`
}
@ -3327,6 +3384,9 @@ func (u *TeamFolderArchiveLaunch) UnmarshalJSON(body []byte) error {
type TeamFolderCreateArg struct {
// Name : Name for the new team folder.
Name string `json:"name"`
// SyncSetting : The sync setting to apply to this team folder. Only
// permitted if the team has team selective sync enabled.
SyncSetting *files.SyncSettingArg `json:"sync_setting,omitempty"`
}
// NewTeamFolderCreateArg returns a new TeamFolderCreateArg instance
@ -3339,6 +3399,8 @@ func NewTeamFolderCreateArg(Name string) *TeamFolderCreateArg {
// TeamFolderCreateError : has no documentation (yet)
type TeamFolderCreateError struct {
dropbox.Tagged
// SyncSettingsError : An error occurred setting the sync settings.
SyncSettingsError *files.SyncSettingsError `json:"sync_settings_error,omitempty"`
}
// Valid tag values for TeamFolderCreateError
@ -3346,9 +3408,34 @@ const (
TeamFolderCreateErrorInvalidFolderName = "invalid_folder_name"
TeamFolderCreateErrorFolderNameAlreadyUsed = "folder_name_already_used"
TeamFolderCreateErrorFolderNameReserved = "folder_name_reserved"
TeamFolderCreateErrorSyncSettingsError = "sync_settings_error"
TeamFolderCreateErrorOther = "other"
)
// UnmarshalJSON deserializes into a TeamFolderCreateError instance
func (u *TeamFolderCreateError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// SyncSettingsError : An error occurred setting the sync settings.
SyncSettingsError json.RawMessage `json:"sync_settings_error,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "sync_settings_error":
err = json.Unmarshal(w.SyncSettingsError, &u.SyncSettingsError)
if err != nil {
return err
}
}
return nil
}
// TeamFolderGetInfoItem : has no documentation (yet)
type TeamFolderGetInfoItem struct {
dropbox.Tagged
@ -3502,18 +3589,24 @@ type TeamFolderMetadata struct {
Name string `json:"name"`
// Status : The status of the team folder.
Status *TeamFolderStatus `json:"status"`
// IsTeamSharedDropbox : True if this team folder is the team shared
// dropbox.
// IsTeamSharedDropbox : True if this team folder is a shared team root.
IsTeamSharedDropbox bool `json:"is_team_shared_dropbox"`
// SyncSetting : The sync setting applied to this team folder.
SyncSetting *files.SyncSetting `json:"sync_setting"`
// ContentSyncSettings : Sync settings applied to contents of this team
// folder.
ContentSyncSettings []*files.ContentSyncSetting `json:"content_sync_settings"`
}
// NewTeamFolderMetadata returns a new TeamFolderMetadata instance
func NewTeamFolderMetadata(TeamFolderId string, Name string, Status *TeamFolderStatus, IsTeamSharedDropbox bool) *TeamFolderMetadata {
func NewTeamFolderMetadata(TeamFolderId string, Name string, Status *TeamFolderStatus, IsTeamSharedDropbox bool, SyncSetting *files.SyncSetting, ContentSyncSettings []*files.ContentSyncSetting) *TeamFolderMetadata {
s := new(TeamFolderMetadata)
s.TeamFolderId = TeamFolderId
s.Name = Name
s.Status = Status
s.IsTeamSharedDropbox = IsTeamSharedDropbox
s.SyncSetting = SyncSetting
s.ContentSyncSettings = ContentSyncSettings
return s
}
@ -3677,6 +3770,94 @@ const (
TeamFolderTeamSharedDropboxErrorOther = "other"
)
// TeamFolderUpdateSyncSettingsArg : has no documentation (yet)
type TeamFolderUpdateSyncSettingsArg struct {
TeamFolderIdArg
// SyncSetting : Sync setting to apply to the team folder itself. Only
// meaningful if the team folder is not a shared team root.
SyncSetting *files.SyncSettingArg `json:"sync_setting,omitempty"`
// ContentSyncSettings : Sync settings to apply to contents of this team
// folder.
ContentSyncSettings []*files.ContentSyncSettingArg `json:"content_sync_settings,omitempty"`
}
// NewTeamFolderUpdateSyncSettingsArg returns a new TeamFolderUpdateSyncSettingsArg instance
func NewTeamFolderUpdateSyncSettingsArg(TeamFolderId string) *TeamFolderUpdateSyncSettingsArg {
s := new(TeamFolderUpdateSyncSettingsArg)
s.TeamFolderId = TeamFolderId
return s
}
// TeamFolderUpdateSyncSettingsError : has no documentation (yet)
type TeamFolderUpdateSyncSettingsError struct {
dropbox.Tagged
// AccessError : has no documentation (yet)
AccessError *TeamFolderAccessError `json:"access_error,omitempty"`
// StatusError : has no documentation (yet)
StatusError *TeamFolderInvalidStatusError `json:"status_error,omitempty"`
// TeamSharedDropboxError : has no documentation (yet)
TeamSharedDropboxError *TeamFolderTeamSharedDropboxError `json:"team_shared_dropbox_error,omitempty"`
// SyncSettingsError : An error occurred setting the sync settings.
SyncSettingsError *files.SyncSettingsError `json:"sync_settings_error,omitempty"`
}
// Valid tag values for TeamFolderUpdateSyncSettingsError
const (
TeamFolderUpdateSyncSettingsErrorAccessError = "access_error"
TeamFolderUpdateSyncSettingsErrorStatusError = "status_error"
TeamFolderUpdateSyncSettingsErrorTeamSharedDropboxError = "team_shared_dropbox_error"
TeamFolderUpdateSyncSettingsErrorOther = "other"
TeamFolderUpdateSyncSettingsErrorSyncSettingsError = "sync_settings_error"
)
// UnmarshalJSON deserializes into a TeamFolderUpdateSyncSettingsError instance
func (u *TeamFolderUpdateSyncSettingsError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// AccessError : has no documentation (yet)
AccessError json.RawMessage `json:"access_error,omitempty"`
// StatusError : has no documentation (yet)
StatusError json.RawMessage `json:"status_error,omitempty"`
// TeamSharedDropboxError : has no documentation (yet)
TeamSharedDropboxError json.RawMessage `json:"team_shared_dropbox_error,omitempty"`
// SyncSettingsError : An error occurred setting the sync settings.
SyncSettingsError json.RawMessage `json:"sync_settings_error,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "access_error":
err = json.Unmarshal(w.AccessError, &u.AccessError)
if err != nil {
return err
}
case "status_error":
err = json.Unmarshal(w.StatusError, &u.StatusError)
if err != nil {
return err
}
case "team_shared_dropbox_error":
err = json.Unmarshal(w.TeamSharedDropboxError, &u.TeamSharedDropboxError)
if err != nil {
return err
}
case "sync_settings_error":
err = json.Unmarshal(w.SyncSettingsError, &u.SyncSettingsError)
if err != nil {
return err
}
}
return nil
}
// TeamGetInfoResult : has no documentation (yet)
type TeamGetInfoResult struct {
// Name : The name of the team.

View File

@ -76,6 +76,19 @@ const (
GroupTypeOther = "other"
)
// MemberSpaceLimitType : The type of the space limit imposed on a team member.
type MemberSpaceLimitType struct {
dropbox.Tagged
}
// Valid tag values for MemberSpaceLimitType
const (
MemberSpaceLimitTypeOff = "off"
MemberSpaceLimitTypeAlertOnly = "alert_only"
MemberSpaceLimitTypeStopSync = "stop_sync"
MemberSpaceLimitTypeOther = "other"
)
// TimeRange : Time range.
type TimeRange struct {
// StartTime : Optional starting time (inclusive).

View File

@ -31,7 +31,14 @@ import (
// Client interface describes all routes in this namespace
type Client interface {
// GetEvents : Retrieves team events. Permission : Team Auditing.
// GetEvents : Retrieves team events. Events have a lifespan of two years.
// Events older than two years will not be returned. Many attributes note
// 'may be missing due to historical data gap'. Note that the
// file_operations category and & analogous paper events are not available
// on all Dropbox Business `plans` </business/plans-comparison>. Use
// `features/get_values`
// </developers/documentation/http/teams#team-features-get_values> to check
// for this feature. Permission : Team Auditing.
GetEvents(arg *GetTeamEventsArg) (res *GetTeamEventsResult, err error)
// GetEventsContinue : Once a cursor has been retrieved from `getEvents`,
// use this to paginate through all events. Permission : Team Auditing.
@ -96,7 +103,7 @@ func (dbx *apiImpl) GetEvents(arg *GetTeamEventsArg) (res *GetTeamEventsResult,
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -165,7 +172,7 @@ func (dbx *apiImpl) GetEventsContinue(arg *GetTeamEventsContinueArg) (res *GetTe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return

File diff suppressed because it is too large Load Diff

View File

@ -149,6 +149,42 @@ const (
SharedLinkCreatePolicyOther = "other"
)
// ShowcaseDownloadPolicy : has no documentation (yet)
type ShowcaseDownloadPolicy struct {
dropbox.Tagged
}
// Valid tag values for ShowcaseDownloadPolicy
const (
ShowcaseDownloadPolicyDisabled = "disabled"
ShowcaseDownloadPolicyEnabled = "enabled"
ShowcaseDownloadPolicyOther = "other"
)
// ShowcaseEnabledPolicy : has no documentation (yet)
type ShowcaseEnabledPolicy struct {
dropbox.Tagged
}
// Valid tag values for ShowcaseEnabledPolicy
const (
ShowcaseEnabledPolicyDisabled = "disabled"
ShowcaseEnabledPolicyEnabled = "enabled"
ShowcaseEnabledPolicyOther = "other"
)
// ShowcaseExternalSharingPolicy : has no documentation (yet)
type ShowcaseExternalSharingPolicy struct {
dropbox.Tagged
}
// Valid tag values for ShowcaseExternalSharingPolicy
const (
ShowcaseExternalSharingPolicyDisabled = "disabled"
ShowcaseExternalSharingPolicyEnabled = "enabled"
ShowcaseExternalSharingPolicyOther = "other"
)
// SmartSyncPolicy : has no documentation (yet)
type SmartSyncPolicy struct {
dropbox.Tagged

View File

@ -104,7 +104,7 @@ func (dbx *apiImpl) GetAccount(arg *GetAccountArg) (res *BasicAccount, err error
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -176,7 +176,7 @@ func (dbx *apiImpl) GetAccountBatch(arg *GetAccountBatchArg) (res []*BasicAccoun
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -240,7 +240,7 @@ func (dbx *apiImpl) GetCurrentAccount() (res *FullAccount, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -304,7 +304,7 @@ func (dbx *apiImpl) GetSpaceUsage() (res *SpaceUsage, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return

View File

@ -27,6 +27,7 @@ import (
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/common"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_common"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_policies"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users_common"
)
@ -128,6 +129,75 @@ func NewFullAccount(AccountId string, Name *Name, Email string, EmailVerified bo
return s
}
// UnmarshalJSON deserializes into a FullAccount instance
func (u *FullAccount) UnmarshalJSON(b []byte) error {
type wrap struct {
// AccountId : The user's unique Dropbox ID.
AccountId string `json:"account_id"`
// Name : Details of a user's name.
Name *Name `json:"name"`
// Email : The user's e-mail address. Do not rely on this without
// checking the `email_verified` field. Even then, it's possible that
// the user has since lost access to their e-mail.
Email string `json:"email"`
// EmailVerified : Whether the user has verified their e-mail address.
EmailVerified bool `json:"email_verified"`
// Disabled : Whether the user has been disabled.
Disabled bool `json:"disabled"`
// Locale : The language that the user specified. Locale tags will be
// `IETF language tags`
// <http://en.wikipedia.org/wiki/IETF_language_tag>.
Locale string `json:"locale"`
// ReferralLink : The user's `referral link`
// <https://www.dropbox.com/referrals>.
ReferralLink string `json:"referral_link"`
// IsPaired : Whether the user has a personal and work account. If the
// current account is personal, then `team` will always be nil, but
// `is_paired` will indicate if a work account is linked.
IsPaired bool `json:"is_paired"`
// AccountType : What type of account this user has.
AccountType *users_common.AccountType `json:"account_type"`
// RootInfo : The root info for this account.
RootInfo json.RawMessage `json:"root_info"`
// ProfilePhotoUrl : URL for the photo representing the user, if one is
// set.
ProfilePhotoUrl string `json:"profile_photo_url,omitempty"`
// Country : The user's two-letter country code, if available. Country
// codes are based on `ISO 3166-1`
// <http://en.wikipedia.org/wiki/ISO_3166-1>.
Country string `json:"country,omitempty"`
// Team : If this account is a member of a team, information about that
// team.
Team *FullTeam `json:"team,omitempty"`
// TeamMemberId : This account's unique team member id. This field will
// only be present if `team` is present.
TeamMemberId string `json:"team_member_id,omitempty"`
}
var w wrap
if err := json.Unmarshal(b, &w); err != nil {
return err
}
u.AccountId = w.AccountId
u.Name = w.Name
u.Email = w.Email
u.EmailVerified = w.EmailVerified
u.Disabled = w.Disabled
u.Locale = w.Locale
u.ReferralLink = w.ReferralLink
u.IsPaired = w.IsPaired
u.AccountType = w.AccountType
RootInfo, err := common.IsRootInfoFromJSON(w.RootInfo)
if err != nil {
return err
}
u.RootInfo = RootInfo
u.ProfilePhotoUrl = w.ProfilePhotoUrl
u.Country = w.Country
u.Team = w.Team
u.TeamMemberId = w.TeamMemberId
return nil
}
// Team : Information about a team.
type Team struct {
// Id : The team's unique ID.
@ -353,12 +423,21 @@ type TeamSpaceAllocation struct {
Used uint64 `json:"used"`
// Allocated : The total space allocated to the user's team (bytes).
Allocated uint64 `json:"allocated"`
// UserWithinTeamSpaceAllocated : The total space allocated to the user
// within its team allocated space (0 means that no restriction is imposed
// on the user's quota within its team).
UserWithinTeamSpaceAllocated uint64 `json:"user_within_team_space_allocated"`
// UserWithinTeamSpaceLimitType : The type of the space limit imposed on the
// team member (off, alert_only, stop_sync).
UserWithinTeamSpaceLimitType *team_common.MemberSpaceLimitType `json:"user_within_team_space_limit_type"`
}
// NewTeamSpaceAllocation returns a new TeamSpaceAllocation instance
func NewTeamSpaceAllocation(Used uint64, Allocated uint64) *TeamSpaceAllocation {
func NewTeamSpaceAllocation(Used uint64, Allocated uint64, UserWithinTeamSpaceAllocated uint64, UserWithinTeamSpaceLimitType *team_common.MemberSpaceLimitType) *TeamSpaceAllocation {
s := new(TeamSpaceAllocation)
s.Used = Used
s.Allocated = Allocated
s.UserWithinTeamSpaceAllocated = UserWithinTeamSpaceAllocated
s.UserWithinTeamSpaceLimitType = UserWithinTeamSpaceLimitType
return s
}

View File

@ -15,7 +15,7 @@ stone -v -a :all go_types.stoneg.py "$gen_dir" "$spec_dir"/*.stone
stone -v -a :all go_client.stoneg.py "$gen_dir" "$spec_dir"/*.stone
# Update SDK and API spec versions
sdk_version=${1:-"3.0.0"}
sdk_version=${1:-"4.2.0"}
pushd ${spec_dir}
spec_version=$(git rev-parse --short HEAD)
popd

View File

@ -192,7 +192,8 @@ class GoClientBackend(CodeBackend):
out('err = apiError')
out('return')
out('var apiError dropbox.APIError')
with self.block('if resp.StatusCode == http.StatusBadRequest'):
with self.block("if resp.StatusCode == http.StatusBadRequest || "
"resp.StatusCode == http.StatusInternalServerError"):
out('apiError.ErrorSummary = string(body)')
out('err = apiError')
out('return')

View File

@ -12,6 +12,7 @@ from stone.ir import (
unwrap_nullable,
is_composite_type,
is_list_type,
is_primitive_type,
is_struct_type,
Void,
)
@ -68,10 +69,14 @@ def _rename_if_reserved(s):
return s
def fmt_type(data_type, namespace=None, use_interface=False):
def fmt_type(data_type, namespace=None, use_interface=False, raw=False):
data_type, nullable = unwrap_nullable(data_type)
if is_list_type(data_type):
return '[]%s' % fmt_type(data_type.data_type, namespace, use_interface)
if raw and is_primitive_type(data_type.data_type):
return "json.RawMessage"
return '[]%s' % fmt_type(data_type.data_type, namespace, use_interface, raw)
if raw:
return "json.RawMessage"
type_name = data_type.name
if use_interface and _needs_base_type(data_type):
type_name = 'Is' + type_name

View File

@ -1,109 +0,0 @@
// Copyright (c) Dropbox, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package files
import "encoding/json"
type listFolderResult struct {
Entries []json.RawMessage `json:"entries"`
Cursor string `json:"cursor"`
HasMore bool `json:"has_more"`
}
// UnmarshalJSON deserializes into a ListFolderResult instance
func (r *ListFolderResult) UnmarshalJSON(b []byte) error {
var l listFolderResult
if err := json.Unmarshal(b, &l); err != nil {
return err
}
r.Cursor = l.Cursor
r.HasMore = l.HasMore
r.Entries = make([]IsMetadata, len(l.Entries))
for i, e := range l.Entries {
metadata, err := IsMetadataFromJSON(e)
if err != nil {
return err
}
r.Entries[i] = metadata
}
return nil
}
type searchMatch struct {
MatchType *SearchMatchType `json:"match_type"`
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a SearchMatch instance
func (s *SearchMatch) UnmarshalJSON(b []byte) error {
var m searchMatch
if err := json.Unmarshal(b, &m); err != nil {
return err
}
s.MatchType = m.MatchType
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}
type deleteResult struct {
FileOpsResult
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a DeleteResult instance
func (s *DeleteResult) UnmarshalJSON(b []byte) error {
var m deleteResult
if err := json.Unmarshal(b, &m); err != nil {
return err
}
s.FileOpsResult = m.FileOpsResult
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}
type relocationResult struct {
FileOpsResult
// Metadata : Metadata of the relocated object.
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a RelocationResult instance
func (s *RelocationResult) UnmarshalJSON(b []byte) error {
var m relocationResult
if err := json.Unmarshal(b, &m); err != nil {
return err
}
s.FileOpsResult = m.FileOpsResult
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}

View File

@ -26,6 +26,7 @@ import (
"log"
"net/http"
"golang.org/x/net/context"
"golang.org/x/oauth2"
)
@ -77,12 +78,12 @@ const (
LogInfo
)
func (l LogLevel) ShouldLog(v LogLevel) bool {
return l > v || l & v == v
func (l LogLevel) shouldLog(v LogLevel) bool {
return l > v || l&v == v
}
func (c *Config) doLog(l LogLevel, format string, v ...interface{}) {
if !c.LogLevel.ShouldLog(l) {
if !c.LogLevel.shouldLog(l) {
return
}
@ -152,7 +153,7 @@ func NewContext(c Config) Context {
if client == nil {
var conf = &oauth2.Config{Endpoint: OAuthEndpoint(domain)}
tok := &oauth2.Token{AccessToken: c.Token}
client = conf.Client(oauth2.NoContext, tok)
client = conf.Client(context.Background(), tok)
}
headerGenerator := c.HeaderGenerator

View File

@ -4,6 +4,7 @@ import shutil
from stone.backend import CodeBackend
from stone.ir import (
is_boolean_type,
is_list_type,
is_nullable_type,
is_primitive_type,
is_struct_type,
@ -16,6 +17,8 @@ from go_helpers import (
fmt_type,
fmt_var,
generate_doc,
needs_base_type,
_needs_base_type
)
@ -26,10 +29,6 @@ class GoTypesBackend(CodeBackend):
self.target_folder_path)
for namespace in api.namespaces.values():
self._generate_namespace(namespace)
if namespace.name == 'files' or namespace.name == 'sharing':
self.logger.info('Copying metadata.go to files')
shutil.copy(os.path.join(rsrc_folder, namespace.name, 'metadata.go'),
os.path.join(self.target_folder_path, namespace.name))
def _generate_namespace(self, namespace):
file_name = os.path.join(self.target_folder_path, namespace.name,
@ -90,6 +89,39 @@ class GoTypesBackend(CodeBackend):
self.emit('// ExtraHeaders can be used to pass Range, If-None-Match headers')
self.emit('ExtraHeaders map[string]string `json:"-"`')
self._generate_struct_builder(struct)
self.emit()
if needs_base_type(struct):
self.emit('// UnmarshalJSON deserializes into a %s instance' % struct.name)
with self.block('func (u *%s) UnmarshalJSON(b []byte) error' % struct.name):
with self.block('type wrap struct'):
for field in struct.all_fields:
self._generate_field(field, namespace=struct.namespace,
raw=_needs_base_type(field.data_type))
self.emit('var w wrap')
with self.block('if err := json.Unmarshal(b, &w); err != nil'):
self.emit('return err')
for field in struct.all_fields:
dt = field.data_type
fn = fmt_var(field.name)
tn = fmt_type(dt, namespace=struct.namespace, use_interface=True)
if _needs_base_type(dt):
if is_list_type(dt):
self.emit("u.{0} = make({1}, len(w.{0}))".format(fn, tn))
# Grab the underlying type to get the correct Is...FromJSON method
tn = fmt_type(dt.data_type, namespace=struct.namespace, use_interface=True)
with self.block("for i, e := range w.{0}".format(fn)):
self.emit("v, err := {1}FromJSON(e)".format(fn, tn))
with self.block('if err != nil'):
self.emit('return err')
self.emit("u.{0}[i] = v".format(fn))
else:
self.emit("{0}, err := {1}FromJSON(w.{0})".format(fn, tn))
with self.block('if err != nil'):
self.emit('return err')
self.emit("u.{0} = {0}".format(fn))
else:
self.emit("u.{0} = w.{0}".format(fn))
self.emit('return nil')
def _generate_struct_builder(self, struct):
fields = ["%s %s" % (fmt_var(field.name),
@ -122,14 +154,11 @@ class GoTypesBackend(CodeBackend):
def _generate_field(self, field, union_field=False, namespace=None, raw=False):
generate_doc(self, field)
field_name = fmt_var(field.name)
type_name = fmt_type(field.data_type, namespace, use_interface=True)
type_name = fmt_type(field.data_type, namespace, use_interface=True, raw=raw)
json_tag = '`json:"%s"`' % field.name
if is_nullable_type(field.data_type) or union_field:
json_tag = '`json:"%s,omitempty"`' % field.name
if raw:
self.emit('%s json.RawMessage %s' % (field_name, json_tag))
else:
self.emit('%s %s %s' % (field_name, type_name, json_tag))
self.emit('%s %s %s' % (field_name, type_name, json_tag))
def _generate_union(self, union):
self._generate_union_helper(union)
@ -187,8 +216,7 @@ class GoTypesBackend(CodeBackend):
if is_union_type(field.data_type):
self.emit('err = json.Unmarshal(w.{0}, &u.{0})'
.format(field_name))
elif is_struct_type(field.data_type) and \
field.data_type.has_enumerated_subtypes():
elif _needs_base_type(field.data_type):
self.emit("u.{0}, err = Is{1}FromJSON(body)"
.format(field_name, field.data_type.name))
else: