vendor: update all dependencies

* Update all dependencies
  * Remove all `[[constraint]]` from Gopkg.toml
  * Add in the minimum number of `[[override]]` to build
  * Remove go get of github.com/inconshreveable/mousetrap as it is vendored
  * Update docs with new policy on constraints
This commit is contained in:
Nick Craig-Wood 2018-05-02 17:09:45 +01:00
parent 21383877df
commit 6427029c4e
4902 changed files with 1443417 additions and 227283 deletions

View file

@ -6,18 +6,11 @@ go:
- 1.8.x
- 1.9.x
install: go get -u golang.org/x/oauth2
install:
- go get -u golang.org/x/oauth2
before_script:
- go get -u github.com/mitchellh/gox
script:
- 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/...
- gox -osarch="darwin/amd64 linux/amd64 windows/amd64" ./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) [![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)
# 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)
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return

View file

@ -118,12 +118,11 @@ 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 team
// with a separate team root. 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 CDM
// team. 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"`
}
@ -206,8 +205,7 @@ func IsRootInfoFromJSON(data []byte) (IsRootInfo, error) {
return nil, nil
}
// TeamRootInfo : Root info when user is member of a team with a separate root
// namespace ID.
// TeamRootInfo : Root info when user is member of a CDM team.
type TeamRootInfo struct {
RootInfo
// HomePath : The path for user's home directory under the shared team root.
@ -223,8 +221,7 @@ func NewTeamRootInfo(RootNamespaceId string, HomeNamespaceId string, HomePath st
return s
}
// 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.
// UserRootInfo : Root info when user is not member of a CDM team.
type UserRootInfo struct {
RootInfo
}

View file

@ -155,7 +155,7 @@ func (dbx *apiImpl) PropertiesAdd(arg *AddPropertiesArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -222,7 +222,7 @@ func (dbx *apiImpl) PropertiesOverwrite(arg *OverwritePropertyGroupArg) (err err
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -289,7 +289,7 @@ func (dbx *apiImpl) PropertiesRemove(arg *RemovePropertiesArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -361,7 +361,7 @@ func (dbx *apiImpl) PropertiesSearch(arg *PropertiesSearchArg) (res *PropertiesS
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -433,7 +433,7 @@ func (dbx *apiImpl) PropertiesSearchContinue(arg *PropertiesSearchContinueArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -500,7 +500,7 @@ func (dbx *apiImpl) PropertiesUpdate(arg *UpdatePropertiesArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -569,7 +569,7 @@ func (dbx *apiImpl) TemplatesAddForTeam(arg *AddTemplateArg) (res *AddTemplateRe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -641,7 +641,7 @@ func (dbx *apiImpl) TemplatesAddForUser(arg *AddTemplateArg) (res *AddTemplateRe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -710,7 +710,7 @@ func (dbx *apiImpl) TemplatesGetForTeam(arg *GetTemplateArg) (res *GetTemplateRe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -782,7 +782,7 @@ func (dbx *apiImpl) TemplatesGetForUser(arg *GetTemplateArg) (res *GetTemplateRe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -843,7 +843,7 @@ func (dbx *apiImpl) TemplatesListForTeam() (res *ListTemplateResult, err error)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -907,7 +907,7 @@ func (dbx *apiImpl) TemplatesListForUser() (res *ListTemplateResult, err error)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -971,7 +971,7 @@ func (dbx *apiImpl) TemplatesRemoveForTeam(arg *RemoveTemplateArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1038,7 +1038,7 @@ func (dbx *apiImpl) TemplatesRemoveForUser(arg *RemoveTemplateArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1107,7 +1107,7 @@ func (dbx *apiImpl) TemplatesUpdateForTeam(arg *UpdateTemplateArg) (res *UpdateT
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1179,7 +1179,7 @@ func (dbx *apiImpl) TemplatesUpdateForUser(arg *UpdateTemplateArg) (res *UpdateT
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return

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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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

@ -100,10 +100,6 @@ 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)
@ -352,7 +348,7 @@ func (dbx *apiImpl) AlphaGetMetadata(arg *AlphaGetMetadataArg) (res IsMetadata,
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -428,7 +424,7 @@ func (dbx *apiImpl) AlphaUpload(arg *CommitInfoWithProperties, content io.Reader
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -514,7 +510,7 @@ func (dbx *apiImpl) Copy(arg *RelocationArg) (res IsMetadata, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -586,7 +582,7 @@ func (dbx *apiImpl) CopyBatch(arg *RelocationBatchArg) (res *RelocationBatchLaun
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -658,7 +654,7 @@ func (dbx *apiImpl) CopyBatchCheck(arg *async.PollArg) (res *RelocationBatchJobS
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -730,7 +726,7 @@ func (dbx *apiImpl) CopyReferenceGet(arg *GetCopyReferenceArg) (res *GetCopyRefe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -802,7 +798,7 @@ func (dbx *apiImpl) CopyReferenceSave(arg *SaveCopyReferenceArg) (res *SaveCopyR
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -874,7 +870,7 @@ func (dbx *apiImpl) CopyV2(arg *RelocationArg) (res *RelocationResult, err error
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -949,7 +945,7 @@ func (dbx *apiImpl) CreateFolder(arg *CreateFolderArg) (res *FolderMetadata, err
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1021,7 +1017,7 @@ func (dbx *apiImpl) CreateFolderV2(arg *CreateFolderArg) (res *CreateFolderResul
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1107,7 +1103,7 @@ func (dbx *apiImpl) Delete(arg *DeleteArg) (res IsMetadata, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1179,7 +1175,7 @@ func (dbx *apiImpl) DeleteBatch(arg *DeleteBatchArg) (res *DeleteBatchLaunch, er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1251,7 +1247,7 @@ func (dbx *apiImpl) DeleteBatchCheck(arg *async.PollArg) (res *DeleteBatchJobSta
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1323,7 +1319,7 @@ func (dbx *apiImpl) DeleteV2(arg *DeleteArg) (res *DeleteResult, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1399,80 +1395,7 @@ func (dbx *apiImpl) Download(arg *DownloadArg) (res *FileMetadata, content io.Re
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
}
//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 {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1555,7 +1478,7 @@ func (dbx *apiImpl) GetMetadata(arg *GetMetadataArg) (res IsMetadata, err error)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1628,7 +1551,7 @@ func (dbx *apiImpl) GetPreview(arg *PreviewArg) (res *FileMetadata, content io.R
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1700,7 +1623,7 @@ func (dbx *apiImpl) GetTemporaryLink(arg *GetTemporaryLinkArg) (res *GetTemporar
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1773,7 +1696,7 @@ func (dbx *apiImpl) GetThumbnail(arg *ThumbnailArg) (res *FileMetadata, content
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1845,7 +1768,7 @@ func (dbx *apiImpl) GetThumbnailBatch(arg *GetThumbnailBatchArg) (res *GetThumbn
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1917,7 +1840,7 @@ func (dbx *apiImpl) ListFolder(arg *ListFolderArg) (res *ListFolderResult, err e
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1989,7 +1912,7 @@ func (dbx *apiImpl) ListFolderContinue(arg *ListFolderContinueArg) (res *ListFol
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2061,7 +1984,7 @@ func (dbx *apiImpl) ListFolderGetLatestCursor(arg *ListFolderArg) (res *ListFold
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2130,7 +2053,7 @@ func (dbx *apiImpl) ListFolderLongpoll(arg *ListFolderLongpollArg) (res *ListFol
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2202,7 +2125,7 @@ func (dbx *apiImpl) ListRevisions(arg *ListRevisionsArg) (res *ListRevisionsResu
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2288,7 +2211,7 @@ func (dbx *apiImpl) Move(arg *RelocationArg) (res IsMetadata, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2360,7 +2283,7 @@ func (dbx *apiImpl) MoveBatch(arg *RelocationBatchArg) (res *RelocationBatchLaun
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2432,7 +2355,7 @@ func (dbx *apiImpl) MoveBatchCheck(arg *async.PollArg) (res *RelocationBatchJobS
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2504,7 +2427,7 @@ func (dbx *apiImpl) MoveV2(arg *RelocationArg) (res *RelocationResult, err error
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2571,7 +2494,7 @@ func (dbx *apiImpl) PermanentlyDelete(arg *DeleteArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2640,7 +2563,7 @@ func (dbx *apiImpl) PropertiesAdd(arg *file_properties.AddPropertiesArg) (err er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2709,7 +2632,7 @@ func (dbx *apiImpl) PropertiesOverwrite(arg *file_properties.OverwritePropertyGr
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2778,7 +2701,7 @@ func (dbx *apiImpl) PropertiesRemove(arg *file_properties.RemovePropertiesArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2852,7 +2775,7 @@ func (dbx *apiImpl) PropertiesTemplateGet(arg *file_properties.GetTemplateArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2918,7 +2841,7 @@ func (dbx *apiImpl) PropertiesTemplateList() (res *file_properties.ListTemplateR
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2987,7 +2910,7 @@ func (dbx *apiImpl) PropertiesUpdate(arg *file_properties.UpdatePropertiesArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3059,7 +2982,7 @@ func (dbx *apiImpl) Restore(arg *RestoreArg) (res *FileMetadata, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3131,7 +3054,7 @@ func (dbx *apiImpl) SaveUrl(arg *SaveUrlArg) (res *SaveUrlResult, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3203,7 +3126,7 @@ func (dbx *apiImpl) SaveUrlCheckJobStatus(arg *async.PollArg) (res *SaveUrlJobSt
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3275,7 +3198,7 @@ func (dbx *apiImpl) Search(arg *SearchArg) (res *SearchResult, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3348,7 +3271,7 @@ func (dbx *apiImpl) Upload(arg *CommitInfo, content io.Reader) (res *FileMetadat
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3419,7 +3342,7 @@ func (dbx *apiImpl) UploadSessionAppend(arg *UploadSessionCursor, content io.Rea
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3487,7 +3410,7 @@ func (dbx *apiImpl) UploadSessionAppendV2(arg *UploadSessionAppendArg, content i
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3560,7 +3483,7 @@ func (dbx *apiImpl) UploadSessionFinish(arg *UploadSessionFinishArg, content io.
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3632,7 +3555,7 @@ func (dbx *apiImpl) UploadSessionFinishBatch(arg *UploadSessionFinishBatchArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3704,7 +3627,7 @@ func (dbx *apiImpl) UploadSessionFinishBatchCheck(arg *async.PollArg) (res *Uplo
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3777,7 +3700,7 @@ func (dbx *apiImpl) UploadSessionStart(arg *UploadSessionStartArg, content io.Re
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return

View file

@ -0,0 +1,109 @@
// 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

@ -449,24 +449,6 @@ 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
@ -578,24 +560,6 @@ 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
@ -793,71 +757,6 @@ 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
@ -1066,32 +965,6 @@ 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.
@ -1496,35 +1369,6 @@ 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.
@ -2173,24 +2017,6 @@ 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
@ -2205,24 +2031,6 @@ 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.
@ -2360,25 +2168,6 @@ 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.
@ -2613,27 +2402,6 @@ 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
@ -2784,15 +2552,12 @@ 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.
PropertiesError *file_properties.InvalidPropertyGroupError `json:"properties_error,omitempty"`
}
// Valid tag values for UploadError
const (
UploadErrorPath = "path"
UploadErrorPropertiesError = "properties_error"
UploadErrorOther = "other"
UploadErrorPath = "path"
UploadErrorOther = "other"
)
// UnmarshalJSON deserializes into a UploadError instance
@ -2801,8 +2566,6 @@ 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.
PropertiesError json.RawMessage `json:"properties_error,omitempty"`
}
var w wrap
var err error
@ -2814,12 +2577,6 @@ 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
}
@ -2832,15 +2589,15 @@ type UploadErrorWithProperties 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.
// PropertiesError : has no documentation (yet)
PropertiesError *file_properties.InvalidPropertyGroupError `json:"properties_error,omitempty"`
}
// Valid tag values for UploadErrorWithProperties
const (
UploadErrorWithPropertiesPath = "path"
UploadErrorWithPropertiesPropertiesError = "properties_error"
UploadErrorWithPropertiesOther = "other"
UploadErrorWithPropertiesPropertiesError = "properties_error"
)
// UnmarshalJSON deserializes into a UploadErrorWithProperties instance
@ -2849,7 +2606,7 @@ 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 : The supplied property group is invalid.
// PropertiesError : has no documentation (yet)
PropertiesError json.RawMessage `json:"properties_error,omitempty"`
}
var w wrap

View file

@ -153,7 +153,7 @@ func (dbx *apiImpl) DocsArchive(arg *RefPaperDoc) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return

View file

@ -26,7 +26,6 @@ import (
"log"
"net/http"
"golang.org/x/net/context"
"golang.org/x/oauth2"
)
@ -36,8 +35,8 @@ const (
hostAPI = "api"
hostContent = "content"
hostNotify = "notify"
sdkVersion = "4.5.0"
specVersion = "a1d5111"
sdkVersion = "4.0.0"
specVersion = "5389e5b"
)
// Version returns the current SDK version and API Spec version
@ -78,12 +77,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
}
@ -153,7 +152,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(context.Background(), tok)
client = conf.Client(oauth2.NoContext, tok)
}
headerGenerator := c.HeaderGenerator

View file

@ -285,7 +285,7 @@ func (dbx *apiImpl) AddFileMember(arg *AddFileMemberArgs) (res []*FileMemberActi
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -352,7 +352,7 @@ func (dbx *apiImpl) AddFolderMember(arg *AddFolderMemberArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -427,7 +427,7 @@ func (dbx *apiImpl) ChangeFileMemberAccess(arg *ChangeFileMemberAccessArgs) (res
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -499,7 +499,7 @@ func (dbx *apiImpl) CheckJobStatus(arg *async.PollArg) (res *JobStatus, err erro
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -571,7 +571,7 @@ func (dbx *apiImpl) CheckRemoveMemberJobStatus(arg *async.PollArg) (res *RemoveM
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -643,7 +643,7 @@ func (dbx *apiImpl) CheckShareJobStatus(arg *async.PollArg) (res *ShareFolderJob
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -718,7 +718,7 @@ func (dbx *apiImpl) CreateSharedLink(arg *CreateSharedLinkArg) (res *PathLinkMet
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -798,7 +798,7 @@ func (dbx *apiImpl) CreateSharedLinkWithSettings(arg *CreateSharedLinkWithSettin
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -870,7 +870,7 @@ func (dbx *apiImpl) GetFileMetadata(arg *GetFileMetadataArg) (res *SharedFileMet
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -942,7 +942,7 @@ func (dbx *apiImpl) GetFileMetadataBatch(arg *GetFileMetadataBatchArg) (res []*G
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1014,7 +1014,7 @@ func (dbx *apiImpl) GetFolderMetadata(arg *GetMetadataArgs) (res *SharedFolderMe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1095,7 +1095,7 @@ func (dbx *apiImpl) GetSharedLinkFile(arg *GetSharedLinkMetadataArg) (res IsShar
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1175,7 +1175,7 @@ func (dbx *apiImpl) GetSharedLinkMetadata(arg *GetSharedLinkMetadataArg) (res Is
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1250,7 +1250,7 @@ func (dbx *apiImpl) GetSharedLinks(arg *GetSharedLinksArg) (res *GetSharedLinksR
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1322,7 +1322,7 @@ func (dbx *apiImpl) ListFileMembers(arg *ListFileMembersArg) (res *SharedFileMem
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1394,7 +1394,7 @@ func (dbx *apiImpl) ListFileMembersBatch(arg *ListFileMembersBatchArg) (res []*L
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1466,7 +1466,7 @@ func (dbx *apiImpl) ListFileMembersContinue(arg *ListFileMembersContinueArg) (re
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1538,7 +1538,7 @@ func (dbx *apiImpl) ListFolderMembers(arg *ListFolderMembersArgs) (res *SharedFo
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1610,7 +1610,7 @@ func (dbx *apiImpl) ListFolderMembersContinue(arg *ListFolderMembersContinueArg)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1682,7 +1682,7 @@ func (dbx *apiImpl) ListFolders(arg *ListFoldersArgs) (res *ListFoldersResult, e
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1754,7 +1754,7 @@ func (dbx *apiImpl) ListFoldersContinue(arg *ListFoldersContinueArg) (res *ListF
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1826,7 +1826,7 @@ func (dbx *apiImpl) ListMountableFolders(arg *ListFoldersArgs) (res *ListFolders
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1898,7 +1898,7 @@ func (dbx *apiImpl) ListMountableFoldersContinue(arg *ListFoldersContinueArg) (r
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1970,7 +1970,7 @@ func (dbx *apiImpl) ListReceivedFiles(arg *ListFilesArg) (res *ListFilesResult,
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2042,7 +2042,7 @@ func (dbx *apiImpl) ListReceivedFilesContinue(arg *ListFilesContinueArg) (res *L
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2114,7 +2114,7 @@ func (dbx *apiImpl) ListSharedLinks(arg *ListSharedLinksArg) (res *ListSharedLin
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2194,7 +2194,7 @@ func (dbx *apiImpl) ModifySharedLinkSettings(arg *ModifySharedLinkSettingsArgs)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2266,7 +2266,7 @@ func (dbx *apiImpl) MountFolder(arg *MountFolderArg) (res *SharedFolderMetadata,
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2333,7 +2333,7 @@ func (dbx *apiImpl) RelinquishFileMembership(arg *RelinquishFileMembershipArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2405,7 +2405,7 @@ func (dbx *apiImpl) RelinquishFolderMembership(arg *RelinquishFolderMembershipAr
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2480,7 +2480,7 @@ func (dbx *apiImpl) RemoveFileMember(arg *RemoveFileMemberArg) (res *FileMemberA
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2552,7 +2552,7 @@ func (dbx *apiImpl) RemoveFileMember2(arg *RemoveFileMemberArg) (res *FileMember
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2624,7 +2624,7 @@ func (dbx *apiImpl) RemoveFolderMember(arg *RemoveFolderMemberArg) (res *async.L
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2691,7 +2691,7 @@ func (dbx *apiImpl) RevokeSharedLink(arg *RevokeSharedLinkArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2763,7 +2763,7 @@ func (dbx *apiImpl) ShareFolder(arg *ShareFolderArg) (res *ShareFolderLaunch, er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2830,7 +2830,7 @@ func (dbx *apiImpl) TransferFolder(arg *TransferFolderArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2897,7 +2897,7 @@ func (dbx *apiImpl) UnmountFolder(arg *UnmountFolderArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2964,7 +2964,7 @@ func (dbx *apiImpl) UnshareFile(arg *UnshareFileArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3036,7 +3036,7 @@ func (dbx *apiImpl) UnshareFolder(arg *UnshareFolderArg) (res *async.LaunchEmpty
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3108,7 +3108,7 @@ func (dbx *apiImpl) UpdateFileMember(arg *UpdateFileMemberArgs) (res *MemberAcce
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3180,7 +3180,7 @@ func (dbx *apiImpl) UpdateFolderMember(arg *UpdateFolderMemberArg) (res *MemberA
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3252,7 +3252,7 @@ func (dbx *apiImpl) UpdateFolderPolicy(arg *UpdateFolderPolicyArg) (res *SharedF
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return

View file

@ -18,38 +18,32 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package dropbox_test
package sharing
import (
"fmt"
"net/http"
"net/http/httptest"
"strings"
"testing"
import "encoding/json"
"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)
type listSharedLinksResult struct {
Links []sharedLinkMetadataUnion `json:"links"`
HasMore bool `json:"has_more"`
Cursor string `json:"cursor,omitempty"`
}
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())
// 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
}

View file

@ -1431,27 +1431,6 @@ 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 {
@ -2419,36 +2398,6 @@ 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 {

View file

@ -335,7 +335,7 @@ func (dbx *apiImpl) DevicesListMemberDevices(arg *ListMemberDevicesArg) (res *Li
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -404,7 +404,7 @@ func (dbx *apiImpl) DevicesListMembersDevices(arg *ListMembersDevicesArg) (res *
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -476,7 +476,7 @@ func (dbx *apiImpl) DevicesListTeamDevices(arg *ListTeamDevicesArg) (res *ListTe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -540,7 +540,7 @@ func (dbx *apiImpl) DevicesRevokeDeviceSession(arg *RevokeDeviceSessionArg) (err
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -609,7 +609,7 @@ func (dbx *apiImpl) DevicesRevokeDeviceSessionBatch(arg *RevokeDeviceSessionBatc
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -678,7 +678,7 @@ func (dbx *apiImpl) FeaturesGetValues(arg *FeaturesGetValuesBatchArg) (res *Feat
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -739,7 +739,7 @@ func (dbx *apiImpl) GetInfo() (res *TeamGetInfoResult, err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -808,7 +808,7 @@ func (dbx *apiImpl) GroupsCreate(arg *GroupCreateArg) (res *GroupFullInfo, err e
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -877,7 +877,7 @@ func (dbx *apiImpl) GroupsDelete(arg *GroupSelector) (res *async.LaunchEmptyResu
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -946,7 +946,7 @@ func (dbx *apiImpl) GroupsGetInfo(arg *GroupsSelector) (res []*GroupsGetInfoItem
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1015,7 +1015,7 @@ func (dbx *apiImpl) GroupsJobStatusGet(arg *async.PollArg) (res *async.PollEmpty
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1084,7 +1084,7 @@ func (dbx *apiImpl) GroupsList(arg *GroupsListArg) (res *GroupsListResult, err e
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1153,7 +1153,7 @@ func (dbx *apiImpl) GroupsListContinue(arg *GroupsListContinueArg) (res *GroupsL
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1222,7 +1222,7 @@ func (dbx *apiImpl) GroupsMembersAdd(arg *GroupMembersAddArg) (res *GroupMembers
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1291,7 +1291,7 @@ func (dbx *apiImpl) GroupsMembersList(arg *GroupsMembersListArg) (res *GroupsMem
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1360,7 +1360,7 @@ func (dbx *apiImpl) GroupsMembersListContinue(arg *GroupsMembersListContinueArg)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1429,7 +1429,7 @@ func (dbx *apiImpl) GroupsMembersRemove(arg *GroupMembersRemoveArg) (res *GroupM
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1498,7 +1498,7 @@ func (dbx *apiImpl) GroupsMembersSetAccessType(arg *GroupMembersSetAccessTypeArg
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1567,7 +1567,7 @@ func (dbx *apiImpl) GroupsUpdate(arg *GroupUpdateArgs) (res *GroupFullInfo, err
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1636,7 +1636,7 @@ func (dbx *apiImpl) LinkedAppsListMemberLinkedApps(arg *ListMemberAppsArg) (res
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1705,7 +1705,7 @@ func (dbx *apiImpl) LinkedAppsListMembersLinkedApps(arg *ListMembersAppsArg) (re
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1777,7 +1777,7 @@ func (dbx *apiImpl) LinkedAppsListTeamLinkedApps(arg *ListTeamAppsArg) (res *Lis
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1841,7 +1841,7 @@ func (dbx *apiImpl) LinkedAppsRevokeLinkedApp(arg *RevokeLinkedApiAppArg) (err e
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1910,7 +1910,7 @@ func (dbx *apiImpl) LinkedAppsRevokeLinkedAppBatch(arg *RevokeLinkedApiAppBatchA
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -1979,7 +1979,7 @@ func (dbx *apiImpl) MemberSpaceLimitsExcludedUsersAdd(arg *ExcludedUsersUpdateAr
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2048,7 +2048,7 @@ func (dbx *apiImpl) MemberSpaceLimitsExcludedUsersList(arg *ExcludedUsersListArg
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2117,7 +2117,7 @@ func (dbx *apiImpl) MemberSpaceLimitsExcludedUsersListContinue(arg *ExcludedUser
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2186,7 +2186,7 @@ func (dbx *apiImpl) MemberSpaceLimitsExcludedUsersRemove(arg *ExcludedUsersUpdat
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2255,7 +2255,7 @@ func (dbx *apiImpl) MemberSpaceLimitsGetCustomQuota(arg *CustomQuotaUsersArg) (r
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2324,7 +2324,7 @@ func (dbx *apiImpl) MemberSpaceLimitsRemoveCustomQuota(arg *CustomQuotaUsersArg)
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2393,7 +2393,7 @@ func (dbx *apiImpl) MemberSpaceLimitsSetCustomQuota(arg *SetCustomQuotaArg) (res
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2462,7 +2462,7 @@ func (dbx *apiImpl) MembersAdd(arg *MembersAddArg) (res *MembersAddLaunch, err e
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2531,7 +2531,7 @@ func (dbx *apiImpl) MembersAddJobStatusGet(arg *async.PollArg) (res *MembersAddJ
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2600,7 +2600,7 @@ func (dbx *apiImpl) MembersGetInfo(arg *MembersGetInfoArgs) (res []*MembersGetIn
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2669,7 +2669,7 @@ func (dbx *apiImpl) MembersList(arg *MembersListArg) (res *MembersListResult, er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2738,7 +2738,7 @@ func (dbx *apiImpl) MembersListContinue(arg *MembersListContinueArg) (res *Membe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2802,7 +2802,7 @@ func (dbx *apiImpl) MembersRecover(arg *MembersRecoverArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2871,7 +2871,7 @@ func (dbx *apiImpl) MembersRemove(arg *MembersRemoveArg) (res *async.LaunchEmpty
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -2940,7 +2940,7 @@ func (dbx *apiImpl) MembersRemoveJobStatusGet(arg *async.PollArg) (res *async.Po
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3004,7 +3004,7 @@ func (dbx *apiImpl) MembersSendWelcomeEmail(arg *UserSelectorArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3073,7 +3073,7 @@ func (dbx *apiImpl) MembersSetAdminPermissions(arg *MembersSetPermissionsArg) (r
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3142,7 +3142,7 @@ func (dbx *apiImpl) MembersSetProfile(arg *MembersSetProfileArg) (res *TeamMembe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3206,7 +3206,7 @@ func (dbx *apiImpl) MembersSuspend(arg *MembersDeactivateArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3270,7 +3270,7 @@ func (dbx *apiImpl) MembersUnsuspend(arg *MembersUnsuspendArg) (err error) {
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3339,7 +3339,7 @@ func (dbx *apiImpl) NamespacesList(arg *TeamNamespacesListArg) (res *TeamNamespa
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3408,7 +3408,7 @@ func (dbx *apiImpl) NamespacesListContinue(arg *TeamNamespacesListContinueArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3479,7 +3479,7 @@ func (dbx *apiImpl) PropertiesTemplateAdd(arg *file_properties.AddTemplateArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3550,7 +3550,7 @@ func (dbx *apiImpl) PropertiesTemplateGet(arg *file_properties.GetTemplateArg) (
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3613,7 +3613,7 @@ func (dbx *apiImpl) PropertiesTemplateList() (res *file_properties.ListTemplateR
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3684,7 +3684,7 @@ func (dbx *apiImpl) PropertiesTemplateUpdate(arg *file_properties.UpdateTemplate
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3753,7 +3753,7 @@ func (dbx *apiImpl) ReportsGetActivity(arg *DateRange) (res *GetActivityReport,
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3822,7 +3822,7 @@ func (dbx *apiImpl) ReportsGetDevices(arg *DateRange) (res *GetDevicesReport, er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3891,7 +3891,7 @@ func (dbx *apiImpl) ReportsGetMembership(arg *DateRange) (res *GetMembershipRepo
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -3960,7 +3960,7 @@ func (dbx *apiImpl) ReportsGetStorage(arg *DateRange) (res *GetStorageReport, er
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4029,7 +4029,7 @@ func (dbx *apiImpl) TeamFolderActivate(arg *TeamFolderIdArg) (res *TeamFolderMet
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4098,7 +4098,7 @@ func (dbx *apiImpl) TeamFolderArchive(arg *TeamFolderArchiveArg) (res *TeamFolde
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4167,7 +4167,7 @@ func (dbx *apiImpl) TeamFolderArchiveCheck(arg *async.PollArg) (res *TeamFolderA
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4236,7 +4236,7 @@ func (dbx *apiImpl) TeamFolderCreate(arg *TeamFolderCreateArg) (res *TeamFolderM
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4305,7 +4305,7 @@ func (dbx *apiImpl) TeamFolderGetInfo(arg *TeamFolderIdListArg) (res []*TeamFold
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4374,7 +4374,7 @@ func (dbx *apiImpl) TeamFolderList(arg *TeamFolderListArg) (res *TeamFolderListR
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4443,7 +4443,7 @@ func (dbx *apiImpl) TeamFolderListContinue(arg *TeamFolderListContinueArg) (res
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4507,7 +4507,7 @@ func (dbx *apiImpl) TeamFolderPermanentlyDelete(arg *TeamFolderIdArg) (err error
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4576,7 +4576,7 @@ func (dbx *apiImpl) TeamFolderRename(arg *TeamFolderRenameArg) (res *TeamFolderM
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -4637,7 +4637,7 @@ func (dbx *apiImpl) TokenGetAuthenticatedAdmin() (res *TokenGetAuthenticatedAdmi
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return

View file

@ -2191,7 +2191,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 +2238,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

View file

@ -96,7 +96,7 @@ func (dbx *apiImpl) GetEvents(arg *GetTeamEventsArg) (res *GetTeamEventsResult,
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
@ -165,7 +165,7 @@ func (dbx *apiImpl) GetEventsContinue(arg *GetTeamEventsContinueArg) (res *GetTe
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return

File diff suppressed because it is too large Load diff

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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
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 || resp.StatusCode == http.StatusInternalServerError {
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return

View file

@ -128,75 +128,6 @@ 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.

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:-"4.2.0"}
sdk_version=${1:-"3.0.0"}
pushd ${spec_dir}
spec_version=$(git rev-parse --short HEAD)
popd

View file

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

View file

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

View file

@ -0,0 +1,109 @@
// 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,7 +26,6 @@ import (
"log"
"net/http"
"golang.org/x/net/context"
"golang.org/x/oauth2"
)
@ -78,12 +77,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
}
@ -153,7 +152,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(context.Background(), tok)
client = conf.Client(oauth2.NoContext, tok)
}
headerGenerator := c.HeaderGenerator

View file

@ -0,0 +1,49 @@
// 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 sharing
import "encoding/json"
type listSharedLinksResult struct {
Links []sharedLinkMetadataUnion `json:"links"`
HasMore bool `json:"has_more"`
Cursor string `json:"cursor,omitempty"`
}
// 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
}

View file

@ -4,7 +4,6 @@ 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,
@ -17,8 +16,6 @@ from go_helpers import (
fmt_type,
fmt_var,
generate_doc,
needs_base_type,
_needs_base_type
)
@ -29,6 +26,10 @@ 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,
@ -89,39 +90,6 @@ 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),
@ -154,11 +122,14 @@ 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, raw=raw)
type_name = fmt_type(field.data_type, namespace, use_interface=True)
json_tag = '`json:"%s"`' % field.name
if is_nullable_type(field.data_type) or union_field:
json_tag = '`json:"%s,omitempty"`' % field.name
self.emit('%s %s %s' % (field_name, type_name, json_tag))
if raw:
self.emit('%s json.RawMessage %s' % (field_name, json_tag))
else:
self.emit('%s %s %s' % (field_name, type_name, json_tag))
def _generate_union(self, union):
self._generate_union_helper(union)
@ -216,7 +187,8 @@ class GoTypesBackend(CodeBackend):
if is_union_type(field.data_type):
self.emit('err = json.Unmarshal(w.{0}, &u.{0})'
.format(field_name))
elif _needs_base_type(field.data_type):
elif is_struct_type(field.data_type) and \
field.data_type.has_enumerated_subtypes():
self.emit("u.{0}, err = Is{1}FromJSON(body)"
.format(field_name, field.data_type.name))
else: