diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/debian/changelog golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/debian/changelog --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/debian/changelog 2018-05-31 20:14:05.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/debian/changelog 2019-07-23 05:47:05.000000000 +0000 @@ -1,3 +1,20 @@ +golang-github-dropbox-dropbox-sdk-go-unofficial (5.4.0-2) unstable; urgency=medium + + * Team upload. + * Standards-Version: 4.4.0 + + -- Drew Parsons Tue, 23 Jul 2019 13:47:05 +0800 + +golang-github-dropbox-dropbox-sdk-go-unofficial (5.4.0-1) experimental; urgency=medium + + * Team upload. + * New upstream version 5.4.0 + * Standards-Version: 4.3.0 + * debhelper compatibility level 12 + Build-Depends: debhelper-compat (= 12) + + -- Drew Parsons Sun, 05 May 2019 21:19:30 +0800 + golang-github-dropbox-dropbox-sdk-go-unofficial (4.1.0-1) unstable; urgency=medium [ Alexandre Viau ] diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/debian/compat golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/debian/compat --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/debian/compat 2018-05-31 18:27:28.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -11 diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/debian/control golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/debian/control --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/debian/control 2018-05-31 20:12:49.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/debian/control 2019-07-23 05:47:05.000000000 +0000 @@ -3,12 +3,12 @@ Priority: optional Maintainer: Debian Go Packaging Team Uploaders: Dr. Tobias Quathamer -Build-Depends: debhelper (>= 11~), +Build-Depends: debhelper-compat (= 12), dh-golang, golang-any, golang-golang-x-net-dev, golang-golang-x-oauth2-google-dev -Standards-Version: 4.1.4 +Standards-Version: 4.4.0 Homepage: https://github.com/dropbox/dropbox-sdk-go-unofficial Vcs-Browser: https://salsa.debian.org/go-team/packages/golang-github-dropbox-dropbox-sdk-go-unofficial Vcs-Git: https://salsa.debian.org/go-team/packages/golang-github-dropbox-dropbox-sdk-go-unofficial.git diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/auth/client.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/auth/client.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/auth/client.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/auth/client.go 2018-12-22 22:15:38.000000000 +0000 @@ -80,7 +80,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -98,17 +98,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -144,7 +138,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -157,17 +151,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/auth/sdk.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/auth/sdk.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/auth/sdk.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/auth/sdk.go 2018-12-22 22:15:38.000000000 +0000 @@ -0,0 +1,67 @@ +package auth + +import ( + "encoding/json" + "mime" + "net/http" + "strconv" + + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" +) + +// AuthAPIError wraps AuthError +type AuthAPIError struct { + dropbox.APIError + AuthError *AuthError `json:"error"` +} + +// AccessAPIError wraps AccessError +type AccessAPIError struct { + dropbox.APIError + AccessError *AccessError `json:"error"` +} + +// RateLimitAPIError wraps RateLimitError +type RateLimitAPIError struct { + dropbox.APIError + RateLimitError *RateLimitError `json:"error"` +} + +// HandleCommonAuthErrors handles common authentication errors +func HandleCommonAuthErrors(c dropbox.Config, resp *http.Response, body []byte) error { + switch resp.StatusCode { + case http.StatusUnauthorized: + var apiError AuthAPIError + if err := json.Unmarshal(body, &apiError); err != nil { + c.LogDebug("Error unmarshaling '%s' into JSON", body) + return err + } + return apiError + case http.StatusForbidden: + var apiError AccessAPIError + if err := json.Unmarshal(body, &apiError); err != nil { + c.LogDebug("Error unmarshaling '%s' into JSON", body) + return err + } + return apiError + case http.StatusTooManyRequests: + var apiError RateLimitAPIError + // Check content-type + contentType, _, _ := mime.ParseMediaType(resp.Header.Get("content-type")) + if contentType == "application/json" { + if err := json.Unmarshal(body, &apiError); err != nil { + c.LogDebug("Error unmarshaling '%s' into JSON", body) + return err + } + } else { // assume plain text + apiError.ErrorSummary = string(body) + reason := RateLimitReason{dropbox.Tagged{Tag: RateLimitReasonTooManyRequests}} + apiError.RateLimitError = NewRateLimitError(&reason) + timeout, _ := strconv.ParseInt(resp.Header.Get("retry-after"), 10, 64) + apiError.RateLimitError.RetryAfter = uint64(timeout) + } + return apiError + default: + return nil + } +} diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/auth/types.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/auth/types.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/auth/types.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/auth/types.go 2018-12-22 22:15:38.000000000 +0000 @@ -87,6 +87,7 @@ AuthErrorInvalidSelectUser = "invalid_select_user" AuthErrorInvalidSelectAdmin = "invalid_select_admin" AuthErrorUserSuspended = "user_suspended" + AuthErrorExpiredAccessToken = "expired_access_token" AuthErrorOther = "other" ) diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/contacts/client.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/contacts/client.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/contacts/client.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/contacts/client.go 2018-12-22 22:15:38.000000000 +0000 @@ -0,0 +1,164 @@ +// 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 contacts + +import ( + "bytes" + "encoding/json" + "io/ioutil" + "net/http" + + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth" +) + +// Client interface describes all routes in this namespace +type Client interface { + // DeleteManualContacts : Removes all manually added contacts. You'll still + // keep contacts who are on your team or who you imported. New contacts will + // be added when you share. + DeleteManualContacts() (err error) + // DeleteManualContactsBatch : Removes manually added contacts from the + // given list. + DeleteManualContactsBatch(arg *DeleteManualContactsArg) (err error) +} + +type apiImpl dropbox.Context + +//DeleteManualContactsAPIError is an error-wrapper for the delete_manual_contacts route +type DeleteManualContactsAPIError struct { + dropbox.APIError + EndpointError struct{} `json:"error"` +} + +func (dbx *apiImpl) DeleteManualContacts() (err error) { + cli := dbx.Client + + headers := map[string]string{} + if dbx.Config.AsMemberID != "" { + headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID + } + + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "contacts", "delete_manual_contacts", 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) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return + } + + dbx.Config.LogDebug("body: %s", body) + if resp.StatusCode == http.StatusOK { + return + } + if resp.StatusCode == http.StatusConflict { + var apiError DeleteManualContactsAPIError + err = json.Unmarshal(body, &apiError) + if err != nil { + return + } + err = apiError + return + } + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) + if err != nil { + return + } + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) + return +} + +//DeleteManualContactsBatchAPIError is an error-wrapper for the delete_manual_contacts_batch route +type DeleteManualContactsBatchAPIError struct { + dropbox.APIError + EndpointError *DeleteManualContactsError `json:"error"` +} + +func (dbx *apiImpl) DeleteManualContactsBatch(arg *DeleteManualContactsArg) (err error) { + cli := dbx.Client + + dbx.Config.LogDebug("arg: %v", arg) + b, err := json.Marshal(arg) + if err != nil { + return + } + + headers := map[string]string{ + "Content-Type": "application/json", + } + if dbx.Config.AsMemberID != "" { + headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID + } + + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "contacts", "delete_manual_contacts_batch", headers, bytes.NewReader(b)) + if err != nil { + return + } + dbx.Config.LogInfo("req: %v", req) + + resp, err := cli.Do(req) + if err != nil { + return + } + + dbx.Config.LogInfo("resp: %v", resp) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return + } + + dbx.Config.LogDebug("body: %s", body) + if resp.StatusCode == http.StatusOK { + return + } + if resp.StatusCode == http.StatusConflict { + var apiError DeleteManualContactsBatchAPIError + err = json.Unmarshal(body, &apiError) + if err != nil { + return + } + err = apiError + return + } + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) + if err != nil { + return + } + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) + return +} + +// New returns a Client implementation for this namespace +func New(c dropbox.Config) Client { + ctx := apiImpl(dropbox.NewContext(c)) + return &ctx +} diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/contacts/types.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/contacts/types.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/contacts/types.go 1970-01-01 00:00:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/contacts/types.go 2018-12-22 22:15:38.000000000 +0000 @@ -0,0 +1,81 @@ +// 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 contacts : has no documentation (yet) +package contacts + +import ( + "encoding/json" + + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" +) + +// DeleteManualContactsArg : has no documentation (yet) +type DeleteManualContactsArg struct { + // EmailAddresses : List of manually added contacts to be deleted. + EmailAddresses []string `json:"email_addresses"` +} + +// NewDeleteManualContactsArg returns a new DeleteManualContactsArg instance +func NewDeleteManualContactsArg(EmailAddresses []string) *DeleteManualContactsArg { + s := new(DeleteManualContactsArg) + s.EmailAddresses = EmailAddresses + return s +} + +// DeleteManualContactsError : has no documentation (yet) +type DeleteManualContactsError struct { + dropbox.Tagged + // ContactsNotFound : Can't delete contacts from this list. Make sure the + // list only has manually added contacts. The deletion was cancelled. + ContactsNotFound []string `json:"contacts_not_found,omitempty"` +} + +// Valid tag values for DeleteManualContactsError +const ( + DeleteManualContactsErrorContactsNotFound = "contacts_not_found" + DeleteManualContactsErrorOther = "other" +) + +// UnmarshalJSON deserializes into a DeleteManualContactsError instance +func (u *DeleteManualContactsError) UnmarshalJSON(body []byte) error { + type wrap struct { + dropbox.Tagged + // ContactsNotFound : Can't delete contacts from this list. Make sure + // the list only has manually added contacts. The deletion was + // cancelled. + ContactsNotFound json.RawMessage `json:"contacts_not_found,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 "contacts_not_found": + err = json.Unmarshal(body, &u.ContactsNotFound) + + if err != nil { + return err + } + } + return nil +} diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/file_properties/client.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/file_properties/client.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/file_properties/client.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/file_properties/client.go 2018-12-22 22:15:38.000000000 +0000 @@ -27,6 +27,7 @@ "net/http" "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth" ) // Client interface describes all routes in this namespace @@ -142,7 +143,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -155,17 +156,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -209,7 +204,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -222,17 +217,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -276,7 +265,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -289,17 +278,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -343,7 +326,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -361,17 +344,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -415,7 +392,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -433,17 +410,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -487,7 +458,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -500,17 +471,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -551,7 +516,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -569,17 +534,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -623,7 +582,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -641,17 +600,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -692,7 +645,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -710,17 +663,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -764,7 +711,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -782,17 +729,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -825,7 +766,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -843,17 +784,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -889,7 +824,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -907,17 +842,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -958,7 +887,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -971,17 +900,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1025,7 +948,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -1038,17 +961,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1089,7 +1006,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1107,17 +1024,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1161,7 +1072,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1179,17 +1090,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/file_requests/client.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/file_requests/client.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/file_requests/client.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/file_requests/client.go 2018-12-22 22:15:38.000000000 +0000 @@ -27,6 +27,7 @@ "net/http" "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth" ) // Client interface describes all routes in this namespace @@ -85,7 +86,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -103,17 +104,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -157,7 +152,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -175,17 +170,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -221,7 +210,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -239,17 +228,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -293,7 +276,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -311,17 +294,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/file_requests/types.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/file_requests/types.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/file_requests/types.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/file_requests/types.go 2018-12-22 22:15:38.000000000 +0000 @@ -38,7 +38,7 @@ // relative to the app folder. Destination string `json:"destination"` // Deadline : The deadline for the file request. Deadlines can only be set - // by Pro and Business accounts. + // by Professional and Business accounts. Deadline *FileRequestDeadline `json:"deadline,omitempty"` // Open : Whether or not the file request should be open. If the file // request is closed, it will not accept any file submissions, but it can be @@ -237,7 +237,8 @@ // files will be sent. For apps with the app folder permission, this will be // relative to the app folder. Destination string `json:"destination,omitempty"` - // Deadline : The new deadline for the file request. + // Deadline : The new deadline for the file request. Deadlines can only be + // set by Professional and Business accounts. Deadline *UpdateFileRequestDeadline `json:"deadline"` // Open : Whether to set this file request as open or closed. Open bool `json:"open,omitempty"` diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/files/client.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/files/client.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/files/client.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/files/client.go 2018-12-22 22:15:38.000000000 +0000 @@ -30,6 +30,7 @@ "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/async" + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth" "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/file_properties" ) @@ -49,19 +50,34 @@ AlphaUpload(arg *CommitInfoWithProperties, content io.Reader) (res *FileMetadata, err error) // Copy : Copy a file or folder to a different location in the user's // Dropbox. If the source path is a folder all its contents will be copied. + CopyV2(arg *RelocationArg) (res *RelocationResult, err error) + // Copy : Copy a file or folder to a different location in the user's + // Dropbox. If the source path is a folder all its contents will be copied. // Deprecated: Use `CopyV2` instead Copy(arg *RelocationArg) (res IsMetadata, err error) // CopyBatch : Copy multiple files or folders to different locations at once + // in the user's Dropbox. This route will replace `copyBatch`. The main + // difference is this route will return stutus for each entry, while + // `copyBatch` raises failure if any entry fails. This route will either + // finish synchronously, or return a job ID and do the async copy job in + // background. Please use `copyBatchCheck` to check the job status. + CopyBatchV2(arg *RelocationBatchArgBase) (res *RelocationBatchV2Launch, err error) + // CopyBatch : Copy multiple files or folders to different locations at once // in the user's Dropbox. If `RelocationBatchArg.allow_shared_folder` is - // false, this route is atomic. If on entry failes, the whole transaction - // will abort. If `RelocationBatchArg.allow_shared_folder` is true, not - // atomicity is guaranteed, but you will be able to copy the contents of + // false, this route is atomic. If one entry fails, the whole transaction + // will abort. If `RelocationBatchArg.allow_shared_folder` is true, + // atomicity is not guaranteed, but it allows you to copy the contents of // shared folders to new locations. This route will return job ID // immediately and do the async copy job in background. Please use // `copyBatchCheck` to check the job status. + // Deprecated: Use `CopyBatchV2` instead CopyBatch(arg *RelocationBatchArg) (res *RelocationBatchLaunch, err error) // CopyBatchCheck : Returns the status of an asynchronous job for + // `copyBatch`. It returns list of results for each entry. + CopyBatchCheckV2(arg *async.PollArg) (res *RelocationBatchV2JobStatus, err error) + // CopyBatchCheck : Returns the status of an asynchronous job for // `copyBatch`. If success, it returns list of results for each entry. + // Deprecated: Use `CopyBatchCheckV2` instead CopyBatchCheck(arg *async.PollArg) (res *RelocationBatchJobStatus, err error) // CopyReferenceGet : Get a copy reference to a file or folder. This // reference string can be used to save that file or folder to another @@ -70,9 +86,8 @@ // CopyReferenceSave : Save a copy reference returned by `copyReferenceGet` // to the user's Dropbox. CopyReferenceSave(arg *SaveCopyReferenceArg) (res *SaveCopyReferenceResult, err error) - // CopyV2 : Copy a file or folder to a different location in the user's - // Dropbox. If the source path is a folder all its contents will be copied. - CopyV2(arg *RelocationArg) (res *RelocationResult, err error) + // CreateFolder : Create a folder at a given path. + CreateFolderV2(arg *CreateFolderArg) (res *CreateFolderResult, err error) // CreateFolder : Create a folder at a given path. // Deprecated: Use `CreateFolderV2` instead CreateFolder(arg *CreateFolderArg) (res *FolderMetadata, err error) @@ -88,8 +103,12 @@ // `createFolderBatch`. If success, it returns list of result for each // entry. CreateFolderBatchCheck(arg *async.PollArg) (res *CreateFolderBatchJobStatus, err error) - // CreateFolderV2 : Create a folder at a given path. - CreateFolderV2(arg *CreateFolderArg) (res *CreateFolderResult, err error) + // Delete : Delete the file or folder at a given path. If the path is a + // folder, all its contents will be deleted too. A successful response + // indicates that the file or folder was deleted. The returned metadata will + // be the corresponding `FileMetadata` or `FolderMetadata` for the item at + // time of deletion, and not a `DeletedMetadata` object. + DeleteV2(arg *DeleteArg) (res *DeleteResult, err error) // Delete : Delete the file or folder at a given path. If the path is a // folder, all its contents will be deleted too. A successful response // indicates that the file or folder was deleted. The returned metadata will @@ -104,17 +123,12 @@ // DeleteBatchCheck : Returns the status of an asynchronous job for // `deleteBatch`. If success, it returns list of result for each entry. DeleteBatchCheck(arg *async.PollArg) (res *DeleteBatchJobStatus, err error) - // DeleteV2 : Delete the file or folder at a given path. If the path is a - // folder, all its contents will be deleted too. A successful response - // indicates that the file or folder was deleted. The returned metadata will - // be the corresponding `FileMetadata` or `FolderMetadata` for the item at - // time of deletion, and not a `DeletedMetadata` object. - 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. + // The folder must be less than 20 GB in size and have fewer than 10,000 + // total files. The input cannot be a single file. Any single file must be + // less than 4GB in size. 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. @@ -127,10 +141,41 @@ // extension error. GetPreview(arg *PreviewArg) (res *FileMetadata, content io.ReadCloser, err error) // GetTemporaryLink : Get a temporary link to stream content of a file. This - // link will expire in four hours and afterwards you will get 410 Gone. + // link will expire in four hours and afterwards you will get 410 Gone. So + // this URL should not be used to display content directly in the browser. // Content-Type of the link is determined automatically by the file's mime // type. GetTemporaryLink(arg *GetTemporaryLinkArg) (res *GetTemporaryLinkResult, err error) + // GetTemporaryUploadLink : Get a one-time use temporary upload link to + // upload a file to a Dropbox location. This endpoint acts as a delayed + // `upload`. The returned temporary upload link may be used to make a POST + // request with the data to be uploaded. The upload will then be perfomed + // with the `CommitInfo` previously provided to `getTemporaryUploadLink` but + // evaluated only upon consumption. Hence, errors stemming from invalid + // `CommitInfo` with respect to the state of the user's Dropbox will only be + // communicated at consumption time. Additionally, these errors are surfaced + // as generic HTTP 409 Conflict responses, potentially hiding issue details. + // The maximum temporary upload link duration is 4 hours. Upon consumption + // or expiration, a new link will have to be generated. Multiple links may + // exist for a specific upload path at any given time. The POST request on + // the temporary upload link must have its Content-Type set to + // "application/octet-stream". Example temporary upload link consumption + // request: curl -X POST + // https://dl.dropboxusercontent.com/apitul/1/bNi2uIYF51cVBND --header + // "Content-Type: application/octet-stream" --data-binary @local_file.txt A + // successful temporary upload link consumption request returns the content + // hash of the uploaded data in JSON format. Example succesful temporary + // upload link consumption response: {"content-hash": + // "599d71033d700ac892a0e48fa61b125d2f5994"} An unsuccessful temporary + // upload link consumption request returns any of the following status + // codes: HTTP 400 Bad Request: Content-Type is not one of + // application/octet-stream and text/plain or request is invalid. HTTP 409 + // Conflict: The temporary upload link does not exist or is currently + // unavailable, the upload failed, or another error happened. HTTP 410 Gone: + // The temporary upload link is expired or consumed. Example unsuccessful + // temporary upload link consumption response: Temporary upload link has + // been recently consumed. + GetTemporaryUploadLink(arg *GetTemporaryUploadLinkArg) (res *GetTemporaryUploadLinkResult, err error) // GetThumbnail : Get a thumbnail for an image. This method currently // supports files with the following file extensions: jpg, jpeg, png, tiff, // tif, gif and bmp. Photos that are larger than 20MB in size won't be @@ -194,20 +239,30 @@ ListRevisions(arg *ListRevisionsArg) (res *ListRevisionsResult, err error) // Move : Move a file or folder to a different location in the user's // Dropbox. If the source path is a folder all its contents will be moved. + MoveV2(arg *RelocationArg) (res *RelocationResult, err error) + // Move : Move a file or folder to a different location in the user's + // Dropbox. If the source path is a folder all its contents will be moved. // Deprecated: Use `MoveV2` instead Move(arg *RelocationArg) (res IsMetadata, err error) // MoveBatch : Move multiple files or folders to different locations at once + // in the user's Dropbox. This route will replace `moveBatch`. The main + // difference is this route will return stutus for each entry, while + // `moveBatch` raises failure if any entry fails. This route will either + // finish synchronously, or return a job ID and do the async move job in + // background. Please use `moveBatchCheck` to check the job status. + MoveBatchV2(arg *MoveBatchArg) (res *RelocationBatchV2Launch, err error) + // MoveBatch : Move multiple files or folders to different locations at once // in the user's Dropbox. This route is 'all or nothing', which means if one // entry fails, the whole transaction will abort. This route will return job // ID immediately and do the async moving job in background. Please use // `moveBatchCheck` to check the job status. MoveBatch(arg *RelocationBatchArg) (res *RelocationBatchLaunch, err error) // MoveBatchCheck : Returns the status of an asynchronous job for + // `moveBatch`. It returns list of results for each entry. + MoveBatchCheckV2(arg *async.PollArg) (res *RelocationBatchV2JobStatus, err error) + // MoveBatchCheck : Returns the status of an asynchronous job for // `moveBatch`. If success, it returns list of results for each entry. MoveBatchCheck(arg *async.PollArg) (res *RelocationBatchJobStatus, err error) - // MoveV2 : Move a file or folder to a different location in the user's - // Dropbox. If the source path is a folder all its contents will be moved. - MoveV2(arg *RelocationArg) (res *RelocationResult, err error) // PermanentlyDelete : Permanently delete the file or folder at a given path // (see https://www.dropbox.com/en/help/40). Note: This endpoint is only // available for Dropbox Business apps. @@ -230,9 +285,11 @@ // PropertiesUpdate : has no documentation (yet) // Deprecated: PropertiesUpdate(arg *file_properties.UpdatePropertiesArg) (err error) - // Restore : Restore a file to a specific revision. + // Restore : Restore a specific revision of a file to the given path. Restore(arg *RestoreArg) (res *FileMetadata, err error) - // SaveUrl : Save a specified URL into a file in user's Dropbox. If the + // SaveUrl : Save the data from a specified URL into a file in user's + // Dropbox. Note that the transfer from the URL must complete within 5 + // minutes, or the operation will time out and the job will fail. If the // given path already exists, the file will be renamed to avoid the conflict // (e.g. myfile (1).txt). SaveUrl(arg *SaveUrlArg) (res *SaveUrlResult, err error) @@ -244,37 +301,57 @@ Search(arg *SearchArg) (res *SearchResult, err error) // Upload : Create a new file with the contents provided in the request. Do // not use this to upload a file larger than 150 MB. Instead, create an - // upload session with `uploadSessionStart`. + // upload session with `uploadSessionStart`. Calls to this endpoint will + // count as data transport calls for any Dropbox Business teams with a limit + // on the number of data transport calls allowed per month. For more + // information, see the `Data transport limit page` + // . Upload(arg *CommitInfo, content io.Reader) (res *FileMetadata, err error) + // UploadSessionAppend : Append more data to an upload session. When the + // parameter close is set, this call will close the session. A single + // request should not upload more than 150 MB. The maximum size of a file + // one can upload to an upload session is 350 GB. Calls to this endpoint + // will count as data transport calls for any Dropbox Business teams with a + // limit on the number of data transport calls allowed per month. For more + // information, see the `Data transport limit page` + // . + UploadSessionAppendV2(arg *UploadSessionAppendArg, content io.Reader) (err error) // UploadSessionAppend : Append more data to an upload session. A single // request should not upload more than 150 MB. The maximum size of a file - // one can upload to an upload session is 350 GB. + // one can upload to an upload session is 350 GB. Calls to this endpoint + // will count as data transport calls for any Dropbox Business teams with a + // limit on the number of data transport calls allowed per month. For more + // information, see the `Data transport limit page` + // . // Deprecated: Use `UploadSessionAppendV2` instead UploadSessionAppend(arg *UploadSessionCursor, content io.Reader) (err error) - // UploadSessionAppendV2 : Append more data to an upload session. When the - // parameter close is set, this call will close the session. A single - // request should not upload more than 150 MB. The maximum size of a file - // one can upload to an upload session is 350 GB. - UploadSessionAppendV2(arg *UploadSessionAppendArg, content io.Reader) (err error) // UploadSessionFinish : Finish an upload session and save the uploaded data // to the given file path. A single request should not upload more than 150 // MB. The maximum size of a file one can upload to an upload session is 350 - // GB. + // GB. Calls to this endpoint will count as data transport calls for any + // Dropbox Business teams with a limit on the number of data transport calls + // allowed per month. For more information, see the `Data transport limit + // page` + // . UploadSessionFinish(arg *UploadSessionFinishArg, content io.Reader) (res *FileMetadata, err error) // UploadSessionFinishBatch : This route helps you commit many files at once - // into a user's Dropbox. Use `uploadSessionStart` and - // `uploadSessionAppendV2` to upload file contents. We recommend uploading - // many files in parallel to increase throughput. Once the file contents - // have been uploaded, rather than calling `uploadSessionFinish`, use this - // route to finish all your upload sessions in a single request. - // `UploadSessionStartArg.close` or `UploadSessionAppendArg.close` needs to - // be true for the last `uploadSessionStart` or `uploadSessionAppendV2` - // call. The maximum size of a file one can upload to an upload session is - // 350 GB. This route will return a job_id immediately and do the async - // commit job in background. Use `uploadSessionFinishBatchCheck` to check - // the job status. For the same account, this route should be executed - // serially. That means you should not start the next job before current job - // finishes. We allow up to 1000 entries in a single request. + // into a user's Dropbox. Use `uploadSessionStart` and `uploadSessionAppend` + // to upload file contents. We recommend uploading many files in parallel to + // increase throughput. Once the file contents have been uploaded, rather + // than calling `uploadSessionFinish`, use this route to finish all your + // upload sessions in a single request. `UploadSessionStartArg.close` or + // `UploadSessionAppendArg.close` needs to be true for the last + // `uploadSessionStart` or `uploadSessionAppend` call. The maximum size of a + // file one can upload to an upload session is 350 GB. This route will + // return a job_id immediately and do the async commit job in background. + // Use `uploadSessionFinishBatchCheck` to check the job status. For the same + // account, this route should be executed serially. That means you should + // not start the next job before current job finishes. We allow up to 1000 + // entries in a single request. Calls to this endpoint will count as data + // transport calls for any Dropbox Business teams with a limit on the number + // of data transport calls allowed per month. For more information, see the + // `Data transport limit page` + // . UploadSessionFinishBatch(arg *UploadSessionFinishBatchArg) (res *UploadSessionFinishBatchLaunch, err error) // UploadSessionFinishBatchCheck : Returns the status of an asynchronous job // for `uploadSessionFinishBatch`. If success, it returns list of result for @@ -283,14 +360,18 @@ // UploadSessionStart : Upload sessions allow you to upload a single file in // one or more requests, for example where the size of the file is greater // than 150 MB. This call starts a new upload session with the given data. - // You can then use `uploadSessionAppendV2` to add more data and + // You can then use `uploadSessionAppend` to add more data and // `uploadSessionFinish` to save all the data to a file in Dropbox. A single // request should not upload more than 150 MB. The maximum size of a file // one can upload to an upload session is 350 GB. An upload session can be // used for a maximum of 48 hours. Attempting to use an - // `UploadSessionStartResult.session_id` with `uploadSessionAppendV2` or + // `UploadSessionStartResult.session_id` with `uploadSessionAppend` or // `uploadSessionFinish` more than 48 hours after its creation will return a - // `UploadSessionLookupError.not_found`. + // `UploadSessionLookupError.not_found`. Calls to this endpoint will count + // as data transport calls for any Dropbox Business teams with a limit on + // the number of data transport calls allowed per month. For more + // information, see the `Data transport limit page` + // . UploadSessionStart(arg *UploadSessionStartArg, content io.Reader) (res *UploadSessionStartResult, err error) } @@ -339,7 +420,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { var tmp metadataUnion err = json.Unmarshal(body, &tmp) @@ -368,17 +449,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -426,7 +501,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -444,17 +519,77 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) + if err != nil { + return + } + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) + return +} + +//CopyV2APIError is an error-wrapper for the copy route +type CopyV2APIError struct { + dropbox.APIError + EndpointError *RelocationError `json:"error"` +} + +func (dbx *apiImpl) CopyV2(arg *RelocationArg) (res *RelocationResult, err error) { + cli := dbx.Client + + dbx.Config.LogDebug("arg: %v", arg) + b, err := json.Marshal(arg) + if err != nil { + return + } + + headers := map[string]string{ + "Content-Type": "application/json", + } + if dbx.Config.AsMemberID != "" { + headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID + } + + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "copy_v2", headers, bytes.NewReader(b)) + if err != nil { + return + } + dbx.Config.LogInfo("req: %v", req) + + resp, err := cli.Do(req) + if err != nil { + return + } + + dbx.Config.LogInfo("resp: %v", resp) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return + } + + dbx.Config.LogDebug("body: %s", body) + if resp.StatusCode == http.StatusOK { + err = json.Unmarshal(body, &res) + if err != nil { + return + } + + return + } + if resp.StatusCode == http.StatusConflict { + var apiError CopyAPIError + err = json.Unmarshal(body, &apiError) + if err != nil { + return + } err = apiError return } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -466,7 +601,7 @@ func (dbx *apiImpl) Copy(arg *RelocationArg) (res IsMetadata, err error) { log.Printf("WARNING: API `Copy` is deprecated") - log.Printf("Use API `CopyV2` instead") + log.Printf("Use API `Copy` instead") cli := dbx.Client @@ -501,7 +636,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { var tmp metadataUnion err = json.Unmarshal(body, &tmp) @@ -530,17 +665,77 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) + if err != nil { + return + } + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) + return +} + +//CopyBatchV2APIError is an error-wrapper for the copy_batch route +type CopyBatchV2APIError struct { + dropbox.APIError + EndpointError struct{} `json:"error"` +} + +func (dbx *apiImpl) CopyBatchV2(arg *RelocationBatchArgBase) (res *RelocationBatchV2Launch, err error) { + cli := dbx.Client + + dbx.Config.LogDebug("arg: %v", arg) + b, err := json.Marshal(arg) + if err != nil { + return + } + + headers := map[string]string{ + "Content-Type": "application/json", + } + if dbx.Config.AsMemberID != "" { + headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID + } + + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "copy_batch_v2", headers, bytes.NewReader(b)) + if err != nil { + return + } + dbx.Config.LogInfo("req: %v", req) + + resp, err := cli.Do(req) + if err != nil { + return + } + + dbx.Config.LogInfo("resp: %v", resp) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return + } + + dbx.Config.LogDebug("body: %s", body) + if resp.StatusCode == http.StatusOK { + err = json.Unmarshal(body, &res) + if err != nil { + return + } + + return + } + if resp.StatusCode == http.StatusConflict { + var apiError CopyBatchAPIError + err = json.Unmarshal(body, &apiError) + if err != nil { + return + } err = apiError return } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -551,6 +746,9 @@ } func (dbx *apiImpl) CopyBatch(arg *RelocationBatchArg) (res *RelocationBatchLaunch, err error) { + log.Printf("WARNING: API `CopyBatch` is deprecated") + log.Printf("Use API `CopyBatch` instead") + cli := dbx.Client dbx.Config.LogDebug("arg: %v", arg) @@ -584,7 +782,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -602,17 +800,77 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) + if err != nil { + return + } + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) + return +} + +//CopyBatchCheckV2APIError is an error-wrapper for the copy_batch/check route +type CopyBatchCheckV2APIError struct { + dropbox.APIError + EndpointError *async.PollError `json:"error"` +} + +func (dbx *apiImpl) CopyBatchCheckV2(arg *async.PollArg) (res *RelocationBatchV2JobStatus, err error) { + cli := dbx.Client + + dbx.Config.LogDebug("arg: %v", arg) + b, err := json.Marshal(arg) + if err != nil { + return + } + + headers := map[string]string{ + "Content-Type": "application/json", + } + if dbx.Config.AsMemberID != "" { + headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID + } + + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "copy_batch/check_v2", headers, bytes.NewReader(b)) + if err != nil { + return + } + dbx.Config.LogInfo("req: %v", req) + + resp, err := cli.Do(req) + if err != nil { + return + } + + dbx.Config.LogInfo("resp: %v", resp) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return + } + + dbx.Config.LogDebug("body: %s", body) + if resp.StatusCode == http.StatusOK { + err = json.Unmarshal(body, &res) + if err != nil { + return + } + + return + } + if resp.StatusCode == http.StatusConflict { + var apiError CopyBatchCheckAPIError + err = json.Unmarshal(body, &apiError) + if err != nil { + return + } err = apiError return } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -623,6 +881,9 @@ } func (dbx *apiImpl) CopyBatchCheck(arg *async.PollArg) (res *RelocationBatchJobStatus, err error) { + log.Printf("WARNING: API `CopyBatchCheck` is deprecated") + log.Printf("Use API `CopyBatchCheck` instead") + cli := dbx.Client dbx.Config.LogDebug("arg: %v", arg) @@ -656,7 +917,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -674,17 +935,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -728,7 +983,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -746,17 +1001,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -800,7 +1049,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -818,27 +1067,21 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } -//CopyV2APIError is an error-wrapper for the copy_v2 route -type CopyV2APIError struct { +//CreateFolderV2APIError is an error-wrapper for the create_folder route +type CreateFolderV2APIError struct { dropbox.APIError - EndpointError *RelocationError `json:"error"` + EndpointError *CreateFolderError `json:"error"` } -func (dbx *apiImpl) CopyV2(arg *RelocationArg) (res *RelocationResult, err error) { +func (dbx *apiImpl) CreateFolderV2(arg *CreateFolderArg) (res *CreateFolderResult, err error) { cli := dbx.Client dbx.Config.LogDebug("arg: %v", arg) @@ -854,7 +1097,7 @@ headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "copy_v2", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "create_folder_v2", headers, bytes.NewReader(b)) if err != nil { return } @@ -872,7 +1115,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -882,7 +1125,7 @@ return } if resp.StatusCode == http.StatusConflict { - var apiError CopyV2APIError + var apiError CreateFolderAPIError err = json.Unmarshal(body, &apiError) if err != nil { return @@ -890,17 +1133,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -912,7 +1149,7 @@ func (dbx *apiImpl) CreateFolder(arg *CreateFolderArg) (res *FolderMetadata, err error) { log.Printf("WARNING: API `CreateFolder` is deprecated") - log.Printf("Use API `CreateFolderV2` instead") + log.Printf("Use API `CreateFolder` instead") cli := dbx.Client @@ -947,7 +1184,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -965,17 +1202,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1019,7 +1250,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1037,17 +1268,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1091,7 +1316,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1109,27 +1334,21 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } -//CreateFolderV2APIError is an error-wrapper for the create_folder_v2 route -type CreateFolderV2APIError struct { +//DeleteV2APIError is an error-wrapper for the delete route +type DeleteV2APIError struct { dropbox.APIError - EndpointError *CreateFolderError `json:"error"` + EndpointError *DeleteError `json:"error"` } -func (dbx *apiImpl) CreateFolderV2(arg *CreateFolderArg) (res *CreateFolderResult, err error) { +func (dbx *apiImpl) DeleteV2(arg *DeleteArg) (res *DeleteResult, err error) { cli := dbx.Client dbx.Config.LogDebug("arg: %v", arg) @@ -1145,7 +1364,7 @@ headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "create_folder_v2", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "delete_v2", headers, bytes.NewReader(b)) if err != nil { return } @@ -1163,7 +1382,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1173,7 +1392,7 @@ return } if resp.StatusCode == http.StatusConflict { - var apiError CreateFolderV2APIError + var apiError DeleteAPIError err = json.Unmarshal(body, &apiError) if err != nil { return @@ -1181,17 +1400,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1203,7 +1416,7 @@ func (dbx *apiImpl) Delete(arg *DeleteArg) (res IsMetadata, err error) { log.Printf("WARNING: API `Delete` is deprecated") - log.Printf("Use API `DeleteV2` instead") + log.Printf("Use API `Delete` instead") cli := dbx.Client @@ -1238,7 +1451,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { var tmp metadataUnion err = json.Unmarshal(body, &tmp) @@ -1267,17 +1480,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1321,7 +1528,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1339,17 +1546,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1393,7 +1594,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1411,89 +1612,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError - return -} - -//DeleteV2APIError is an error-wrapper for the delete_v2 route -type DeleteV2APIError struct { - dropbox.APIError - EndpointError *DeleteError `json:"error"` -} - -func (dbx *apiImpl) DeleteV2(arg *DeleteArg) (res *DeleteResult, err error) { - cli := dbx.Client - - dbx.Config.LogDebug("arg: %v", arg) - b, err := json.Marshal(arg) - if err != nil { - return - } - - headers := map[string]string{ - "Content-Type": "application/json", - } - if dbx.Config.AsMemberID != "" { - headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID - } - - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "delete_v2", headers, bytes.NewReader(b)) - if err != nil { - return - } - dbx.Config.LogInfo("req: %v", req) - - resp, err := cli.Do(req) - if err != nil { - return - } - - dbx.Config.LogInfo("resp: %v", resp) - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return - } - - dbx.Config.LogDebug("body: %v", body) - if resp.StatusCode == http.StatusOK { - err = json.Unmarshal(body, &res) - if err != nil { - return - } - - return - } - if resp.StatusCode == http.StatusConflict { - var apiError DeleteV2APIError - err = json.Unmarshal(body, &apiError) - if err != nil { - return - } - err = apiError - return - } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) - if err != nil { - return - } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1536,7 +1659,7 @@ dbx.Config.LogInfo("resp: %v", resp) body := []byte(resp.Header.Get("Dropbox-API-Result")) content = resp.Body - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusPartialContent { err = json.Unmarshal(body, &res) if err != nil { @@ -1559,17 +1682,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1609,7 +1726,7 @@ dbx.Config.LogInfo("resp: %v", resp) body := []byte(resp.Header.Get("Dropbox-API-Result")) content = resp.Body - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1632,17 +1749,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1686,7 +1797,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { var tmp metadataUnion err = json.Unmarshal(body, &tmp) @@ -1715,17 +1826,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1757,15 +1862,86 @@ } dbx.Config.LogInfo("req: %v", req) - resp, err := cli.Do(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: %s", 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 GetPreviewAPIError + err = json.Unmarshal(body, &apiError) + if err != nil { + return + } + err = apiError + return + } + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) + if err != nil { + return + } + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) + return +} + +//GetTemporaryLinkAPIError is an error-wrapper for the get_temporary_link route +type GetTemporaryLinkAPIError struct { + dropbox.APIError + EndpointError *GetTemporaryLinkError `json:"error"` +} + +func (dbx *apiImpl) GetTemporaryLink(arg *GetTemporaryLinkArg) (res *GetTemporaryLinkResult, err error) { + cli := dbx.Client + + dbx.Config.LogDebug("arg: %v", arg) + b, err := json.Marshal(arg) + if err != nil { + return + } + + headers := map[string]string{ + "Content-Type": "application/json", + } + if dbx.Config.AsMemberID != "" { + headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID + } + + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "get_temporary_link", headers, bytes.NewReader(b)) + if err != nil { + return + } + dbx.Config.LogInfo("req: %v", req) + + resp, err := cli.Do(req) + if err != nil { + return + } + + dbx.Config.LogInfo("resp: %v", resp) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) if err != nil { return } - dbx.Config.LogInfo("resp: %v", resp) - body := []byte(resp.Header.Get("Dropbox-API-Result")) - content = resp.Body - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1775,12 +1951,7 @@ return } if resp.StatusCode == http.StatusConflict { - defer resp.Body.Close() - body, err = ioutil.ReadAll(resp.Body) - if err != nil { - return - } - var apiError GetPreviewAPIError + var apiError GetTemporaryLinkAPIError err = json.Unmarshal(body, &apiError) if err != nil { return @@ -1788,27 +1959,21 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } -//GetTemporaryLinkAPIError is an error-wrapper for the get_temporary_link route -type GetTemporaryLinkAPIError struct { +//GetTemporaryUploadLinkAPIError is an error-wrapper for the get_temporary_upload_link route +type GetTemporaryUploadLinkAPIError struct { dropbox.APIError - EndpointError *GetTemporaryLinkError `json:"error"` + EndpointError struct{} `json:"error"` } -func (dbx *apiImpl) GetTemporaryLink(arg *GetTemporaryLinkArg) (res *GetTemporaryLinkResult, err error) { +func (dbx *apiImpl) GetTemporaryUploadLink(arg *GetTemporaryUploadLinkArg) (res *GetTemporaryUploadLinkResult, err error) { cli := dbx.Client dbx.Config.LogDebug("arg: %v", arg) @@ -1824,7 +1989,7 @@ headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "get_temporary_link", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "get_temporary_upload_link", headers, bytes.NewReader(b)) if err != nil { return } @@ -1842,7 +2007,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1852,7 +2017,7 @@ return } if resp.StatusCode == http.StatusConflict { - var apiError GetTemporaryLinkAPIError + var apiError GetTemporaryUploadLinkAPIError err = json.Unmarshal(body, &apiError) if err != nil { return @@ -1860,17 +2025,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1910,7 +2069,7 @@ dbx.Config.LogInfo("resp: %v", resp) body := []byte(resp.Header.Get("Dropbox-API-Result")) content = resp.Body - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1933,17 +2092,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1987,7 +2140,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2005,17 +2158,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2059,7 +2206,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2077,17 +2224,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2131,7 +2272,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2149,17 +2290,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2203,7 +2338,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2221,17 +2356,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2272,7 +2401,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2290,17 +2419,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2344,7 +2467,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2362,17 +2485,77 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) + if err != nil { + return + } + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) + return +} + +//MoveV2APIError is an error-wrapper for the move route +type MoveV2APIError struct { + dropbox.APIError + EndpointError *RelocationError `json:"error"` +} + +func (dbx *apiImpl) MoveV2(arg *RelocationArg) (res *RelocationResult, err error) { + cli := dbx.Client + + dbx.Config.LogDebug("arg: %v", arg) + b, err := json.Marshal(arg) + if err != nil { + return + } + + headers := map[string]string{ + "Content-Type": "application/json", + } + if dbx.Config.AsMemberID != "" { + headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID + } + + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "move_v2", headers, bytes.NewReader(b)) + if err != nil { + return + } + dbx.Config.LogInfo("req: %v", req) + + resp, err := cli.Do(req) + if err != nil { + return + } + + dbx.Config.LogInfo("resp: %v", resp) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return + } + + dbx.Config.LogDebug("body: %s", body) + if resp.StatusCode == http.StatusOK { + err = json.Unmarshal(body, &res) + if err != nil { + return + } + + return + } + if resp.StatusCode == http.StatusConflict { + var apiError MoveAPIError + err = json.Unmarshal(body, &apiError) + if err != nil { + return + } err = apiError return } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2384,7 +2567,7 @@ func (dbx *apiImpl) Move(arg *RelocationArg) (res IsMetadata, err error) { log.Printf("WARNING: API `Move` is deprecated") - log.Printf("Use API `MoveV2` instead") + log.Printf("Use API `Move` instead") cli := dbx.Client @@ -2419,7 +2602,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { var tmp metadataUnion err = json.Unmarshal(body, &tmp) @@ -2448,17 +2631,77 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) + if err != nil { + return + } + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) + return +} + +//MoveBatchV2APIError is an error-wrapper for the move_batch route +type MoveBatchV2APIError struct { + dropbox.APIError + EndpointError struct{} `json:"error"` +} + +func (dbx *apiImpl) MoveBatchV2(arg *MoveBatchArg) (res *RelocationBatchV2Launch, err error) { + cli := dbx.Client + + dbx.Config.LogDebug("arg: %v", arg) + b, err := json.Marshal(arg) + if err != nil { + return + } + + headers := map[string]string{ + "Content-Type": "application/json", + } + if dbx.Config.AsMemberID != "" { + headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID + } + + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "move_batch_v2", headers, bytes.NewReader(b)) + if err != nil { + return + } + dbx.Config.LogInfo("req: %v", req) + + resp, err := cli.Do(req) + if err != nil { + return + } + + dbx.Config.LogInfo("resp: %v", resp) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return + } + + dbx.Config.LogDebug("body: %s", body) + if resp.StatusCode == http.StatusOK { + err = json.Unmarshal(body, &res) + if err != nil { + return + } + + return + } + if resp.StatusCode == http.StatusConflict { + var apiError MoveBatchAPIError + err = json.Unmarshal(body, &apiError) + if err != nil { + return + } err = apiError return } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2502,7 +2745,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2520,27 +2763,21 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } -//MoveBatchCheckAPIError is an error-wrapper for the move_batch/check route -type MoveBatchCheckAPIError struct { +//MoveBatchCheckV2APIError is an error-wrapper for the move_batch/check route +type MoveBatchCheckV2APIError struct { dropbox.APIError EndpointError *async.PollError `json:"error"` } -func (dbx *apiImpl) MoveBatchCheck(arg *async.PollArg) (res *RelocationBatchJobStatus, err error) { +func (dbx *apiImpl) MoveBatchCheckV2(arg *async.PollArg) (res *RelocationBatchV2JobStatus, err error) { cli := dbx.Client dbx.Config.LogDebug("arg: %v", arg) @@ -2556,7 +2793,7 @@ headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "move_batch/check", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "move_batch/check_v2", headers, bytes.NewReader(b)) if err != nil { return } @@ -2574,7 +2811,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2592,27 +2829,21 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } -//MoveV2APIError is an error-wrapper for the move_v2 route -type MoveV2APIError struct { +//MoveBatchCheckAPIError is an error-wrapper for the move_batch/check route +type MoveBatchCheckAPIError struct { dropbox.APIError - EndpointError *RelocationError `json:"error"` + EndpointError *async.PollError `json:"error"` } -func (dbx *apiImpl) MoveV2(arg *RelocationArg) (res *RelocationResult, err error) { +func (dbx *apiImpl) MoveBatchCheck(arg *async.PollArg) (res *RelocationBatchJobStatus, err error) { cli := dbx.Client dbx.Config.LogDebug("arg: %v", arg) @@ -2628,7 +2859,7 @@ headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "move_v2", headers, bytes.NewReader(b)) + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "files", "move_batch/check", headers, bytes.NewReader(b)) if err != nil { return } @@ -2646,7 +2877,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2656,7 +2887,7 @@ return } if resp.StatusCode == http.StatusConflict { - var apiError MoveV2APIError + var apiError MoveBatchCheckAPIError err = json.Unmarshal(body, &apiError) if err != nil { return @@ -2664,17 +2895,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2718,7 +2943,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -2731,17 +2956,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2787,7 +3006,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -2800,17 +3019,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2856,7 +3069,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -2869,17 +3082,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2925,7 +3132,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -2938,17 +3145,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2994,7 +3195,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3012,17 +3213,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3060,7 +3255,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3078,17 +3273,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3134,7 +3323,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -3147,17 +3336,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3201,7 +3384,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3219,17 +3402,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3273,7 +3450,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3291,17 +3468,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3345,7 +3516,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3363,17 +3534,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3417,7 +3582,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3435,17 +3600,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3490,7 +3649,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3508,30 +3667,21 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } -//UploadSessionAppendAPIError is an error-wrapper for the upload_session/append route -type UploadSessionAppendAPIError struct { +//UploadSessionAppendV2APIError is an error-wrapper for the upload_session/append route +type UploadSessionAppendV2APIError struct { dropbox.APIError EndpointError *UploadSessionLookupError `json:"error"` } -func (dbx *apiImpl) UploadSessionAppend(arg *UploadSessionCursor, content io.Reader) (err error) { - log.Printf("WARNING: API `UploadSessionAppend` is deprecated") - log.Printf("Use API `UploadSessionAppendV2` instead") - +func (dbx *apiImpl) UploadSessionAppendV2(arg *UploadSessionAppendArg, content io.Reader) (err error) { cli := dbx.Client dbx.Config.LogDebug("arg: %v", arg) @@ -3548,7 +3698,7 @@ headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("content", "upload", true, "files", "upload_session/append", headers, content) + req, err := (*dropbox.Context)(dbx).NewRequest("content", "upload", true, "files", "upload_session/append_v2", headers, content) if err != nil { return } @@ -3566,7 +3716,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -3579,27 +3729,24 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } -//UploadSessionAppendV2APIError is an error-wrapper for the upload_session/append_v2 route -type UploadSessionAppendV2APIError struct { +//UploadSessionAppendAPIError is an error-wrapper for the upload_session/append route +type UploadSessionAppendAPIError struct { dropbox.APIError EndpointError *UploadSessionLookupError `json:"error"` } -func (dbx *apiImpl) UploadSessionAppendV2(arg *UploadSessionAppendArg, content io.Reader) (err error) { +func (dbx *apiImpl) UploadSessionAppend(arg *UploadSessionCursor, content io.Reader) (err error) { + log.Printf("WARNING: API `UploadSessionAppend` is deprecated") + log.Printf("Use API `UploadSessionAppend` instead") + cli := dbx.Client dbx.Config.LogDebug("arg: %v", arg) @@ -3616,7 +3763,7 @@ headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID } - req, err := (*dropbox.Context)(dbx).NewRequest("content", "upload", true, "files", "upload_session/append_v2", headers, content) + req, err := (*dropbox.Context)(dbx).NewRequest("content", "upload", true, "files", "upload_session/append", headers, content) if err != nil { return } @@ -3634,12 +3781,12 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } if resp.StatusCode == http.StatusConflict { - var apiError UploadSessionAppendV2APIError + var apiError UploadSessionAppendAPIError err = json.Unmarshal(body, &apiError) if err != nil { return @@ -3647,17 +3794,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3702,7 +3843,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3720,17 +3861,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3774,7 +3909,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3792,17 +3927,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3846,7 +3975,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3864,17 +3993,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3919,7 +4042,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3937,17 +4060,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/files/types.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/files/types.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/files/types.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/files/types.go 2018-12-22 22:15:38.000000000 +0000 @@ -183,6 +183,11 @@ Mute bool `json:"mute"` // PropertyGroups : List of custom properties to add to file. PropertyGroups []*file_properties.PropertyGroup `json:"property_groups,omitempty"` + // StrictConflict : Be more strict about how each `WriteMode` detects + // conflict. For example, always return a conflict error when `mode` = + // `WriteMode.update` and the given "rev" doesn't match the existing file's + // "rev", even if the existing file has been deleted. + StrictConflict bool `json:"strict_conflict"` } // NewCommitInfo returns a new CommitInfo instance @@ -192,6 +197,7 @@ s.Mode = &WriteMode{Tagged: dropbox.Tagged{"add"}} s.Autorename = false s.Mute = false + s.StrictConflict = false return s } @@ -207,6 +213,7 @@ s.Mode = &WriteMode{Tagged: dropbox.Tagged{"add"}} s.Autorename = false s.Mute = false + s.StrictConflict = false return s } @@ -402,7 +409,8 @@ // CreateFolderBatchResult : has no documentation (yet) type CreateFolderBatchResult struct { FileOpsResult - // Entries : has no documentation (yet) + // Entries : Each entry in `CreateFolderBatchArg.paths` will appear at the + // same position inside `CreateFolderBatchResult.entries`. Entries []*CreateFolderBatchResultEntry `json:"entries"` } @@ -701,7 +709,8 @@ // DeleteBatchResult : has no documentation (yet) type DeleteBatchResult struct { FileOpsResult - // Entries : has no documentation (yet) + // Entries : Each entry in `DeleteBatchArg.entries` will appear at the same + // position inside `DeleteBatchResult.entries`. Entries []*DeleteBatchResultEntry `json:"entries"` } @@ -1171,7 +1180,7 @@ HasExplicitSharedMembers bool `json:"has_explicit_shared_members,omitempty"` // ContentHash : A hash of the file content. This field can be used to // verify data integrity. For more information see our `Content hash` - // page. + // page. ContentHash string `json:"content_hash,omitempty"` } @@ -1436,6 +1445,39 @@ return s } +// GetTemporaryUploadLinkArg : has no documentation (yet) +type GetTemporaryUploadLinkArg struct { + // CommitInfo : Contains the path and other optional modifiers for the + // future upload commit. Equivalent to the parameters provided to `upload`. + CommitInfo *CommitInfo `json:"commit_info"` + // Duration : How long before this link expires, in seconds. Attempting to + // start an upload with this link longer than this period of time after + // link creation will result in an error. + Duration float64 `json:"duration"` +} + +// NewGetTemporaryUploadLinkArg returns a new GetTemporaryUploadLinkArg instance +func NewGetTemporaryUploadLinkArg(CommitInfo *CommitInfo) *GetTemporaryUploadLinkArg { + s := new(GetTemporaryUploadLinkArg) + s.CommitInfo = CommitInfo + s.Duration = 14400.0 + return s +} + +// GetTemporaryUploadLinkResult : has no documentation (yet) +type GetTemporaryUploadLinkResult struct { + // Link : The temporary link which can be used to stream a file to a Dropbox + // location. + Link string `json:"link"` +} + +// NewGetTemporaryUploadLinkResult returns a new GetTemporaryUploadLinkResult instance +func NewGetTemporaryUploadLinkResult(Link string) *GetTemporaryUploadLinkResult { + s := new(GetTemporaryUploadLinkResult) + s.Link = Link + return s +} + // GetThumbnailBatchArg : Arguments for `getThumbnailBatch`. type GetThumbnailBatchArg struct { // Entries : List of files to get thumbnails. @@ -1477,7 +1519,8 @@ type GetThumbnailBatchResultData struct { // Metadata : has no documentation (yet) Metadata *FileMetadata `json:"metadata"` - // Thumbnail : has no documentation (yet) + // Thumbnail : A string containing the base64-encoded thumbnail data for + // this file. Thumbnail string `json:"thumbnail"` } @@ -1895,7 +1938,10 @@ // LookupError : has no documentation (yet) type LookupError struct { dropbox.Tagged - // MalformedPath : has no documentation (yet) + // MalformedPath : The given path does not satisfy the required path format. + // Please refer to the `Path formats documentation` + // + // for more information. MalformedPath string `json:"malformed_path,omitempty"` } @@ -1913,7 +1959,10 @@ func (u *LookupError) UnmarshalJSON(body []byte) error { type wrap struct { dropbox.Tagged - // MalformedPath : has no documentation (yet) + // MalformedPath : The given path does not satisfy the required path + // format. Please refer to the `Path formats documentation` + // + // for more information. MalformedPath json.RawMessage `json:"malformed_path,omitempty"` } var w wrap @@ -2057,6 +2106,42 @@ return nil, nil } +// RelocationBatchArgBase : has no documentation (yet) +type RelocationBatchArgBase struct { + // Entries : List of entries to be moved or copied. Each entry is + // `RelocationPath`. + Entries []*RelocationPath `json:"entries"` + // Autorename : If there's a conflict with any file, have the Dropbox server + // try to autorename that file to avoid the conflict. + Autorename bool `json:"autorename"` +} + +// NewRelocationBatchArgBase returns a new RelocationBatchArgBase instance +func NewRelocationBatchArgBase(Entries []*RelocationPath) *RelocationBatchArgBase { + s := new(RelocationBatchArgBase) + s.Entries = Entries + s.Autorename = false + return s +} + +// MoveBatchArg : has no documentation (yet) +type MoveBatchArg struct { + RelocationBatchArgBase + // AllowOwnershipTransfer : Allow moves by owner even if it would result in + // an ownership transfer for the content being moved. This does not apply to + // copies. + AllowOwnershipTransfer bool `json:"allow_ownership_transfer"` +} + +// NewMoveBatchArg returns a new MoveBatchArg instance +func NewMoveBatchArg(Entries []*RelocationPath) *MoveBatchArg { + s := new(MoveBatchArg) + s.Entries = Entries + s.Autorename = false + s.AllowOwnershipTransfer = false + return s +} + // PhotoMetadata : Metadata for a photo. type PhotoMetadata struct { MediaMetadata @@ -2167,17 +2252,12 @@ // RelocationBatchArg : has no documentation (yet) type RelocationBatchArg struct { - // Entries : List of entries to be moved or copied. Each entry is - // `RelocationPath`. - Entries []*RelocationPath `json:"entries"` + RelocationBatchArgBase // AllowSharedFolder : If true, `copyBatch` will copy contents in shared // folder, otherwise `RelocationError.cant_copy_shared_folder` will be - // returned if `RelocationPath.from_path` contains shared folder. This - // field is always true for `moveBatch`. + // returned if `RelocationPath.from_path` contains shared folder. This field + // is always true for `moveBatch`. AllowSharedFolder bool `json:"allow_shared_folder"` - // Autorename : If there's a conflict with any file, have the Dropbox server - // try to autorename that file to avoid the conflict. - Autorename bool `json:"autorename"` // AllowOwnershipTransfer : Allow moves by owner even if it would result in // an ownership transfer for the content being moved. This does not apply to // copies. @@ -2188,8 +2268,8 @@ func NewRelocationBatchArg(Entries []*RelocationPath) *RelocationBatchArg { s := new(RelocationBatchArg) s.Entries = Entries - s.AllowSharedFolder = false s.Autorename = false + s.AllowSharedFolder = false s.AllowOwnershipTransfer = false return s } @@ -2217,6 +2297,7 @@ RelocationErrorDuplicatedOrNestedPaths = "duplicated_or_nested_paths" RelocationErrorCantTransferOwnership = "cant_transfer_ownership" RelocationErrorInsufficientQuota = "insufficient_quota" + RelocationErrorInternalError = "internal_error" RelocationErrorOther = "other" ) @@ -2283,6 +2364,7 @@ RelocationBatchErrorDuplicatedOrNestedPaths = "duplicated_or_nested_paths" RelocationBatchErrorCantTransferOwnership = "cant_transfer_ownership" RelocationBatchErrorInsufficientQuota = "insufficient_quota" + RelocationBatchErrorInternalError = "internal_error" RelocationBatchErrorOther = "other" RelocationBatchErrorTooManyWriteOperations = "too_many_write_operations" ) @@ -2327,6 +2409,45 @@ return nil } +// RelocationBatchErrorEntry : has no documentation (yet) +type RelocationBatchErrorEntry struct { + dropbox.Tagged + // RelocationError : User errors that retry won't help. + RelocationError *RelocationError `json:"relocation_error,omitempty"` +} + +// Valid tag values for RelocationBatchErrorEntry +const ( + RelocationBatchErrorEntryRelocationError = "relocation_error" + RelocationBatchErrorEntryInternalError = "internal_error" + RelocationBatchErrorEntryTooManyWriteOperations = "too_many_write_operations" + RelocationBatchErrorEntryOther = "other" +) + +// UnmarshalJSON deserializes into a RelocationBatchErrorEntry instance +func (u *RelocationBatchErrorEntry) UnmarshalJSON(body []byte) error { + type wrap struct { + dropbox.Tagged + // RelocationError : User errors that retry won't help. + RelocationError json.RawMessage `json:"relocation_error,omitempty"` + } + var w wrap + var err error + if err = json.Unmarshal(body, &w); err != nil { + return err + } + u.Tag = w.Tag + switch u.Tag { + case "relocation_error": + err = json.Unmarshal(w.RelocationError, &u.RelocationError) + + if err != nil { + return err + } + } + return nil +} + // RelocationBatchJobStatus : has no documentation (yet) type RelocationBatchJobStatus struct { dropbox.Tagged @@ -2469,6 +2590,156 @@ return nil } +// RelocationBatchResultEntry : has no documentation (yet) +type RelocationBatchResultEntry struct { + dropbox.Tagged + // Success : has no documentation (yet) + Success IsMetadata `json:"success,omitempty"` + // Failure : has no documentation (yet) + Failure *RelocationBatchErrorEntry `json:"failure,omitempty"` +} + +// Valid tag values for RelocationBatchResultEntry +const ( + RelocationBatchResultEntrySuccess = "success" + RelocationBatchResultEntryFailure = "failure" + RelocationBatchResultEntryOther = "other" +) + +// UnmarshalJSON deserializes into a RelocationBatchResultEntry instance +func (u *RelocationBatchResultEntry) UnmarshalJSON(body []byte) error { + type wrap struct { + dropbox.Tagged + // Success : has no documentation (yet) + Success json.RawMessage `json:"success,omitempty"` + // Failure : has no documentation (yet) + Failure json.RawMessage `json:"failure,omitempty"` + } + var w wrap + var err error + if err = json.Unmarshal(body, &w); err != nil { + return err + } + u.Tag = w.Tag + switch u.Tag { + case "success": + u.Success, err = IsMetadataFromJSON(body) + + if err != nil { + return err + } + case "failure": + err = json.Unmarshal(w.Failure, &u.Failure) + + if err != nil { + return err + } + } + return nil +} + +// RelocationBatchV2JobStatus : Result returned by `copyBatch` or `moveBatch` +// that may either launch an asynchronous job or complete synchronously. +type RelocationBatchV2JobStatus struct { + dropbox.Tagged + // Complete : The copy or move batch job has finished. + Complete *RelocationBatchV2Result `json:"complete,omitempty"` +} + +// Valid tag values for RelocationBatchV2JobStatus +const ( + RelocationBatchV2JobStatusInProgress = "in_progress" + RelocationBatchV2JobStatusComplete = "complete" +) + +// UnmarshalJSON deserializes into a RelocationBatchV2JobStatus instance +func (u *RelocationBatchV2JobStatus) UnmarshalJSON(body []byte) error { + type wrap struct { + dropbox.Tagged + // Complete : The copy or move batch job has finished. + Complete json.RawMessage `json:"complete,omitempty"` + } + var w wrap + var err error + if err = json.Unmarshal(body, &w); err != nil { + return err + } + u.Tag = w.Tag + switch u.Tag { + case "complete": + err = json.Unmarshal(body, &u.Complete) + + if err != nil { + return err + } + } + return nil +} + +// RelocationBatchV2Launch : Result returned by `copyBatch` or `moveBatch` that +// may either launch an asynchronous job or complete synchronously. +type RelocationBatchV2Launch struct { + dropbox.Tagged + // AsyncJobId : This response indicates that the processing is asynchronous. + // The string is an id that can be used to obtain the status of the + // asynchronous job. + AsyncJobId string `json:"async_job_id,omitempty"` + // Complete : has no documentation (yet) + Complete *RelocationBatchV2Result `json:"complete,omitempty"` +} + +// Valid tag values for RelocationBatchV2Launch +const ( + RelocationBatchV2LaunchAsyncJobId = "async_job_id" + RelocationBatchV2LaunchComplete = "complete" +) + +// UnmarshalJSON deserializes into a RelocationBatchV2Launch instance +func (u *RelocationBatchV2Launch) UnmarshalJSON(body []byte) error { + type wrap struct { + dropbox.Tagged + // Complete : has no documentation (yet) + Complete json.RawMessage `json:"complete,omitempty"` + } + var w wrap + var err error + if err = json.Unmarshal(body, &w); err != nil { + return err + } + u.Tag = w.Tag + switch u.Tag { + case "async_job_id": + err = json.Unmarshal(body, &u.AsyncJobId) + + if err != nil { + return err + } + case "complete": + err = json.Unmarshal(body, &u.Complete) + + if err != nil { + return err + } + } + return nil +} + +// RelocationBatchV2Result : has no documentation (yet) +type RelocationBatchV2Result struct { + FileOpsResult + // Entries : Each entry in CopyBatchArg.entries or `MoveBatchArg.entries` + // will appear at the same position inside + // `RelocationBatchV2Result.entries`. + Entries []*RelocationBatchResultEntry `json:"entries"` +} + +// NewRelocationBatchV2Result returns a new RelocationBatchV2Result instance +func NewRelocationBatchV2Result(Entries []*RelocationBatchResultEntry) *RelocationBatchV2Result { + s := new(RelocationBatchV2Result) + s.Entries = Entries + return s +} + // RelocationResult : has no documentation (yet) type RelocationResult struct { FileOpsResult @@ -2503,9 +2774,9 @@ // RestoreArg : has no documentation (yet) type RestoreArg struct { - // Path : The path to the file you want to restore. + // Path : The path to save the restored file. Path string `json:"path"` - // Rev : The revision to restore for the file. + // Rev : The revision to restore. Rev string `json:"rev"` } @@ -3258,7 +3529,7 @@ // Cursor : Contains the upload session ID and the offset. Cursor *UploadSessionCursor `json:"cursor"` // Close : If true, the current session will be closed, at which point you - // won't be able to call `uploadSessionAppendV2` anymore with the current + // won't be able to call `uploadSessionAppend` anymore with the current // session. Close bool `json:"close"` } @@ -3407,7 +3678,8 @@ // UploadSessionFinishBatchResult : has no documentation (yet) type UploadSessionFinishBatchResult struct { - // Entries : Commit result for each file in the batch. + // Entries : Each entry in `UploadSessionFinishBatchArg.entries` will appear + // at the same position inside `UploadSessionFinishBatchResult.entries`. Entries []*UploadSessionFinishBatchResultEntry `json:"entries"` } @@ -3597,7 +3869,7 @@ // UploadSessionStartArg : has no documentation (yet) type UploadSessionStartArg struct { // Close : If true, the current session will be closed, at which point you - // won't be able to call `uploadSessionAppendV2` anymore with the current + // won't be able to call `uploadSessionAppend` anymore with the current // session. Close bool `json:"close"` } @@ -3612,7 +3884,7 @@ // UploadSessionStartResult : has no documentation (yet) type UploadSessionStartResult struct { // SessionId : A unique identifier for the upload session. Pass this to - // `uploadSessionAppendV2` and `uploadSessionFinish`. + // `uploadSessionAppend` and `uploadSessionFinish`. SessionId string `json:"session_id"` } @@ -3670,7 +3942,10 @@ // WriteError : has no documentation (yet) type WriteError struct { dropbox.Tagged - // MalformedPath : has no documentation (yet) + // MalformedPath : The given path does not satisfy the required path format. + // Please refer to the `Path formats documentation` + // + // for more information. MalformedPath string `json:"malformed_path,omitempty"` // Conflict : Couldn't write to the target path because there was something // in the way. @@ -3693,7 +3968,10 @@ func (u *WriteError) UnmarshalJSON(body []byte) error { type wrap struct { dropbox.Tagged - // MalformedPath : has no documentation (yet) + // MalformedPath : The given path does not satisfy the required path + // format. Please refer to the `Path formats documentation` + // + // for more information. MalformedPath json.RawMessage `json:"malformed_path,omitempty"` // Conflict : Couldn't write to the target path because there was // something in the way. diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/paper/client.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/paper/client.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/paper/client.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/paper/client.go 2018-12-22 22:15:38.000000000 +0000 @@ -28,6 +28,7 @@ "net/http" "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth" ) // Client interface describes all routes in this namespace @@ -139,7 +140,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -152,17 +153,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -207,7 +202,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -225,17 +220,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -275,7 +264,7 @@ dbx.Config.LogInfo("resp: %v", resp) body := []byte(resp.Header.Get("Dropbox-API-Result")) content = resp.Body - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -298,17 +287,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -352,7 +335,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -370,17 +353,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -424,7 +401,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -442,17 +419,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -496,7 +467,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -514,17 +485,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -568,7 +533,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -586,17 +551,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -640,7 +599,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -658,17 +617,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -712,7 +665,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -725,17 +678,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -779,7 +726,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -797,17 +744,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -851,7 +792,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -864,17 +805,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -919,7 +854,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -937,17 +872,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -991,7 +920,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1009,17 +938,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1063,7 +986,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1081,17 +1004,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1135,7 +1052,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1153,17 +1070,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1207,7 +1118,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -1220,17 +1131,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/sdk.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/sdk.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/sdk.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/sdk.go 2018-12-22 22:15:38.000000000 +0000 @@ -21,6 +21,7 @@ package dropbox import ( + "encoding/json" "fmt" "io" "log" @@ -36,8 +37,8 @@ hostAPI = "api" hostContent = "content" hostNotify = "notify" - sdkVersion = "4.2.0" - specVersion = "222ba8c" + sdkVersion = "5.4.0" + specVersion = "097e9ba" ) // Version returns the current SDK version and API Spec version @@ -206,8 +207,17 @@ return e.ErrorSummary } -func init() { - // These are not registered in the oauth library by default - oauth2.RegisterBrokenAuthHeaderProvider("https://api.dropboxapi.com") - oauth2.RegisterBrokenAuthHeaderProvider("https://api-dbdev.dev.corp.dropbox.com") +// HandleCommonAPIErrors handles common API errors +func HandleCommonAPIErrors(c Config, resp *http.Response, body []byte) error { + var apiError APIError + if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { + apiError.ErrorSummary = string(body) + return apiError + } + e := json.Unmarshal(body, &apiError) + if e != nil { + c.LogDebug("%v", e) + return e + } + return apiError } diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/sdk_test.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/sdk_test.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/sdk_test.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/sdk_test.go 2018-12-22 22:15:38.000000000 +0000 @@ -28,6 +28,7 @@ "testing" "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth" "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users" ) @@ -53,3 +54,118 @@ t.Errorf("v: %v e: '%s'\n", v, e.Error()) } } + +func TestRateLimitPlainText(t *testing.T) { + eString := "too_many_requests" + ts := httptest.NewServer(http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/plain; charset=utf-8") + w.Header().Set("Retry-After", "10") + http.Error(w, eString, http.StatusTooManyRequests) + })) + 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) + _, e := client.GetCurrentAccount() + re, ok := e.(auth.RateLimitAPIError) + if !ok { + t.Errorf("Unexpected error type: %T\n", e) + } + if re.RateLimitError.RetryAfter != 10 { + t.Errorf("Unexpected retry-after value: %d\n", re.RateLimitError.RetryAfter) + } + if re.RateLimitError.Reason.Tag != auth.RateLimitReasonTooManyRequests { + t.Errorf("Unexpected reason: %v\n", re.RateLimitError.Reason) + } +} + +func TestRateLimitJSON(t *testing.T) { + eString := `{"error_summary": "too_many_requests/..", "error": {"reason": {".tag": "too_many_requests"}, "retry_after": 300}}` + ts := httptest.NewServer(http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Retry-After", "10") + w.WriteHeader(http.StatusTooManyRequests) + w.Write([]byte(eString)) + })) + 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) + _, e := client.GetCurrentAccount() + re, ok := e.(auth.RateLimitAPIError) + if !ok { + t.Errorf("Unexpected error type: %T\n", e) + } + if re.RateLimitError.RetryAfter != 300 { + t.Errorf("Unexpected retry-after value: %d\n", re.RateLimitError.RetryAfter) + } + if re.RateLimitError.Reason.Tag != auth.RateLimitReasonTooManyRequests { + t.Errorf("Unexpected reason: %v\n", re.RateLimitError.Reason) + } +} + +func TestAuthError(t *testing.T) { + eString := `{"error_summary": "user_suspended/...", "error": {".tag": "user_suspended"}}` + ts := httptest.NewServer(http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(http.StatusUnauthorized) + w.Write([]byte(eString)) + })) + 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) + _, e := client.GetCurrentAccount() + re, ok := e.(auth.AuthAPIError) + if !ok { + t.Errorf("Unexpected error type: %T\n", e) + } + fmt.Printf("ERROR is %v\n", re) + if re.AuthError.Tag != auth.AuthErrorUserSuspended { + t.Errorf("Unexpected tag: %s\n", re.AuthError.Tag) + } +} + +func TestAccessError(t *testing.T) { + eString := `{"error_summary": "access_error/...", + "error": { + ".tag": "paper_access_denied", + "paper_access_denied": {".tag": "not_paper_user"} + }}` + ts := httptest.NewServer(http.HandlerFunc( + func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(http.StatusForbidden) + w.Write([]byte(eString)) + })) + 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) + _, e := client.GetCurrentAccount() + re, ok := e.(auth.AccessAPIError) + if !ok { + t.Errorf("Unexpected error type: %T\n", e) + } + if re.AccessError.Tag != auth.AccessErrorPaperAccessDenied { + t.Errorf("Unexpected tag: %s\n", re.AccessError.Tag) + } + if re.AccessError.PaperAccessDenied.Tag != auth.PaperAccessErrorNotPaperUser { + t.Errorf("Unexpected tag: %s\n", re.AccessError.PaperAccessDenied.Tag) + } +} diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/sharing/client.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/sharing/client.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/sharing/client.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/sharing/client.go 2018-12-22 22:15:38.000000000 +0000 @@ -30,6 +30,7 @@ "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/async" + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth" ) // Client interface describes all routes in this namespace @@ -39,23 +40,19 @@ // AddFolderMember : Allows an owner or editor (if the ACL update policy // allows) of a shared folder to add another member. For the new member to // get access to all the functionality for this folder, you will need to - // call `mountFolder` on their behalf. Apps must have full Dropbox access to - // use this endpoint. + // call `mountFolder` on their behalf. AddFolderMember(arg *AddFolderMemberArg) (err error) // ChangeFileMemberAccess : Identical to update_file_member but with less // information returned. // Deprecated: Use `UpdateFileMember` instead ChangeFileMemberAccess(arg *ChangeFileMemberAccessArgs) (res *FileMemberActionResult, err error) - // CheckJobStatus : Returns the status of an asynchronous job. Apps must - // have full Dropbox access to use this endpoint. + // CheckJobStatus : Returns the status of an asynchronous job. CheckJobStatus(arg *async.PollArg) (res *JobStatus, err error) // CheckRemoveMemberJobStatus : Returns the status of an asynchronous job - // for sharing a folder. Apps must have full Dropbox access to use this - // endpoint. + // for sharing a folder. CheckRemoveMemberJobStatus(arg *async.PollArg) (res *RemoveMemberJobStatus, err error) // CheckShareJobStatus : Returns the status of an asynchronous job for - // sharing a folder. Apps must have full Dropbox access to use this - // endpoint. + // sharing a folder. CheckShareJobStatus(arg *async.PollArg) (res *ShareFolderJobStatus, err error) // CreateSharedLink : Create a shared link. If a shared link already exists // for the given path, that link is returned. Note that in the returned @@ -76,8 +73,7 @@ GetFileMetadata(arg *GetFileMetadataArg) (res *SharedFileMetadata, err error) // GetFileMetadataBatch : Returns shared file metadata. GetFileMetadataBatch(arg *GetFileMetadataBatchArg) (res []*GetFileMetadataBatchResult, err error) - // GetFolderMetadata : Returns shared folder metadata by its folder ID. Apps - // must have full Dropbox access to use this endpoint. + // GetFolderMetadata : Returns shared folder metadata by its folder ID. GetFolderMetadata(arg *GetMetadataArgs) (res *SharedFolderMetadata, err error) // GetSharedLinkFile : Download the shared link's file from a user's // Dropbox. @@ -107,30 +103,26 @@ // all shared file members. ListFileMembersContinue(arg *ListFileMembersContinueArg) (res *SharedFileMembers, err error) // ListFolderMembers : Returns shared folder membership by its folder ID. - // Apps must have full Dropbox access to use this endpoint. ListFolderMembers(arg *ListFolderMembersArgs) (res *SharedFolderMembers, err error) // ListFolderMembersContinue : Once a cursor has been retrieved from // `listFolderMembers`, use this to paginate through all shared folder - // members. Apps must have full Dropbox access to use this endpoint. + // members. ListFolderMembersContinue(arg *ListFolderMembersContinueArg) (res *SharedFolderMembers, err error) // ListFolders : Return the list of all shared folders the current user has - // access to. Apps must have full Dropbox access to use this endpoint. + // access to. ListFolders(arg *ListFoldersArgs) (res *ListFoldersResult, err error) // ListFoldersContinue : Once a cursor has been retrieved from // `listFolders`, use this to paginate through all shared folders. The // cursor must come from a previous call to `listFolders` or - // `listFoldersContinue`. Apps must have full Dropbox access to use this - // endpoint. + // `listFoldersContinue`. ListFoldersContinue(arg *ListFoldersContinueArg) (res *ListFoldersResult, err error) // ListMountableFolders : Return the list of all shared folders the current - // user can mount or unmount. Apps must have full Dropbox access to use this - // endpoint. + // user can mount or unmount. ListMountableFolders(arg *ListFoldersArgs) (res *ListFoldersResult, err error) // ListMountableFoldersContinue : Once a cursor has been retrieved from // `listMountableFolders`, use this to paginate through all mountable shared // folders. The cursor must come from a previous call to - // `listMountableFolders` or `listMountableFoldersContinue`. Apps must have - // full Dropbox access to use this endpoint. + // `listMountableFolders` or `listMountableFoldersContinue`. ListMountableFoldersContinue(arg *ListFoldersContinueArg) (res *ListFoldersResult, err error) // ListReceivedFiles : Returns a list of all files shared with current user. // Does not include files the user has received via shared folders, and does @@ -156,20 +148,17 @@ ModifySharedLinkSettings(arg *ModifySharedLinkSettingsArgs) (res IsSharedLinkMetadata, err error) // MountFolder : The current user mounts the designated folder. Mount a // shared folder for a user after they have been added as a member. Once - // mounted, the shared folder will appear in their Dropbox. Apps must have - // full Dropbox access to use this endpoint. + // mounted, the shared folder will appear in their Dropbox. MountFolder(arg *MountFolderArg) (res *SharedFolderMetadata, err error) // RelinquishFileMembership : The current user relinquishes their membership // in the designated file. Note that the current user may still have - // inherited access to this file through the parent folder. Apps must have - // full Dropbox access to use this endpoint. + // inherited access to this file through the parent folder. RelinquishFileMembership(arg *RelinquishFileMembershipArg) (err error) // RelinquishFolderMembership : The current user relinquishes their // membership in the designated shared folder and will no longer have access // to the folder. A folder owner cannot relinquish membership in their own // folder. This will run synchronously if leave_a_copy is false, and - // asynchronously if leave_a_copy is true. Apps must have full Dropbox - // access to use this endpoint. + // asynchronously if leave_a_copy is true. RelinquishFolderMembership(arg *RelinquishFolderMembershipArg) (res *async.LaunchEmptyResult, err error) // RemoveFileMember : Identical to remove_file_member_2 but with less // information returned. @@ -178,8 +167,7 @@ // RemoveFileMember2 : Removes a specified member from the file. RemoveFileMember2(arg *RemoveFileMemberArg) (res *FileMemberRemoveActionResult, err error) // RemoveFolderMember : Allows an owner or editor (if the ACL update policy - // allows) of a shared folder to remove another member. Apps must have full - // Dropbox access to use this endpoint. + // allows) of a shared folder to remove another member. RemoveFolderMember(arg *RemoveFolderMemberArg) (res *async.LaunchResultBase, err error) // RevokeSharedLink : Revoke a shared link. Note that even after revoking a // shared link to a file, the file may be accessible if there are shared @@ -198,35 +186,30 @@ // To make testing the async case repeatable, set // `ShareFolderArg.force_async`. If a `ShareFolderLaunch.async_job_id` is // returned, you'll need to call `checkShareJobStatus` until the action - // completes to get the metadata for the folder. Apps must have full Dropbox - // access to use this endpoint. + // completes to get the metadata for the folder. ShareFolder(arg *ShareFolderArg) (res *ShareFolderLaunch, err error) // TransferFolder : Transfer ownership of a shared folder to a member of the // shared folder. User must have `AccessLevel.owner` access to the shared - // folder to perform a transfer. Apps must have full Dropbox access to use - // this endpoint. + // folder to perform a transfer. TransferFolder(arg *TransferFolderArg) (err error) // UnmountFolder : The current user unmounts the designated folder. They can - // re-mount the folder at a later time using `mountFolder`. Apps must have - // full Dropbox access to use this endpoint. + // re-mount the folder at a later time using `mountFolder`. UnmountFolder(arg *UnmountFolderArg) (err error) // UnshareFile : Remove all members from this file. Does not remove // inherited members. UnshareFile(arg *UnshareFileArg) (err error) // UnshareFolder : Allows a shared folder owner to unshare the folder. // You'll need to call `checkJobStatus` to determine if the action has - // completed successfully. Apps must have full Dropbox access to use this - // endpoint. + // completed successfully. UnshareFolder(arg *UnshareFolderArg) (res *async.LaunchEmptyResult, err error) // UpdateFileMember : Changes a member's access on a shared file. UpdateFileMember(arg *UpdateFileMemberArgs) (res *MemberAccessLevelResult, err error) // UpdateFolderMember : Allows an owner or editor of a shared folder to - // update another member's permissions. Apps must have full Dropbox access - // to use this endpoint. + // update another member's permissions. UpdateFolderMember(arg *UpdateFolderMemberArg) (res *MemberAccessLevelResult, err error) // UpdateFolderPolicy : Update the sharing policies for a shared folder. // User must have `AccessLevel.owner` access to the shared folder to update - // its policies. Apps must have full Dropbox access to use this endpoint. + // its policies. UpdateFolderPolicy(arg *UpdateFolderPolicyArg) (res *SharedFolderMetadata, err error) } @@ -272,7 +255,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -290,17 +273,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -344,7 +321,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -357,17 +334,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -414,7 +385,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -432,17 +403,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -486,7 +451,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -504,17 +469,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -558,7 +517,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -576,17 +535,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -630,7 +583,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -648,17 +601,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -705,7 +652,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -723,17 +670,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -777,7 +718,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { var tmp sharedLinkMetadataUnion err = json.Unmarshal(body, &tmp) @@ -803,17 +744,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -857,7 +792,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -875,17 +810,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -929,7 +858,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -947,17 +876,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1001,7 +924,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1019,17 +942,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1069,7 +986,7 @@ dbx.Config.LogInfo("resp: %v", resp) body := []byte(resp.Header.Get("Dropbox-API-Result")) content = resp.Body - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { var tmp sharedLinkMetadataUnion err = json.Unmarshal(body, &tmp) @@ -1100,17 +1017,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1154,7 +1065,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { var tmp sharedLinkMetadataUnion err = json.Unmarshal(body, &tmp) @@ -1180,17 +1091,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1237,7 +1142,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1255,17 +1160,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1309,7 +1208,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1327,17 +1226,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1381,7 +1274,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1399,17 +1292,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1453,7 +1340,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1471,17 +1358,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1525,7 +1406,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1543,17 +1424,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1597,7 +1472,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1615,17 +1490,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1669,7 +1538,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1687,17 +1556,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1741,7 +1604,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1759,17 +1622,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1813,7 +1670,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1831,17 +1688,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1885,7 +1736,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1903,17 +1754,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1957,7 +1802,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1975,17 +1820,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2029,7 +1868,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2047,17 +1886,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2101,7 +1934,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2119,17 +1952,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2173,7 +2000,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { var tmp sharedLinkMetadataUnion err = json.Unmarshal(body, &tmp) @@ -2199,17 +2026,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2253,7 +2074,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2271,17 +2092,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2325,7 +2140,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -2338,17 +2153,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2392,7 +2201,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2410,17 +2219,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2467,7 +2270,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2485,17 +2288,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2539,7 +2336,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2557,17 +2354,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2611,7 +2402,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2629,17 +2420,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2683,7 +2468,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -2696,17 +2481,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2750,7 +2529,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2768,17 +2547,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2822,7 +2595,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2840,17 +2613,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2894,7 +2661,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -2907,17 +2674,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2961,7 +2722,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -2974,17 +2735,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3028,7 +2783,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -3041,17 +2796,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3095,7 +2844,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3113,17 +2862,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3167,7 +2910,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3185,17 +2928,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3239,7 +2976,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3257,17 +2994,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3311,7 +3042,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3329,17 +3060,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/sharing/types.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/sharing/types.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/sharing/types.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/sharing/types.go 2018-12-22 22:15:38.000000000 +0000 @@ -693,6 +693,7 @@ FileActionEnableViewerInfo = "enable_viewer_info" FileActionInviteViewer = "invite_viewer" FileActionInviteViewerNoComment = "invite_viewer_no_comment" + FileActionInviteEditor = "invite_editor" FileActionUnshare = "unshare" FileActionRelinquishMembership = "relinquish_membership" FileActionShareLink = "share_link" @@ -1496,7 +1497,9 @@ // MembershipInfo : The information about a member of the shared content. type MembershipInfo struct { - // AccessType : The access type for this member. + // AccessType : The access type for this member. It contains inherited + // access type from parent folder, and acquired access type from this + // folder. AccessType *AccessLevel `json:"access_type"` // Permissions : The permissions that requesting user has on this member. // The set of permissions corresponds to the MemberActions in the request. @@ -1754,6 +1757,7 @@ const ( LinkAudiencePublic = "public" LinkAudienceTeam = "team" + LinkAudienceNoOne = "no_one" LinkAudienceMembers = "members" LinkAudienceOther = "other" ) @@ -3262,6 +3266,8 @@ // ViewerInfoPolicy : Who can enable/disable viewer info for this shared // folder. ViewerInfoPolicy *ViewerInfoPolicy `json:"viewer_info_policy,omitempty"` + // AccessInheritance : The access inheritance settings for the folder. + AccessInheritance *AccessInheritance `json:"access_inheritance"` } // NewShareFolderArgBase returns a new ShareFolderArgBase instance @@ -3269,6 +3275,7 @@ s := new(ShareFolderArgBase) s.Path = Path s.ForceAsync = false + s.AccessInheritance = &AccessInheritance{Tagged: dropbox.Tagged{"inherit"}} return s } @@ -3289,6 +3296,7 @@ s := new(ShareFolderArg) s.Path = Path s.ForceAsync = false + s.AccessInheritance = &AccessInheritance{Tagged: dropbox.Tagged{"inherit"}} return s } diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/team/client.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/team/client.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/team/client.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/team/client.go 2018-12-22 22:15:38.000000000 +0000 @@ -29,6 +29,7 @@ "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/async" + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth" "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/file_properties" ) @@ -37,8 +38,10 @@ // DevicesListMemberDevices : List all device sessions of a team's member. DevicesListMemberDevices(arg *ListMemberDevicesArg) (res *ListMemberDevicesResult, err error) // DevicesListMembersDevices : List all device sessions of a team. + // Permission : Team member file access. DevicesListMembersDevices(arg *ListMembersDevicesArg) (res *ListMembersDevicesResult, err error) - // DevicesListTeamDevices : List all device sessions of a team. + // DevicesListTeamDevices : List all device sessions of a team. Permission : + // Team member file access. // Deprecated: Use `DevicesListMembersDevices` instead DevicesListTeamDevices(arg *ListTeamDevicesArg) (res *ListTeamDevicesResult, err error) // DevicesRevokeDeviceSession : Revoke a device session of a team's member. @@ -168,6 +171,16 @@ // `membersList`, use this to paginate through all team members. Permission // : Team information. MembersListContinue(arg *MembersListContinueArg) (res *MembersListResult, err error) + // MembersMoveFormerMemberFiles : Moves removed member's files to a + // different member. This endpoint initiates an asynchronous job. To obtain + // the final result of the job, the client should periodically poll + // `membersMoveFormerMemberFilesJobStatusCheck`. Permission : Team member + // management. + MembersMoveFormerMemberFiles(arg *MembersDataTransferArg) (res *async.LaunchEmptyResult, err error) + // MembersMoveFormerMemberFilesJobStatusCheck : Once an async_job_id is + // returned from `membersMoveFormerMemberFiles` , use this to poll the + // status of the asynchronous request. Permission : Team member management. + MembersMoveFormerMemberFilesJobStatusCheck(arg *async.PollArg) (res *async.PollEmptyResult, err error) // MembersRecover : Recover a deleted member. Permission : Team member // management Exactly one of team_member_id, email, or external_id must be // provided to identify the user account. @@ -219,16 +232,16 @@ // `namespacesList`, use this to paginate through all team-accessible // namespaces. Duplicates may occur in the list. NamespacesListContinue(arg *TeamNamespacesListContinueArg) (res *TeamNamespacesListResult, err error) - // PropertiesTemplateAdd : has no documentation (yet) + // PropertiesTemplateAdd : Permission : Team member file access. // Deprecated: PropertiesTemplateAdd(arg *file_properties.AddTemplateArg) (res *file_properties.AddTemplateResult, err error) - // PropertiesTemplateGet : has no documentation (yet) + // PropertiesTemplateGet : Permission : Team member file access. // Deprecated: PropertiesTemplateGet(arg *file_properties.GetTemplateArg) (res *file_properties.GetTemplateResult, err error) - // PropertiesTemplateList : has no documentation (yet) + // PropertiesTemplateList : Permission : Team member file access. // Deprecated: PropertiesTemplateList() (res *file_properties.ListTemplateResult, err error) - // PropertiesTemplateUpdate : has no documentation (yet) + // PropertiesTemplateUpdate : Permission : Team member file access. // Deprecated: PropertiesTemplateUpdate(arg *file_properties.UpdateTemplateArg) (res *file_properties.UpdateTemplateResult, err error) // ReportsGetActivity : Retrieves reporting data about a team's user @@ -320,7 +333,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -338,17 +351,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -389,7 +396,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -407,17 +414,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -461,7 +462,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -479,17 +480,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -530,7 +525,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -543,17 +538,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -594,7 +583,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -612,17 +601,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -663,7 +646,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -681,17 +664,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -724,7 +701,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -742,17 +719,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -793,7 +764,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -811,17 +782,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -862,7 +827,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -880,17 +845,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -931,7 +890,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -949,17 +908,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1000,7 +953,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1018,17 +971,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1069,7 +1016,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1087,17 +1034,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1138,7 +1079,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1156,17 +1097,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1207,7 +1142,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1225,17 +1160,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1276,7 +1205,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1294,17 +1223,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1345,7 +1268,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1363,17 +1286,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1414,7 +1331,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1432,17 +1349,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1483,7 +1394,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1501,17 +1412,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1552,7 +1457,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1570,17 +1475,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1621,7 +1520,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1639,17 +1538,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1690,7 +1583,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1708,17 +1601,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1762,7 +1649,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1780,17 +1667,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1831,7 +1712,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -1844,17 +1725,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1895,7 +1770,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1913,17 +1788,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -1964,7 +1833,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -1982,17 +1851,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2033,7 +1896,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2051,17 +1914,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2102,7 +1959,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2120,17 +1977,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2171,7 +2022,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2189,17 +2040,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2240,7 +2085,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2258,17 +2103,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2309,7 +2148,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2327,17 +2166,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2378,7 +2211,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2396,17 +2229,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2447,7 +2274,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2465,17 +2292,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2516,7 +2337,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2534,17 +2355,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2585,7 +2400,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2603,17 +2418,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2654,7 +2463,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2672,17 +2481,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2723,7 +2526,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2741,17 +2544,137 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) + if err != nil { + return + } + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) + return +} + +//MembersMoveFormerMemberFilesAPIError is an error-wrapper for the members/move_former_member_files route +type MembersMoveFormerMemberFilesAPIError struct { + dropbox.APIError + EndpointError *MembersTransferFormerMembersFilesError `json:"error"` +} + +func (dbx *apiImpl) MembersMoveFormerMemberFiles(arg *MembersDataTransferArg) (res *async.LaunchEmptyResult, err error) { + cli := dbx.Client + + dbx.Config.LogDebug("arg: %v", arg) + b, err := json.Marshal(arg) + if err != nil { + return + } + + headers := map[string]string{ + "Content-Type": "application/json", + } + + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "team", "members/move_former_member_files", headers, bytes.NewReader(b)) + if err != nil { + return + } + dbx.Config.LogInfo("req: %v", req) + + resp, err := cli.Do(req) + if err != nil { + return + } + + dbx.Config.LogInfo("resp: %v", resp) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return + } + + dbx.Config.LogDebug("body: %s", body) + if resp.StatusCode == http.StatusOK { + err = json.Unmarshal(body, &res) + if err != nil { + return + } + + return + } + if resp.StatusCode == http.StatusConflict { + var apiError MembersMoveFormerMemberFilesAPIError + err = json.Unmarshal(body, &apiError) + if err != nil { + return + } err = apiError return } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) + return +} + +//MembersMoveFormerMemberFilesJobStatusCheckAPIError is an error-wrapper for the members/move_former_member_files/job_status/check route +type MembersMoveFormerMemberFilesJobStatusCheckAPIError struct { + dropbox.APIError + EndpointError *async.PollError `json:"error"` +} + +func (dbx *apiImpl) MembersMoveFormerMemberFilesJobStatusCheck(arg *async.PollArg) (res *async.PollEmptyResult, err error) { + cli := dbx.Client + + dbx.Config.LogDebug("arg: %v", arg) + b, err := json.Marshal(arg) + if err != nil { + return + } + + headers := map[string]string{ + "Content-Type": "application/json", + } + + req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "team", "members/move_former_member_files/job_status/check", headers, bytes.NewReader(b)) + if err != nil { + return + } + dbx.Config.LogInfo("req: %v", req) + + resp, err := cli.Do(req) + if err != nil { + return + } + + dbx.Config.LogInfo("resp: %v", resp) + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return + } + + dbx.Config.LogDebug("body: %s", body) + if resp.StatusCode == http.StatusOK { + err = json.Unmarshal(body, &res) + if err != nil { + return + } + + return + } + if resp.StatusCode == http.StatusConflict { + var apiError MembersMoveFormerMemberFilesJobStatusCheckAPIError + err = json.Unmarshal(body, &apiError) + if err != nil { + return + } + err = apiError + return + } + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) + if err != nil { + return + } + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2792,7 +2715,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -2805,17 +2728,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2856,7 +2773,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2874,17 +2791,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2925,7 +2836,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -2943,17 +2854,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -2994,7 +2899,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -3007,17 +2912,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3058,7 +2957,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3076,17 +2975,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3127,7 +3020,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3145,17 +3038,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3196,7 +3083,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -3209,17 +3096,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3260,7 +3141,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -3273,24 +3154,18 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } //NamespacesListAPIError is an error-wrapper for the namespaces/list route type NamespacesListAPIError struct { dropbox.APIError - EndpointError struct{} `json:"error"` + EndpointError *TeamNamespacesListError `json:"error"` } func (dbx *apiImpl) NamespacesList(arg *TeamNamespacesListArg) (res *TeamNamespacesListResult, err error) { @@ -3324,7 +3199,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3342,17 +3217,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3393,7 +3262,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3411,17 +3280,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3464,7 +3327,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3482,17 +3345,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3535,7 +3392,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3553,17 +3410,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3598,7 +3449,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3616,17 +3467,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3669,7 +3514,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3687,17 +3532,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3738,7 +3577,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3756,17 +3595,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3807,7 +3640,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3825,17 +3658,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3876,7 +3703,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3894,17 +3721,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -3945,7 +3766,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -3963,17 +3784,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -4014,7 +3829,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -4032,17 +3847,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -4083,7 +3892,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -4101,17 +3910,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -4152,7 +3955,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -4170,17 +3973,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -4221,7 +4018,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -4239,17 +4036,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -4290,7 +4081,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -4308,17 +4099,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -4359,7 +4144,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -4377,17 +4162,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -4428,7 +4207,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -4446,17 +4225,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -4497,7 +4270,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { return } @@ -4510,17 +4283,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -4561,7 +4328,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -4579,17 +4346,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -4630,7 +4391,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -4648,17 +4409,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -4691,7 +4446,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -4709,17 +4464,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/team/types.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/team/types.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/team/types.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/team/types.go 2018-12-22 22:15:38.000000000 +0000 @@ -2315,11 +2315,43 @@ return nil } -// MembersDeactivateArg : Exactly one of team_member_id, email, or external_id -// must be provided to identify the user account. -type MembersDeactivateArg struct { - // User : Identity of user to remove/suspend. +// MembersDeactivateBaseArg : Exactly one of team_member_id, email, or +// external_id must be provided to identify the user account. +type MembersDeactivateBaseArg struct { + // User : Identity of user to remove/suspend/have their files moved. User *UserSelectorArg `json:"user"` +} + +// NewMembersDeactivateBaseArg returns a new MembersDeactivateBaseArg instance +func NewMembersDeactivateBaseArg(User *UserSelectorArg) *MembersDeactivateBaseArg { + s := new(MembersDeactivateBaseArg) + s.User = User + return s +} + +// MembersDataTransferArg : has no documentation (yet) +type MembersDataTransferArg struct { + MembersDeactivateBaseArg + // TransferDestId : Files from the deleted member account will be + // transferred to this user. + TransferDestId *UserSelectorArg `json:"transfer_dest_id"` + // TransferAdminId : Errors during the transfer process will be sent via + // email to this user. + TransferAdminId *UserSelectorArg `json:"transfer_admin_id"` +} + +// NewMembersDataTransferArg returns a new MembersDataTransferArg instance +func NewMembersDataTransferArg(User *UserSelectorArg, TransferDestId *UserSelectorArg, TransferAdminId *UserSelectorArg) *MembersDataTransferArg { + s := new(MembersDataTransferArg) + s.User = User + s.TransferDestId = TransferDestId + s.TransferAdminId = TransferAdminId + return s +} + +// MembersDeactivateArg : has no documentation (yet) +type MembersDeactivateArg struct { + MembersDeactivateBaseArg // WipeData : If provided, controls if the user's data will be deleted on // their linked devices. WipeData bool `json:"wipe_data"` @@ -2542,6 +2574,27 @@ return s } +// MembersTransferFilesError : has no documentation (yet) +type MembersTransferFilesError struct { + dropbox.Tagged +} + +// Valid tag values for MembersTransferFilesError +const ( + MembersTransferFilesErrorUserNotFound = "user_not_found" + MembersTransferFilesErrorUserNotInTeam = "user_not_in_team" + MembersTransferFilesErrorOther = "other" + MembersTransferFilesErrorRemovedAndTransferDestShouldDiffer = "removed_and_transfer_dest_should_differ" + MembersTransferFilesErrorRemovedAndTransferAdminShouldDiffer = "removed_and_transfer_admin_should_differ" + MembersTransferFilesErrorTransferDestUserNotFound = "transfer_dest_user_not_found" + MembersTransferFilesErrorTransferDestUserNotInTeam = "transfer_dest_user_not_in_team" + MembersTransferFilesErrorTransferAdminUserNotInTeam = "transfer_admin_user_not_in_team" + MembersTransferFilesErrorTransferAdminUserNotFound = "transfer_admin_user_not_found" + MembersTransferFilesErrorUnspecifiedTransferAdminId = "unspecified_transfer_admin_id" + MembersTransferFilesErrorTransferAdminIsNotAdmin = "transfer_admin_is_not_admin" + MembersTransferFilesErrorRecipientNotVerified = "recipient_not_verified" +) + // MembersRemoveError : has no documentation (yet) type MembersRemoveError struct { dropbox.Tagged @@ -2552,15 +2605,16 @@ MembersRemoveErrorUserNotFound = "user_not_found" MembersRemoveErrorUserNotInTeam = "user_not_in_team" MembersRemoveErrorOther = "other" - MembersRemoveErrorRemoveLastAdmin = "remove_last_admin" MembersRemoveErrorRemovedAndTransferDestShouldDiffer = "removed_and_transfer_dest_should_differ" MembersRemoveErrorRemovedAndTransferAdminShouldDiffer = "removed_and_transfer_admin_should_differ" MembersRemoveErrorTransferDestUserNotFound = "transfer_dest_user_not_found" MembersRemoveErrorTransferDestUserNotInTeam = "transfer_dest_user_not_in_team" - MembersRemoveErrorTransferAdminUserNotFound = "transfer_admin_user_not_found" MembersRemoveErrorTransferAdminUserNotInTeam = "transfer_admin_user_not_in_team" + MembersRemoveErrorTransferAdminUserNotFound = "transfer_admin_user_not_found" MembersRemoveErrorUnspecifiedTransferAdminId = "unspecified_transfer_admin_id" MembersRemoveErrorTransferAdminIsNotAdmin = "transfer_admin_is_not_admin" + MembersRemoveErrorRecipientNotVerified = "recipient_not_verified" + MembersRemoveErrorRemoveLastAdmin = "remove_last_admin" MembersRemoveErrorCannotKeepAccountAndTransfer = "cannot_keep_account_and_transfer" MembersRemoveErrorCannotKeepAccountAndDeleteData = "cannot_keep_account_and_delete_data" MembersRemoveErrorEmailAddressTooLongToBeDisabled = "email_address_too_long_to_be_disabled" @@ -2692,6 +2746,31 @@ MembersSuspendErrorTeamLicenseLimit = "team_license_limit" ) +// MembersTransferFormerMembersFilesError : has no documentation (yet) +type MembersTransferFormerMembersFilesError struct { + dropbox.Tagged +} + +// Valid tag values for MembersTransferFormerMembersFilesError +const ( + MembersTransferFormerMembersFilesErrorUserNotFound = "user_not_found" + MembersTransferFormerMembersFilesErrorUserNotInTeam = "user_not_in_team" + MembersTransferFormerMembersFilesErrorOther = "other" + MembersTransferFormerMembersFilesErrorRemovedAndTransferDestShouldDiffer = "removed_and_transfer_dest_should_differ" + MembersTransferFormerMembersFilesErrorRemovedAndTransferAdminShouldDiffer = "removed_and_transfer_admin_should_differ" + MembersTransferFormerMembersFilesErrorTransferDestUserNotFound = "transfer_dest_user_not_found" + MembersTransferFormerMembersFilesErrorTransferDestUserNotInTeam = "transfer_dest_user_not_in_team" + MembersTransferFormerMembersFilesErrorTransferAdminUserNotInTeam = "transfer_admin_user_not_in_team" + MembersTransferFormerMembersFilesErrorTransferAdminUserNotFound = "transfer_admin_user_not_found" + MembersTransferFormerMembersFilesErrorUnspecifiedTransferAdminId = "unspecified_transfer_admin_id" + MembersTransferFormerMembersFilesErrorTransferAdminIsNotAdmin = "transfer_admin_is_not_admin" + MembersTransferFormerMembersFilesErrorRecipientNotVerified = "recipient_not_verified" + MembersTransferFormerMembersFilesErrorUserDataIsBeingTransferred = "user_data_is_being_transferred" + MembersTransferFormerMembersFilesErrorUserNotRemoved = "user_not_removed" + MembersTransferFormerMembersFilesErrorUserDataCannotBeTransferred = "user_data_cannot_be_transferred" + MembersTransferFormerMembersFilesErrorUserDataAlreadyTransferred = "user_data_already_transferred" +) + // MembersUnsuspendArg : Exactly one of team_member_id, email, or external_id // must be provided to identify the user account. type MembersUnsuspendArg struct { @@ -2848,12 +2927,16 @@ type RemovedStatus struct { // IsRecoverable : True if the removed team member is recoverable. IsRecoverable bool `json:"is_recoverable"` + // IsDisconnected : True if the team member's account was converted to + // individual account. + IsDisconnected bool `json:"is_disconnected"` } // NewRemovedStatus returns a new RemovedStatus instance -func NewRemovedStatus(IsRecoverable bool) *RemovedStatus { +func NewRemovedStatus(IsRecoverable bool, IsDisconnected bool) *RemovedStatus { s := new(RemovedStatus) s.IsRecoverable = IsRecoverable + s.IsDisconnected = IsDisconnected return s } @@ -4002,6 +4085,17 @@ return s } +// TeamNamespacesListError : has no documentation (yet) +type TeamNamespacesListError struct { + dropbox.Tagged +} + +// Valid tag values for TeamNamespacesListError +const ( + TeamNamespacesListErrorInvalidArg = "invalid_arg" + TeamNamespacesListErrorOther = "other" +) + // TeamNamespacesListContinueError : has no documentation (yet) type TeamNamespacesListContinueError struct { dropbox.Tagged @@ -4009,8 +4103,9 @@ // Valid tag values for TeamNamespacesListContinueError const ( - TeamNamespacesListContinueErrorInvalidCursor = "invalid_cursor" + TeamNamespacesListContinueErrorInvalidArg = "invalid_arg" TeamNamespacesListContinueErrorOther = "other" + TeamNamespacesListContinueErrorInvalidCursor = "invalid_cursor" ) // TeamNamespacesListResult : Result for `namespacesList`. diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/team_log/client.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/team_log/client.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/team_log/client.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/team_log/client.go 2018-12-22 22:15:38.000000000 +0000 @@ -27,6 +27,7 @@ "net/http" "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth" ) // Client interface describes all routes in this namespace @@ -84,7 +85,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -102,17 +103,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -153,7 +148,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -171,17 +166,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/team_log/types.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/team_log/types.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/team_log/types.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/team_log/types.go 2018-12-22 22:15:38.000000000 +0000 @@ -834,6 +834,48 @@ return nil } +// CameraUploadsPolicy : Policy for controlling if team members can activate +// camera uploads +type CameraUploadsPolicy struct { + dropbox.Tagged +} + +// Valid tag values for CameraUploadsPolicy +const ( + CameraUploadsPolicyDisabled = "disabled" + CameraUploadsPolicyEnabled = "enabled" + CameraUploadsPolicyOther = "other" +) + +// CameraUploadsPolicyChangedDetails : Changed camera uploads setting for team. +type CameraUploadsPolicyChangedDetails struct { + // NewValue : New camera uploads setting. + NewValue *CameraUploadsPolicy `json:"new_value"` + // PreviousValue : Previous camera uploads setting. + PreviousValue *CameraUploadsPolicy `json:"previous_value"` +} + +// NewCameraUploadsPolicyChangedDetails returns a new CameraUploadsPolicyChangedDetails instance +func NewCameraUploadsPolicyChangedDetails(NewValue *CameraUploadsPolicy, PreviousValue *CameraUploadsPolicy) *CameraUploadsPolicyChangedDetails { + s := new(CameraUploadsPolicyChangedDetails) + s.NewValue = NewValue + s.PreviousValue = PreviousValue + return s +} + +// CameraUploadsPolicyChangedType : has no documentation (yet) +type CameraUploadsPolicyChangedType struct { + // Description : has no documentation (yet) + Description string `json:"description"` +} + +// NewCameraUploadsPolicyChangedType returns a new CameraUploadsPolicyChangedType instance +func NewCameraUploadsPolicyChangedType(Description string) *CameraUploadsPolicyChangedType { + s := new(CameraUploadsPolicyChangedType) + s.Description = Description + return s +} + // Certificate : Certificate details. type Certificate struct { // Subject : Certificate subject. @@ -909,15 +951,19 @@ TeamMember *TeamMemberLogInfo `json:"team_member,omitempty"` // NonTeamMember : Action was done on behalf of a non team member. NonTeamMember *NonTeamMemberLogInfo `json:"non_team_member,omitempty"` + // TrustedNonTeamMember : Action was done on behalf of a trusted non team + // member. + TrustedNonTeamMember *TrustedNonTeamMemberLogInfo `json:"trusted_non_team_member,omitempty"` } // Valid tag values for ContextLogInfo const ( - ContextLogInfoTeamMember = "team_member" - ContextLogInfoNonTeamMember = "non_team_member" - ContextLogInfoAnonymous = "anonymous" - ContextLogInfoTeam = "team" - ContextLogInfoOther = "other" + ContextLogInfoTeamMember = "team_member" + ContextLogInfoNonTeamMember = "non_team_member" + ContextLogInfoAnonymous = "anonymous" + ContextLogInfoTeam = "team" + ContextLogInfoTrustedNonTeamMember = "trusted_non_team_member" + ContextLogInfoOther = "other" ) // UnmarshalJSON deserializes into a ContextLogInfo instance @@ -928,6 +974,9 @@ TeamMember json.RawMessage `json:"team_member,omitempty"` // NonTeamMember : Action was done on behalf of a non team member. NonTeamMember json.RawMessage `json:"non_team_member,omitempty"` + // TrustedNonTeamMember : Action was done on behalf of a trusted non + // team member. + TrustedNonTeamMember json.RawMessage `json:"trusted_non_team_member,omitempty"` } var w wrap var err error @@ -948,6 +997,12 @@ if err != nil { return err } + case "trusted_non_team_member": + err = json.Unmarshal(body, &u.TrustedNonTeamMember) + + if err != nil { + return err + } } return nil } @@ -2310,6 +2365,8 @@ FileChangeCommentSubscriptionDetails *FileChangeCommentSubscriptionDetails `json:"file_change_comment_subscription_details,omitempty"` // FileDeleteCommentDetails : has no documentation (yet) FileDeleteCommentDetails *FileDeleteCommentDetails `json:"file_delete_comment_details,omitempty"` + // FileEditCommentDetails : has no documentation (yet) + FileEditCommentDetails *FileEditCommentDetails `json:"file_edit_comment_details,omitempty"` // FileLikeCommentDetails : has no documentation (yet) FileLikeCommentDetails *FileLikeCommentDetails `json:"file_like_comment_details,omitempty"` // FileResolveCommentDetails : has no documentation (yet) @@ -2465,6 +2522,8 @@ MemberChangeNameDetails *MemberChangeNameDetails `json:"member_change_name_details,omitempty"` // MemberChangeStatusDetails : has no documentation (yet) MemberChangeStatusDetails *MemberChangeStatusDetails `json:"member_change_status_details,omitempty"` + // MemberDeleteManualContactsDetails : has no documentation (yet) + MemberDeleteManualContactsDetails *MemberDeleteManualContactsDetails `json:"member_delete_manual_contacts_details,omitempty"` // MemberPermanentlyDeleteAccountContentsDetails : has no documentation // (yet) MemberPermanentlyDeleteAccountContentsDetails *MemberPermanentlyDeleteAccountContentsDetails `json:"member_permanently_delete_account_contents_details,omitempty"` @@ -2522,6 +2581,8 @@ PaperDocFollowedDetails *PaperDocFollowedDetails `json:"paper_doc_followed_details,omitempty"` // PaperDocMentionDetails : has no documentation (yet) PaperDocMentionDetails *PaperDocMentionDetails `json:"paper_doc_mention_details,omitempty"` + // PaperDocOwnershipChangedDetails : has no documentation (yet) + PaperDocOwnershipChangedDetails *PaperDocOwnershipChangedDetails `json:"paper_doc_ownership_changed_details,omitempty"` // PaperDocRequestAccessDetails : has no documentation (yet) PaperDocRequestAccessDetails *PaperDocRequestAccessDetails `json:"paper_doc_request_access_details,omitempty"` // PaperDocResolveCommentDetails : has no documentation (yet) @@ -2788,6 +2849,8 @@ AllowDownloadDisabledDetails *AllowDownloadDisabledDetails `json:"allow_download_disabled_details,omitempty"` // AllowDownloadEnabledDetails : has no documentation (yet) AllowDownloadEnabledDetails *AllowDownloadEnabledDetails `json:"allow_download_enabled_details,omitempty"` + // CameraUploadsPolicyChangedDetails : has no documentation (yet) + CameraUploadsPolicyChangedDetails *CameraUploadsPolicyChangedDetails `json:"camera_uploads_policy_changed_details,omitempty"` // DataPlacementRestrictionChangePolicyDetails : has no documentation (yet) DataPlacementRestrictionChangePolicyDetails *DataPlacementRestrictionChangePolicyDetails `json:"data_placement_restriction_change_policy_details,omitempty"` // DataPlacementRestrictionSatisfyPolicyDetails : has no documentation (yet) @@ -2875,10 +2938,14 @@ SmartSyncOptOutDetails *SmartSyncOptOutDetails `json:"smart_sync_opt_out_details,omitempty"` // SsoChangePolicyDetails : has no documentation (yet) SsoChangePolicyDetails *SsoChangePolicyDetails `json:"sso_change_policy_details,omitempty"` + // TeamSelectiveSyncPolicyChangedDetails : has no documentation (yet) + TeamSelectiveSyncPolicyChangedDetails *TeamSelectiveSyncPolicyChangedDetails `json:"team_selective_sync_policy_changed_details,omitempty"` // TfaChangePolicyDetails : has no documentation (yet) TfaChangePolicyDetails *TfaChangePolicyDetails `json:"tfa_change_policy_details,omitempty"` // TwoAccountChangePolicyDetails : has no documentation (yet) TwoAccountChangePolicyDetails *TwoAccountChangePolicyDetails `json:"two_account_change_policy_details,omitempty"` + // ViewerInfoPolicyChangedDetails : has no documentation (yet) + ViewerInfoPolicyChangedDetails *ViewerInfoPolicyChangedDetails `json:"viewer_info_policy_changed_details,omitempty"` // WebSessionsChangeFixedLengthPolicyDetails : has no documentation (yet) WebSessionsChangeFixedLengthPolicyDetails *WebSessionsChangeFixedLengthPolicyDetails `json:"web_sessions_change_fixed_length_policy_details,omitempty"` // WebSessionsChangeIdleLengthPolicyDetails : has no documentation (yet) @@ -2925,6 +2992,7 @@ EventDetailsFileAddCommentDetails = "file_add_comment_details" EventDetailsFileChangeCommentSubscriptionDetails = "file_change_comment_subscription_details" EventDetailsFileDeleteCommentDetails = "file_delete_comment_details" + EventDetailsFileEditCommentDetails = "file_edit_comment_details" EventDetailsFileLikeCommentDetails = "file_like_comment_details" EventDetailsFileResolveCommentDetails = "file_resolve_comment_details" EventDetailsFileUnlikeCommentDetails = "file_unlike_comment_details" @@ -3002,6 +3070,7 @@ EventDetailsMemberChangeMembershipTypeDetails = "member_change_membership_type_details" EventDetailsMemberChangeNameDetails = "member_change_name_details" EventDetailsMemberChangeStatusDetails = "member_change_status_details" + EventDetailsMemberDeleteManualContactsDetails = "member_delete_manual_contacts_details" EventDetailsMemberPermanentlyDeleteAccountContentsDetails = "member_permanently_delete_account_contents_details" EventDetailsMemberSpaceLimitsAddCustomQuotaDetails = "member_space_limits_add_custom_quota_details" EventDetailsMemberSpaceLimitsChangeCustomQuotaDetails = "member_space_limits_change_custom_quota_details" @@ -3030,6 +3099,7 @@ EventDetailsPaperDocEditCommentDetails = "paper_doc_edit_comment_details" EventDetailsPaperDocFollowedDetails = "paper_doc_followed_details" EventDetailsPaperDocMentionDetails = "paper_doc_mention_details" + EventDetailsPaperDocOwnershipChangedDetails = "paper_doc_ownership_changed_details" EventDetailsPaperDocRequestAccessDetails = "paper_doc_request_access_details" EventDetailsPaperDocResolveCommentDetails = "paper_doc_resolve_comment_details" EventDetailsPaperDocRevertDetails = "paper_doc_revert_details" @@ -3162,6 +3232,7 @@ EventDetailsAccountCaptureChangePolicyDetails = "account_capture_change_policy_details" EventDetailsAllowDownloadDisabledDetails = "allow_download_disabled_details" EventDetailsAllowDownloadEnabledDetails = "allow_download_enabled_details" + EventDetailsCameraUploadsPolicyChangedDetails = "camera_uploads_policy_changed_details" EventDetailsDataPlacementRestrictionChangePolicyDetails = "data_placement_restriction_change_policy_details" EventDetailsDataPlacementRestrictionSatisfyPolicyDetails = "data_placement_restriction_satisfy_policy_details" EventDetailsDeviceApprovalsChangeDesktopPolicyDetails = "device_approvals_change_desktop_policy_details" @@ -3205,8 +3276,10 @@ EventDetailsSmartSyncNotOptOutDetails = "smart_sync_not_opt_out_details" EventDetailsSmartSyncOptOutDetails = "smart_sync_opt_out_details" EventDetailsSsoChangePolicyDetails = "sso_change_policy_details" + EventDetailsTeamSelectiveSyncPolicyChangedDetails = "team_selective_sync_policy_changed_details" EventDetailsTfaChangePolicyDetails = "tfa_change_policy_details" EventDetailsTwoAccountChangePolicyDetails = "two_account_change_policy_details" + EventDetailsViewerInfoPolicyChangedDetails = "viewer_info_policy_changed_details" EventDetailsWebSessionsChangeFixedLengthPolicyDetails = "web_sessions_change_fixed_length_policy_details" EventDetailsWebSessionsChangeIdleLengthPolicyDetails = "web_sessions_change_idle_length_policy_details" EventDetailsTeamMergeFromDetails = "team_merge_from_details" @@ -3245,6 +3318,8 @@ FileChangeCommentSubscriptionDetails json.RawMessage `json:"file_change_comment_subscription_details,omitempty"` // FileDeleteCommentDetails : has no documentation (yet) FileDeleteCommentDetails json.RawMessage `json:"file_delete_comment_details,omitempty"` + // FileEditCommentDetails : has no documentation (yet) + FileEditCommentDetails json.RawMessage `json:"file_edit_comment_details,omitempty"` // FileLikeCommentDetails : has no documentation (yet) FileLikeCommentDetails json.RawMessage `json:"file_like_comment_details,omitempty"` // FileResolveCommentDetails : has no documentation (yet) @@ -3405,6 +3480,8 @@ MemberChangeNameDetails json.RawMessage `json:"member_change_name_details,omitempty"` // MemberChangeStatusDetails : has no documentation (yet) MemberChangeStatusDetails json.RawMessage `json:"member_change_status_details,omitempty"` + // MemberDeleteManualContactsDetails : has no documentation (yet) + MemberDeleteManualContactsDetails json.RawMessage `json:"member_delete_manual_contacts_details,omitempty"` // MemberPermanentlyDeleteAccountContentsDetails : has no documentation // (yet) MemberPermanentlyDeleteAccountContentsDetails json.RawMessage `json:"member_permanently_delete_account_contents_details,omitempty"` @@ -3464,6 +3541,8 @@ PaperDocFollowedDetails json.RawMessage `json:"paper_doc_followed_details,omitempty"` // PaperDocMentionDetails : has no documentation (yet) PaperDocMentionDetails json.RawMessage `json:"paper_doc_mention_details,omitempty"` + // PaperDocOwnershipChangedDetails : has no documentation (yet) + PaperDocOwnershipChangedDetails json.RawMessage `json:"paper_doc_ownership_changed_details,omitempty"` // PaperDocRequestAccessDetails : has no documentation (yet) PaperDocRequestAccessDetails json.RawMessage `json:"paper_doc_request_access_details,omitempty"` // PaperDocResolveCommentDetails : has no documentation (yet) @@ -3734,6 +3813,8 @@ AllowDownloadDisabledDetails json.RawMessage `json:"allow_download_disabled_details,omitempty"` // AllowDownloadEnabledDetails : has no documentation (yet) AllowDownloadEnabledDetails json.RawMessage `json:"allow_download_enabled_details,omitempty"` + // CameraUploadsPolicyChangedDetails : has no documentation (yet) + CameraUploadsPolicyChangedDetails json.RawMessage `json:"camera_uploads_policy_changed_details,omitempty"` // DataPlacementRestrictionChangePolicyDetails : has no documentation // (yet) DataPlacementRestrictionChangePolicyDetails json.RawMessage `json:"data_placement_restriction_change_policy_details,omitempty"` @@ -3829,10 +3910,14 @@ SmartSyncOptOutDetails json.RawMessage `json:"smart_sync_opt_out_details,omitempty"` // SsoChangePolicyDetails : has no documentation (yet) SsoChangePolicyDetails json.RawMessage `json:"sso_change_policy_details,omitempty"` + // TeamSelectiveSyncPolicyChangedDetails : has no documentation (yet) + TeamSelectiveSyncPolicyChangedDetails json.RawMessage `json:"team_selective_sync_policy_changed_details,omitempty"` // TfaChangePolicyDetails : has no documentation (yet) TfaChangePolicyDetails json.RawMessage `json:"tfa_change_policy_details,omitempty"` // TwoAccountChangePolicyDetails : has no documentation (yet) TwoAccountChangePolicyDetails json.RawMessage `json:"two_account_change_policy_details,omitempty"` + // ViewerInfoPolicyChangedDetails : has no documentation (yet) + ViewerInfoPolicyChangedDetails json.RawMessage `json:"viewer_info_policy_changed_details,omitempty"` // WebSessionsChangeFixedLengthPolicyDetails : has no documentation // (yet) WebSessionsChangeFixedLengthPolicyDetails json.RawMessage `json:"web_sessions_change_fixed_length_policy_details,omitempty"` @@ -3919,6 +4004,12 @@ if err != nil { return err } + case "file_edit_comment_details": + err = json.Unmarshal(body, &u.FileEditCommentDetails) + + if err != nil { + return err + } case "file_like_comment_details": err = json.Unmarshal(body, &u.FileLikeCommentDetails) @@ -4381,6 +4472,12 @@ if err != nil { return err } + case "member_delete_manual_contacts_details": + err = json.Unmarshal(body, &u.MemberDeleteManualContactsDetails) + + if err != nil { + return err + } case "member_permanently_delete_account_contents_details": err = json.Unmarshal(body, &u.MemberPermanentlyDeleteAccountContentsDetails) @@ -4549,6 +4646,12 @@ if err != nil { return err } + case "paper_doc_ownership_changed_details": + err = json.Unmarshal(body, &u.PaperDocOwnershipChangedDetails) + + if err != nil { + return err + } case "paper_doc_request_access_details": err = json.Unmarshal(body, &u.PaperDocRequestAccessDetails) @@ -5341,6 +5444,12 @@ if err != nil { return err } + case "camera_uploads_policy_changed_details": + err = json.Unmarshal(body, &u.CameraUploadsPolicyChangedDetails) + + if err != nil { + return err + } case "data_placement_restriction_change_policy_details": err = json.Unmarshal(body, &u.DataPlacementRestrictionChangePolicyDetails) @@ -5599,6 +5708,12 @@ if err != nil { return err } + case "team_selective_sync_policy_changed_details": + err = json.Unmarshal(body, &u.TeamSelectiveSyncPolicyChangedDetails) + + if err != nil { + return err + } case "tfa_change_policy_details": err = json.Unmarshal(body, &u.TfaChangePolicyDetails) @@ -5611,6 +5726,12 @@ if err != nil { return err } + case "viewer_info_policy_changed_details": + err = json.Unmarshal(body, &u.ViewerInfoPolicyChangedDetails) + + if err != nil { + return err + } case "web_sessions_change_fixed_length_policy_details": err = json.Unmarshal(body, &u.WebSessionsChangeFixedLengthPolicyDetails) @@ -5735,6 +5856,8 @@ FileChangeCommentSubscription *FileChangeCommentSubscriptionType `json:"file_change_comment_subscription,omitempty"` // FileDeleteComment : (comments) Deleted file comment FileDeleteComment *FileDeleteCommentType `json:"file_delete_comment,omitempty"` + // FileEditComment : (comments) Edited file comment + FileEditComment *FileEditCommentType `json:"file_edit_comment,omitempty"` // FileLikeComment : (comments) Liked file comment (deprecated, no longer // logged) FileLikeComment *FileLikeCommentType `json:"file_like_comment,omitempty"` @@ -5922,6 +6045,8 @@ // MemberChangeStatus : (members) Changed member status (invited, joined, // suspended, etc.) MemberChangeStatus *MemberChangeStatusType `json:"member_change_status,omitempty"` + // MemberDeleteManualContacts : (members) Cleared manually added contacts + MemberDeleteManualContacts *MemberDeleteManualContactsType `json:"member_delete_manual_contacts,omitempty"` // MemberPermanentlyDeleteAccountContents : (members) Permanently deleted // contents of deleted team member account MemberPermanentlyDeleteAccountContents *MemberPermanentlyDeleteAccountContentsType `json:"member_permanently_delete_account_contents,omitempty"` @@ -5989,6 +6114,8 @@ PaperDocFollowed *PaperDocFollowedType `json:"paper_doc_followed,omitempty"` // PaperDocMention : (paper) Mentioned team member in Paper doc PaperDocMention *PaperDocMentionType `json:"paper_doc_mention,omitempty"` + // PaperDocOwnershipChanged : (paper) Transferred ownership of Paper doc + PaperDocOwnershipChanged *PaperDocOwnershipChangedType `json:"paper_doc_ownership_changed,omitempty"` // PaperDocRequestAccess : (paper) Requested access to Paper doc PaperDocRequestAccess *PaperDocRequestAccessType `json:"paper_doc_request_access,omitempty"` // PaperDocResolveComment : (paper) Resolved Paper doc comment @@ -6315,6 +6442,9 @@ // AllowDownloadEnabled : (team_policies) Enabled downloads (deprecated, no // longer logged) AllowDownloadEnabled *AllowDownloadEnabledType `json:"allow_download_enabled,omitempty"` + // CameraUploadsPolicyChanged : (team_policies) Changed camera uploads + // setting for team + CameraUploadsPolicyChanged *CameraUploadsPolicyChangedType `json:"camera_uploads_policy_changed,omitempty"` // DataPlacementRestrictionChangePolicy : (team_policies) Set restrictions // on data center locations where team data resides DataPlacementRestrictionChangePolicy *DataPlacementRestrictionChangePolicyType `json:"data_placement_restriction_change_policy,omitempty"` @@ -6441,6 +6571,9 @@ SmartSyncOptOut *SmartSyncOptOutType `json:"smart_sync_opt_out,omitempty"` // SsoChangePolicy : (team_policies) Changed single sign-on setting for team SsoChangePolicy *SsoChangePolicyType `json:"sso_change_policy,omitempty"` + // TeamSelectiveSyncPolicyChanged : (team_policies) Enabled/disabled Team + // Selective Sync for team + TeamSelectiveSyncPolicyChanged *TeamSelectiveSyncPolicyChangedType `json:"team_selective_sync_policy_changed,omitempty"` // TfaChangePolicy : (team_policies) Changed two-step verification setting // for team TfaChangePolicy *TfaChangePolicyType `json:"tfa_change_policy,omitempty"` @@ -6448,6 +6581,9 @@ // members to link personal Dropbox account and team account to same // computer TwoAccountChangePolicy *TwoAccountChangePolicyType `json:"two_account_change_policy,omitempty"` + // ViewerInfoPolicyChanged : (team_policies) Changed team policy for viewer + // info + ViewerInfoPolicyChanged *ViewerInfoPolicyChangedType `json:"viewer_info_policy_changed,omitempty"` // WebSessionsChangeFixedLengthPolicy : (team_policies) Changed how long // members can stay signed in to Dropbox.com WebSessionsChangeFixedLengthPolicy *WebSessionsChangeFixedLengthPolicyType `json:"web_sessions_change_fixed_length_policy,omitempty"` @@ -6501,6 +6637,7 @@ EventTypeFileAddComment = "file_add_comment" EventTypeFileChangeCommentSubscription = "file_change_comment_subscription" EventTypeFileDeleteComment = "file_delete_comment" + EventTypeFileEditComment = "file_edit_comment" EventTypeFileLikeComment = "file_like_comment" EventTypeFileResolveComment = "file_resolve_comment" EventTypeFileUnlikeComment = "file_unlike_comment" @@ -6578,6 +6715,7 @@ EventTypeMemberChangeMembershipType = "member_change_membership_type" EventTypeMemberChangeName = "member_change_name" EventTypeMemberChangeStatus = "member_change_status" + EventTypeMemberDeleteManualContacts = "member_delete_manual_contacts" EventTypeMemberPermanentlyDeleteAccountContents = "member_permanently_delete_account_contents" EventTypeMemberSpaceLimitsAddCustomQuota = "member_space_limits_add_custom_quota" EventTypeMemberSpaceLimitsChangeCustomQuota = "member_space_limits_change_custom_quota" @@ -6606,6 +6744,7 @@ EventTypePaperDocEditComment = "paper_doc_edit_comment" EventTypePaperDocFollowed = "paper_doc_followed" EventTypePaperDocMention = "paper_doc_mention" + EventTypePaperDocOwnershipChanged = "paper_doc_ownership_changed" EventTypePaperDocRequestAccess = "paper_doc_request_access" EventTypePaperDocResolveComment = "paper_doc_resolve_comment" EventTypePaperDocRevert = "paper_doc_revert" @@ -6738,6 +6877,7 @@ EventTypeAccountCaptureChangePolicy = "account_capture_change_policy" EventTypeAllowDownloadDisabled = "allow_download_disabled" EventTypeAllowDownloadEnabled = "allow_download_enabled" + EventTypeCameraUploadsPolicyChanged = "camera_uploads_policy_changed" EventTypeDataPlacementRestrictionChangePolicy = "data_placement_restriction_change_policy" EventTypeDataPlacementRestrictionSatisfyPolicy = "data_placement_restriction_satisfy_policy" EventTypeDeviceApprovalsChangeDesktopPolicy = "device_approvals_change_desktop_policy" @@ -6781,8 +6921,10 @@ EventTypeSmartSyncNotOptOut = "smart_sync_not_opt_out" EventTypeSmartSyncOptOut = "smart_sync_opt_out" EventTypeSsoChangePolicy = "sso_change_policy" + EventTypeTeamSelectiveSyncPolicyChanged = "team_selective_sync_policy_changed" EventTypeTfaChangePolicy = "tfa_change_policy" EventTypeTwoAccountChangePolicy = "two_account_change_policy" + EventTypeViewerInfoPolicyChanged = "viewer_info_policy_changed" EventTypeWebSessionsChangeFixedLengthPolicy = "web_sessions_change_fixed_length_policy" EventTypeWebSessionsChangeIdleLengthPolicy = "web_sessions_change_idle_length_policy" EventTypeTeamMergeFrom = "team_merge_from" @@ -6821,6 +6963,8 @@ FileChangeCommentSubscription json.RawMessage `json:"file_change_comment_subscription,omitempty"` // FileDeleteComment : (comments) Deleted file comment FileDeleteComment json.RawMessage `json:"file_delete_comment,omitempty"` + // FileEditComment : (comments) Edited file comment + FileEditComment json.RawMessage `json:"file_edit_comment,omitempty"` // FileLikeComment : (comments) Liked file comment (deprecated, no // longer logged) FileLikeComment json.RawMessage `json:"file_like_comment,omitempty"` @@ -7011,6 +7155,9 @@ // MemberChangeStatus : (members) Changed member status (invited, // joined, suspended, etc.) MemberChangeStatus json.RawMessage `json:"member_change_status,omitempty"` + // MemberDeleteManualContacts : (members) Cleared manually added + // contacts + MemberDeleteManualContacts json.RawMessage `json:"member_delete_manual_contacts,omitempty"` // MemberPermanentlyDeleteAccountContents : (members) Permanently // deleted contents of deleted team member account MemberPermanentlyDeleteAccountContents json.RawMessage `json:"member_permanently_delete_account_contents,omitempty"` @@ -7080,6 +7227,8 @@ PaperDocFollowed json.RawMessage `json:"paper_doc_followed,omitempty"` // PaperDocMention : (paper) Mentioned team member in Paper doc PaperDocMention json.RawMessage `json:"paper_doc_mention,omitempty"` + // PaperDocOwnershipChanged : (paper) Transferred ownership of Paper doc + PaperDocOwnershipChanged json.RawMessage `json:"paper_doc_ownership_changed,omitempty"` // PaperDocRequestAccess : (paper) Requested access to Paper doc PaperDocRequestAccess json.RawMessage `json:"paper_doc_request_access,omitempty"` // PaperDocResolveComment : (paper) Resolved Paper doc comment @@ -7418,6 +7567,9 @@ // AllowDownloadEnabled : (team_policies) Enabled downloads (deprecated, // no longer logged) AllowDownloadEnabled json.RawMessage `json:"allow_download_enabled,omitempty"` + // CameraUploadsPolicyChanged : (team_policies) Changed camera uploads + // setting for team + CameraUploadsPolicyChanged json.RawMessage `json:"camera_uploads_policy_changed,omitempty"` // DataPlacementRestrictionChangePolicy : (team_policies) Set // restrictions on data center locations where team data resides DataPlacementRestrictionChangePolicy json.RawMessage `json:"data_placement_restriction_change_policy,omitempty"` @@ -7548,6 +7700,9 @@ // SsoChangePolicy : (team_policies) Changed single sign-on setting for // team SsoChangePolicy json.RawMessage `json:"sso_change_policy,omitempty"` + // TeamSelectiveSyncPolicyChanged : (team_policies) Enabled/disabled + // Team Selective Sync for team + TeamSelectiveSyncPolicyChanged json.RawMessage `json:"team_selective_sync_policy_changed,omitempty"` // TfaChangePolicy : (team_policies) Changed two-step verification // setting for team TfaChangePolicy json.RawMessage `json:"tfa_change_policy,omitempty"` @@ -7555,6 +7710,9 @@ // members to link personal Dropbox account and team account to same // computer TwoAccountChangePolicy json.RawMessage `json:"two_account_change_policy,omitempty"` + // ViewerInfoPolicyChanged : (team_policies) Changed team policy for + // viewer info + ViewerInfoPolicyChanged json.RawMessage `json:"viewer_info_policy_changed,omitempty"` // WebSessionsChangeFixedLengthPolicy : (team_policies) Changed how long // members can stay signed in to Dropbox.com WebSessionsChangeFixedLengthPolicy json.RawMessage `json:"web_sessions_change_fixed_length_policy,omitempty"` @@ -7649,6 +7807,12 @@ if err != nil { return err } + case "file_edit_comment": + err = json.Unmarshal(body, &u.FileEditComment) + + if err != nil { + return err + } case "file_like_comment": err = json.Unmarshal(body, &u.FileLikeComment) @@ -8111,6 +8275,12 @@ if err != nil { return err } + case "member_delete_manual_contacts": + err = json.Unmarshal(body, &u.MemberDeleteManualContacts) + + if err != nil { + return err + } case "member_permanently_delete_account_contents": err = json.Unmarshal(body, &u.MemberPermanentlyDeleteAccountContents) @@ -8279,6 +8449,12 @@ if err != nil { return err } + case "paper_doc_ownership_changed": + err = json.Unmarshal(body, &u.PaperDocOwnershipChanged) + + if err != nil { + return err + } case "paper_doc_request_access": err = json.Unmarshal(body, &u.PaperDocRequestAccess) @@ -9071,6 +9247,12 @@ if err != nil { return err } + case "camera_uploads_policy_changed": + err = json.Unmarshal(body, &u.CameraUploadsPolicyChanged) + + if err != nil { + return err + } case "data_placement_restriction_change_policy": err = json.Unmarshal(body, &u.DataPlacementRestrictionChangePolicy) @@ -9329,6 +9511,12 @@ if err != nil { return err } + case "team_selective_sync_policy_changed": + err = json.Unmarshal(body, &u.TeamSelectiveSyncPolicyChanged) + + if err != nil { + return err + } case "tfa_change_policy": err = json.Unmarshal(body, &u.TfaChangePolicy) @@ -9341,6 +9529,12 @@ if err != nil { return err } + case "viewer_info_policy_changed": + err = json.Unmarshal(body, &u.ViewerInfoPolicyChanged) + + if err != nil { + return err + } case "web_sessions_change_fixed_length_policy": err = json.Unmarshal(body, &u.WebSessionsChangeFixedLengthPolicy) @@ -9768,6 +9962,34 @@ return s } +// FileEditCommentDetails : Edited file comment. +type FileEditCommentDetails struct { + // CommentText : Comment text. Might be missing due to historical data gap. + CommentText string `json:"comment_text,omitempty"` + // PreviousCommentText : Previous comment text. + PreviousCommentText string `json:"previous_comment_text"` +} + +// NewFileEditCommentDetails returns a new FileEditCommentDetails instance +func NewFileEditCommentDetails(PreviousCommentText string) *FileEditCommentDetails { + s := new(FileEditCommentDetails) + s.PreviousCommentText = PreviousCommentText + return s +} + +// FileEditCommentType : has no documentation (yet) +type FileEditCommentType struct { + // Description : has no documentation (yet) + Description string `json:"description"` +} + +// NewFileEditCommentType returns a new FileEditCommentType instance +func NewFileEditCommentType(Description string) *FileEditCommentType { + s := new(FileEditCommentType) + s.Description = Description + return s +} + // FileEditDetails : Edited files. type FileEditDetails struct { } @@ -10417,7 +10639,10 @@ // GetTeamEventsArg : has no documentation (yet) type GetTeamEventsArg struct { - // Limit : Number of results to return per call. + // Limit : The maximal number of results to return per call. Note that some + // calls may not return `limit` number of events, and may even return no + // events, even with `has_more` set to true. In this case, callers should + // fetch again using `getEventsContinue`. Limit uint32 `json:"limit"` // AccountId : Filter the events by account ID. Return ony events with this // account_id as either Actor, Context, or Participants. @@ -10452,14 +10677,44 @@ // `getEventsContinue`. type GetTeamEventsContinueError struct { dropbox.Tagged + // Reset : Cursors are intended to be used quickly. Individual cursor values + // are normally valid for days, but in rare cases may be reset sooner. + // Cursor reset errors should be handled by fetching a new cursor from + // `getEvents`. The associated value is the approximate timestamp of the + // most recent event returned by the cursor. This should be used as a + // resumption point when calling `getEvents` to obtain a new cursor. + Reset time.Time `json:"reset,omitempty"` } // Valid tag values for GetTeamEventsContinueError const ( GetTeamEventsContinueErrorBadCursor = "bad_cursor" + GetTeamEventsContinueErrorReset = "reset" GetTeamEventsContinueErrorOther = "other" ) +// UnmarshalJSON deserializes into a GetTeamEventsContinueError instance +func (u *GetTeamEventsContinueError) UnmarshalJSON(body []byte) error { + type wrap struct { + dropbox.Tagged + } + var w wrap + var err error + if err = json.Unmarshal(body, &w); err != nil { + return err + } + u.Tag = w.Tag + switch u.Tag { + case "reset": + err = json.Unmarshal(body, &u.Reset) + + if err != nil { + return err + } + } + return nil +} + // GetTeamEventsError : Errors that can be raised when calling `getEvents`. type GetTeamEventsError struct { dropbox.Tagged @@ -10474,14 +10729,20 @@ // GetTeamEventsResult : has no documentation (yet) type GetTeamEventsResult struct { - // Events : List of events. + // Events : List of events. Note that events are not guaranteed to be sorted + // by their timestamp value. Events []*TeamEvent `json:"events"` // Cursor : Pass the cursor into `getEventsContinue` to obtain additional - // events. + // events. The value of `cursor` may change for each response from + // `getEventsContinue`, regardless of the value of `has_more`; older cursor + // strings may expire. Thus, callers should ensure that they update their + // cursor based on the latest value of `cursor` after each call, and poll + // regularly if they wish to poll for new events. Callers should handle + // reset exceptions for expired cursors. Cursor string `json:"cursor"` - // HasMore : Is true if there are additional events that have not been + // HasMore : Is true if there may be additional events that have not been // returned yet. An additional call to `getEventsContinue` can retrieve - // them. + // them. Note that `has_more` may be true, even if `events` is empty. HasMore bool `json:"has_more"` } @@ -11352,6 +11613,29 @@ return s } +// MemberDeleteManualContactsDetails : Cleared manually added contacts. +type MemberDeleteManualContactsDetails struct { +} + +// NewMemberDeleteManualContactsDetails returns a new MemberDeleteManualContactsDetails instance +func NewMemberDeleteManualContactsDetails() *MemberDeleteManualContactsDetails { + s := new(MemberDeleteManualContactsDetails) + return s +} + +// MemberDeleteManualContactsType : has no documentation (yet) +type MemberDeleteManualContactsType struct { + // Description : has no documentation (yet) + Description string `json:"description"` +} + +// NewMemberDeleteManualContactsType returns a new MemberDeleteManualContactsType instance +func NewMemberDeleteManualContactsType(Description string) *MemberDeleteManualContactsType { + s := new(MemberDeleteManualContactsType) + s.Description = Description + return s +} + // MemberPermanentlyDeleteAccountContentsDetails : Permanently deleted contents // of deleted team member account. type MemberPermanentlyDeleteAccountContentsDetails struct { @@ -11935,14 +12219,17 @@ dropbox.Tagged // TeamMember : has no documentation (yet) TeamMember *TeamMemberLogInfo `json:"team_member,omitempty"` + // TrustedNonTeamMember : has no documentation (yet) + TrustedNonTeamMember *TrustedNonTeamMemberLogInfo `json:"trusted_non_team_member,omitempty"` // NonTeamMember : has no documentation (yet) NonTeamMember *NonTeamMemberLogInfo `json:"non_team_member,omitempty"` } // Valid tag values for UserLogInfo const ( - UserLogInfoTeamMember = "team_member" - UserLogInfoNonTeamMember = "non_team_member" + UserLogInfoTeamMember = "team_member" + UserLogInfoTrustedNonTeamMember = "trusted_non_team_member" + UserLogInfoNonTeamMember = "non_team_member" ) // UnmarshalJSON deserializes into a userLogInfoUnion instance @@ -11951,6 +12238,8 @@ dropbox.Tagged // TeamMember : has no documentation (yet) TeamMember json.RawMessage `json:"team_member,omitempty"` + // TrustedNonTeamMember : has no documentation (yet) + TrustedNonTeamMember json.RawMessage `json:"trusted_non_team_member,omitempty"` // NonTeamMember : has no documentation (yet) NonTeamMember json.RawMessage `json:"non_team_member,omitempty"` } @@ -11967,6 +12256,12 @@ if err != nil { return err } + case "trusted_non_team_member": + err = json.Unmarshal(body, &u.TrustedNonTeamMember) + + if err != nil { + return err + } case "non_team_member": err = json.Unmarshal(body, &u.NonTeamMember) @@ -11987,6 +12282,9 @@ case "team_member": return t.TeamMember, nil + case "trusted_non_team_member": + return t.TrustedNonTeamMember, nil + case "non_team_member": return t.NonTeamMember, nil @@ -12868,6 +13166,37 @@ return s } +// PaperDocOwnershipChangedDetails : Transferred ownership of Paper doc. +type PaperDocOwnershipChangedDetails struct { + // EventUuid : Event unique identifier. + EventUuid string `json:"event_uuid"` + // OldOwnerUserId : Previous owner. + OldOwnerUserId string `json:"old_owner_user_id,omitempty"` + // NewOwnerUserId : New owner. + NewOwnerUserId string `json:"new_owner_user_id"` +} + +// NewPaperDocOwnershipChangedDetails returns a new PaperDocOwnershipChangedDetails instance +func NewPaperDocOwnershipChangedDetails(EventUuid string, NewOwnerUserId string) *PaperDocOwnershipChangedDetails { + s := new(PaperDocOwnershipChangedDetails) + s.EventUuid = EventUuid + s.NewOwnerUserId = NewOwnerUserId + return s +} + +// PaperDocOwnershipChangedType : has no documentation (yet) +type PaperDocOwnershipChangedType struct { + // Description : has no documentation (yet) + Description string `json:"description"` +} + +// NewPaperDocOwnershipChangedType returns a new PaperDocOwnershipChangedType instance +func NewPaperDocOwnershipChangedType(Description string) *PaperDocOwnershipChangedType { + s := new(PaperDocOwnershipChangedType) + s.Description = Description + return s +} + // PaperDocRequestAccessDetails : Requested access to Paper doc. type PaperDocRequestAccessDetails struct { // EventUuid : Event unique identifier. @@ -13132,6 +13461,7 @@ PaperDownloadFormatDocx = "docx" PaperDownloadFormatHtml = "html" PaperDownloadFormatMarkdown = "markdown" + PaperDownloadFormatPdf = "pdf" PaperDownloadFormatOther = "other" ) @@ -13452,6 +13782,19 @@ return nil } +// PassPolicy : has no documentation (yet) +type PassPolicy struct { + dropbox.Tagged +} + +// Valid tag values for PassPolicy +const ( + PassPolicyEnabled = "enabled" + PassPolicyAllow = "allow" + PassPolicyDisabled = "disabled" + PassPolicyOther = "other" +) + // PasswordChangeDetails : Changed password. type PasswordChangeDetails struct { } @@ -13580,6 +13923,17 @@ PlacementRestrictionOther = "other" ) +// QuickActionType : Quick action type. +type QuickActionType struct { + dropbox.Tagged +} + +// Valid tag values for QuickActionType +const ( + QuickActionTypeDeleteSharedLink = "delete_shared_link" + QuickActionTypeOther = "other" +) + // RelocateAssetReferencesLogInfo : Provides the indices of the source asset and // the destination asset for a relocate action. type RelocateAssetReferencesLogInfo struct { @@ -14940,6 +15294,12 @@ // NewParentNsId : New parent namespace ID. Might be missing due to // historical data gap. NewParentNsId string `json:"new_parent_ns_id,omitempty"` + // PreviousNsPath : Previous namespace path. Might be missing due to + // historical data gap. + PreviousNsPath string `json:"previous_ns_path,omitempty"` + // NewNsPath : New namespace path. Might be missing due to historical data + // gap. + NewNsPath string `json:"new_ns_path,omitempty"` } // NewSharedFolderNestDetails returns a new SharedFolderNestDetails instance @@ -17227,6 +17587,49 @@ return s } +// TeamSelectiveSyncPolicy : Policy for controlling whether team selective sync +// is enabled for team. +type TeamSelectiveSyncPolicy struct { + dropbox.Tagged +} + +// Valid tag values for TeamSelectiveSyncPolicy +const ( + TeamSelectiveSyncPolicyDisabled = "disabled" + TeamSelectiveSyncPolicyEnabled = "enabled" + TeamSelectiveSyncPolicyOther = "other" +) + +// TeamSelectiveSyncPolicyChangedDetails : Enabled/disabled Team Selective Sync +// for team. +type TeamSelectiveSyncPolicyChangedDetails struct { + // NewValue : New Team Selective Sync policy. + NewValue *TeamSelectiveSyncPolicy `json:"new_value"` + // PreviousValue : Previous Team Selective Sync policy. + PreviousValue *TeamSelectiveSyncPolicy `json:"previous_value"` +} + +// NewTeamSelectiveSyncPolicyChangedDetails returns a new TeamSelectiveSyncPolicyChangedDetails instance +func NewTeamSelectiveSyncPolicyChangedDetails(NewValue *TeamSelectiveSyncPolicy, PreviousValue *TeamSelectiveSyncPolicy) *TeamSelectiveSyncPolicyChangedDetails { + s := new(TeamSelectiveSyncPolicyChangedDetails) + s.NewValue = NewValue + s.PreviousValue = PreviousValue + return s +} + +// TeamSelectiveSyncPolicyChangedType : has no documentation (yet) +type TeamSelectiveSyncPolicyChangedType struct { + // Description : has no documentation (yet) + Description string `json:"description"` +} + +// NewTeamSelectiveSyncPolicyChangedType returns a new TeamSelectiveSyncPolicyChangedType instance +func NewTeamSelectiveSyncPolicyChangedType(Description string) *TeamSelectiveSyncPolicyChangedType { + s := new(TeamSelectiveSyncPolicyChangedType) + s.Description = Description + return s +} + // TeamSelectiveSyncSettingsChangedDetails : Changed sync default. type TeamSelectiveSyncSettingsChangedDetails struct { // PreviousValue : Previous value. @@ -17489,6 +17892,33 @@ TimeUnitOther = "other" ) +// TrustedNonTeamMemberLogInfo : User that is not a member of the team but +// considered trusted. +type TrustedNonTeamMemberLogInfo struct { + UserLogInfo + // TrustedNonTeamMemberType : Indicates the type of the trusted non team + // member user. + TrustedNonTeamMemberType *TrustedNonTeamMemberType `json:"trusted_non_team_member_type"` +} + +// NewTrustedNonTeamMemberLogInfo returns a new TrustedNonTeamMemberLogInfo instance +func NewTrustedNonTeamMemberLogInfo(TrustedNonTeamMemberType *TrustedNonTeamMemberType) *TrustedNonTeamMemberLogInfo { + s := new(TrustedNonTeamMemberLogInfo) + s.TrustedNonTeamMemberType = TrustedNonTeamMemberType + return s +} + +// TrustedNonTeamMemberType : has no documentation (yet) +type TrustedNonTeamMemberType struct { + dropbox.Tagged +} + +// Valid tag values for TrustedNonTeamMemberType +const ( + TrustedNonTeamMemberTypeMultiInstanceAdmin = "multi_instance_admin" + TrustedNonTeamMemberTypeOther = "other" +) + // TwoAccountChangePolicyDetails : Enabled/disabled option for members to link // personal Dropbox account and team account to same computer. type TwoAccountChangePolicyDetails struct { @@ -17572,6 +18002,35 @@ return s } +// ViewerInfoPolicyChangedDetails : Changed team policy for viewer info. +type ViewerInfoPolicyChangedDetails struct { + // PreviousValue : Previous Viewer Info policy. + PreviousValue *PassPolicy `json:"previous_value"` + // NewValue : New Viewer Info policy. + NewValue *PassPolicy `json:"new_value"` +} + +// NewViewerInfoPolicyChangedDetails returns a new ViewerInfoPolicyChangedDetails instance +func NewViewerInfoPolicyChangedDetails(PreviousValue *PassPolicy, NewValue *PassPolicy) *ViewerInfoPolicyChangedDetails { + s := new(ViewerInfoPolicyChangedDetails) + s.PreviousValue = PreviousValue + s.NewValue = NewValue + return s +} + +// ViewerInfoPolicyChangedType : has no documentation (yet) +type ViewerInfoPolicyChangedType struct { + // Description : has no documentation (yet) + Description string `json:"description"` +} + +// NewViewerInfoPolicyChangedType returns a new ViewerInfoPolicyChangedType instance +func NewViewerInfoPolicyChangedType(Description string) *ViewerInfoPolicyChangedType { + s := new(ViewerInfoPolicyChangedType) + s.Description = Description + return s +} + // WebDeviceSessionLogInfo : Information on active web sessions type WebDeviceSessionLogInfo struct { DeviceSessionLogInfo diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/team_policies/types.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/team_policies/types.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/team_policies/types.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/team_policies/types.go 2018-12-22 22:15:38.000000000 +0000 @@ -23,6 +23,18 @@ import "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" +// CameraUploadsPolicyState : has no documentation (yet) +type CameraUploadsPolicyState struct { + dropbox.Tagged +} + +// Valid tag values for CameraUploadsPolicyState +const ( + CameraUploadsPolicyStateDisabled = "disabled" + CameraUploadsPolicyStateEnabled = "enabled" + CameraUploadsPolicyStateOther = "other" +) + // EmmState : has no documentation (yet) type EmmState struct { dropbox.Tagged diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/users/client.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/users/client.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/dropbox/users/client.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/dropbox/users/client.go 2018-12-22 22:15:38.000000000 +0000 @@ -27,6 +27,7 @@ "net/http" "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox" + "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth" ) // Client interface describes all routes in this namespace @@ -85,7 +86,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -103,17 +104,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -157,7 +152,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -175,17 +170,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -221,7 +210,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -239,17 +228,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } @@ -285,7 +268,7 @@ return } - dbx.Config.LogDebug("body: %v", body) + dbx.Config.LogDebug("body: %s", body) if resp.StatusCode == http.StatusOK { err = json.Unmarshal(body, &res) if err != nil { @@ -303,17 +286,11 @@ err = apiError return } - var apiError dropbox.APIError - if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { - apiError.ErrorSummary = string(body) - err = apiError - return - } - err = json.Unmarshal(body, &apiError) + err = auth.HandleCommonAuthErrors(dbx.Config, resp, body) if err != nil { return } - err = apiError + err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body) return } diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/generator/generate-sdk.sh golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/generator/generate-sdk.sh --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/generator/generate-sdk.sh 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/generator/generate-sdk.sh 2018-12-22 22:15:38.000000000 +0000 @@ -15,7 +15,7 @@ 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:-"5.0.0"} pushd ${spec_dir} spec_version=$(git rev-parse --short HEAD) popd diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/generator/go_client.stoneg.py golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/generator/go_client.stoneg.py --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/generator/go_client.stoneg.py 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/generator/go_client.stoneg.py 2018-12-22 22:15:38.000000000 +0000 @@ -48,6 +48,8 @@ req = fmt_type(route.arg_data_type, namespace) res = fmt_type(route.result_data_type, namespace, use_interface=True) fn = fmt_var(route.name) + if route.version != 1: + fn += 'V%d' % route.version style = route.attrs.get('style', 'rpc') arg = '' if is_void_type(route.arg_data_type) else 'arg {req}' @@ -67,6 +69,8 @@ def _generate_route(self, namespace, route): out = self.emit fn = fmt_var(route.name) + if route.version != 1: + fn += 'V%d' % route.version err = fmt_type(route.error_data_type, namespace) out('//%sAPIError is an error-wrapper for the %s route' % (fn, route.name)) @@ -95,7 +99,7 @@ ok_check += ' || resp.StatusCode == http.StatusPartialContent' with self.block(ok_check): self._generate_result(route) - self._generate_error_handling(route) + self._generate_error_handling(namespace, route) out() @@ -138,9 +142,12 @@ out('headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID') out() + fn = route.name + if route.version != 1: + fn += '_v%d' % route.version authed = 'false' if auth == 'noauth' else 'true' out('req, err := (*dropbox.Context)(dbx).NewRequest("{}", "{}", {}, "{}", "{}", headers, {})'.format( - host, style, authed, namespace.name, route.name, body)) + host, style, authed, namespace.name, fn, body)) with self.block('if err != nil'): out('return') @@ -172,9 +179,9 @@ out('return') out() - out('dbx.Config.LogDebug("body: %v", body)') + out('dbx.Config.LogDebug("body: %s", body)') - def _generate_error_handling(self, route): + def _generate_error_handling(self, namespace, route): out = self.emit style = route.attrs.get('style', 'rpc') with self.block('if resp.StatusCode == http.StatusConflict'): @@ -191,16 +198,11 @@ out('return') out('err = apiError') out('return') - out('var apiError dropbox.APIError') - with self.block("if resp.StatusCode == http.StatusBadRequest || " - "resp.StatusCode == http.StatusInternalServerError"): - out('apiError.ErrorSummary = string(body)') - out('err = apiError') - out('return') - with self.block('err = json.Unmarshal(body, &apiError);' - 'if err != nil'): + auth_ns = "" if namespace.name == "auth" else "auth." + with self.block('err = %sHandleCommonAuthErrors(dbx.Config, resp, body);' + 'if err != nil' % auth_ns): out('return') - out('err = apiError') + out('err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body)') out('return') def _generate_result(self, route): diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/generator/go_helpers.py golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/generator/go_helpers.py --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/generator/go_helpers.py 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/generator/go_helpers.py 2018-12-22 22:15:38.000000000 +0000 @@ -128,7 +128,11 @@ if t.deprecated is not None: d = 'Deprecated: ' if t.deprecated.by is not None: - d += 'Use `%s` instead' % fmt_var(t.deprecated.by.name) + deprecated_by = t.deprecated.by + fn = fmt_var(deprecated_by.name) + if deprecated_by.version != 1: + fn += 'V%d' % deprecated_by.version + d += 'Use `%s` instead' % fn code_generator.emit_wrapped_text(d, prefix='// ') diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/generator/go_rsrc/sdk.go golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/generator/go_rsrc/sdk.go --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/generator/go_rsrc/sdk.go 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/generator/go_rsrc/sdk.go 2018-12-22 22:15:38.000000000 +0000 @@ -21,6 +21,7 @@ package dropbox import ( + "encoding/json" "fmt" "io" "log" @@ -206,8 +207,17 @@ return e.ErrorSummary } -func init() { - // These are not registered in the oauth library by default - oauth2.RegisterBrokenAuthHeaderProvider("https://api.dropboxapi.com") - oauth2.RegisterBrokenAuthHeaderProvider("https://api-dbdev.dev.corp.dropbox.com") +// HandleCommonAPIErrors handles common API errors +func HandleCommonAPIErrors(c Config, resp *http.Response, body []byte) error { + var apiError APIError + if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError { + apiError.ErrorSummary = string(body) + return apiError + } + e := json.Unmarshal(body, &apiError) + if e != nil { + c.LogDebug("%v", e) + return e + } + return apiError } diff -Nru golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/.travis.yml golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/.travis.yml --- golang-github-dropbox-dropbox-sdk-go-unofficial-4.1.0/.travis.yml 2018-05-23 05:05:00.000000000 +0000 +++ golang-github-dropbox-dropbox-sdk-go-unofficial-5.4.0/.travis.yml 2018-12-22 22:15:38.000000000 +0000 @@ -1,9 +1,9 @@ language: go go: - - 1.8.x - - 1.9.x - - 1.10.x + - "1.9.x" + - "1.10.x" + - "1.11.x" install: go get -u golang.org/x/oauth2 @@ -17,6 +17,6 @@ jobs: include: - stage: run tests - go: 1.9.x + go: "1.11.x" install: go get -u golang.org/x/oauth2 - script: go test ./dropbox/... + script: go test -v ./dropbox/...