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

This commit is contained in:
Nick Craig-Wood 2017-09-23 11:53:26 +01:00
parent 6390bb2b09
commit 29e2744155
25 changed files with 4222 additions and 1283 deletions

4
Gopkg.lock generated
View File

@ -76,8 +76,8 @@
[[projects]]
branch = "master"
name = "github.com/dropbox/dropbox-sdk-go-unofficial"
packages = ["dropbox","dropbox/async","dropbox/files","dropbox/properties"]
revision = "350942579f314463a49b660b7a35f01dbf392a7f"
packages = ["dropbox","dropbox/async","dropbox/file_properties","dropbox/files"]
revision = "98997935f6b3ff4f4fa46275abaa23b02537178d"
[[projects]]
name = "github.com/go-ini/ini"

View File

@ -1,9 +1,10 @@
language: go
go:
- 1.6.4
- 1.7.6
- 1.8.3
- 1.6.x
- 1.7.x
- 1.8.x
- 1.9.x
install:
- go get -u golang.org/x/oauth2

View File

@ -45,11 +45,11 @@ type PathRoot struct {
dropbox.Tagged
// Team : Paths are relative to the given team directory. (This results in
// `PathRootError.invalid` if the user is not a member of the team
// associated with that path root id.)
// associated with that path root id.).
Team string `json:"team,omitempty"`
// NamespaceId : Paths are relative to given namespace id (This results in
// `PathRootError.no_permission` if you don't have access to this
// namespace.)
// namespace.).
NamespaceId string `json:"namespace_id,omitempty"`
}

View File

