Issue #1788: Pointing to Dropbox's v5.0.0 tag

s3-about
Mathieu Carbou 2018-12-05 13:15:41 -05:00 committed by Nick Craig-Wood
parent fc654a4cec
commit 4138d5aa75
16 changed files with 2214 additions and 1941 deletions

3
go.mod
View File

@ -3,6 +3,7 @@ module github.com/ncw/rclone
require (
bazil.org/fuse v0.0.0-20180421153158-65cc252bf669
cloud.google.com/go v0.33.1 // indirect
github.com/Azure/azure-pipeline-go v0.1.8
github.com/Azure/azure-storage-blob-go v0.0.0-20181023070848-cf01652132cc
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78
github.com/Unknwon/goconfig v0.0.0-20181105214110-56bd8ab18619
@ -14,7 +15,7 @@ require (
github.com/cpuguy83/go-md2man v1.0.8 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/djherbis/times v1.1.0
github.com/dropbox/dropbox-sdk-go-unofficial v4.1.0+incompatible
github.com/dropbox/dropbox-sdk-go-unofficial v5.0.1-0.20181205034806-56e5f6595305+incompatible
github.com/goftp/file-driver v0.0.0-20180502053751-5d604a0fc0c9 // indirect
github.com/goftp/server v0.0.0-20180914132916-1fd52c8552f1
github.com/google/go-querystring v1.0.0 // indirect

3
go.sum
View File

@ -28,6 +28,9 @@ github.com/djherbis/times v1.1.0 h1:NFhBDODme0XNX+/5ETW9qL6v3Ty57psiXIQBrzzg44E=
github.com/djherbis/times v1.1.0/go.mod h1:CGMZlo255K5r4Yw0b9RRfFQpM2y7uOmxg4jm9HsaVf8=
github.com/dropbox/dropbox-sdk-go-unofficial v4.1.0+incompatible h1:ZFvUIiBbGhDY5zF8yjLoWhUAYs7uDodUpbvTS5oelDE=
github.com/dropbox/dropbox-sdk-go-unofficial v4.1.0+incompatible/go.mod h1:lr+LhMM3F6Y3lW1T9j2U5l7QeuWm87N9+PPXo3yH4qY=
github.com/dropbox/dropbox-sdk-go-unofficial v5.0.0+incompatible h1:FQu9Ef2dkC8g2rQmcQmpXXeoRegXHODBfveKKZu6+e8=
github.com/dropbox/dropbox-sdk-go-unofficial v5.0.1-0.20181205034806-56e5f6595305+incompatible h1:4HSS6BiPqvgsn/zrwt6KOYY+mw153zmhvewZIRh1+Ds=
github.com/dropbox/dropbox-sdk-go-unofficial v5.0.1-0.20181205034806-56e5f6595305+incompatible/go.mod h1:lr+LhMM3F6Y3lW1T9j2U5l7QeuWm87N9+PPXo3yH4qY=
github.com/goftp/file-driver v0.0.0-20180502053751-5d604a0fc0c9 h1:cC0Hbb+18DJ4i6ybqDybvj4wdIDS4vnD0QEci98PgM8=
github.com/goftp/file-driver v0.0.0-20180502053751-5d604a0fc0c9/go.mod h1:GpOj6zuVBG3Inr9qjEnuVTgBlk2lZ1S9DcoFiXWyKss=
github.com/goftp/server v0.0.0-20180914132916-1fd52c8552f1 h1:WjgeEHEDLGx56ndxS6FYi6qFjZGajSVHPuEPdpJ60cI=

View File

@ -0,0 +1,166 @@
// 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 auth
import (
"bytes"
"encoding/json"
"io/ioutil"
"net/http"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
)
// Client interface describes all routes in this namespace
type Client interface {
// TokenFromOauth1 : Creates an OAuth 2.0 access token from the supplied
// OAuth 1.0 access token.
TokenFromOauth1(arg *TokenFromOAuth1Arg) (res *TokenFromOAuth1Result, err error)
// TokenRevoke : Disables the access token used to authenticate the call.
TokenRevoke() (err error)
}
type apiImpl dropbox.Context
//TokenFromOauth1APIError is an error-wrapper for the token/from_oauth1 route
type TokenFromOauth1APIError struct {
dropbox.APIError
EndpointError *TokenFromOAuth1Error `json:"error"`
}
func (dbx *apiImpl) TokenFromOauth1(arg *TokenFromOAuth1Arg) (res *TokenFromOAuth1Result, 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, "auth", "token/from_oauth1", 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 TokenFromOauth1APIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
err = HandleCommonAuthErrors(dbx.Config, resp, body)
if err != nil {
return
}
err = dropbox.HandleCommonAPIErrors(dbx.Config, resp, body)
return
}
//TokenRevokeAPIError is an error-wrapper for the token/revoke route
type TokenRevokeAPIError struct {
dropbox.APIError
EndpointError struct{} `json:"error"`
}
func (dbx *apiImpl) TokenRevoke() (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, "auth", "token/revoke", 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 TokenRevokeAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
err = 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
}

View File

@ -0,0 +1,38 @@
package auth
import (
"encoding/json"
"mime"
"net/http"
"strconv"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
)
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 {
if resp.StatusCode == 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
}
return nil
}

View File

@ -0,0 +1,188 @@
// 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 auth : has no documentation (yet)
package auth
import (
"encoding/json"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
)
// AccessError : Error occurred because the account doesn't have permission to
// access the resource.
type AccessError struct {
dropbox.Tagged
// InvalidAccountType : Current account type cannot access the resource.
InvalidAccountType *InvalidAccountTypeError `json:"invalid_account_type,omitempty"`
// PaperAccessDenied : Current account cannot access Paper.
PaperAccessDenied *PaperAccessError `json:"paper_access_denied,omitempty"`
}
// Valid tag values for AccessError
const (
AccessErrorInvalidAccountType = "invalid_account_type"
AccessErrorPaperAccessDenied = "paper_access_denied"
AccessErrorOther = "other"
)
// UnmarshalJSON deserializes into a AccessError instance
func (u *AccessError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// InvalidAccountType : Current account type cannot access the resource.
InvalidAccountType json.RawMessage `json:"invalid_account_type,omitempty"`
// PaperAccessDenied : Current account cannot access Paper.
PaperAccessDenied json.RawMessage `json:"paper_access_denied,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 "invalid_account_type":
err = json.Unmarshal(w.InvalidAccountType, &u.InvalidAccountType)
if err != nil {
return err
}
case "paper_access_denied":
err = json.Unmarshal(w.PaperAccessDenied, &u.PaperAccessDenied)
if err != nil {
return err
}
}
return nil
}
// AuthError : Errors occurred during authentication.
type AuthError struct {
dropbox.Tagged
}
// Valid tag values for AuthError
const (
AuthErrorInvalidAccessToken = "invalid_access_token"
AuthErrorInvalidSelectUser = "invalid_select_user"
AuthErrorInvalidSelectAdmin = "invalid_select_admin"
AuthErrorUserSuspended = "user_suspended"
AuthErrorExpiredAccessToken = "expired_access_token"
AuthErrorOther = "other"
)
// InvalidAccountTypeError : has no documentation (yet)
type InvalidAccountTypeError struct {
dropbox.Tagged
}
// Valid tag values for InvalidAccountTypeError
const (
InvalidAccountTypeErrorEndpoint = "endpoint"
InvalidAccountTypeErrorFeature = "feature"
InvalidAccountTypeErrorOther = "other"
)
// PaperAccessError : has no documentation (yet)
type PaperAccessError struct {
dropbox.Tagged
}
// Valid tag values for PaperAccessError
const (
PaperAccessErrorPaperDisabled = "paper_disabled"
PaperAccessErrorNotPaperUser = "not_paper_user"
PaperAccessErrorOther = "other"
)
// RateLimitError : Error occurred because the app is being rate limited.
type RateLimitError struct {
// Reason : The reason why the app is being rate limited.
Reason *RateLimitReason `json:"reason"`
// RetryAfter : The number of seconds that the app should wait before making
// another request.
RetryAfter uint64 `json:"retry_after"`
}
// NewRateLimitError returns a new RateLimitError instance
func NewRateLimitError(Reason *RateLimitReason) *RateLimitError {
s := new(RateLimitError)
s.Reason = Reason
s.RetryAfter = 1
return s
}
// RateLimitReason : has no documentation (yet)
type RateLimitReason struct {
dropbox.Tagged
}
// Valid tag values for RateLimitReason
const (
RateLimitReasonTooManyRequests = "too_many_requests"
RateLimitReasonTooManyWriteOperations = "too_many_write_operations"
RateLimitReasonOther = "other"
)
// TokenFromOAuth1Arg : has no documentation (yet)
type TokenFromOAuth1Arg struct {
// Oauth1Token : The supplied OAuth 1.0 access token.
Oauth1Token string `json:"oauth1_token"`
// Oauth1TokenSecret : The token secret associated with the supplied access
// token.
Oauth1TokenSecret string `json:"oauth1_token_secret"`
}
// NewTokenFromOAuth1Arg returns a new TokenFromOAuth1Arg instance
func NewTokenFromOAuth1Arg(Oauth1Token string, Oauth1TokenSecret string) *TokenFromOAuth1Arg {
s := new(TokenFromOAuth1Arg)
s.Oauth1Token = Oauth1Token
s.Oauth1TokenSecret = Oauth1TokenSecret
return s
}
// TokenFromOAuth1Error : has no documentation (yet)
type TokenFromOAuth1Error struct {
dropbox.Tagged
}
// Valid tag values for TokenFromOAuth1Error
const (
TokenFromOAuth1ErrorInvalidOauth1TokenInfo = "invalid_oauth1_token_info"
TokenFromOAuth1ErrorAppIdMismatch = "app_id_mismatch"
TokenFromOAuth1ErrorOther = "other"
)
// TokenFromOAuth1Result : has no documentation (yet)
type TokenFromOAuth1Result struct {
// Oauth2Token : The OAuth 2.0 token generated from the supplied OAuth 1.0
// token.
Oauth2Token string `json:"oauth2_token"`
}
// NewTokenFromOAuth1Result returns a new TokenFromOAuth1Result instance
func NewTokenFromOAuth1Result(Oauth2Token string) *TokenFromOAuth1Result {
s := new(TokenFromOAuth1Result)
s.Oauth2Token = Oauth2Token
return s
}

View File

@ -27,6 +27,7 @@ import (
"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 @@ func (dbx *apiImpl) PropertiesAdd(arg *AddPropertiesArg) (err error) {
return
}
dbx.Config.LogDebug("body: %v", body)
dbx.Config.LogDebug("body: %s", body)
if resp.StatusCode == http.StatusOK {
return
}
@ -155,17 +156,11 @@ func (dbx *apiImpl) PropertiesAdd(arg *AddPropertiesArg) (err error) {
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 @@ func (dbx *apiImpl) PropertiesOverwrite(arg *OverwritePropertyGroupArg) (err err
return
}
dbx.Config.LogDebug("body: %v", body)
dbx.Config.LogDebug("body: %s", body)
if resp.StatusCode == http.StatusOK {
return
}
@ -222,17 +217,11 @@ func (dbx *apiImpl) PropertiesOverwrite(arg *OverwritePropertyGroupArg) (err err
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 @@ func (dbx *apiImpl) PropertiesRemove(arg *RemovePropertiesArg) (err error) {
return
}
dbx.Config.LogDebug("body: %v", body)
dbx.Config.LogDebug("body: %s", body)
if resp.StatusCode == http.StatusOK {
return
}
@ -289,17 +278,11 @@ func (dbx *apiImpl) PropertiesRemove(arg *RemovePropertiesArg) (err error) {
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 @@ func (dbx *apiImpl) PropertiesSearch(arg *PropertiesSearchArg) (res *PropertiesS
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 @@ func (dbx *apiImpl) PropertiesSearch(arg *PropertiesSearchArg) (res *PropertiesS
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 @@ func (dbx *apiImpl) PropertiesSearchContinue(arg *PropertiesSearchContinueArg) (
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 @@ func (dbx *apiImpl) PropertiesSearchContinue(arg *PropertiesSearchContinueArg) (
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 @@ func (dbx *apiImpl) PropertiesUpdate(arg *UpdatePropertiesArg) (err error) {
return
}
dbx.Config.LogDebug("body: %v", body)
dbx.Config.LogDebug("body: %s", body)
if resp.StatusCode == http.StatusOK {
return
}
@ -500,17 +471,11 @@ func (dbx *apiImpl) PropertiesUpdate(arg *UpdatePropertiesArg) (err error) {
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 @@ func (dbx *apiImpl) TemplatesAddForTeam(arg *AddTemplateArg) (res *AddTemplateRe
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 @@ func (dbx *apiImpl) TemplatesAddForTeam(arg *AddTemplateArg) (res *AddTemplateRe
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 @@ func (dbx *apiImpl) TemplatesAddForUser(arg *AddTemplateArg) (res *AddTemplateRe
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 @@ func (dbx *apiImpl) TemplatesAddForUser(arg *AddTemplateArg) (res *AddTemplateRe
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 @@ func (dbx *apiImpl) TemplatesGetForTeam(arg *GetTemplateArg) (res *GetTemplateRe
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 @@ func (dbx *apiImpl) TemplatesGetForTeam(arg *GetTemplateArg) (res *GetTemplateRe
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 @@ func (dbx *apiImpl) TemplatesGetForUser(arg *GetTemplateArg) (res *GetTemplateRe
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 @@ func (dbx *apiImpl) TemplatesGetForUser(arg *GetTemplateArg) (res *GetTemplateRe
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 @@ func (dbx *apiImpl) TemplatesListForTeam() (res *ListTemplateResult, err error)
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 @@ func (dbx *apiImpl) TemplatesListForTeam() (res *ListTemplateResult, err error)
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 @@ func (dbx *apiImpl) TemplatesListForUser() (res *ListTemplateResult, err error)
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 @@ func (dbx *apiImpl) TemplatesListForUser() (res *ListTemplateResult, err error)
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 @@ func (dbx *apiImpl) TemplatesRemoveForTeam(arg *RemoveTemplateArg) (err error) {
return
}
dbx.Config.LogDebug("body: %v", body)
dbx.Config.LogDebug("body: %s", body)
if resp.StatusCode == http.StatusOK {
return
}
@ -971,17 +900,11 @@ func (dbx *apiImpl) TemplatesRemoveForTeam(arg *RemoveTemplateArg) (err error) {
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 @@ func (dbx *apiImpl) TemplatesRemoveForUser(arg *RemoveTemplateArg) (err error) {
return
}
dbx.Config.LogDebug("body: %v", body)
dbx.Config.LogDebug("body: %s", body)
if resp.StatusCode == http.StatusOK {
return
}
@ -1038,17 +961,11 @@ func (dbx *apiImpl) TemplatesRemoveForUser(arg *RemoveTemplateArg) (err error) {
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 @@ func (dbx *apiImpl) TemplatesUpdateForTeam(arg *UpdateTemplateArg) (res *UpdateT
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 @@ func (dbx *apiImpl) TemplatesUpdateForTeam(arg *UpdateTemplateArg) (res *UpdateT
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 @@ func (dbx *apiImpl) TemplatesUpdateForUser(arg *UpdateTemplateArg) (res *UpdateT
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 @@ func (dbx *apiImpl) TemplatesUpdateForUser(arg *UpdateTemplateArg) (res *UpdateT
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
}

File diff suppressed because it is too large Load Diff

View File

@ -183,6 +183,11 @@ type CommitInfo struct {
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 @@ func NewCommitInfo(Path string) *CommitInfo {
s.Mode = &WriteMode{Tagged: dropbox.Tagged{"add"}}
s.Autorename = false
s.Mute = false
s.StrictConflict = false
return s
}
@ -207,6 +213,7 @@ func NewCommitInfoWithProperties(Path string) *CommitInfoWithProperties {
s.Mode = &WriteMode{Tagged: dropbox.Tagged{"add"}}
s.Autorename = false
s.Mute = false
s.StrictConflict = false
return s
}
@ -402,7 +409,8 @@ func NewFileOpsResult() *FileOpsResult {
// 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 @@ func (u *DeleteBatchLaunch) UnmarshalJSON(body []byte) error {
// 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 @@ type FileMetadata struct {
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`
// </developers/reference/content-hash> page.
// <https://www.dropbox.com/developers/reference/content-hash> page.
ContentHash string `json:"content_hash,omitempty"`
}
@ -1436,6 +1445,39 @@ func NewGetTemporaryLinkResult(Metadata *FileMetadata, Link string) *GetTemporar
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 @@ func NewGetThumbnailBatchResult(Entries []*GetThumbnailBatchResultEntry) *GetThu
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 @@ func NewListRevisionsResult(IsDeleted bool, Entries []*FileMetadata) *ListRevisi
// 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`
// <https://www.dropbox.com/developers/documentation/http/documentation#path-formats>
// for more information.
MalformedPath string `json:"malformed_path,omitempty"`
}
@ -1913,7 +1959,10 @@ const (
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`
// <https://www.dropbox.com/developers/documentation/http/documentation#path-formats>
// for more information.
MalformedPath json.RawMessage `json:"malformed_path,omitempty"`
}
var w wrap
@ -2057,6 +2106,42 @@ func IsMediaMetadataFromJSON(data []byte) (IsMediaMetadata, error) {
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 @@ func NewRelocationArg(FromPath string, ToPath string) *RelocationArg {
// 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 @@ type RelocationBatchArg struct {
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 @@ const (
RelocationErrorDuplicatedOrNestedPaths = "duplicated_or_nested_paths"
RelocationErrorCantTransferOwnership = "cant_transfer_ownership"
RelocationErrorInsufficientQuota = "insufficient_quota"
RelocationErrorInternalError = "internal_error"
RelocationErrorOther = "other"
)
@ -2283,6 +2364,7 @@ const (
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 @@ func (u *RelocationBatchError) UnmarshalJSON(body []byte) error {
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 @@ func (u *RelocationBatchResultData) UnmarshalJSON(b []byte) error {
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 @@ func (u *RelocationResult) UnmarshalJSON(b []byte) error {
// 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 @@ type UploadSessionAppendArg struct {
// 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 @@ func (u *UploadSessionFinishBatchLaunch) UnmarshalJSON(body []byte) error {
// 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 @@ func NewUploadSessionOffsetError(CorrectOffset uint64) *UploadSessionOffsetError
// 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 @@ func NewUploadSessionStartArg() *UploadSessionStartArg {
// 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 @@ const (
// 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`
// <https://www.dropbox.com/developers/documentation/http/documentation#path-formats>
// 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 @@ const (
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`
// <https://www.dropbox.com/developers/documentation/http/documentation#path-formats>
// 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.

View File

@ -21,6 +21,7 @@
package dropbox
import (
"encoding/json"
"fmt"
"io"
"log"
@ -36,8 +37,8 @@ const (
hostAPI = "api"
hostContent = "content"
hostNotify = "notify"
sdkVersion = "4.2.0"
specVersion = "222ba8c"
sdkVersion = "5.2.0"
specVersion = "097e9ba"
)
// Version returns the current SDK version and API Spec version
@ -206,8 +207,17 @@ func (e APIError) Error() string {
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
}

File diff suppressed because it is too large Load Diff

View File

@ -693,6 +693,7 @@ const (
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 @@ func NewGroupInfo(GroupName string, GroupId string, GroupManagementType *team_co
// 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 @@ type LinkAudience struct {
const (
LinkAudiencePublic = "public"
LinkAudienceTeam = "team"
LinkAudienceNoOne = "no_one"
LinkAudienceMembers = "members"
LinkAudienceOther = "other"
)
@ -3262,6 +3266,8 @@ type ShareFolderArgBase struct {
// 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 @@ func NewShareFolderArgBase(Path string) *ShareFolderArgBase {
s := new(ShareFolderArgBase)
s.Path = Path
s.ForceAsync = false
s.AccessInheritance = &AccessInheritance{Tagged: dropbox.Tagged{"inherit"}}
return s
}
@ -3289,6 +3296,7 @@ func NewShareFolderArg(Path string) *ShareFolderArg {
s := new(ShareFolderArg)
s.Path = Path
s.ForceAsync = false
s.AccessInheritance = &AccessInheritance{Tagged: dropbox.Tagged{"inherit"}}
return s
}

File diff suppressed because it is too large Load Diff

View File

@ -2315,11 +2315,43 @@ func (u *MembersAddLaunch) UnmarshalJSON(body []byte) error {
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 @@ func NewMembersRemoveArg(User *UserSelectorArg) *MembersRemoveArg {
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 @@ const (
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 @@ const (
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 @@ func (u *RemoveCustomQuotaResult) UnmarshalJSON(body []byte) error {
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 @@ func NewTeamNamespacesListContinueArg(Cursor string) *TeamNamespacesListContinue
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 @@ type TeamNamespacesListContinueError struct {
// Valid tag values for TeamNamespacesListContinueError
const (
TeamNamespacesListContinueErrorInvalidCursor = "invalid_cursor"
TeamNamespacesListContinueErrorInvalidArg = "invalid_arg"
TeamNamespacesListContinueErrorOther = "other"
TeamNamespacesListContinueErrorInvalidCursor = "invalid_cursor"
)
// TeamNamespacesListResult : Result for `namespacesList`.

View File

@ -23,6 +23,18 @@ package team_policies
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

View File

@ -27,6 +27,7 @@ import (
"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 @@ func (dbx *apiImpl) GetAccount(arg *GetAccountArg) (res *BasicAccount, err error
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 @@ func (dbx *apiImpl) GetAccount(arg *GetAccountArg) (res *BasicAccount, err error
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 @@ func (dbx *apiImpl) GetAccountBatch(arg *GetAccountBatchArg) (res []*BasicAccoun
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 @@ func (dbx *apiImpl) GetAccountBatch(arg *GetAccountBatchArg) (res []*BasicAccoun
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 @@ func (dbx *apiImpl) GetCurrentAccount() (res *FullAccount, err error) {
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 @@ func (dbx *apiImpl) GetCurrentAccount() (res *FullAccount, err error) {
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 @@ func (dbx *apiImpl) GetSpaceUsage() (res *SpaceUsage, err error) {
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 @@ func (dbx *apiImpl) GetSpaceUsage() (res *SpaceUsage, err error) {
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
}

3
vendor/modules.txt vendored
View File

@ -63,7 +63,7 @@ github.com/cpuguy83/go-md2man/md2man
github.com/davecgh/go-spew/spew
# github.com/djherbis/times v1.1.0
github.com/djherbis/times
# github.com/dropbox/dropbox-sdk-go-unofficial v4.1.0+incompatible
# github.com/dropbox/dropbox-sdk-go-unofficial v5.0.1-0.20181205034806-56e5f6595305+incompatible
github.com/dropbox/dropbox-sdk-go-unofficial/dropbox
github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/common
github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files
@ -71,6 +71,7 @@ github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/sharing
github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team
github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users
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
github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/seen_state
github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_common