@ -0,0 +1,980 @@
// 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 file_properties
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 {
// PropertiesAdd : Add property groups to a Dropbox file. See
// `templatesAddForUser` or `templatesAddForTeam` to create new templates.
PropertiesAdd(arg *AddPropertiesArg) (err error)
// PropertiesOverwrite : Overwrite property groups associated with a file.
// This endpoint should be used instead of `propertiesUpdate` when property
// groups are being updated via a "snapshot" instead of via a "delta". In
// other words, this endpoint will delete all omitted fields from a property
// group, whereas `propertiesUpdate` will only delete fields that are
// explicitly marked for deletion.
PropertiesOverwrite(arg *OverwritePropertyGroupArg) (err error)
// PropertiesRemove : Remove the specified property group from the file. To
// remove specific property field key value pairs, see route
// `propertiesUpdate`. To update a template, see `templatesUpdateForUser` or
// `templatesUpdateForTeam`. Templates can't be removed once created.
PropertiesRemove(arg *RemovePropertiesArg) (err error)
// PropertiesSearch : Search across property templates for particular
// property field values.
PropertiesSearch(arg *PropertiesSearchArg) (res *PropertiesSearchResult, err error)
// PropertiesUpdate : Add, update or remove properties associated with the
// supplied file and templates. This endpoint should be used instead of
// `propertiesOverwrite` when property groups are being updated via a
// "delta" instead of via a "snapshot" . In other words, this endpoint will
// not delete any omitted fields from a property group, whereas
// `propertiesOverwrite` will delete any fields that are omitted from a
// property group.
PropertiesUpdate(arg *UpdatePropertiesArg) (err error)
// TemplatesAddForTeam : Add a template associated with a team. See route
// `propertiesAdd` to add properties to a file or folder.
TemplatesAddForTeam(arg *AddTemplateArg) (res *AddTemplateResult, err error)
// TemplatesAddForUser : Add a template associated with a user. See route
// `propertiesAdd` to add properties to a file.
TemplatesAddForUser(arg *AddTemplateArg) (res *AddTemplateResult, err error)
// TemplatesGetForTeam : Get the schema for a specified template.
TemplatesGetForTeam(arg *GetTemplateArg) (res *GetTemplateResult, err error)
// TemplatesGetForUser : Get the schema for a specified template.
TemplatesGetForUser(arg *GetTemplateArg) (res *GetTemplateResult, err error)
// TemplatesListForTeam : Get the template identifiers for a team. To get
// the schema of each template use `templatesGetForTeam`.
TemplatesListForTeam() (res *ListTemplateResult, err error)
// TemplatesListForUser : Get the template identifiers for a team. To get
// the schema of each template use `templatesGetForUser`.
TemplatesListForUser() (res *ListTemplateResult, err error)
// TemplatesUpdateForTeam : Update a template associated with a team. This
// route can update the template name, the template description and add
// optional properties to templates.
TemplatesUpdateForTeam(arg *UpdateTemplateArg) (res *UpdateTemplateResult, err error)
// TemplatesUpdateForUser : Update a template associated with a user. This
// route can update the template name, the template description and add
// optional properties to templates.
TemplatesUpdateForUser(arg *UpdateTemplateArg) (res *UpdateTemplateResult, err error)
}
type apiImpl dropbox.Context
//PropertiesAddAPIError is an error-wrapper for the properties/add route
type PropertiesAddAPIError struct {
dropbox.APIError
EndpointError *AddPropertiesError `json:"error"`
}
func (dbx *apiImpl) PropertiesAdd(arg *AddPropertiesArg) (err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_properties", "properties/add", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("body: %v", body)
if resp.StatusCode == http.StatusOK {
return
}
if resp.StatusCode == http.StatusConflict {
var apiError PropertiesAddAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//PropertiesOverwriteAPIError is an error-wrapper for the properties/overwrite route
type PropertiesOverwriteAPIError struct {
dropbox.APIError
EndpointError *InvalidPropertyGroupError `json:"error"`
}
func (dbx *apiImpl) PropertiesOverwrite(arg *OverwritePropertyGroupArg) (err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_properties", "properties/overwrite", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("body: %v", body)
if resp.StatusCode == http.StatusOK {
return
}
if resp.StatusCode == http.StatusConflict {
var apiError PropertiesOverwriteAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//PropertiesRemoveAPIError is an error-wrapper for the properties/remove route
type PropertiesRemoveAPIError struct {
dropbox.APIError
EndpointError *RemovePropertiesError `json:"error"`
}
func (dbx *apiImpl) PropertiesRemove(arg *RemovePropertiesArg) (err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_properties", "properties/remove", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("body: %v", body)
if resp.StatusCode == http.StatusOK {
return
}
if resp.StatusCode == http.StatusConflict {
var apiError PropertiesRemoveAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//PropertiesSearchAPIError is an error-wrapper for the properties/search route
type PropertiesSearchAPIError struct {
dropbox.APIError
EndpointError *PropertiesSearchError `json:"error"`
}
func (dbx *apiImpl) PropertiesSearch(arg *PropertiesSearchArg) (res *PropertiesSearchResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_properties", "properties/search", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 PropertiesSearchAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//PropertiesUpdateAPIError is an error-wrapper for the properties/update route
type PropertiesUpdateAPIError struct {
dropbox.APIError
EndpointError *UpdatePropertiesError `json:"error"`
}
func (dbx *apiImpl) PropertiesUpdate(arg *UpdatePropertiesArg) (err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_properties", "properties/update", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("body: %v", body)
if resp.StatusCode == http.StatusOK {
return
}
if resp.StatusCode == http.StatusConflict {
var apiError PropertiesUpdateAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//TemplatesAddForTeamAPIError is an error-wrapper for the templates/add_for_team route
type TemplatesAddForTeamAPIError struct {
dropbox.APIError
EndpointError *ModifyTemplateError `json:"error"`
}
func (dbx *apiImpl) TemplatesAddForTeam(arg *AddTemplateArg) (res *AddTemplateResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_properties", "templates/add_for_team", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 TemplatesAddForTeamAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//TemplatesAddForUserAPIError is an error-wrapper for the templates/add_for_user route
type TemplatesAddForUserAPIError struct {
dropbox.APIError
EndpointError *ModifyTemplateError `json:"error"`
}
func (dbx *apiImpl) TemplatesAddForUser(arg *AddTemplateArg) (res *AddTemplateResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_properties", "templates/add_for_user", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 TemplatesAddForUserAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//TemplatesGetForTeamAPIError is an error-wrapper for the templates/get_for_team route
type TemplatesGetForTeamAPIError struct {
dropbox.APIError
EndpointError *TemplateError `json:"error"`
}
func (dbx *apiImpl) TemplatesGetForTeam(arg *GetTemplateArg) (res *GetTemplateResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_properties", "templates/get_for_team", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 TemplatesGetForTeamAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//TemplatesGetForUserAPIError is an error-wrapper for the templates/get_for_user route
type TemplatesGetForUserAPIError struct {
dropbox.APIError
EndpointError *TemplateError `json:"error"`
}
func (dbx *apiImpl) TemplatesGetForUser(arg *GetTemplateArg) (res *GetTemplateResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_properties", "templates/get_for_user", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 TemplatesGetForUserAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//TemplatesListForTeamAPIError is an error-wrapper for the templates/list_for_team route
type TemplatesListForTeamAPIError struct {
dropbox.APIError
EndpointError *TemplateError `json:"error"`
}
func (dbx *apiImpl) TemplatesListForTeam() (res *ListTemplateResult, err error) {
cli := dbx.Client
headers := map[string]string{}
req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "file_properties", "templates/list_for_team", headers, nil)
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 TemplatesListForTeamAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//TemplatesListForUserAPIError is an error-wrapper for the templates/list_for_user route
type TemplatesListForUserAPIError struct {
dropbox.APIError
EndpointError *TemplateError `json:"error"`
}
func (dbx *apiImpl) TemplatesListForUser() (res *ListTemplateResult, 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, "file_properties", "templates/list_for_user", headers, nil)
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 TemplatesListForUserAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//TemplatesUpdateForTeamAPIError is an error-wrapper for the templates/update_for_team route
type TemplatesUpdateForTeamAPIError struct {
dropbox.APIError
EndpointError *ModifyTemplateError `json:"error"`
}
func (dbx *apiImpl) TemplatesUpdateForTeam(arg *UpdateTemplateArg) (res *UpdateTemplateResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_properties", "templates/update_for_team", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 TemplatesUpdateForTeamAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//TemplatesUpdateForUserAPIError is an error-wrapper for the templates/update_for_user route
type TemplatesUpdateForUserAPIError struct {
dropbox.APIError
EndpointError *ModifyTemplateError `json:"error"`
}
func (dbx *apiImpl) TemplatesUpdateForUser(arg *UpdateTemplateArg) (res *UpdateTemplateResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_properties", "templates/update_for_user", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 TemplatesUpdateForUserAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
// New returns a Client implementation for this namespace
func New(c dropbox.Config) *apiImpl {
ctx := apiImpl(dropbox.NewContext(c))
return &ctx
}

View File

@ -0,0 +1,759 @@
// 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 file_properties : This namespace contains helpers for property and
// template metadata endpoints. These endpoints enable you to tag arbitrary
// key/value data to Dropbox files. The most basic unit in this namespace is
// the `PropertyField`. These fields encapsulate the actual key/value data.
// Fields are added to a Dropbox file using a `PropertyGroup`. Property groups
// contain a reference to a Dropbox file and a `PropertyGroupTemplate`. Property
// groups are uniquely identified by the combination of their associated Dropbox
// file and template. The `PropertyGroupTemplate` is a way of restricting the
// possible key names and value types of the data within a property group. The
// possible key names and value types are explicitly enumerated using
// `PropertyFieldTemplate` objects. You can think of a property group template
// as a class definition for a particular key/value metadata object, and the
// property groups themselves as the instantiations of these objects.
package file_properties
import (
"encoding/json"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
)
// AddPropertiesArg : has no documentation (yet)
type AddPropertiesArg struct {
// Path : A unique identifier for the file or folder.
Path string `json:"path"`
// PropertyGroups : The property groups which are to be added to a Dropbox
// file.
PropertyGroups []*PropertyGroup `json:"property_groups"`
}
// NewAddPropertiesArg returns a new AddPropertiesArg instance
func NewAddPropertiesArg(Path string, PropertyGroups []*PropertyGroup) *AddPropertiesArg {
s := new(AddPropertiesArg)
s.Path = Path
s.PropertyGroups = PropertyGroups
return s
}
// TemplateError : has no documentation (yet)
type TemplateError struct {
dropbox.Tagged
// TemplateNotFound : Template does not exist for the given identifier.
TemplateNotFound string `json:"template_not_found,omitempty"`
}
// Valid tag values for TemplateError
const (
TemplateErrorTemplateNotFound = "template_not_found"
TemplateErrorRestrictedContent = "restricted_content"
TemplateErrorOther = "other"
)
// UnmarshalJSON deserializes into a TemplateError instance
func (u *TemplateError) 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 "template_not_found":
err = json.Unmarshal(body, &u.TemplateNotFound)
if err != nil {
return err
}
}
return nil
}
// PropertiesError : has no documentation (yet)
type PropertiesError struct {
dropbox.Tagged
// Path : has no documentation (yet)
Path *LookupError `json:"path,omitempty"`
}
// Valid tag values for PropertiesError
const (
PropertiesErrorPath = "path"
PropertiesErrorUnsupportedFolder = "unsupported_folder"
)
// UnmarshalJSON deserializes into a PropertiesError instance
func (u *PropertiesError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Path : has no documentation (yet)
Path json.RawMessage `json:"path,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "path":
err = json.Unmarshal(w.Path, &u.Path)
if err != nil {
return err
}
}
return nil
}
// InvalidPropertyGroupError : has no documentation (yet)
type InvalidPropertyGroupError struct {
dropbox.Tagged
}
// Valid tag values for InvalidPropertyGroupError
const (
InvalidPropertyGroupErrorPropertyFieldTooLarge = "property_field_too_large"
InvalidPropertyGroupErrorDoesNotFitTemplate = "does_not_fit_template"
)
// AddPropertiesError : has no documentation (yet)
type AddPropertiesError struct {
dropbox.Tagged
}
// Valid tag values for AddPropertiesError
const (
AddPropertiesErrorPropertyGroupAlreadyExists = "property_group_already_exists"
)
// PropertyGroupTemplate : Defines how a property group may be structured.
type PropertyGroupTemplate struct {
// Name : Display name for the template. Template names can be up to 256
// bytes.
Name string `json:"name"`
// Description : Description for the template. Template descriptions can be
// up to 1024 bytes.
Description string `json:"description"`
// Fields : Definitions of the property fields associated with this
// template. There can be up to 32 properties in a single template.
Fields []*PropertyFieldTemplate `json:"fields"`
}
// NewPropertyGroupTemplate returns a new PropertyGroupTemplate instance
func NewPropertyGroupTemplate(Name string, Description string, Fields []*PropertyFieldTemplate) *PropertyGroupTemplate {
s := new(PropertyGroupTemplate)
s.Name = Name
s.Description = Description
s.Fields = Fields
return s
}
// AddTemplateArg : has no documentation (yet)
type AddTemplateArg struct {
PropertyGroupTemplate
}
// NewAddTemplateArg returns a new AddTemplateArg instance
func NewAddTemplateArg(Name string, Description string, Fields []*PropertyFieldTemplate) *AddTemplateArg {
s := new(AddTemplateArg)
s.Name = Name
s.Description = Description
s.Fields = Fields
return s
}
// AddTemplateResult : has no documentation (yet)
type AddTemplateResult struct {
// TemplateId : An identifier for template added by See
// `templatesAddForUser` or `templatesAddForTeam`.
TemplateId string `json:"template_id"`
}
// NewAddTemplateResult returns a new AddTemplateResult instance
func NewAddTemplateResult(TemplateId string) *AddTemplateResult {
s := new(AddTemplateResult)
s.TemplateId = TemplateId
return s
}
// GetTemplateArg : has no documentation (yet)
type GetTemplateArg struct {
// TemplateId : An identifier for template added by route See
// `templatesAddForUser` or `templatesAddForTeam`.
TemplateId string `json:"template_id"`
}
// NewGetTemplateArg returns a new GetTemplateArg instance
func NewGetTemplateArg(TemplateId string) *GetTemplateArg {
s := new(GetTemplateArg)
s.TemplateId = TemplateId
return s
}
// GetTemplateResult : has no documentation (yet)
type GetTemplateResult struct {
PropertyGroupTemplate
}
// NewGetTemplateResult returns a new GetTemplateResult instance
func NewGetTemplateResult(Name string, Description string, Fields []*PropertyFieldTemplate) *GetTemplateResult {
s := new(GetTemplateResult)
s.Name = Name
s.Description = Description
s.Fields = Fields
return s
}
// ListTemplateResult : has no documentation (yet)
type ListTemplateResult struct {
// TemplateIds : List of identifiers for templates added by See
// `templatesAddForUser` or `templatesAddForTeam`.
TemplateIds []string `json:"template_ids"`
}
// NewListTemplateResult returns a new ListTemplateResult instance
func NewListTemplateResult(TemplateIds []string) *ListTemplateResult {
s := new(ListTemplateResult)
s.TemplateIds = TemplateIds
return s
}
// LogicalOperator : Logical operator to join search queries together.
type LogicalOperator struct {
dropbox.Tagged
}
// Valid tag values for LogicalOperator
const (
LogicalOperatorOrOperator = "or_operator"
LogicalOperatorOther = "other"
)
// LookUpPropertiesError : has no documentation (yet)
type LookUpPropertiesError struct {
dropbox.Tagged
}
// Valid tag values for LookUpPropertiesError
const (
LookUpPropertiesErrorPropertyGroupNotFound = "property_group_not_found"
LookUpPropertiesErrorOther = "other"
)
// LookupError : has no documentation (yet)
type LookupError struct {
dropbox.Tagged
// MalformedPath : has no documentation (yet)
MalformedPath string `json:"malformed_path,omitempty"`
}
// Valid tag values for LookupError
const (
LookupErrorMalformedPath = "malformed_path"
LookupErrorNotFound = "not_found"
LookupErrorNotFile = "not_file"
LookupErrorNotFolder = "not_folder"
LookupErrorRestrictedContent = "restricted_content"
LookupErrorOther = "other"
)
// UnmarshalJSON deserializes into a LookupError instance
func (u *LookupError) 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 "malformed_path":
err = json.Unmarshal(body, &u.MalformedPath)
if err != nil {
return err
}
}
return nil
}
// ModifyTemplateError : has no documentation (yet)
type ModifyTemplateError struct {
dropbox.Tagged
}
// Valid tag values for ModifyTemplateError
const (
ModifyTemplateErrorConflictingPropertyNames = "conflicting_property_names"
ModifyTemplateErrorTooManyProperties = "too_many_properties"
ModifyTemplateErrorTooManyTemplates = "too_many_templates"
ModifyTemplateErrorTemplateAttributeTooLarge = "template_attribute_too_large"
)
// OverwritePropertyGroupArg : has no documentation (yet)
type OverwritePropertyGroupArg struct {
// Path : A unique identifier for the file or folder.
Path string `json:"path"`
// PropertyGroups : The property groups "snapshot" updates to force apply.
PropertyGroups []*PropertyGroup `json:"property_groups"`
}
// NewOverwritePropertyGroupArg returns a new OverwritePropertyGroupArg instance
func NewOverwritePropertyGroupArg(Path string, PropertyGroups []*PropertyGroup) *OverwritePropertyGroupArg {
s := new(OverwritePropertyGroupArg)
s.Path = Path
s.PropertyGroups = PropertyGroups
return s
}
// PropertiesSearchArg : has no documentation (yet)
type PropertiesSearchArg struct {
// Queries : Queries to search.
Queries []*PropertiesSearchQuery `json:"queries"`
// TemplateFilter : Filter results to contain only properties associated
// with these template IDs.
TemplateFilter *TemplateFilter `json:"template_filter"`
}
// NewPropertiesSearchArg returns a new PropertiesSearchArg instance
func NewPropertiesSearchArg(Queries []*PropertiesSearchQuery) *PropertiesSearchArg {
s := new(PropertiesSearchArg)
s.Queries = Queries
s.TemplateFilter = &TemplateFilter{Tagged: dropbox.Tagged{"filter_none"}}
return s
}
// PropertiesSearchError : has no documentation (yet)
type PropertiesSearchError struct {
dropbox.Tagged
// PropertyGroupLookup : has no documentation (yet)
PropertyGroupLookup *LookUpPropertiesError `json:"property_group_lookup,omitempty"`
}
// Valid tag values for PropertiesSearchError
const (
PropertiesSearchErrorPropertyGroupLookup = "property_group_lookup"
PropertiesSearchErrorOther = "other"
)
// UnmarshalJSON deserializes into a PropertiesSearchError instance
func (u *PropertiesSearchError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// PropertyGroupLookup : has no documentation (yet)
PropertyGroupLookup json.RawMessage `json:"property_group_lookup,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 "property_group_lookup":
err = json.Unmarshal(w.PropertyGroupLookup, &u.PropertyGroupLookup)
if err != nil {
return err
}
}
return nil
}
// PropertiesSearchMatch : has no documentation (yet)
type PropertiesSearchMatch struct {
// Id : The ID for the matched file or folder.
Id string `json:"id"`
// Path : The path for the matched file or folder.
Path string `json:"path"`
// PropertyGroups : List of custom property groups associated with the file.
PropertyGroups []*PropertyGroup `json:"property_groups"`
}
// NewPropertiesSearchMatch returns a new PropertiesSearchMatch instance
func NewPropertiesSearchMatch(Id string, Path string, PropertyGroups []*PropertyGroup) *PropertiesSearchMatch {
s := new(PropertiesSearchMatch)
s.Id = Id
s.Path = Path
s.PropertyGroups = PropertyGroups
return s
}
// PropertiesSearchMode : has no documentation (yet)
type PropertiesSearchMode struct {
dropbox.Tagged
// FieldName : Search for a value associated with this field name.
FieldName string `json:"field_name,omitempty"`
}
// Valid tag values for PropertiesSearchMode
const (
PropertiesSearchModeFieldName = "field_name"
PropertiesSearchModeOther = "other"
)
// UnmarshalJSON deserializes into a PropertiesSearchMode instance
func (u *PropertiesSearchMode) 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 "field_name":
err = json.Unmarshal(body, &u.FieldName)
if err != nil {
return err
}
}
return nil
}
// PropertiesSearchQuery : has no documentation (yet)
type PropertiesSearchQuery struct {
// Query : The property field value for which to search across templates.
Query string `json:"query"`
// Mode : The mode with which to perform the search.
Mode *PropertiesSearchMode `json:"mode"`
// LogicalOperator : The logical operator with which to append the query.
LogicalOperator *LogicalOperator `json:"logical_operator"`
}
// NewPropertiesSearchQuery returns a new PropertiesSearchQuery instance
func NewPropertiesSearchQuery(Query string, Mode *PropertiesSearchMode) *PropertiesSearchQuery {
s := new(PropertiesSearchQuery)
s.Query = Query
s.Mode = Mode
s.LogicalOperator = &LogicalOperator{Tagged: dropbox.Tagged{"or_operator"}}
return s
}
// PropertiesSearchResult : has no documentation (yet)
type PropertiesSearchResult struct {
// Matches : A list (possibly empty) of matches for the query.
Matches []*PropertiesSearchMatch `json:"matches"`
}
// NewPropertiesSearchResult returns a new PropertiesSearchResult instance
func NewPropertiesSearchResult(Matches []*PropertiesSearchMatch) *PropertiesSearchResult {
s := new(PropertiesSearchResult)
s.Matches = Matches
return s
}
// PropertyField : Raw key/value data to be associated with a Dropbox file.
// Property fields are added to Dropbox files as a `PropertyGroup`.
type PropertyField struct {
// Name : Key of the property field associated with a file and template.
// Keys can be up to 256 bytes.
Name string `json:"name"`
// Value : Value of the property field associated with a file and template.
// Values can be up to 1024 bytes.
Value string `json:"value"`
}
// NewPropertyField returns a new PropertyField instance
func NewPropertyField(Name string, Value string) *PropertyField {
s := new(PropertyField)
s.Name = Name
s.Value = Value
return s
}
// PropertyFieldTemplate : Defines how a single property field may be
// structured. Used exclusively by `PropertyGroupTemplate`.
type PropertyFieldTemplate struct {
// Name : Key of the property field being described. Property field keys can
// be up to 256 bytes.
Name string `json:"name"`
// Description : Description of the property field. Property field
// descriptions can be up to 1024 bytes.
Description string `json:"description"`
// Type : Data type of the value of this property field. This type will be
// enforced upon property creation and modifications.
Type *PropertyType `json:"type"`
}
// NewPropertyFieldTemplate returns a new PropertyFieldTemplate instance
func NewPropertyFieldTemplate(Name string, Description string, Type *PropertyType) *PropertyFieldTemplate {
s := new(PropertyFieldTemplate)
s.Name = Name
s.Description = Description
s.Type = Type
return s
}
// PropertyGroup : A subset of the property fields described by the
// corresponding `PropertyGroupTemplate`. Properties are always added to a
// Dropbox file as a `PropertyGroup`. The possible key names and value types in
// this group are defined by the corresponding `PropertyGroupTemplate`.
type PropertyGroup struct {
// TemplateId : A unique identifier for the associated template.
TemplateId string `json:"template_id"`
// Fields : The actual properties associated with the template. There can be
// up to 32 property types per template.
Fields []*PropertyField `json:"fields"`
}
// NewPropertyGroup returns a new PropertyGroup instance
func NewPropertyGroup(TemplateId string, Fields []*PropertyField) *PropertyGroup {
s := new(PropertyGroup)
s.TemplateId = TemplateId
s.Fields = Fields
return s
}
// PropertyGroupUpdate : has no documentation (yet)
type PropertyGroupUpdate struct {
// TemplateId : A unique identifier for a property template.
TemplateId string `json:"template_id"`
// AddOrUpdateFields : Property fields to update. If the property field
// already exists, it is updated. If the property field doesn't exist, the
// property group is added.
AddOrUpdateFields []*PropertyField `json:"add_or_update_fields,omitempty"`
// RemoveFields : Property fields to remove (by name), provided they exist.
RemoveFields []string `json:"remove_fields,omitempty"`
}
// NewPropertyGroupUpdate returns a new PropertyGroupUpdate instance
func NewPropertyGroupUpdate(TemplateId string) *PropertyGroupUpdate {
s := new(PropertyGroupUpdate)
s.TemplateId = TemplateId
return s
}
// PropertyType : Data type of the given property field added.
type PropertyType struct {
dropbox.Tagged
}
// Valid tag values for PropertyType
const (
PropertyTypeString = "string"
PropertyTypeOther = "other"
)
// RemovePropertiesArg : has no documentation (yet)
type RemovePropertiesArg struct {
// Path : A unique identifier for the file or folder.
Path string `json:"path"`
// PropertyTemplateIds : A list of identifiers for a template created by
// `templatesAddForUser` or `templatesAddForTeam`.
PropertyTemplateIds []string `json:"property_template_ids"`
}
// NewRemovePropertiesArg returns a new RemovePropertiesArg instance
func NewRemovePropertiesArg(Path string, PropertyTemplateIds []string) *RemovePropertiesArg {
s := new(RemovePropertiesArg)
s.Path = Path
s.PropertyTemplateIds = PropertyTemplateIds
return s
}
// RemovePropertiesError : has no documentation (yet)
type RemovePropertiesError struct {
dropbox.Tagged
// PropertyGroupLookup : has no documentation (yet)
PropertyGroupLookup *LookUpPropertiesError `json:"property_group_lookup,omitempty"`
}
// Valid tag values for RemovePropertiesError
const (
RemovePropertiesErrorPropertyGroupLookup = "property_group_lookup"
)
// UnmarshalJSON deserializes into a RemovePropertiesError instance
func (u *RemovePropertiesError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// PropertyGroupLookup : has no documentation (yet)
PropertyGroupLookup json.RawMessage `json:"property_group_lookup,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 "property_group_lookup":
err = json.Unmarshal(w.PropertyGroupLookup, &u.PropertyGroupLookup)
if err != nil {
return err
}
}
return nil
}
// TemplateFilter : has no documentation (yet)
type TemplateFilter struct {
dropbox.Tagged
// FilterSome : Only templates with an ID in the supplied list will be
// returned (a subset of templates will be returned).
FilterSome []string `json:"filter_some,omitempty"`
}
// Valid tag values for TemplateFilter
const (
TemplateFilterFilterNone = "filter_none"
TemplateFilterFilterSome = "filter_some"
TemplateFilterOther = "other"
)
// UnmarshalJSON deserializes into a TemplateFilter instance
func (u *TemplateFilter) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// FilterSome : Only templates with an ID in the supplied list will be
// returned (a subset of templates will be returned).
FilterSome json.RawMessage `json:"filter_some,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 "filter_some":
err = json.Unmarshal(body, &u.FilterSome)
if err != nil {
return err
}
}
return nil
}
// TemplateOwnerType : has no documentation (yet)
type TemplateOwnerType struct {
dropbox.Tagged
}
// Valid tag values for TemplateOwnerType
const (
TemplateOwnerTypeUser = "user"
TemplateOwnerTypeTeam = "team"
TemplateOwnerTypeOther = "other"
)
// UpdatePropertiesArg : has no documentation (yet)
type UpdatePropertiesArg struct {
// Path : A unique identifier for the file or folder.
Path string `json:"path"`
// UpdatePropertyGroups : The property groups "delta" updates to apply.
UpdatePropertyGroups []*PropertyGroupUpdate `json:"update_property_groups"`
}
// NewUpdatePropertiesArg returns a new UpdatePropertiesArg instance
func NewUpdatePropertiesArg(Path string, UpdatePropertyGroups []*PropertyGroupUpdate) *UpdatePropertiesArg {
s := new(UpdatePropertiesArg)
s.Path = Path
s.UpdatePropertyGroups = UpdatePropertyGroups
return s
}
// UpdatePropertiesError : has no documentation (yet)
type UpdatePropertiesError struct {
dropbox.Tagged
// PropertyGroupLookup : has no documentation (yet)
PropertyGroupLookup *LookUpPropertiesError `json:"property_group_lookup,omitempty"`
}
// Valid tag values for UpdatePropertiesError
const (
UpdatePropertiesErrorPropertyGroupLookup = "property_group_lookup"
)
// UnmarshalJSON deserializes into a UpdatePropertiesError instance
func (u *UpdatePropertiesError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// PropertyGroupLookup : has no documentation (yet)
PropertyGroupLookup json.RawMessage `json:"property_group_lookup,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 "property_group_lookup":
err = json.Unmarshal(w.PropertyGroupLookup, &u.PropertyGroupLookup)
if err != nil {
return err
}
}
return nil
}
// UpdateTemplateArg : has no documentation (yet)
type UpdateTemplateArg struct {
// TemplateId : An identifier for template added by See
// `templatesAddForUser` or `templatesAddForTeam`.
TemplateId string `json:"template_id"`
// Name : A display name for the template. template names can be up to 256
// bytes.
Name string `json:"name,omitempty"`
// Description : Description for the new template. Template descriptions can
// be up to 1024 bytes.
Description string `json:"description,omitempty"`
// AddFields : Property field templates to be added to the group template.
// There can be up to 32 properties in a single template.
AddFields []*PropertyFieldTemplate `json:"add_fields,omitempty"`
}
// NewUpdateTemplateArg returns a new UpdateTemplateArg instance
func NewUpdateTemplateArg(TemplateId string) *UpdateTemplateArg {
s := new(UpdateTemplateArg)
s.TemplateId = TemplateId
return s
}
// UpdateTemplateResult : has no documentation (yet)
type UpdateTemplateResult struct {
// TemplateId : An identifier for template added by route See
// `templatesAddForUser` or `templatesAddForTeam`.
TemplateId string `json:"template_id"`
}
// NewUpdateTemplateResult returns a new UpdateTemplateResult instance
func NewUpdateTemplateResult(TemplateId string) *UpdateTemplateResult {
s := new(UpdateTemplateResult)
s.TemplateId = TemplateId
return s
}

View File

@ -0,0 +1,332 @@
// 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 file_requests
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 {
// Create : Creates a file request for this user.
Create(arg *CreateFileRequestArgs) (res *FileRequest, err error)
// Get : Returns the specified file request.
Get(arg *GetFileRequestArgs) (res *FileRequest, err error)
// List : Returns a list of file requests owned by this user. For apps with
// the app folder permission, this will only return file requests with
// destinations in the app folder.
List() (res *ListFileRequestsResult, err error)
// Update : Update a file request.
Update(arg *UpdateFileRequestArgs) (res *FileRequest, err error)
}
type apiImpl dropbox.Context
//CreateAPIError is an error-wrapper for the create route
type CreateAPIError struct {
dropbox.APIError
EndpointError *CreateFileRequestError `json:"error"`
}
func (dbx *apiImpl) Create(arg *CreateFileRequestArgs) (res *FileRequest, err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_requests", "create", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 CreateAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//GetAPIError is an error-wrapper for the get route
type GetAPIError struct {
dropbox.APIError
EndpointError *GetFileRequestError `json:"error"`
}
func (dbx *apiImpl) Get(arg *GetFileRequestArgs) (res *FileRequest, err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_requests", "get", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 GetAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//ListAPIError is an error-wrapper for the list route
type ListAPIError struct {
dropbox.APIError
EndpointError *ListFileRequestsError `json:"error"`
}
func (dbx *apiImpl) List() (res *ListFileRequestsResult, 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, "file_requests", "list", headers, nil)
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 ListAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//UpdateAPIError is an error-wrapper for the update route
type UpdateAPIError struct {
dropbox.APIError
EndpointError *UpdateFileRequestError `json:"error"`
}
func (dbx *apiImpl) Update(arg *UpdateFileRequestArgs) (res *FileRequest, err error) {
cli := dbx.Client
dbx.Config.TryLog("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, "file_requests", "update", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 UpdateAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
// New returns a Client implementation for this namespace
func New(c dropbox.Config) *apiImpl {
ctx := apiImpl(dropbox.NewContext(c))
return &ctx
}

View File

@ -0,0 +1,277 @@
// 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 file_requests : This namespace contains endpoints and data types for
// file request operations. Warning: This namespace is in beta and is subject to
// backwards-incompatible changes.
package file_requests
import (
"encoding/json"
"time"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
)
// CreateFileRequestArgs : Arguments for `create`.
type CreateFileRequestArgs struct {
// Title : The title of the file request. Must not be empty.
Title string `json:"title"`
// Destination : The path of the folder in the Dropbox where uploaded files
// will be sent. For apps with the app folder permission, this will be
// 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.
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
// opened later.
Open bool `json:"open"`
}
// NewCreateFileRequestArgs returns a new CreateFileRequestArgs instance
func NewCreateFileRequestArgs(Title string, Destination string) *CreateFileRequestArgs {
s := new(CreateFileRequestArgs)
s.Title = Title
s.Destination = Destination
s.Open = true
return s
}
// GeneralFileRequestsError : There is an error accessing the file requests
// functionality.
type GeneralFileRequestsError struct {
dropbox.Tagged
}
// Valid tag values for GeneralFileRequestsError
const (
GeneralFileRequestsErrorDisabledForTeam = "disabled_for_team"
GeneralFileRequestsErrorOther = "other"
)
// FileRequestError : There is an error with the file request.
type FileRequestError struct {
dropbox.Tagged
}
// Valid tag values for FileRequestError
const (
FileRequestErrorNotFound = "not_found"
FileRequestErrorNotAFolder = "not_a_folder"
FileRequestErrorAppLacksAccess = "app_lacks_access"
FileRequestErrorNoPermission = "no_permission"
FileRequestErrorEmailUnverified = "email_unverified"
FileRequestErrorValidationError = "validation_error"
)
// CreateFileRequestError : There was an error creating the file request.
type CreateFileRequestError struct {
dropbox.Tagged
}
// Valid tag values for CreateFileRequestError
const (
CreateFileRequestErrorInvalidLocation = "invalid_location"
CreateFileRequestErrorRateLimit = "rate_limit"
)
// FileRequest : A `file request` <https://www.dropbox.com/help/9090> for
// receiving files into the user's Dropbox account.
type FileRequest struct {
// Id : The ID of the file request.
Id string `json:"id"`
// Url : The URL of the file request.
Url string `json:"url"`
// Title : The title of the file request.
Title string `json:"title"`
// Destination : The path of the folder in the Dropbox where uploaded files
// will be sent. This can be nil if the destination was removed. For apps
// with the app folder permission, this will be relative to the app folder.
Destination string `json:"destination,omitempty"`
// Created : When this file request was created.
Created time.Time `json:"created"`
// Deadline : The deadline for this file request. Only set if the request
// has a deadline.
Deadline *FileRequestDeadline `json:"deadline,omitempty"`
// IsOpen : Whether or not the file request is open. If the file request is
// closed, it will not accept any more file submissions.
IsOpen bool `json:"is_open"`
// FileCount : The number of files this file request has received.
FileCount int64 `json:"file_count"`
}
// NewFileRequest returns a new FileRequest instance
func NewFileRequest(Id string, Url string, Title string, Created time.Time, IsOpen bool, FileCount int64) *FileRequest {
s := new(FileRequest)
s.Id = Id
s.Url = Url
s.Title = Title
s.Created = Created
s.IsOpen = IsOpen
s.FileCount = FileCount
return s
}
// FileRequestDeadline : has no documentation (yet)
type FileRequestDeadline struct {
// Deadline : The deadline for this file request.
Deadline time.Time `json:"deadline"`
// AllowLateUploads : If set, allow uploads after the deadline has passed.
// These uploads will be marked overdue.
AllowLateUploads *GracePeriod `json:"allow_late_uploads,omitempty"`
}
// NewFileRequestDeadline returns a new FileRequestDeadline instance
func NewFileRequestDeadline(Deadline time.Time) *FileRequestDeadline {
s := new(FileRequestDeadline)
s.Deadline = Deadline
return s
}
// GetFileRequestArgs : Arguments for `get`.
type GetFileRequestArgs struct {
// Id : The ID of the file request to retrieve.
Id string `json:"id"`
}
// NewGetFileRequestArgs returns a new GetFileRequestArgs instance
func NewGetFileRequestArgs(Id string) *GetFileRequestArgs {
s := new(GetFileRequestArgs)
s.Id = Id
return s
}
// GetFileRequestError : There was an error retrieving the specified file
// request.
type GetFileRequestError struct {
dropbox.Tagged
}
// Valid tag values for GetFileRequestError
const ()
// GracePeriod : has no documentation (yet)
type GracePeriod struct {
dropbox.Tagged
}
// Valid tag values for GracePeriod
const (
GracePeriodOneDay = "one_day"
GracePeriodTwoDays = "two_days"
GracePeriodSevenDays = "seven_days"
GracePeriodThirtyDays = "thirty_days"
GracePeriodAlways = "always"
GracePeriodOther = "other"
)
// ListFileRequestsError : There was an error retrieving the file requests.
type ListFileRequestsError struct {
dropbox.Tagged
}
// Valid tag values for ListFileRequestsError
const ()
// ListFileRequestsResult : Result for `list`.
type ListFileRequestsResult struct {
// FileRequests : The file requests owned by this user. Apps with the app
// folder permission will only see file requests in their app folder.
FileRequests []*FileRequest `json:"file_requests"`
}
// NewListFileRequestsResult returns a new ListFileRequestsResult instance
func NewListFileRequestsResult(FileRequests []*FileRequest) *ListFileRequestsResult {
s := new(ListFileRequestsResult)
s.FileRequests = FileRequests
return s
}
// UpdateFileRequestArgs : Arguments for `update`.
type UpdateFileRequestArgs struct {
// Id : The ID of the file request to update.
Id string `json:"id"`
// Title : The new title of the file request. Must not be empty.
Title string `json:"title,omitempty"`
// Destination : The new path of the folder in the Dropbox where uploaded
// 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 *UpdateFileRequestDeadline `json:"deadline"`
// Open : Whether to set this file request as open or closed.
Open bool `json:"open,omitempty"`
}
// NewUpdateFileRequestArgs returns a new UpdateFileRequestArgs instance
func NewUpdateFileRequestArgs(Id string) *UpdateFileRequestArgs {
s := new(UpdateFileRequestArgs)
s.Id = Id
s.Deadline = &UpdateFileRequestDeadline{Tagged: dropbox.Tagged{"no_update"}}
return s
}
// UpdateFileRequestDeadline : has no documentation (yet)
type UpdateFileRequestDeadline struct {
dropbox.Tagged
// Update : If nil, the file request's deadline is cleared.
Update *FileRequestDeadline `json:"update,omitempty"`
}
// Valid tag values for UpdateFileRequestDeadline
const (
UpdateFileRequestDeadlineNoUpdate = "no_update"
UpdateFileRequestDeadlineUpdate = "update"
UpdateFileRequestDeadlineOther = "other"
)
// UnmarshalJSON deserializes into a UpdateFileRequestDeadline instance
func (u *UpdateFileRequestDeadline) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Update : If nil, the file request's deadline is cleared.
Update json.RawMessage `json:"update,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 "update":
err = json.Unmarshal(body, &u.Update)
if err != nil {
return err
}
}
return nil
}
// UpdateFileRequestError : There is an error updating the file request.
type UpdateFileRequestError struct {
dropbox.Tagged
}
// Valid tag values for UpdateFileRequestError
const ()

View File

@ -30,7 +30,7 @@ import (
"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/properties"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/file_properties"
)
// Client interface describes all routes in this namespace
@ -118,6 +118,12 @@ type Client interface {
// tif, gif and bmp. Photos that are larger than 20MB in size won't be
// converted to a thumbnail.
GetThumbnail(arg *ThumbnailArg) (res *FileMetadata, content io.ReadCloser, err error)
// GetThumbnailBatch : Get thumbnails for a list of images. We allow up to
// 25 thumbnails in a single batch. 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 converted to a
// thumbnail.
GetThumbnailBatch(arg *GetThumbnailBatchArg) (res *GetThumbnailBatchResult, err error)
// ListFolder : Starts returning the contents of a folder. If the result's
// `ListFolderResult.has_more` field is true, call `listFolderContinue` with
// the returned `ListFolderResult.cursor` to retrieve more entries. If
@ -180,27 +186,24 @@ type Client interface {
// (see https://www.dropbox.com/en/help/40). Note: This endpoint is only
// available for Dropbox Business apps.
PermanentlyDelete(arg *DeleteArg) (err error)
// PropertiesAdd : Add custom properties to a file using a filled property
// template. See properties/template/add to create new property templates.
PropertiesAdd(arg *PropertyGroupWithPath) (err error)
// PropertiesOverwrite : Overwrite custom properties from a specified
// template associated with a file.
PropertiesOverwrite(arg *PropertyGroupWithPath) (err error)
// PropertiesRemove : Remove all custom properties from a specified template
// associated with a file. To remove specific property key value pairs, see
// `propertiesUpdate`. To update a property template, see
// properties/template/update. Property templates can't be removed once
// created.
PropertiesRemove(arg *RemovePropertiesArg) (err error)
// PropertiesTemplateGet : Get the schema for a specified template.
PropertiesTemplateGet(arg *properties.GetPropertyTemplateArg) (res *properties.GetPropertyTemplateResult, err error)
// PropertiesTemplateList : Get the property template identifiers for a
// user. To get the schema of each template use `propertiesTemplateGet`.
PropertiesTemplateList() (res *properties.ListPropertyTemplateIds, err error)
// PropertiesUpdate : Add, update or remove custom properties from a
// specified template associated with a file. Fields that already exist and
// not described in the request will not be modified.
PropertiesUpdate(arg *UpdatePropertyGroupArg) (err error)
// PropertiesAdd : has no documentation (yet)
// Deprecated:
PropertiesAdd(arg *file_properties.AddPropertiesArg) (err error)
// PropertiesOverwrite : has no documentation (yet)
// Deprecated:
PropertiesOverwrite(arg *file_properties.OverwritePropertyGroupArg) (err error)
// PropertiesRemove : has no documentation (yet)
// Deprecated:
PropertiesRemove(arg *file_properties.RemovePropertiesArg) (err error)
// PropertiesTemplateGet : has no documentation (yet)
// Deprecated:
PropertiesTemplateGet(arg *file_properties.GetTemplateArg) (res *file_properties.GetTemplateResult, err error)
// PropertiesTemplateList : has no documentation (yet)
// Deprecated:
PropertiesTemplateList() (res *file_properties.ListTemplateResult, err error)
// PropertiesUpdate : has no documentation (yet)
// Deprecated:
PropertiesUpdate(arg *file_properties.UpdatePropertiesArg) (err error)
// Restore : Restore a file to a specific revision.
Restore(arg *RestoreArg) (res *FileMetadata, err error)
// SaveUrl : Save a specified URL into a file in user's Dropbox. If the
@ -1675,6 +1678,78 @@ func (dbx *apiImpl) GetThumbnail(arg *ThumbnailArg) (res *FileMetadata, content
return
}
//GetThumbnailBatchAPIError is an error-wrapper for the get_thumbnail_batch route
type GetThumbnailBatchAPIError struct {
dropbox.APIError
EndpointError *GetThumbnailBatchError `json:"error"`
}
func (dbx *apiImpl) GetThumbnailBatch(arg *GetThumbnailBatchArg) (res *GetThumbnailBatchResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("arg: %v", arg)
b, err := json.Marshal(arg)
if err != nil {
return
}
headers := map[string]string{
"Dropbox-API-Arg": string(b),
}
if dbx.Config.AsMemberID != "" {
headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID
}
req, err := (*dropbox.Context)(dbx).NewRequest("content", "rpc", true, "files", "get_thumbnail_batch", headers, nil)
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 GetThumbnailBatchAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//ListFolderAPIError is an error-wrapper for the list_folder route
type ListFolderAPIError struct {
dropbox.APIError
@ -2404,10 +2479,12 @@ func (dbx *apiImpl) PermanentlyDelete(arg *DeleteArg) (err error) {
//PropertiesAddAPIError is an error-wrapper for the properties/add route
type PropertiesAddAPIError struct {
dropbox.APIError
EndpointError *AddPropertiesError `json:"error"`
EndpointError *file_properties.AddPropertiesError `json:"error"`
}
func (dbx *apiImpl) PropertiesAdd(arg *PropertyGroupWithPath) (err error) {
func (dbx *apiImpl) PropertiesAdd(arg *file_properties.AddPropertiesArg) (err error) {
log.Printf("WARNING: API `PropertiesAdd` is deprecated")
cli := dbx.Client
dbx.Config.TryLog("arg: %v", arg)
@ -2471,10 +2548,12 @@ func (dbx *apiImpl) PropertiesAdd(arg *PropertyGroupWithPath) (err error) {
//PropertiesOverwriteAPIError is an error-wrapper for the properties/overwrite route
type PropertiesOverwriteAPIError struct {
dropbox.APIError
EndpointError *InvalidPropertyGroupError `json:"error"`
EndpointError *file_properties.InvalidPropertyGroupError `json:"error"`
}
func (dbx *apiImpl) PropertiesOverwrite(arg *PropertyGroupWithPath) (err error) {
func (dbx *apiImpl) PropertiesOverwrite(arg *file_properties.OverwritePropertyGroupArg) (err error) {
log.Printf("WARNING: API `PropertiesOverwrite` is deprecated")
cli := dbx.Client
dbx.Config.TryLog("arg: %v", arg)
@ -2538,10 +2617,12 @@ func (dbx *apiImpl) PropertiesOverwrite(arg *PropertyGroupWithPath) (err error)
//PropertiesRemoveAPIError is an error-wrapper for the properties/remove route
type PropertiesRemoveAPIError struct {
dropbox.APIError
EndpointError *RemovePropertiesError `json:"error"`
EndpointError *file_properties.RemovePropertiesError `json:"error"`
}
func (dbx *apiImpl) PropertiesRemove(arg *RemovePropertiesArg) (err error) {
func (dbx *apiImpl) PropertiesRemove(arg *file_properties.RemovePropertiesArg) (err error) {
log.Printf("WARNING: API `PropertiesRemove` is deprecated")
cli := dbx.Client
dbx.Config.TryLog("arg: %v", arg)
@ -2605,10 +2686,12 @@ func (dbx *apiImpl) PropertiesRemove(arg *RemovePropertiesArg) (err error) {
//PropertiesTemplateGetAPIError is an error-wrapper for the properties/template/get route
type PropertiesTemplateGetAPIError struct {
dropbox.APIError
EndpointError *properties.PropertyTemplateError `json:"error"`
EndpointError *file_properties.TemplateError `json:"error"`
}
func (dbx *apiImpl) PropertiesTemplateGet(arg *properties.GetPropertyTemplateArg) (res *properties.GetPropertyTemplateResult, err error) {
func (dbx *apiImpl) PropertiesTemplateGet(arg *file_properties.GetTemplateArg) (res *file_properties.GetTemplateResult, err error) {
log.Printf("WARNING: API `PropertiesTemplateGet` is deprecated")
cli := dbx.Client
dbx.Config.TryLog("arg: %v", arg)
@ -2677,10 +2760,12 @@ func (dbx *apiImpl) PropertiesTemplateGet(arg *properties.GetPropertyTemplateArg
//PropertiesTemplateListAPIError is an error-wrapper for the properties/template/list route
type PropertiesTemplateListAPIError struct {
dropbox.APIError
EndpointError *properties.PropertyTemplateError `json:"error"`
EndpointError *file_properties.TemplateError `json:"error"`
}
func (dbx *apiImpl) PropertiesTemplateList() (res *properties.ListPropertyTemplateIds, err error) {
func (dbx *apiImpl) PropertiesTemplateList() (res *file_properties.ListTemplateResult, err error) {
log.Printf("WARNING: API `PropertiesTemplateList` is deprecated")
cli := dbx.Client
headers := map[string]string{}
@ -2741,10 +2826,12 @@ func (dbx *apiImpl) PropertiesTemplateList() (res *properties.ListPropertyTempla
//PropertiesUpdateAPIError is an error-wrapper for the properties/update route
type PropertiesUpdateAPIError struct {
dropbox.APIError
EndpointError *UpdatePropertiesError `json:"error"`
EndpointError *file_properties.UpdatePropertiesError `json:"error"`
}
func (dbx *apiImpl) PropertiesUpdate(arg *UpdatePropertyGroupArg) (err error) {
func (dbx *apiImpl) PropertiesUpdate(arg *file_properties.UpdatePropertiesArg) (err error) {
log.Printf("WARNING: API `PropertiesUpdate` is deprecated")
cli := dbx.Client
dbx.Config.TryLog("arg: %v", arg)

View File

@ -23,9 +23,9 @@ package files
import "encoding/json"
type listFolderResult struct {
Entries []metadataUnion `json:"entries"`
Cursor string `json:"cursor"`
HasMore bool `json:"has_more"`
Entries []json.RawMessage `json:"entries"`
Cursor string `json:"cursor"`
HasMore bool `json:"has_more"`
}
// UnmarshalJSON deserializes into a ListFolderResult instance
@ -38,21 +38,18 @@ func (r *ListFolderResult) UnmarshalJSON(b []byte) error {
r.HasMore = l.HasMore
r.Entries = make([]IsMetadata, len(l.Entries))
for i, e := range l.Entries {
switch e.Tag {
case "file":
r.Entries[i] = e.File
case "folder":
r.Entries[i] = e.Folder
case "deleted":
r.Entries[i] = e.Deleted
metadata, err := IsMetadataFromJSON(e)
if err != nil {
return err
}
r.Entries[i] = metadata
}
return nil
}
type searchMatch struct {
MatchType *SearchMatchType `json:"match_type"`
Metadata metadataUnion `json:"metadata"`
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a SearchMatch instance
@ -62,38 +59,51 @@ func (s *SearchMatch) UnmarshalJSON(b []byte) error {
return err
}
s.MatchType = m.MatchType
e := m.Metadata
switch e.Tag {
case "file":
s.Metadata = e.File
case "folder":
s.Metadata = e.Folder
case "deleted":
s.Metadata = e.Deleted
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}
type deleteResult struct {
FileOpsResult
Metadata metadataUnion `json:"metadata"`
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a SearchMatch instance
// UnmarshalJSON deserializes into a DeleteResult instance
func (s *DeleteResult) UnmarshalJSON(b []byte) error {
var m deleteResult
if err := json.Unmarshal(b, &m); err != nil {
return err
}
s.FileOpsResult = m.FileOpsResult
e := m.Metadata
switch e.Tag {
case "file":
s.Metadata = e.File
case "folder":
s.Metadata = e.Folder
case "deleted":
s.Metadata = e.Deleted
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}
type relocationResult struct {
FileOpsResult
// Metadata : Metadata of the relocated object.
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a RelocationResult instance
func (s *RelocationResult) UnmarshalJSON(b []byte) error {
var m relocationResult
if err := json.Unmarshal(b, &m); err != nil {
return err
}
s.FileOpsResult = m.FileOpsResult
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}

View File

@ -27,64 +27,7 @@ import (
"time"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/properties"
)
// PropertiesError : has no documentation (yet)
type PropertiesError struct {
dropbox.Tagged
// Path : has no documentation (yet)
Path *LookupError `json:"path,omitempty"`
}
// Valid tag values for PropertiesError
const (
PropertiesErrorPath = "path"
)
// UnmarshalJSON deserializes into a PropertiesError instance
func (u *PropertiesError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Path : has no documentation (yet)
Path json.RawMessage `json:"path,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "path":
err = json.Unmarshal(w.Path, &u.Path)
if err != nil {
return err
}
}
return nil
}
// InvalidPropertyGroupError : has no documentation (yet)
type InvalidPropertyGroupError struct {
dropbox.Tagged
}
// Valid tag values for InvalidPropertyGroupError
const (
InvalidPropertyGroupErrorPropertyFieldTooLarge = "property_field_too_large"
InvalidPropertyGroupErrorDoesNotFitTemplate = "does_not_fit_template"
)
// AddPropertiesError : has no documentation (yet)
type AddPropertiesError struct {
dropbox.Tagged
}
// Valid tag values for AddPropertiesError
const (
AddPropertiesErrorPropertyGroupAlreadyExists = "property_group_already_exists"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/file_properties"
)
// GetMetadataArg : has no documentation (yet)
@ -171,7 +114,7 @@ func (u *GetMetadataError) UnmarshalJSON(body []byte) error {
type AlphaGetMetadataError struct {
dropbox.Tagged
// PropertiesError : has no documentation (yet)
PropertiesError *LookUpPropertiesError `json:"properties_error,omitempty"`
PropertiesError *file_properties.LookUpPropertiesError `json:"properties_error,omitempty"`
}
// Valid tag values for AlphaGetMetadataError
@ -239,7 +182,7 @@ func NewCommitInfo(Path string) *CommitInfo {
type CommitInfoWithProperties struct {
CommitInfo
// PropertyGroups : List of custom properties to add to file.
PropertyGroups []*properties.PropertyGroup `json:"property_groups,omitempty"`
PropertyGroups []*file_properties.PropertyGroup `json:"property_groups,omitempty"`
}
// NewCommitInfoWithProperties returns a new CommitInfoWithProperties instance
@ -606,7 +549,7 @@ type Metadata struct {
// only the casing of paths won't be returned by `listFolderContinue`. This
// field will be null if the file or folder is not mounted.
PathDisplay string `json:"path_display,omitempty"`
// ParentSharedFolderId : Deprecated. Please use
// ParentSharedFolderId : Please use
// `FileSharingInfo.parent_shared_folder_id` or
// `FolderSharingInfo.parent_shared_folder_id` instead.
ParentSharedFolderId string `json:"parent_shared_folder_id,omitempty"`
@ -737,7 +680,7 @@ func NewDimensions(Height uint64, Width uint64) *Dimensions {
type DownloadArg struct {
// Path : The path of the file to download.
Path string `json:"path"`
// Rev : Deprecated. Please specify revision in `path` instead.
// Rev : Please specify revision in `path` instead.
Rev string `json:"rev,omitempty"`
// ExtraHeaders can be used to pass Range, If-None-Match headers
ExtraHeaders map[string]string `json:"-"`
@ -812,7 +755,7 @@ type FileMetadata struct {
SharingInfo *FileSharingInfo `json:"sharing_info,omitempty"`
// PropertyGroups : Additional information if the file has custom properties
// with the property template specified.
PropertyGroups []*properties.PropertyGroup `json:"property_groups,omitempty"`
PropertyGroups []*file_properties.PropertyGroup `json:"property_groups,omitempty"`
// HasExplicitSharedMembers : This flag will only be present if
// include_has_explicit_shared_members is true in `listFolder` or
// `getMetadata`. If this flag is present, it will be true if this file has
@ -876,14 +819,14 @@ type FolderMetadata struct {
Metadata
// Id : A unique identifier for the folder.
Id string `json:"id"`
// SharedFolderId : Deprecated. Please use `sharing_info` instead.
// SharedFolderId : Please use `sharing_info` instead.
SharedFolderId string `json:"shared_folder_id,omitempty"`
// SharingInfo : Set if the folder is contained in a shared folder or is a
// shared folder mount point.
SharingInfo *FolderSharingInfo `json:"sharing_info,omitempty"`
// PropertyGroups : Additional information if the file has custom properties
// with the property template specified.
PropertyGroups []*properties.PropertyGroup `json:"property_groups,omitempty"`
PropertyGroups []*file_properties.PropertyGroup `json:"property_groups,omitempty"`
}
// NewFolderMetadata returns a new FolderMetadata instance
@ -1059,6 +1002,107 @@ func NewGetTemporaryLinkResult(Metadata *FileMetadata, Link string) *GetTemporar
return s
}
// GetThumbnailBatchArg : Arguments for `getThumbnailBatch`.
type GetThumbnailBatchArg struct {
// Entries : List of files to get thumbnails.
Entries []*ThumbnailArg `json:"entries"`
}
// NewGetThumbnailBatchArg returns a new GetThumbnailBatchArg instance
func NewGetThumbnailBatchArg(Entries []*ThumbnailArg) *GetThumbnailBatchArg {
s := new(GetThumbnailBatchArg)
s.Entries = Entries
return s
}
// GetThumbnailBatchError : has no documentation (yet)
type GetThumbnailBatchError struct {
dropbox.Tagged
}
// Valid tag values for GetThumbnailBatchError
const (
GetThumbnailBatchErrorTooManyFiles = "too_many_files"
GetThumbnailBatchErrorOther = "other"
)
// GetThumbnailBatchResult : has no documentation (yet)
type GetThumbnailBatchResult struct {
// Entries : List of files and their thumbnails.
Entries []*GetThumbnailBatchResultEntry `json:"entries"`
}
// NewGetThumbnailBatchResult returns a new GetThumbnailBatchResult instance
func NewGetThumbnailBatchResult(Entries []*GetThumbnailBatchResultEntry) *GetThumbnailBatchResult {
s := new(GetThumbnailBatchResult)
s.Entries = Entries
return s
}
// GetThumbnailBatchResultData : has no documentation (yet)
type GetThumbnailBatchResultData struct {
// Metadata : has no documentation (yet)
Metadata *FileMetadata `json:"metadata"`
// Thumbnail : has no documentation (yet)
Thumbnail string `json:"thumbnail"`
}
// NewGetThumbnailBatchResultData returns a new GetThumbnailBatchResultData instance
func NewGetThumbnailBatchResultData(Metadata *FileMetadata, Thumbnail string) *GetThumbnailBatchResultData {
s := new(GetThumbnailBatchResultData)
s.Metadata = Metadata
s.Thumbnail = Thumbnail
return s
}
// GetThumbnailBatchResultEntry : has no documentation (yet)
type GetThumbnailBatchResultEntry struct {
dropbox.Tagged
// Success : has no documentation (yet)
Success *GetThumbnailBatchResultData `json:"success,omitempty"`
// Failure : The result for this file if it was an error.
Failure *ThumbnailError `json:"failure,omitempty"`
}
// Valid tag values for GetThumbnailBatchResultEntry
const (
GetThumbnailBatchResultEntrySuccess = "success"
GetThumbnailBatchResultEntryFailure = "failure"
GetThumbnailBatchResultEntryOther = "other"
)
// UnmarshalJSON deserializes into a GetThumbnailBatchResultEntry instance
func (u *GetThumbnailBatchResultEntry) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Success : has no documentation (yet)
Success json.RawMessage `json:"success,omitempty"`
// Failure : The result for this file if it was an error.
Failure json.RawMessage `json:"failure,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "success":
err = json.Unmarshal(body, &u.Success)
if err != nil {
return err
}
case "failure":
err = json.Unmarshal(w.Failure, &u.Failure)
if err != nil {
return err
}
}
return nil
}
// GpsCoordinates : GPS coordinates for a photo or video.
type GpsCoordinates struct {
// Latitude : Latitude of the GPS coordinates.
@ -1093,6 +1137,13 @@ type ListFolderArg struct {
// flag for each file indicating whether or not that file has any explicit
// members.
IncludeHasExplicitSharedMembers bool `json:"include_has_explicit_shared_members"`
// IncludeMountedFolders : If true, the results will include entries under
// mounted folders which includes app folder, shared folder and team folder.
IncludeMountedFolders bool `json:"include_mounted_folders"`
// Limit : The maximum number of results to return per request. Note: This
// is an approximate number and there can be slightly more entries returned
// in some cases.
Limit uint32 `json:"limit,omitempty"`
}
// NewListFolderArg returns a new ListFolderArg instance
@ -1103,6 +1154,7 @@ func NewListFolderArg(Path string) *ListFolderArg {
s.IncludeMediaInfo = false
s.IncludeDeleted = false
s.IncludeHasExplicitSharedMembers = false
s.IncludeMountedFolders = true
return s
}
@ -1351,16 +1403,6 @@ func NewListRevisionsResult(IsDeleted bool, Entries []*FileMetadata) *ListRevisi
return s
}
// LookUpPropertiesError : has no documentation (yet)
type LookUpPropertiesError struct {
dropbox.Tagged
}
// Valid tag values for LookUpPropertiesError
const (
LookUpPropertiesErrorPropertyGroupNotFound = "property_group_not_found"
)
// LookupError : has no documentation (yet)
type LookupError struct {
dropbox.Tagged
@ -1541,7 +1583,7 @@ func NewPhotoMetadata() *PhotoMetadata {
type PreviewArg struct {
// Path : The path of the file to preview.
Path string `json:"path"`
// Rev : Deprecated. Please specify revision in `path` instead.
// Rev : Please specify revision in `path` instead.
Rev string `json:"rev,omitempty"`
}
@ -1591,42 +1633,6 @@ func (u *PreviewError) UnmarshalJSON(body []byte) error {
return nil
}
// PropertyGroupUpdate : has no documentation (yet)
type PropertyGroupUpdate struct {
// TemplateId : A unique identifier for a property template.
TemplateId string `json:"template_id"`
// AddOrUpdateFields : List of property fields to update if the field
// already exists. If the field doesn't exist, add the field to the property
// group.
AddOrUpdateFields []*properties.PropertyField `json:"add_or_update_fields,omitempty"`
// RemoveFields : List of property field names to remove from property group
// if the field exists.
RemoveFields []string `json:"remove_fields,omitempty"`
}
// NewPropertyGroupUpdate returns a new PropertyGroupUpdate instance
func NewPropertyGroupUpdate(TemplateId string) *PropertyGroupUpdate {
s := new(PropertyGroupUpdate)
s.TemplateId = TemplateId
return s
}
// PropertyGroupWithPath : has no documentation (yet)
type PropertyGroupWithPath struct {
// Path : A unique identifier for the file.
Path string `json:"path"`
// PropertyGroups : Filled custom property templates associated with a file.
PropertyGroups []*properties.PropertyGroup `json:"property_groups"`
}
// NewPropertyGroupWithPath returns a new PropertyGroupWithPath instance
func NewPropertyGroupWithPath(Path string, PropertyGroups []*properties.PropertyGroup) *PropertyGroupWithPath {
s := new(PropertyGroupWithPath)
s.Path = Path
s.PropertyGroups = PropertyGroups
return s
}
// RelocationPath : has no documentation (yet)
type RelocationPath struct {
// FromPath : Path in the user's Dropbox to be copied or moved.
@ -1900,59 +1906,6 @@ func NewRelocationResult(Metadata IsMetadata) *RelocationResult {
return s
}
// RemovePropertiesArg : has no documentation (yet)
type RemovePropertiesArg struct {
// Path : A unique identifier for the file.
Path string `json:"path"`
// PropertyTemplateIds : A list of identifiers for a property template
// created by route properties/template/add.
PropertyTemplateIds []string `json:"property_template_ids"`
}
// NewRemovePropertiesArg returns a new RemovePropertiesArg instance
func NewRemovePropertiesArg(Path string, PropertyTemplateIds []string) *RemovePropertiesArg {
s := new(RemovePropertiesArg)
s.Path = Path
s.PropertyTemplateIds = PropertyTemplateIds
return s
}
// RemovePropertiesError : has no documentation (yet)
type RemovePropertiesError struct {
dropbox.Tagged
// PropertyGroupLookup : has no documentation (yet)
PropertyGroupLookup *LookUpPropertiesError `json:"property_group_lookup,omitempty"`
}
// Valid tag values for RemovePropertiesError
const (
RemovePropertiesErrorPropertyGroupLookup = "property_group_lookup"
)
// UnmarshalJSON deserializes into a RemovePropertiesError instance
func (u *RemovePropertiesError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// PropertyGroupLookup : has no documentation (yet)
PropertyGroupLookup json.RawMessage `json:"property_group_lookup,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 "property_group_lookup":
err = json.Unmarshal(w.PropertyGroupLookup, &u.PropertyGroupLookup)
if err != nil {
return err
}
}
return nil
}
// RestoreArg : has no documentation (yet)
type RestoreArg struct {
// Path : The path to the file you want to restore.
@ -2442,59 +2395,6 @@ const (
ThumbnailSizeW1024h768 = "w1024h768"
)
// UpdatePropertiesError : has no documentation (yet)
type UpdatePropertiesError struct {
dropbox.Tagged
// PropertyGroupLookup : has no documentation (yet)
PropertyGroupLookup *LookUpPropertiesError `json:"property_group_lookup,omitempty"`
}
// Valid tag values for UpdatePropertiesError
const (
UpdatePropertiesErrorPropertyGroupLookup = "property_group_lookup"
)
// UnmarshalJSON deserializes into a UpdatePropertiesError instance
func (u *UpdatePropertiesError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// PropertyGroupLookup : has no documentation (yet)
PropertyGroupLookup json.RawMessage `json:"property_group_lookup,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 "property_group_lookup":
err = json.Unmarshal(w.PropertyGroupLookup, &u.PropertyGroupLookup)
if err != nil {
return err
}
}
return nil
}
// UpdatePropertyGroupArg : has no documentation (yet)
type UpdatePropertyGroupArg struct {
// Path : A unique identifier for the file.
Path string `json:"path"`
// UpdatePropertyGroups : Filled custom property templates associated with a
// file.
UpdatePropertyGroups []*PropertyGroupUpdate `json:"update_property_groups"`
}
// NewUpdatePropertyGroupArg returns a new UpdatePropertyGroupArg instance
func NewUpdatePropertyGroupArg(Path string, UpdatePropertyGroups []*PropertyGroupUpdate) *UpdatePropertyGroupArg {
s := new(UpdatePropertyGroupArg)
s.Path = Path
s.UpdatePropertyGroups = UpdatePropertyGroups
return s
}
// UploadError : has no documentation (yet)
type UploadError struct {
dropbox.Tagged
@ -2536,7 +2436,7 @@ func (u *UploadError) UnmarshalJSON(body []byte) error {
type UploadErrorWithProperties struct {
dropbox.Tagged
// PropertiesError : has no documentation (yet)
PropertiesError *InvalidPropertyGroupError `json:"properties_error,omitempty"`
PropertiesError *file_properties.InvalidPropertyGroupError `json:"properties_error,omitempty"`
}
// Valid tag values for UploadErrorWithProperties

View File

@ -35,6 +35,8 @@ type Client interface {
// DocsArchive : Marks the given Paper doc as archived. Note: This action
// can be performed or undone by anyone with edit permissions to the doc.
DocsArchive(arg *RefPaperDoc) (err error)
// DocsCreate : Creates a new Paper doc with the provided content.
DocsCreate(arg *PaperDocCreateArgs, content io.Reader) (res *PaperDocCreateUpdateResult, err error)
// DocsDownload : Exports and downloads Paper doc either as HTML or
// markdown.
DocsDownload(arg *PaperDocExport) (res *PaperDocExportResult, content io.ReadCloser, err error)
@ -74,6 +76,8 @@ type Client interface {
// 'public_sharing_policy' cannot be set to the value 'disabled' because
// this setting can be changed only via the team admin console.
DocsSharingPolicySet(arg *PaperDocSharingPolicy) (err error)
// DocsUpdate : Updates an existing Paper doc with the provided content.
DocsUpdate(arg *PaperDocUpdateArgs, content io.Reader) (res *PaperDocCreateUpdateResult, err error)
// DocsUsersAdd : Allows an owner or editor to add users to a Paper doc or
// change their permissions using their email address or Dropbox account ID.
// Note: The Doc owner's permissions cannot be changed.
@ -162,6 +166,79 @@ func (dbx *apiImpl) DocsArchive(arg *RefPaperDoc) (err error) {
return
}
//DocsCreateAPIError is an error-wrapper for the docs/create route
type DocsCreateAPIError struct {
dropbox.APIError
EndpointError *PaperDocCreateError `json:"error"`
}
func (dbx *apiImpl) DocsCreate(arg *PaperDocCreateArgs, content io.Reader) (res *PaperDocCreateUpdateResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("arg: %v", arg)
b, err := json.Marshal(arg)
if err != nil {
return
}
headers := map[string]string{
"Content-Type": "application/octet-stream",
"Dropbox-API-Arg": string(b),
}
if dbx.Config.AsMemberID != "" {
headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID
}
req, err := (*dropbox.Context)(dbx).NewRequest("api", "upload", true, "paper", "docs/create", headers, content)
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 DocsCreateAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//DocsDownloadAPIError is an error-wrapper for the docs/download route
type DocsDownloadAPIError struct {
dropbox.APIError
@ -178,7 +255,7 @@ func (dbx *apiImpl) DocsDownload(arg *PaperDocExport) (res *PaperDocExportResult
}
headers := map[string]string{
"Content-Type": "application/json",
"Dropbox-API-Arg": string(b),
}
if dbx.Config.AsMemberID != "" {
headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID
@ -796,6 +873,79 @@ func (dbx *apiImpl) DocsSharingPolicySet(arg *PaperDocSharingPolicy) (err error)
return
}
//DocsUpdateAPIError is an error-wrapper for the docs/update route
type DocsUpdateAPIError struct {
dropbox.APIError
EndpointError *PaperDocUpdateError `json:"error"`
}
func (dbx *apiImpl) DocsUpdate(arg *PaperDocUpdateArgs, content io.Reader) (res *PaperDocCreateUpdateResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("arg: %v", arg)
b, err := json.Marshal(arg)
if err != nil {
return
}
headers := map[string]string{
"Content-Type": "application/octet-stream",
"Dropbox-API-Arg": string(b),
}
if dbx.Config.AsMemberID != "" {
headers["Dropbox-API-Select-User"] = dbx.Config.AsMemberID
}
req, err := (*dropbox.Context)(dbx).NewRequest("api", "upload", true, "paper", "docs/update", headers, content)
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 DocsUpdateAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//DocsUsersAddAPIError is an error-wrapper for the docs/users/add route
type DocsUsersAddAPIError struct {
dropbox.APIError

View File

@ -247,6 +247,19 @@ func NewFoldersContainingPaperDoc() *FoldersContainingPaperDoc {
return s
}
// ImportFormat : The import format of the incoming data.
type ImportFormat struct {
dropbox.Tagged
}
// Valid tag values for ImportFormat
const (
ImportFormatHtml = "html"
ImportFormatMarkdown = "markdown"
ImportFormatPlainText = "plain_text"
ImportFormatOther = "other"
)
// InviteeInfoWithPermissionLevel : has no documentation (yet)
type InviteeInfoWithPermissionLevel struct {
// Invitee : Email address invited to the Paper doc.
@ -582,6 +595,55 @@ const (
PaperApiCursorErrorOther = "other"
)
// PaperDocCreateArgs : has no documentation (yet)
type PaperDocCreateArgs struct {
// ParentFolderId : The Paper folder ID where the Paper document should be
// created. The API user has to have write access to this folder or error is
// thrown.
ParentFolderId string `json:"parent_folder_id,omitempty"`
// ImportFormat : The format of provided data.
ImportFormat *ImportFormat `json:"import_format"`
}
// NewPaperDocCreateArgs returns a new PaperDocCreateArgs instance
func NewPaperDocCreateArgs(ImportFormat *ImportFormat) *PaperDocCreateArgs {
s := new(PaperDocCreateArgs)
s.ImportFormat = ImportFormat
return s
}
// PaperDocCreateError : has no documentation (yet)
type PaperDocCreateError struct {
dropbox.Tagged
}
// Valid tag values for PaperDocCreateError
const (
PaperDocCreateErrorContentMalformed = "content_malformed"
PaperDocCreateErrorFolderNotFound = "folder_not_found"
PaperDocCreateErrorDocLengthExceeded = "doc_length_exceeded"
PaperDocCreateErrorImageSizeExceeded = "image_size_exceeded"
)
// PaperDocCreateUpdateResult : has no documentation (yet)
type PaperDocCreateUpdateResult struct {
// DocId : Doc ID of the newly created doc.
DocId string `json:"doc_id"`
// Revision : The Paper doc revision. Simply an ever increasing number.
Revision int64 `json:"revision"`
// Title : The Paper doc title.
Title string `json:"title"`
}
// NewPaperDocCreateUpdateResult returns a new PaperDocCreateUpdateResult instance
func NewPaperDocCreateUpdateResult(DocId string, Revision int64, Title string) *PaperDocCreateUpdateResult {
s := new(PaperDocCreateUpdateResult)
s.DocId = DocId
s.Revision = Revision
s.Title = Title
return s
}
// PaperDocExport : has no documentation (yet)
type PaperDocExport struct {
RefPaperDoc
@ -647,6 +709,57 @@ func NewPaperDocSharingPolicy(DocId string, SharingPolicy *SharingPolicy) *Paper
return s
}
// PaperDocUpdateArgs : has no documentation (yet)
type PaperDocUpdateArgs struct {
RefPaperDoc
// DocUpdatePolicy : The policy used for the current update call.
DocUpdatePolicy *PaperDocUpdatePolicy `json:"doc_update_policy"`
// Revision : The latest doc revision. This value must match the head
// revision or an error code will be returned. This is to prevent colliding
// writes.
Revision int64 `json:"revision"`
// ImportFormat : The format of provided data.
ImportFormat *ImportFormat `json:"import_format"`
}
// NewPaperDocUpdateArgs returns a new PaperDocUpdateArgs instance
func NewPaperDocUpdateArgs(DocId string, DocUpdatePolicy *PaperDocUpdatePolicy, Revision int64, ImportFormat *ImportFormat) *PaperDocUpdateArgs {
s := new(PaperDocUpdateArgs)
s.DocId = DocId
s.DocUpdatePolicy = DocUpdatePolicy
s.Revision = Revision
s.ImportFormat = ImportFormat
return s
}
// PaperDocUpdateError : has no documentation (yet)
type PaperDocUpdateError struct {
dropbox.Tagged
}
// Valid tag values for PaperDocUpdateError
const (
PaperDocUpdateErrorContentMalformed = "content_malformed"
PaperDocUpdateErrorRevisionMismatch = "revision_mismatch"
PaperDocUpdateErrorDocLengthExceeded = "doc_length_exceeded"
PaperDocUpdateErrorImageSizeExceeded = "image_size_exceeded"
PaperDocUpdateErrorDocArchived = "doc_archived"
PaperDocUpdateErrorDocDeleted = "doc_deleted"
)
// PaperDocUpdatePolicy : has no documentation (yet)
type PaperDocUpdatePolicy struct {
dropbox.Tagged
}
// Valid tag values for PaperDocUpdatePolicy
const (
PaperDocUpdatePolicyAppend = "append"
PaperDocUpdatePolicyPrepend = "prepend"
PaperDocUpdatePolicyOverwriteAll = "overwrite_all"
PaperDocUpdatePolicyOther = "other"
)
// RemovePaperDocUser : has no documentation (yet)
type RemovePaperDocUser struct {
RefPaperDoc

View File

@ -1,213 +0,0 @@
// Copyright (c) Dropbox, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// Package properties : This namespace contains helper entities for property and
// property/template endpoints.
package properties
import (
"encoding/json"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
)
// GetPropertyTemplateArg : has no documentation (yet)
type GetPropertyTemplateArg struct {
// TemplateId : An identifier for property template added by route
// properties/template/add.
TemplateId string `json:"template_id"`
}
// NewGetPropertyTemplateArg returns a new GetPropertyTemplateArg instance
func NewGetPropertyTemplateArg(TemplateId string) *GetPropertyTemplateArg {
s := new(GetPropertyTemplateArg)
s.TemplateId = TemplateId
return s
}
// PropertyGroupTemplate : Describes property templates that can be filled and
// associated with a file.
type PropertyGroupTemplate struct {
// Name : A display name for the property template. Property template names
// can be up to 256 bytes.
Name string `json:"name"`
// Description : Description for new property template. Property template
// descriptions can be up to 1024 bytes.
Description string `json:"description"`
// Fields : This is a list of custom properties associated with a property
// template. There can be up to 64 properties in a single property template.
Fields []*PropertyFieldTemplate `json:"fields"`
}
// NewPropertyGroupTemplate returns a new PropertyGroupTemplate instance
func NewPropertyGroupTemplate(Name string, Description string, Fields []*PropertyFieldTemplate) *PropertyGroupTemplate {
s := new(PropertyGroupTemplate)
s.Name = Name
s.Description = Description
s.Fields = Fields
return s
}
// GetPropertyTemplateResult : The Property template for the specified template.
type GetPropertyTemplateResult struct {
PropertyGroupTemplate
}
// NewGetPropertyTemplateResult returns a new GetPropertyTemplateResult instance
func NewGetPropertyTemplateResult(Name string, Description string, Fields []*PropertyFieldTemplate) *GetPropertyTemplateResult {
s := new(GetPropertyTemplateResult)
s.Name = Name
s.Description = Description
s.Fields = Fields
return s
}
// ListPropertyTemplateIds : has no documentation (yet)
type ListPropertyTemplateIds struct {
// TemplateIds : List of identifiers for templates added by route
// properties/template/add.
TemplateIds []string `json:"template_ids"`
}
// NewListPropertyTemplateIds returns a new ListPropertyTemplateIds instance
func NewListPropertyTemplateIds(TemplateIds []string) *ListPropertyTemplateIds {
s := new(ListPropertyTemplateIds)
s.TemplateIds = TemplateIds
return s
}
// PropertyTemplateError : has no documentation (yet)
type PropertyTemplateError struct {
dropbox.Tagged
// TemplateNotFound : Property template does not exist for given identifier.
TemplateNotFound string `json:"template_not_found,omitempty"`
}
// Valid tag values for PropertyTemplateError
const (
PropertyTemplateErrorTemplateNotFound = "template_not_found"
PropertyTemplateErrorRestrictedContent = "restricted_content"
PropertyTemplateErrorOther = "other"
)
// UnmarshalJSON deserializes into a PropertyTemplateError instance
func (u *PropertyTemplateError) 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 "template_not_found":
err = json.Unmarshal(body, &u.TemplateNotFound)
if err != nil {
return err
}
}
return nil
}
// ModifyPropertyTemplateError : has no documentation (yet)
type ModifyPropertyTemplateError struct {
dropbox.Tagged
}
// Valid tag values for ModifyPropertyTemplateError
const (
ModifyPropertyTemplateErrorConflictingPropertyNames = "conflicting_property_names"
ModifyPropertyTemplateErrorTooManyProperties = "too_many_properties"
ModifyPropertyTemplateErrorTooManyTemplates = "too_many_templates"
ModifyPropertyTemplateErrorTemplateAttributeTooLarge = "template_attribute_too_large"
)
// PropertyField : has no documentation (yet)
type PropertyField struct {
// Name : This is the name or key of a custom property in a property
// template. File property names can be up to 256 bytes.
Name string `json:"name"`
// Value : Value of a custom property attached to a file. Values can be up
// to 1024 bytes.
Value string `json:"value"`
}
// NewPropertyField returns a new PropertyField instance
func NewPropertyField(Name string, Value string) *PropertyField {
s := new(PropertyField)
s.Name = Name
s.Value = Value
return s
}
// PropertyFieldTemplate : Describe a single property field type which that can
// be part of a property template.
type PropertyFieldTemplate struct {
// Name : This is the name or key of a custom property in a property
// template. File property names can be up to 256 bytes.
Name string `json:"name"`
// Description : This is the description for a custom property in a property
// template. File property description can be up to 1024 bytes.
Description string `json:"description"`
// Type : This is the data type of the value of this property. This type
// will be enforced upon property creation and modifications.
Type *PropertyType `json:"type"`
}
// NewPropertyFieldTemplate returns a new PropertyFieldTemplate instance
func NewPropertyFieldTemplate(Name string, Description string, Type *PropertyType) *PropertyFieldTemplate {
s := new(PropertyFieldTemplate)
s.Name = Name
s.Description = Description
s.Type = Type
return s
}
// PropertyGroup : Collection of custom properties in filled property templates.
type PropertyGroup struct {
// TemplateId : A unique identifier for a property template type.
TemplateId string `json:"template_id"`
// Fields : This is a list of custom properties associated with a file.
// There can be up to 32 properties for a template.
Fields []*PropertyField `json:"fields"`
}
// NewPropertyGroup returns a new PropertyGroup instance
func NewPropertyGroup(TemplateId string, Fields []*PropertyField) *PropertyGroup {
s := new(PropertyGroup)
s.TemplateId = TemplateId
s.Fields = Fields
return s
}
// PropertyType : Data type of the given property added. This endpoint is in
// beta and only properties of type strings is supported.
type PropertyType struct {
dropbox.Tagged
}
// Valid tag values for PropertyType
const (
PropertyTypeString = "string"
PropertyTypeOther = "other"
)

View File

@ -36,7 +36,7 @@ const (
hostContent = "content"
hostNotify = "notify"
sdkVersion = "1.0.0-beta"
specVersion = "6194bea"
specVersion = "52ee619"
)
// Version returns the current SDK version and API Spec version

View File

@ -552,9 +552,9 @@ func (u *CreateSharedLinkError) UnmarshalJSON(body []byte) error {
// CreateSharedLinkWithSettingsArg : has no documentation (yet)
type CreateSharedLinkWithSettingsArg struct {
// Path : The path to be shared by the shared link
// Path : The path to be shared by the shared link.
Path string `json:"path"`
// Settings : The requested settings for the newly created shared link
// Settings : The requested settings for the newly created shared link.
Settings *SharedLinkSettings `json:"settings,omitempty"`
}
@ -570,7 +570,7 @@ type CreateSharedLinkWithSettingsError struct {
dropbox.Tagged
// Path : has no documentation (yet)
Path *files.LookupError `json:"path,omitempty"`
// SettingsError : There is an error with the given settings
// SettingsError : There is an error with the given settings.
SettingsError *SharedLinkSettingsError `json:"settings_error,omitempty"`
}
@ -589,7 +589,7 @@ func (u *CreateSharedLinkWithSettingsError) UnmarshalJSON(body []byte) error {
dropbox.Tagged
// Path : has no documentation (yet)
Path json.RawMessage `json:"path,omitempty"`
// SettingsError : There is an error with the given settings
// SettingsError : There is an error with the given settings.
SettingsError json.RawMessage `json:"settings_error,omitempty"`
}
var w wrap
@ -741,7 +741,7 @@ func (u *FileErrorResult) UnmarshalJSON(body []byte) error {
return nil
}
// SharedLinkMetadata : The metadata of a shared link
// SharedLinkMetadata : The metadata of a shared link.
type SharedLinkMetadata struct {
// Url : URL of the shared link.
Url string `json:"url"`
@ -847,7 +847,7 @@ func IsSharedLinkMetadataFromJSON(data []byte) (IsSharedLinkMetadata, error) {
return nil, nil
}
// FileLinkMetadata : The metadata of a file shared link
// FileLinkMetadata : The metadata of a file shared link.
type FileLinkMetadata struct {
SharedLinkMetadata
// ClientModified : The modification time set by the desktop client when the
@ -1092,7 +1092,7 @@ const (
FolderActionOther = "other"
)
// FolderLinkMetadata : The metadata of a folder shared link
// FolderLinkMetadata : The metadata of a folder shared link.
type FolderLinkMetadata struct {
SharedLinkMetadata
}
@ -1820,7 +1820,7 @@ type LinkPermissions struct {
// after considering these policies, can be found in `resolved_visibility`.
// This is shown only if the caller is the link's owner.
RequestedVisibility *RequestedVisibility `json:"requested_visibility,omitempty"`
// CanRevoke : Whether the caller can revoke the shared link
// CanRevoke : Whether the caller can revoke the shared link.
CanRevoke bool `json:"can_revoke"`
// RevokeFailureReason : The failure reason for revoking the link. This
// field will only be present if the `can_revoke` is false.
@ -2510,7 +2510,7 @@ func (u *MemberSelector) UnmarshalJSON(body []byte) error {
// ModifySharedLinkSettingsArgs : has no documentation (yet)
type ModifySharedLinkSettingsArgs struct {
// Url : URL of the shared link to change its settings
// Url : URL of the shared link to change its settings.
Url string `json:"url"`
// Settings : Set of settings for the shared link.
Settings *SharedLinkSettings `json:"settings"`
@ -2531,7 +2531,7 @@ func NewModifySharedLinkSettingsArgs(Url string, Settings *SharedLinkSettings) *
// ModifySharedLinkSettingsError : has no documentation (yet)
type ModifySharedLinkSettingsError struct {
dropbox.Tagged
// SettingsError : There is an error with the given settings
// SettingsError : There is an error with the given settings.
SettingsError *SharedLinkSettingsError `json:"settings_error,omitempty"`
}
@ -2545,7 +2545,7 @@ const (
func (u *ModifySharedLinkSettingsError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// SettingsError : There is an error with the given settings
// SettingsError : There is an error with the given settings.
SettingsError json.RawMessage `json:"settings_error,omitempty"`
}
var w wrap
@ -2706,6 +2706,7 @@ const (
PermissionDeniedReasonUserAccountType = "user_account_type"
PermissionDeniedReasonUserNotOnTeam = "user_not_on_team"
PermissionDeniedReasonFolderIsInsideSharedFolder = "folder_is_inside_shared_folder"
PermissionDeniedReasonRestrictedByParentFolder = "restricted_by_parent_folder"
PermissionDeniedReasonInsufficientPlan = "insufficient_plan"
PermissionDeniedReasonOther = "other"
)
@ -3683,7 +3684,7 @@ const (
// TeamMemberInfo : Information about a team member.
type TeamMemberInfo struct {
// TeamInfo : Information about the member's team
// TeamInfo : Information about the member's team.
TeamInfo *users.Team `json:"team_info"`
// DisplayName : The display name of the user.
DisplayName string `json:"display_name"`

View File

@ -29,7 +29,7 @@ import (
"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/properties"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/file_properties"
)
// Client interface describes all routes in this namespace
@ -41,10 +41,10 @@ type Client interface {
// DevicesListTeamDevices : List all device sessions of a team.
// Deprecated: Use `DevicesListMembersDevices` instead
DevicesListTeamDevices(arg *ListTeamDevicesArg) (res *ListTeamDevicesResult, err error)
// DevicesRevokeDeviceSession : Revoke a device session of a team's member
// DevicesRevokeDeviceSession : Revoke a device session of a team's member.
DevicesRevokeDeviceSession(arg *RevokeDeviceSessionArg) (err error)
// DevicesRevokeDeviceSessionBatch : Revoke a list of device sessions of
// team members
// team members.
DevicesRevokeDeviceSessionBatch(arg *RevokeDeviceSessionBatchArg) (res *RevokeDeviceSessionBatchResult, err error)
// FeaturesGetValues : Get the values for one or more featues. This route
// allows you to check your account's capability for what feature you can
@ -113,11 +113,22 @@ type Client interface {
// Deprecated: Use `LinkedAppsListMembersLinkedApps` instead
LinkedAppsListTeamLinkedApps(arg *ListTeamAppsArg) (res *ListTeamAppsResult, err error)
// LinkedAppsRevokeLinkedApp : Revoke a linked application of the team
// member
// member.
LinkedAppsRevokeLinkedApp(arg *RevokeLinkedApiAppArg) (err error)
// LinkedAppsRevokeLinkedAppBatch : Revoke a list of linked applications of
// the team members
// the team members.
LinkedAppsRevokeLinkedAppBatch(arg *RevokeLinkedApiAppBatchArg) (res *RevokeLinkedAppBatchResult, err error)
// MemberSpaceLimitsGetCustomQuota : Get users custom quota. Returns none as
// the custom quota if none was set. A maximum of 1000 members can be
// specified in a single call.
MemberSpaceLimitsGetCustomQuota(arg *CustomQuotaUsersArg) (res []*CustomQuotaResult, err error)
// MemberSpaceLimitsRemoveCustomQuota : Remove users custom quota. A maximum
// of 1000 members can be specified in a single call.
MemberSpaceLimitsRemoveCustomQuota(arg *CustomQuotaUsersArg) (res []*RemoveCustomQuotaResult, err error)
// MemberSpaceLimitsSetCustomQuota : Set users custom quota. Custom quota
// has to be at least 25GB. A maximum of 1000 members can be specified in a
// single call.
MemberSpaceLimitsSetCustomQuota(arg *SetCustomQuotaArg) (res []*CustomQuotaResult, err error)
// MembersAdd : Adds members to a team. Permission : Team member management
// A maximum of 20 members can be specified in a single call. If no Dropbox
// account exists with the email address specified, a new Dropbox account
@ -132,18 +143,18 @@ type Client interface {
MembersAdd(arg *MembersAddArg) (res *MembersAddLaunch, err error)
// MembersAddJobStatusGet : Once an async_job_id is returned from
// `membersAdd` , use this to poll the status of the asynchronous request.
// Permission : Team member management
// Permission : Team member management.
MembersAddJobStatusGet(arg *async.PollArg) (res *MembersAddJobStatus, err error)
// MembersGetInfo : Returns information about multiple team members.
// Permission : Team information This endpoint will return
// `MembersGetInfoItem.id_not_found`, for IDs (or emails) that cannot be
// matched to a valid team member.
MembersGetInfo(arg *MembersGetInfoArgs) (res []*MembersGetInfoItem, err error)
// MembersList : Lists members of a team. Permission : Team information
// MembersList : Lists members of a team. Permission : Team information.
MembersList(arg *MembersListArg) (res *MembersListResult, err error)
// MembersListContinue : Once a cursor has been retrieved from
// `membersList`, use this to paginate through all team members. Permission
// : Team information
// : Team information.
MembersListContinue(arg *MembersListContinueArg) (res *MembersListResult, err error)
// MembersRecover : Recover a deleted member. Permission : Team member
// management Exactly one of team_member_id, email, or external_id must be
@ -155,13 +166,16 @@ type Client interface {
// `membersRecover` for a 7 day period or until the account has been
// permanently deleted or transferred to another account (whichever comes
// first). Calling `membersAdd` while a user is still recoverable on your
// team will return with `MemberAddResult.user_already_on_team`. This
// endpoint may initiate an asynchronous job. To obtain the final result of
// the job, the client should periodically poll `membersRemoveJobStatusGet`.
// team will return with `MemberAddResult.user_already_on_team`. Accounts
// can have their files transferred via the admin console for a limited
// time, based on the version history length associated with the team (120
// days for most teams). This endpoint may initiate an asynchronous job. To
// obtain the final result of the job, the client should periodically poll
// `membersRemoveJobStatusGet`.
MembersRemove(arg *MembersRemoveArg) (res *async.LaunchEmptyResult, err error)
// MembersRemoveJobStatusGet : Once an async_job_id is returned from
// `membersRemove` , use this to poll the status of the asynchronous
// request. Permission : Team member management
// request. Permission : Team member management.
MembersRemoveJobStatusGet(arg *async.PollArg) (res *async.PollEmptyResult, err error)
// MembersSendWelcomeEmail : Sends welcome email to pending team member.
// Permission : Team member management Exactly one of team_member_id, email,
@ -169,10 +183,10 @@ type Client interface {
// team member is not pending.
MembersSendWelcomeEmail(arg *UserSelectorArg) (err error)
// MembersSetAdminPermissions : Updates a team member's permissions.
// Permission : Team member management
// Permission : Team member management.
MembersSetAdminPermissions(arg *MembersSetPermissionsArg) (res *MembersSetPermissionsResult, err error)
// MembersSetProfile : Updates a team member's profile. Permission : Team
// member management
// member management.
MembersSetProfile(arg *MembersSetProfileArg) (res *TeamMemberInfo, err error)
// MembersSuspend : Suspend a member from a team. Permission : Team member
// management Exactly one of team_member_id, email, or external_id must be
@ -193,18 +207,18 @@ type Client interface {
// `namespacesList`, use this to paginate through all team-accessible
// namespaces. Duplicates may occur in the list.
NamespacesListContinue(arg *TeamNamespacesListContinueArg) (res *TeamNamespacesListResult, err error)
// PropertiesTemplateAdd : Add a property template. See route
// files/properties/add to add properties to a file.
PropertiesTemplateAdd(arg *AddPropertyTemplateArg) (res *AddPropertyTemplateResult, err error)
// PropertiesTemplateGet : Get the schema for a specified template.
PropertiesTemplateGet(arg *properties.GetPropertyTemplateArg) (res *properties.GetPropertyTemplateResult, err error)
// PropertiesTemplateList : Get the property template identifiers for a
// team. To get the schema of each template use `propertiesTemplateGet`.
PropertiesTemplateList() (res *properties.ListPropertyTemplateIds, err error)
// PropertiesTemplateUpdate : Update a property template. This route can
// update the template name, the template description and add optional
// properties to templates.
PropertiesTemplateUpdate(arg *UpdatePropertyTemplateArg) (res *UpdatePropertyTemplateResult, err error)
// PropertiesTemplateAdd : has no documentation (yet)
// Deprecated:
PropertiesTemplateAdd(arg *file_properties.AddTemplateArg) (res *file_properties.AddTemplateResult, err error)
// PropertiesTemplateGet : has no documentation (yet)
// Deprecated:
PropertiesTemplateGet(arg *file_properties.GetTemplateArg) (res *file_properties.GetTemplateResult, err error)
// PropertiesTemplateList : has no documentation (yet)
// Deprecated:
PropertiesTemplateList() (res *file_properties.ListTemplateResult, err error)
// PropertiesTemplateUpdate : has no documentation (yet)
// Deprecated:
PropertiesTemplateUpdate(arg *file_properties.UpdateTemplateArg) (res *file_properties.UpdateTemplateResult, err error)
// ReportsGetActivity : Retrieves reporting data about a team's user
// activity.
ReportsGetActivity(arg *DateRange) (res *GetActivityReport, err error)
@ -1897,6 +1911,213 @@ func (dbx *apiImpl) LinkedAppsRevokeLinkedAppBatch(arg *RevokeLinkedApiAppBatchA
return
}
//MemberSpaceLimitsGetCustomQuotaAPIError is an error-wrapper for the member_space_limits/get_custom_quota route
type MemberSpaceLimitsGetCustomQuotaAPIError struct {
dropbox.APIError
EndpointError *CustomQuotaError `json:"error"`
}
func (dbx *apiImpl) MemberSpaceLimitsGetCustomQuota(arg *CustomQuotaUsersArg) (res []*CustomQuotaResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("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", "member_space_limits/get_custom_quota", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 MemberSpaceLimitsGetCustomQuotaAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//MemberSpaceLimitsRemoveCustomQuotaAPIError is an error-wrapper for the member_space_limits/remove_custom_quota route
type MemberSpaceLimitsRemoveCustomQuotaAPIError struct {
dropbox.APIError
EndpointError *CustomQuotaError `json:"error"`
}
func (dbx *apiImpl) MemberSpaceLimitsRemoveCustomQuota(arg *CustomQuotaUsersArg) (res []*RemoveCustomQuotaResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("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", "member_space_limits/remove_custom_quota", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 MemberSpaceLimitsRemoveCustomQuotaAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//MemberSpaceLimitsSetCustomQuotaAPIError is an error-wrapper for the member_space_limits/set_custom_quota route
type MemberSpaceLimitsSetCustomQuotaAPIError struct {
dropbox.APIError
EndpointError *CustomQuotaError `json:"error"`
}
func (dbx *apiImpl) MemberSpaceLimitsSetCustomQuota(arg *SetCustomQuotaArg) (res []*CustomQuotaResult, err error) {
cli := dbx.Client
dbx.Config.TryLog("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", "member_space_limits/set_custom_quota", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.TryLog("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.TryLog("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.TryLog("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 MemberSpaceLimitsSetCustomQuotaAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//MembersAddAPIError is an error-wrapper for the members/add route
type MembersAddAPIError struct {
dropbox.APIError
@ -2915,10 +3136,12 @@ func (dbx *apiImpl) NamespacesListContinue(arg *TeamNamespacesListContinueArg) (
//PropertiesTemplateAddAPIError is an error-wrapper for the properties/template/add route
type PropertiesTemplateAddAPIError struct {
dropbox.APIError
EndpointError *properties.ModifyPropertyTemplateError `json:"error"`
EndpointError *file_properties.ModifyTemplateError `json:"error"`
}
func (dbx *apiImpl) PropertiesTemplateAdd(arg *AddPropertyTemplateArg) (res *AddPropertyTemplateResult, err error) {
func (dbx *apiImpl) PropertiesTemplateAdd(arg *file_properties.AddTemplateArg) (res *file_properties.AddTemplateResult, err error) {
log.Printf("WARNING: API `PropertiesTemplateAdd` is deprecated")
cli := dbx.Client
dbx.Config.TryLog("arg: %v", arg)
@ -2984,10 +3207,12 @@ func (dbx *apiImpl) PropertiesTemplateAdd(arg *AddPropertyTemplateArg) (res *Add
//PropertiesTemplateGetAPIError is an error-wrapper for the properties/template/get route
type PropertiesTemplateGetAPIError struct {
dropbox.APIError
EndpointError *properties.PropertyTemplateError `json:"error"`
EndpointError *file_properties.TemplateError `json:"error"`
}
func (dbx *apiImpl) PropertiesTemplateGet(arg *properties.GetPropertyTemplateArg) (res *properties.GetPropertyTemplateResult, err error) {
func (dbx *apiImpl) PropertiesTemplateGet(arg *file_properties.GetTemplateArg) (res *file_properties.GetTemplateResult, err error) {
log.Printf("WARNING: API `PropertiesTemplateGet` is deprecated")
cli := dbx.Client
dbx.Config.TryLog("arg: %v", arg)
@ -3053,10 +3278,12 @@ func (dbx *apiImpl) PropertiesTemplateGet(arg *properties.GetPropertyTemplateArg
//PropertiesTemplateListAPIError is an error-wrapper for the properties/template/list route
type PropertiesTemplateListAPIError struct {
dropbox.APIError
EndpointError *properties.PropertyTemplateError `json:"error"`
EndpointError *file_properties.TemplateError `json:"error"`
}
func (dbx *apiImpl) PropertiesTemplateList() (res *properties.ListPropertyTemplateIds, err error) {
func (dbx *apiImpl) PropertiesTemplateList() (res *file_properties.ListTemplateResult, err error) {
log.Printf("WARNING: API `PropertiesTemplateList` is deprecated")
cli := dbx.Client
headers := map[string]string{}
@ -3114,10 +3341,12 @@ func (dbx *apiImpl) PropertiesTemplateList() (res *properties.ListPropertyTempla
//PropertiesTemplateUpdateAPIError is an error-wrapper for the properties/template/update route
type PropertiesTemplateUpdateAPIError struct {
dropbox.APIError
EndpointError *properties.ModifyPropertyTemplateError `json:"error"`
EndpointError *file_properties.ModifyTemplateError `json:"error"`
}
func (dbx *apiImpl) PropertiesTemplateUpdate(arg *UpdatePropertyTemplateArg) (res *UpdatePropertyTemplateResult, err error) {
func (dbx *apiImpl) PropertiesTemplateUpdate(arg *file_properties.UpdateTemplateArg) (res *file_properties.UpdateTemplateResult, err error) {
log.Printf("WARNING: API `PropertiesTemplateUpdate` is deprecated")
cli := dbx.Client
dbx.Config.TryLog("arg: %v", arg)

View File

@ -26,7 +26,6 @@ import (
"time"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/properties"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_common"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team_policies"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users"
@ -34,16 +33,16 @@ import (
// DeviceSession : has no documentation (yet)
type DeviceSession struct {
// SessionId : The session id
// SessionId : The session id.
SessionId string `json:"session_id"`
// IpAddress : The IP address of the last activity from this session
// IpAddress : The IP address of the last activity from this session.
IpAddress string `json:"ip_address,omitempty"`
// Country : The country from which the last activity from this session was
// made
// made.
Country string `json:"country,omitempty"`
// Created : The time this session was created
// Created : The time this session was created.
Created time.Time `json:"created,omitempty"`
// Updated : The time of the last activity from this session
// Updated : The time of the last activity from this session.
Updated time.Time `json:"updated,omitempty"`
}
@ -54,16 +53,16 @@ func NewDeviceSession(SessionId string) *DeviceSession {
return s
}
// ActiveWebSession : Information on active web sessions
// ActiveWebSession : Information on active web sessions.
type ActiveWebSession struct {
DeviceSession
// UserAgent : Information on the hosting device
// UserAgent : Information on the hosting device.
UserAgent string `json:"user_agent"`
// Os : Information on the hosting operating system
// Os : Information on the hosting operating system.
Os string `json:"os"`
// Browser : Information on the browser used for this web session
// Browser : Information on the browser used for this web session.
Browser string `json:"browser"`
// Expires : The time this session expires
// Expires : The time this session expires.
Expires time.Time `json:"expires,omitempty"`
}
@ -77,34 +76,6 @@ func NewActiveWebSession(SessionId string, UserAgent string, Os string, Browser
return s
}
// AddPropertyTemplateArg : Arguments for adding property templates.
type AddPropertyTemplateArg struct {
properties.PropertyGroupTemplate
}
// NewAddPropertyTemplateArg returns a new AddPropertyTemplateArg instance
func NewAddPropertyTemplateArg(Name string, Description string, Fields []*properties.PropertyFieldTemplate) *AddPropertyTemplateArg {
s := new(AddPropertyTemplateArg)
s.Name = Name
s.Description = Description
s.Fields = Fields
return s
}
// AddPropertyTemplateResult : has no documentation (yet)
type AddPropertyTemplateResult struct {
// TemplateId : An identifier for property template added by
// `propertiesTemplateAdd`.
TemplateId string `json:"template_id"`
}
// NewAddPropertyTemplateResult returns a new AddPropertyTemplateResult instance
func NewAddPropertyTemplateResult(TemplateId string) *AddPropertyTemplateResult {
s := new(AddPropertyTemplateResult)
s.TemplateId = TemplateId
return s
}
// AdminTier : Describes which team-related admin permissions a user has.
type AdminTier struct {
dropbox.Tagged
@ -118,19 +89,19 @@ const (
AdminTierMemberOnly = "member_only"
)
// ApiApp : Information on linked third party applications
// ApiApp : Information on linked third party applications.
type ApiApp struct {
// AppId : The application unique id
// AppId : The application unique id.
AppId string `json:"app_id"`
// AppName : The application name
// AppName : The application name.
AppName string `json:"app_name"`
// Publisher : The application publisher name
// Publisher : The application publisher name.
Publisher string `json:"publisher,omitempty"`
// PublisherUrl : The publisher's URL
// PublisherUrl : The publisher's URL.
PublisherUrl string `json:"publisher_url,omitempty"`
// Linked : The time this application was linked
// Linked : The time this application was linked.
Linked time.Time `json:"linked,omitempty"`
// IsAppFolder : Whether the linked application uses a dedicated folder
// IsAppFolder : Whether the linked application uses a dedicated folder.
IsAppFolder bool `json:"is_app_folder"`
}
@ -216,11 +187,83 @@ func (u *BaseTeamFolderError) UnmarshalJSON(body []byte) error {
return nil
}
// CustomQuotaError : Error returned by setting member custom quota.
type CustomQuotaError struct {
dropbox.Tagged
}
// Valid tag values for CustomQuotaError
const (
CustomQuotaErrorTooManyUsers = "too_many_users"
CustomQuotaErrorOther = "other"
)
// CustomQuotaResult : User custom quota.
type CustomQuotaResult struct {
dropbox.Tagged
// Success : User's custom quota.
Success *UserCustomQuotaResult `json:"success,omitempty"`
// InvalidUser : Invalid user (not in team).
InvalidUser *UserSelectorArg `json:"invalid_user,omitempty"`
}
// Valid tag values for CustomQuotaResult
const (
CustomQuotaResultSuccess = "success"
CustomQuotaResultInvalidUser = "invalid_user"
CustomQuotaResultOther = "other"
)
// UnmarshalJSON deserializes into a CustomQuotaResult instance
func (u *CustomQuotaResult) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Success : User's custom quota.
Success json.RawMessage `json:"success,omitempty"`
// InvalidUser : Invalid user (not in team).
InvalidUser json.RawMessage `json:"invalid_user,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "success":
err = json.Unmarshal(body, &u.Success)
if err != nil {
return err
}
case "invalid_user":
err = json.Unmarshal(w.InvalidUser, &u.InvalidUser)
if err != nil {
return err
}
}
return nil
}
// CustomQuotaUsersArg : has no documentation (yet)
type CustomQuotaUsersArg struct {
// Users : List of users.
Users []*UserSelectorArg `json:"users"`
}
// NewCustomQuotaUsersArg returns a new CustomQuotaUsersArg instance
func NewCustomQuotaUsersArg(Users []*UserSelectorArg) *CustomQuotaUsersArg {
s := new(CustomQuotaUsersArg)
s.Users = Users
return s
}
// DateRange : Input arguments that can be provided for most reports.
type DateRange struct {
// StartDate : Optional starting date (inclusive)
// StartDate : Optional starting date (inclusive).
StartDate time.Time `json:"start_date,omitempty"`
// EndDate : Optional ending date (exclusive)
// EndDate : Optional ending date (exclusive).
EndDate time.Time `json:"end_date,omitempty"`
}
@ -242,19 +285,19 @@ const (
)
// DesktopClientSession : Information about linked Dropbox desktop client
// sessions
// sessions.
type DesktopClientSession struct {
DeviceSession
// HostName : Name of the hosting desktop
// HostName : Name of the hosting desktop.
HostName string `json:"host_name"`
// ClientType : The Dropbox desktop client type
// ClientType : The Dropbox desktop client type.
ClientType *DesktopPlatform `json:"client_type"`
// ClientVersion : The Dropbox client version
// ClientVersion : The Dropbox client version.
ClientVersion string `json:"client_version"`
// Platform : Information on the hosting platform
// Platform : Information on the hosting platform.
Platform string `json:"platform"`
// IsDeleteOnUnlinkSupported : Whether it's possible to delete all of the
// account files upon unlinking
// account files upon unlinking.
IsDeleteOnUnlinkSupported bool `json:"is_delete_on_unlink_supported"`
}
@ -285,9 +328,9 @@ const (
// DeviceSessionArg : has no documentation (yet)
type DeviceSessionArg struct {
// SessionId : The session id
// SessionId : The session id.
SessionId string `json:"session_id"`
// TeamMemberId : The unique id of the member owning the device
// TeamMemberId : The unique id of the member owning the device.
TeamMemberId string `json:"team_member_id"`
}
@ -1330,7 +1373,7 @@ func (u *HasTeamSharedDropboxValue) UnmarshalJSON(body []byte) error {
// ListMemberAppsArg : has no documentation (yet)
type ListMemberAppsArg struct {
// TeamMemberId : The team member id
// TeamMemberId : The team member id.
TeamMemberId string `json:"team_member_id"`
}
@ -1355,7 +1398,7 @@ const (
// ListMemberAppsResult : has no documentation (yet)
type ListMemberAppsResult struct {
// LinkedApiApps : List of third party applications linked by this team
// member
// member.
LinkedApiApps []*ApiApp `json:"linked_api_apps"`
}
@ -1368,15 +1411,15 @@ func NewListMemberAppsResult(LinkedApiApps []*ApiApp) *ListMemberAppsResult {
// ListMemberDevicesArg : has no documentation (yet)
type ListMemberDevicesArg struct {
// TeamMemberId : The team's member id
// TeamMemberId : The team's member id.
TeamMemberId string `json:"team_member_id"`
// IncludeWebSessions : Whether to list web sessions of the team's member
// IncludeWebSessions : Whether to list web sessions of the team's member.
IncludeWebSessions bool `json:"include_web_sessions"`
// IncludeDesktopClients : Whether to list linked desktop devices of the
// team's member
// team's member.
IncludeDesktopClients bool `json:"include_desktop_clients"`
// IncludeMobileClients : Whether to list linked mobile devices of the
// team's member
// team's member.
IncludeMobileClients bool `json:"include_mobile_clients"`
}
@ -1403,11 +1446,11 @@ const (
// ListMemberDevicesResult : has no documentation (yet)
type ListMemberDevicesResult struct {
// ActiveWebSessions : List of web sessions made by this team member
// ActiveWebSessions : List of web sessions made by this team member.
ActiveWebSessions []*ActiveWebSession `json:"active_web_sessions,omitempty"`
// DesktopClientSessions : List of desktop clients used by this team member
// DesktopClientSessions : List of desktop clients used by this team member.
DesktopClientSessions []*DesktopClientSession `json:"desktop_client_sessions,omitempty"`
// MobileClientSessions : List of mobile client used by this team member
// MobileClientSessions : List of mobile client used by this team member.
MobileClientSessions []*MobileClientSession `json:"mobile_client_sessions,omitempty"`
}
@ -1422,7 +1465,7 @@ type ListMembersAppsArg struct {
// Cursor : At the first call to the `linkedAppsListMembersLinkedApps` the
// cursor shouldn't be passed. Then, if the result of the call includes a
// cursor, the following requests should include the received cursors in
// order to receive the next sub list of the team applications
// order to receive the next sub list of the team applications.
Cursor string `json:"cursor,omitempty"`
}
@ -1432,7 +1475,7 @@ func NewListMembersAppsArg() *ListMembersAppsArg {
return s
}
// ListMembersAppsError : Error returned by `linkedAppsListMembersLinkedApps`
// ListMembersAppsError : Error returned by `linkedAppsListMembersLinkedApps`.
type ListMembersAppsError struct {
dropbox.Tagged
}
@ -1446,7 +1489,7 @@ const (
// ListMembersAppsResult : Information returned by
// `linkedAppsListMembersLinkedApps`.
type ListMembersAppsResult struct {
// Apps : The linked applications of each member of the team
// Apps : The linked applications of each member of the team.
Apps []*MemberLinkedApps `json:"apps"`
// HasMore : If true, then there are more apps available. Pass the cursor to
// `linkedAppsListMembersLinkedApps` to retrieve the rest.
@ -1469,14 +1512,15 @@ type ListMembersDevicesArg struct {
// Cursor : At the first call to the `devicesListMembersDevices` the cursor
// shouldn't be passed. Then, if the result of the call includes a cursor,
// the following requests should include the received cursors in order to
// receive the next sub list of team devices
// receive the next sub list of team devices.
Cursor string `json:"cursor,omitempty"`
// IncludeWebSessions : Whether to list web sessions of the team members
// IncludeWebSessions : Whether to list web sessions of the team members.
IncludeWebSessions bool `json:"include_web_sessions"`
// IncludeDesktopClients : Whether to list desktop clients of the team
// members
// members.
IncludeDesktopClients bool `json:"include_desktop_clients"`
// IncludeMobileClients : Whether to list mobile clients of the team members
// IncludeMobileClients : Whether to list mobile clients of the team
// members.
IncludeMobileClients bool `json:"include_mobile_clients"`
}
@ -1502,7 +1546,7 @@ const (
// ListMembersDevicesResult : has no documentation (yet)
type ListMembersDevicesResult struct {
// Devices : The devices of each member of the team
// Devices : The devices of each member of the team.
Devices []*MemberDevices `json:"devices"`
// HasMore : If true, then there are more devices available. Pass the cursor
// to `devicesListMembersDevices` to retrieve the rest.
@ -1525,7 +1569,7 @@ type ListTeamAppsArg struct {
// Cursor : At the first call to the `linkedAppsListTeamLinkedApps` the
// cursor shouldn't be passed. Then, if the result of the call includes a
// cursor, the following requests should include the received cursors in
// order to receive the next sub list of the team applications
// order to receive the next sub list of the team applications.
Cursor string `json:"cursor,omitempty"`
}
@ -1535,7 +1579,7 @@ func NewListTeamAppsArg() *ListTeamAppsArg {
return s
}
// ListTeamAppsError : Error returned by `linkedAppsListTeamLinkedApps`
// ListTeamAppsError : Error returned by `linkedAppsListTeamLinkedApps`.
type ListTeamAppsError struct {
dropbox.Tagged
}
@ -1548,7 +1592,7 @@ const (
// ListTeamAppsResult : Information returned by `linkedAppsListTeamLinkedApps`.
type ListTeamAppsResult struct {
// Apps : The linked applications of each member of the team
// Apps : The linked applications of each member of the team.
Apps []*MemberLinkedApps `json:"apps"`
// HasMore : If true, then there are more apps available. Pass the cursor to
// `linkedAppsListTeamLinkedApps` to retrieve the rest.
@ -1571,14 +1615,15 @@ type ListTeamDevicesArg struct {
// Cursor : At the first call to the `devicesListTeamDevices` the cursor
// shouldn't be passed. Then, if the result of the call includes a cursor,
// the following requests should include the received cursors in order to
// receive the next sub list of team devices
// receive the next sub list of team devices.
Cursor string `json:"cursor,omitempty"`
// IncludeWebSessions : Whether to list web sessions of the team members
// IncludeWebSessions : Whether to list web sessions of the team members.
IncludeWebSessions bool `json:"include_web_sessions"`
// IncludeDesktopClients : Whether to list desktop clients of the team
// members
// members.
IncludeDesktopClients bool `json:"include_desktop_clients"`
// IncludeMobileClients : Whether to list mobile clients of the team members
// IncludeMobileClients : Whether to list mobile clients of the team
// members.
IncludeMobileClients bool `json:"include_mobile_clients"`
}
@ -1604,7 +1649,7 @@ const (
// ListTeamDevicesResult : has no documentation (yet)
type ListTeamDevicesResult struct {
// Devices : The devices of each member of the team
// Devices : The devices of each member of the team.
Devices []*MemberDevices `json:"devices"`
// HasMore : If true, then there are more devices available. Pass the cursor
// to `devicesListTeamDevices` to retrieve the rest.
@ -1811,13 +1856,13 @@ func (u *MemberAddResult) UnmarshalJSON(body []byte) error {
// MemberDevices : Information on devices of a team's member.
type MemberDevices struct {
// TeamMemberId : The member unique Id
// TeamMemberId : The member unique Id.
TeamMemberId string `json:"team_member_id"`
// WebSessions : List of web sessions made by this team member
// WebSessions : List of web sessions made by this team member.
WebSessions []*ActiveWebSession `json:"web_sessions,omitempty"`
// DesktopClients : List of desktop clients by this team member
// DesktopClients : List of desktop clients by this team member.
DesktopClients []*DesktopClientSession `json:"desktop_clients,omitempty"`
// MobileClients : List of mobile clients by this team member
// MobileClients : List of mobile clients by this team member.
MobileClients []*MobileClientSession `json:"mobile_clients,omitempty"`
}
@ -1830,10 +1875,10 @@ func NewMemberDevices(TeamMemberId string) *MemberDevices {
// MemberLinkedApps : Information on linked applications of a team member.
type MemberLinkedApps struct {
// TeamMemberId : The member unique Id
// TeamMemberId : The member unique Id.
TeamMemberId string `json:"team_member_id"`
// LinkedApiApps : List of third party applications linked by this team
// member
// member.
LinkedApiApps []*ApiApp `json:"linked_api_apps"`
}
@ -2409,18 +2454,19 @@ const (
MobileClientPlatformOther = "other"
)
// MobileClientSession : Information about linked Dropbox mobile client sessions
// MobileClientSession : Information about linked Dropbox mobile client
// sessions.
type MobileClientSession struct {
DeviceSession
// DeviceName : The device name
// DeviceName : The device name.
DeviceName string `json:"device_name"`
// ClientType : The mobile application type
// ClientType : The mobile application type.
ClientType *MobileClientPlatform `json:"client_type"`
// ClientVersion : The dropbox client version
// ClientVersion : The dropbox client version.
ClientVersion string `json:"client_version,omitempty"`
// OsVersion : The hosting OS version
// OsVersion : The hosting OS version.
OsVersion string `json:"os_version,omitempty"`
// LastCarrier : last carrier used by the device
// LastCarrier : last carrier used by the device.
LastCarrier string `json:"last_carrier,omitempty"`
}
@ -2469,6 +2515,54 @@ const (
NamespaceTypeOther = "other"
)
// RemoveCustomQuotaResult : User result for setting member custom quota.
type RemoveCustomQuotaResult struct {
dropbox.Tagged
// Success : Successfully removed user.
Success *UserSelectorArg `json:"success,omitempty"`
// InvalidUser : Invalid user (not in team).
InvalidUser *UserSelectorArg `json:"invalid_user,omitempty"`
}
// Valid tag values for RemoveCustomQuotaResult
const (
RemoveCustomQuotaResultSuccess = "success"
RemoveCustomQuotaResultInvalidUser = "invalid_user"
RemoveCustomQuotaResultOther = "other"
)
// UnmarshalJSON deserializes into a RemoveCustomQuotaResult instance
func (u *RemoveCustomQuotaResult) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Success : Successfully removed user.
Success json.RawMessage `json:"success,omitempty"`
// InvalidUser : Invalid user (not in team).
InvalidUser json.RawMessage `json:"invalid_user,omitempty"`
}
var w wrap
var err error
if err = json.Unmarshal(body, &w); err != nil {
return err
}
u.Tag = w.Tag
switch u.Tag {
case "success":
err = json.Unmarshal(w.Success, &u.Success)
if err != nil {
return err
}
case "invalid_user":
err = json.Unmarshal(w.InvalidUser, &u.InvalidUser)
if err != nil {
return err
}
}
return nil
}
// RemovedStatus : has no documentation (yet)
type RemovedStatus struct {
// IsRecoverable : True if the removed team member is recoverable.
@ -2487,7 +2581,7 @@ type RevokeDesktopClientArg struct {
DeviceSessionArg
// DeleteOnUnlink : Whether to delete all files of the account (this is
// possible only if supported by the desktop client and will be made the
// next time the client access the account)
// next time the client access the account).
DeleteOnUnlink bool `json:"delete_on_unlink"`
}
@ -2503,11 +2597,11 @@ func NewRevokeDesktopClientArg(SessionId string, TeamMemberId string) *RevokeDes
// RevokeDeviceSessionArg : has no documentation (yet)
type RevokeDeviceSessionArg struct {
dropbox.Tagged
// WebSession : End an active session
// WebSession : End an active session.
WebSession *DeviceSessionArg `json:"web_session,omitempty"`
// DesktopClient : Unlink a linked desktop device
// DesktopClient : Unlink a linked desktop device.
DesktopClient *RevokeDesktopClientArg `json:"desktop_client,omitempty"`
// MobileClient : Unlink a linked mobile device
// MobileClient : Unlink a linked mobile device.
MobileClient *DeviceSessionArg `json:"mobile_client,omitempty"`
}
@ -2522,11 +2616,11 @@ const (
func (u *RevokeDeviceSessionArg) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// WebSession : End an active session
// WebSession : End an active session.
WebSession json.RawMessage `json:"web_session,omitempty"`
// DesktopClient : Unlink a linked desktop device
// DesktopClient : Unlink a linked desktop device.
DesktopClient json.RawMessage `json:"desktop_client,omitempty"`
// MobileClient : Unlink a linked mobile device
// MobileClient : Unlink a linked mobile device.
MobileClient json.RawMessage `json:"mobile_client,omitempty"`
}
var w wrap
@ -2608,9 +2702,9 @@ const (
// RevokeDeviceSessionStatus : has no documentation (yet)
type RevokeDeviceSessionStatus struct {
// Success : Result of the revoking request
// Success : Result of the revoking request.
Success bool `json:"success"`
// ErrorType : The error cause in case of a failure
// ErrorType : The error cause in case of a failure.
ErrorType *RevokeDeviceSessionError `json:"error_type,omitempty"`
}
@ -2623,12 +2717,12 @@ func NewRevokeDeviceSessionStatus(Success bool) *RevokeDeviceSessionStatus {
// RevokeLinkedApiAppArg : has no documentation (yet)
type RevokeLinkedApiAppArg struct {
// AppId : The application's unique id
// AppId : The application's unique id.
AppId string `json:"app_id"`
// TeamMemberId : The unique id of the member owning the device
// TeamMemberId : The unique id of the member owning the device.
TeamMemberId string `json:"team_member_id"`
// KeepAppFolder : Whether to keep the application dedicated folder (in case
// the application uses one)
// the application uses one).
KeepAppFolder bool `json:"keep_app_folder"`
}
@ -2692,9 +2786,9 @@ const (
// RevokeLinkedAppStatus : has no documentation (yet)
type RevokeLinkedAppStatus struct {
// Success : Result of the revoking request
// Success : Result of the revoking request.
Success bool `json:"success"`
// ErrorType : The error cause in case of a failure
// ErrorType : The error cause in case of a failure.
ErrorType *RevokeLinkedAppError `json:"error_type,omitempty"`
}
@ -2705,6 +2799,19 @@ func NewRevokeLinkedAppStatus(Success bool) *RevokeLinkedAppStatus {
return s
}
// SetCustomQuotaArg : has no documentation (yet)
type SetCustomQuotaArg struct {
// UsersAndQuotas : List of users and their custom quotas.
UsersAndQuotas []*UserCustomQuotaArg `json:"users_and_quotas"`
}
// NewSetCustomQuotaArg returns a new SetCustomQuotaArg instance
func NewSetCustomQuotaArg(UsersAndQuotas []*UserCustomQuotaArg) *SetCustomQuotaArg {
s := new(SetCustomQuotaArg)
s.UsersAndQuotas = UsersAndQuotas
return s
}
// StorageBucket : Describes the number of users in a specific storage bucket.
type StorageBucket struct {
// Bucket : The name of the storage bucket. For example, '1G' is a bucket of
@ -3238,8 +3345,7 @@ const (
// TeamNamespacesListArg : has no documentation (yet)
type TeamNamespacesListArg struct {
// Limit : The approximate maximum number of results to return per request.
// This limit may be exceeded.
// Limit : Specifying a value here has no effect.
Limit uint32 `json:"limit"`
}
@ -3322,43 +3428,6 @@ func NewTokenGetAuthenticatedAdminResult(AdminProfile *TeamMemberProfile) *Token
return s
}
// UpdatePropertyTemplateArg : has no documentation (yet)
type UpdatePropertyTemplateArg struct {
// TemplateId : An identifier for property template added by
// `propertiesTemplateAdd`.
TemplateId string `json:"template_id"`
// Name : A display name for the property template. Property template names
// can be up to 256 bytes.
Name string `json:"name,omitempty"`
// Description : Description for new property template. Property template
// descriptions can be up to 1024 bytes.
Description string `json:"description,omitempty"`
// AddFields : This is a list of custom properties to add to the property
// template. There can be up to 64 properties in a single property template.
AddFields []*properties.PropertyFieldTemplate `json:"add_fields,omitempty"`
}
// NewUpdatePropertyTemplateArg returns a new UpdatePropertyTemplateArg instance
func NewUpdatePropertyTemplateArg(TemplateId string) *UpdatePropertyTemplateArg {
s := new(UpdatePropertyTemplateArg)
s.TemplateId = TemplateId
return s
}
// UpdatePropertyTemplateResult : has no documentation (yet)
type UpdatePropertyTemplateResult struct {
// TemplateId : An identifier for property template added by
// `propertiesTemplateAdd`.
TemplateId string `json:"template_id"`
}
// NewUpdatePropertyTemplateResult returns a new UpdatePropertyTemplateResult instance
func NewUpdatePropertyTemplateResult(TemplateId string) *UpdatePropertyTemplateResult {
s := new(UpdatePropertyTemplateResult)
s.TemplateId = TemplateId
return s
}
// UploadApiRateLimitValue : The value for `Feature.upload_api_rate_limit`.
type UploadApiRateLimitValue struct {
dropbox.Tagged
@ -3395,6 +3464,39 @@ func (u *UploadApiRateLimitValue) UnmarshalJSON(body []byte) error {
return nil
}
// UserCustomQuotaArg : User and their required custom quota in GB (1 TB = 1024
// GB).
type UserCustomQuotaArg struct {
// User : has no documentation (yet)
User *UserSelectorArg `json:"user"`
// QuotaGb : has no documentation (yet)
QuotaGb uint32 `json:"quota_gb"`
}
// NewUserCustomQuotaArg returns a new UserCustomQuotaArg instance
func NewUserCustomQuotaArg(User *UserSelectorArg, QuotaGb uint32) *UserCustomQuotaArg {
s := new(UserCustomQuotaArg)
s.User = User
s.QuotaGb = QuotaGb
return s
}
// UserCustomQuotaResult : User and their custom quota in GB (1 TB = 1024 GB).
// No quota returns if the user has no custom quota set.
type UserCustomQuotaResult struct {
// User : has no documentation (yet)
User *UserSelectorArg `json:"user"`
// QuotaGb : has no documentation (yet)
QuotaGb uint32 `json:"quota_gb,omitempty"`
}
// NewUserCustomQuotaResult returns a new UserCustomQuotaResult instance
func NewUserCustomQuotaResult(User *UserSelectorArg) *UserCustomQuotaResult {
s := new(UserCustomQuotaResult)
s.User = User
return s
}
// UserSelectorArg : Argument for selecting a single user, either by
// team_member_id, external_id or email.
type UserSelectorArg struct {

File diff suppressed because it is too large Load Diff

View File

@ -48,6 +48,56 @@ const (
OfficeAddInPolicyOther = "other"
)
// PaperDeploymentPolicy : has no documentation (yet)
type PaperDeploymentPolicy struct {
dropbox.Tagged
}
// Valid tag values for PaperDeploymentPolicy
const (
PaperDeploymentPolicyFull = "full"
PaperDeploymentPolicyPartial = "partial"
PaperDeploymentPolicyOther = "other"
)
// PaperEnabledPolicy : has no documentation (yet)
type PaperEnabledPolicy struct {
dropbox.Tagged
}
// Valid tag values for PaperEnabledPolicy
const (
PaperEnabledPolicyDisabled = "disabled"
PaperEnabledPolicyEnabled = "enabled"
PaperEnabledPolicyUnspecified = "unspecified"
PaperEnabledPolicyOther = "other"
)
// PasswordStrengthPolicy : has no documentation (yet)
type PasswordStrengthPolicy struct {
dropbox.Tagged
}
// Valid tag values for PasswordStrengthPolicy
const (
PasswordStrengthPolicyMinimalRequirements = "minimal_requirements"
PasswordStrengthPolicyModeratePassword = "moderate_password"
PasswordStrengthPolicyStrongPassword = "strong_password"
PasswordStrengthPolicyOther = "other"
)
// RolloutMethod : has no documentation (yet)
type RolloutMethod struct {
dropbox.Tagged
}
// Valid tag values for RolloutMethod
const (
RolloutMethodUnlinkAll = "unlink_all"
RolloutMethodUnlinkMostInactive = "unlink_most_inactive"
RolloutMethodAddMemberToExceptions = "add_member_to_exceptions"
)
// SharedFolderJoinPolicy : Policy governing which shared folders a team member
// can join.
type SharedFolderJoinPolicy struct {
@ -88,6 +138,19 @@ const (
SharedLinkCreatePolicyOther = "other"
)
// SsoPolicy : has no documentation (yet)
type SsoPolicy struct {
dropbox.Tagged
}
// Valid tag values for SsoPolicy
const (
SsoPolicyDisabled = "disabled"
SsoPolicyOptional = "optional"
SsoPolicyRequired = "required"
SsoPolicyOther = "other"
)
// TeamMemberPolicies : Policies governing team members.
type TeamMemberPolicies struct {
// Sharing : Policies governing sharing.

View File

@ -19,7 +19,7 @@
// THE SOFTWARE.
// Package users_common : This namespace contains common data types used within
// the users namespace
// the users namespace.
package users_common
import "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"

View File

@ -1,7 +1,7 @@
#! /usr/bin/env bash
set -euo pipefail
if [[ $# -ne 0 ]]; then
if [[ $# -gt 1 ]]; then
echo "$0: Not expecting any command-line arguments, got $#." 1>&2
exit 1
fi
@ -15,7 +15,7 @@ stone -v -a :all go_types.stoneg.py "$gen_dir" "$spec_dir"/*.stone
stone -v -a :all go_client.stoneg.py "$gen_dir" "$spec_dir"/*.stone
# Update SDK and API spec versions
sdk_version="1.0.0-beta"
sdk_version=${1:-"1.0.0-beta"}
pushd ${spec_dir}
spec_version=$(git rev-parse --short HEAD)
popd

View File

@ -1,7 +1,7 @@
import os
from stone.generator import CodeGenerator
from stone.data_type import (
from stone.backend import CodeBackend
from stone.ir import (
is_void_type,
is_struct_type
)
@ -14,7 +14,7 @@ from go_helpers import (
)
class GoClientGenerator(CodeGenerator):
class GoClientBackend(CodeBackend):
def generate(self, api):
for namespace in api.namespaces.values():
if len(namespace.routes) > 0:
@ -120,7 +120,7 @@ class GoClientGenerator(CodeGenerator):
headers = {}
if not is_void_type(route.arg_data_type):
if host == 'content':
if host == 'content' or style in ['upload', 'download']:
headers["Dropbox-API-Arg"] = "string(b)"
else:
headers["Content-Type"] = '"application/json"'

View File

@ -1,5 +1,5 @@
from stone.api import (ApiNamespace, ApiRoute)
from stone.data_type import (
from stone.ir import (ApiNamespace, ApiRoute)
from stone.ir import (
Boolean,
Float32,
Float64,
@ -15,7 +15,7 @@ from stone.data_type import (
is_struct_type,
Void,
)
from stone.target import helpers
from stone.backends import helpers
HEADER = """\
// Copyright (c) Dropbox, Inc.

View File

@ -23,9 +23,9 @@ package files
import "encoding/json"
type listFolderResult struct {
Entries []metadataUnion `json:"entries"`
Cursor string `json:"cursor"`
HasMore bool `json:"has_more"`
Entries []json.RawMessage `json:"entries"`
Cursor string `json:"cursor"`
HasMore bool `json:"has_more"`
}
// UnmarshalJSON deserializes into a ListFolderResult instance
@ -38,21 +38,18 @@ func (r *ListFolderResult) UnmarshalJSON(b []byte) error {
r.HasMore = l.HasMore
r.Entries = make([]IsMetadata, len(l.Entries))
for i, e := range l.Entries {
switch e.Tag {
case "file":
r.Entries[i] = e.File
case "folder":
r.Entries[i] = e.Folder
case "deleted":
r.Entries[i] = e.Deleted
metadata, err := IsMetadataFromJSON(e)
if err != nil {
return err
}
r.Entries[i] = metadata
}
return nil
}
type searchMatch struct {
MatchType *SearchMatchType `json:"match_type"`
Metadata metadataUnion `json:"metadata"`
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a SearchMatch instance
@ -62,38 +59,51 @@ func (s *SearchMatch) UnmarshalJSON(b []byte) error {
return err
}
s.MatchType = m.MatchType
e := m.Metadata
switch e.Tag {
case "file":
s.Metadata = e.File
case "folder":
s.Metadata = e.Folder
case "deleted":
s.Metadata = e.Deleted
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}
type deleteResult struct {
FileOpsResult
Metadata metadataUnion `json:"metadata"`
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a SearchMatch instance
// UnmarshalJSON deserializes into a DeleteResult instance
func (s *DeleteResult) UnmarshalJSON(b []byte) error {
var m deleteResult
if err := json.Unmarshal(b, &m); err != nil {
return err
}
s.FileOpsResult = m.FileOpsResult
e := m.Metadata
switch e.Tag {
case "file":
s.Metadata = e.File
case "folder":
s.Metadata = e.Folder
case "deleted":
s.Metadata = e.Deleted
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}
type relocationResult struct {
FileOpsResult
// Metadata : Metadata of the relocated object.
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a RelocationResult instance
func (s *RelocationResult) UnmarshalJSON(b []byte) error {
var m relocationResult
if err := json.Unmarshal(b, &m); err != nil {
return err
}
s.FileOpsResult = m.FileOpsResult
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}

View File

@ -1,8 +1,8 @@
import os
import shutil
from stone.generator import CodeGenerator
from stone.data_type import (
from stone.backend import CodeBackend
from stone.ir import (
is_boolean_type,
is_nullable_type,
is_primitive_type,
@ -19,7 +19,7 @@ from go_helpers import (
)
class GoTypesGenerator(CodeGenerator):
class GoTypesBackend(CodeBackend):
def generate(self, api):
rsrc_folder = os.path.join(os.path.dirname(__file__), 'go_rsrc')
shutil.copy(os.path.join(rsrc_folder, 'sdk.go'),