Skip to content

Commit 4b07b6e

Browse files
koogororajatgoel
authored andcommitted
add map to generator, generate new version
1 parent b9c8233 commit 4b07b6e

File tree

10 files changed

+662
-29
lines changed

10 files changed

+662
-29
lines changed

generator/go_helpers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
unwrap_nullable,
1313
is_composite_type,
1414
is_list_type,
15+
is_map_type,
1516
is_struct_type,
1617
Void,
1718
)
@@ -74,6 +75,10 @@ def fmt_type(data_type, namespace=None, use_interface=False, raw=False):
7475
if raw and not _needs_base_type(data_type.data_type):
7576
return "json.RawMessage"
7677
return '[]%s' % fmt_type(data_type.data_type, namespace, use_interface, raw)
78+
if is_map_type(data_type):
79+
if raw and not _needs_base_type(data_type.data_type):
80+
return "json.RawMessage"
81+
return 'map[string]%s' % fmt_type(data_type.value_data_type, namespace, use_interface, raw)
7782
if raw:
7883
return "json.RawMessage"
7984
type_name = data_type.name
@@ -146,6 +151,8 @@ def _needs_base_type(data_type):
146151
return True
147152
if is_list_type(data_type):
148153
return _needs_base_type(data_type.data_type)
154+
if is_map_type(data_type):
155+
return _needs_base_type(data_type.value_data_type)
149156
return False
150157

151158

v6/dropbox/files/client.go

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ type Client interface {
121121
// The folder must be less than 20 GB in size and any single file within
122122
// must be less than 4 GB in size. The resulting zip must have fewer than
123123
// 10,000 total file and folder entries, including the top level folder. The
124-
// input cannot be a single file.
124+
// input cannot be a single file. Note: this endpoint does not support HTTP
125+
// range requests.
125126
DownloadZip(arg *DownloadZipArg) (res *DownloadZipResult, content io.ReadCloser, err error)
126127
// Export : Export a file from a user's Dropbox. This route only supports
127128
// exporting files that cannot be downloaded directly and whose
@@ -331,8 +332,9 @@ type Client interface {
331332
// Duplicate results may be returned across pages. Some results may not be
332333
// returned.
333334
SearchContinueV2(arg *SearchV2ContinueArg) (res *SearchV2Result, err error)
334-
// TagsAdd : Add a tag to an item. A tag is a string. No more than 20 tags
335-
// can be added to a given item.
335+
// TagsAdd : Add a tag to an item. A tag is a string. The strings are
336+
// automatically converted to lowercase letters. No more than 20 tags can be
337+
// added to a given item.
336338
TagsAdd(arg *AddTagArg) (err error)
337339
// TagsGet : Get list of tags assigned to items.
338340
TagsGet(arg *GetTagsArg) (res *GetTagsResult, err error)
@@ -449,6 +451,13 @@ type Client interface {
449451
// `uploadSessionAppend` with `UploadSessionStartArg.close` to true, that
450452
// may contain any remaining data).
451453
UploadSessionStart(arg *UploadSessionStartArg, content io.Reader) (res *UploadSessionStartResult, err error)
454+
// UploadSessionStartBatch : This route starts batch of upload_sessions.
455+
// Please refer to `upload_session/start` usage. Calls to this endpoint will
456+
// count as data transport calls for any Dropbox Business teams with a limit
457+
// on the number of data transport calls allowed per month. For more
458+
// information, see the `Data transport limit page`
459+
// <https://www.dropbox.com/developers/reference/data-transport-limit>.
460+
UploadSessionStartBatch(arg *UploadSessionStartBatchArg) (res *UploadSessionStartBatchResult, err error)
452461
}
453462

454463
type apiImpl dropbox.Context
@@ -3107,6 +3116,44 @@ func (dbx *apiImpl) UploadSessionStart(arg *UploadSessionStartArg, content io.Re
31073116
return
31083117
}
31093118

3119+
//UploadSessionStartBatchAPIError is an error-wrapper for the upload_session/start_batch route
3120+
type UploadSessionStartBatchAPIError struct {
3121+
dropbox.APIError
3122+
EndpointError struct{} `json:"error"`
3123+
}
3124+
3125+
func (dbx *apiImpl) UploadSessionStartBatch(arg *UploadSessionStartBatchArg) (res *UploadSessionStartBatchResult, err error) {
3126+
req := dropbox.Request{
3127+
Host: "api",
3128+
Namespace: "files",
3129+
Route: "upload_session/start_batch",
3130+
Auth: "user",
3131+
Style: "rpc",
3132+
Arg: arg,
3133+
ExtraHeaders: nil,
3134+
}
3135+
3136+
var resp []byte
3137+
var respBody io.ReadCloser
3138+
resp, respBody, err = (*dropbox.Context)(dbx).Execute(req, nil)
3139+
if err != nil {
3140+
var appErr UploadSessionStartBatchAPIError
3141+
err = auth.ParseError(err, &appErr)
3142+
if err == &appErr {
3143+
err = appErr
3144+
}
3145+
return
3146+
}
3147+
3148+
err = json.Unmarshal(resp, &res)
3149+
if err != nil {
3150+
return
3151+
}
3152+
3153+
_ = respBody
3154+
return
3155+
}
3156+
31103157
// New returns a Client implementation for this namespace
31113158
func New(c dropbox.Config) Client {
31123159
ctx := apiImpl(dropbox.NewContext(c))

v6/dropbox/files/types.go

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import (
3434
type AddTagArg struct {
3535
// Path : Path to the item to be tagged.
3636
Path string `json:"path"`
37-
// TagText : The value of the tag to add.
37+
// TagText : The value of the tag to add. Will be automatically converted to
38+
// lowercase letters.
3839
TagText string `json:"tag_text"`
3940
}
4041

@@ -923,6 +924,8 @@ type Metadata struct {
923924
// `FileSharingInfo.parent_shared_folder_id` or
924925
// `FolderSharingInfo.parent_shared_folder_id` instead.
925926
ParentSharedFolderId string `json:"parent_shared_folder_id,omitempty"`
927+
// PreviewUrl : The preview URL of the file.
928+
PreviewUrl string `json:"preview_url,omitempty"`
926929
}
927930

928931
// NewMetadata returns a new Metadata instance
@@ -3552,7 +3555,8 @@ func (u *RelocationResult) UnmarshalJSON(b []byte) error {
35523555
type RemoveTagArg struct {
35533556
// Path : Path to the item to tag.
35543557
Path string `json:"path"`
3555-
// TagText : The tag to remove.
3558+
// TagText : The tag to remove. Will be automatically converted to lowercase
3559+
// letters.
35563560
TagText string `json:"tag_text"`
35573561
}
35583562

@@ -4087,6 +4091,8 @@ type SearchOptions struct {
40874091
// FileCategories : Restricts search to only the file categories specified.
40884092
// Only supported for active file search.
40894093
FileCategories []*FileCategory `json:"file_categories,omitempty"`
4094+
// AccountId : Restricts results to the given account id.
4095+
AccountId string `json:"account_id,omitempty"`
40904096
}
40914097

40924098
// NewSearchOptions returns a new SearchOptions instance
@@ -4546,9 +4552,9 @@ func NewUnlockFileBatchArg(Entries []*UnlockFileArg) *UnlockFileBatchArg {
45464552
// UploadArg : has no documentation (yet)
45474553
type UploadArg struct {
45484554
CommitInfo
4549-
// ContentHash : NOT YET SUPPORTED. A hash of the file content uploaded in
4550-
// this call. If provided and the uploaded content does not match this hash,
4551-
// an error will be returned. For more information see our `Content hash`
4555+
// ContentHash : A hash of the file content uploaded in this call. If
4556+
// provided and the uploaded content does not match this hash, an error will
4557+
// be returned. For more information see our `Content hash`
45524558
// <https://www.dropbox.com/developers/reference/content-hash> page.
45534559
ContentHash string `json:"content_hash,omitempty"`
45544560
}
@@ -4618,9 +4624,9 @@ type UploadSessionAppendArg struct {
46184624
// won't be able to call `uploadSessionAppend` anymore with the current
46194625
// session.
46204626
Close bool `json:"close"`
4621-
// ContentHash : NOT YET SUPPORTED. A hash of the file content uploaded in
4622-
// this call. If provided and the uploaded content does not match this hash,
4623-
// an error will be returned. For more information see our `Content hash`
4627+
// ContentHash : A hash of the file content uploaded in this call. If
4628+
// provided and the uploaded content does not match this hash, an error will
4629+
// be returned. For more information see our `Content hash`
46244630
// <https://www.dropbox.com/developers/reference/content-hash> page.
46254631
ContentHash string `json:"content_hash,omitempty"`
46264632
}
@@ -4746,9 +4752,9 @@ type UploadSessionFinishArg struct {
47464752
Cursor *UploadSessionCursor `json:"cursor"`
47474753
// Commit : Contains the path and other optional modifiers for the commit.
47484754
Commit *CommitInfo `json:"commit"`
4749-
// ContentHash : NOT YET SUPPORTED. A hash of the file content uploaded in
4750-
// this call. If provided and the uploaded content does not match this hash,
4751-
// an error will be returned. For more information see our `Content hash`
4755+
// ContentHash : A hash of the file content uploaded in this call. If
4756+
// provided and the uploaded content does not match this hash, an error will
4757+
// be returned. For more information see our `Content hash`
47524758
// <https://www.dropbox.com/developers/reference/content-hash> page.
47534759
ContentHash string `json:"content_hash,omitempty"`
47544760
}
@@ -4998,9 +5004,9 @@ type UploadSessionStartArg struct {
49985004
// SessionType : Type of upload session you want to start. If not specified,
49995005
// default is `UploadSessionType.sequential`.
50005006
SessionType *UploadSessionType `json:"session_type,omitempty"`
5001-
// ContentHash : NOT YET SUPPORTED. A hash of the file content uploaded in
5002-
// this call. If provided and the uploaded content does not match this hash,
5003-
// an error will be returned. For more information see our `Content hash`
5007+
// ContentHash : A hash of the file content uploaded in this call. If
5008+
// provided and the uploaded content does not match this hash, an error will
5009+
// be returned. For more information see our `Content hash`
50045010
// <https://www.dropbox.com/developers/reference/content-hash> page.
50055011
ContentHash string `json:"content_hash,omitempty"`
50065012
}
@@ -5012,6 +5018,36 @@ func NewUploadSessionStartArg() *UploadSessionStartArg {
50125018
return s
50135019
}
50145020

5021+
// UploadSessionStartBatchArg : has no documentation (yet)
5022+
type UploadSessionStartBatchArg struct {
5023+
// SessionType : Type of upload session you want to start. If not specified,
5024+
// default is `UploadSessionType.sequential`.
5025+
SessionType *UploadSessionType `json:"session_type,omitempty"`
5026+
// NumSessions : The number of upload sessions to start.
5027+
NumSessions uint64 `json:"num_sessions"`
5028+
}
5029+
5030+
// NewUploadSessionStartBatchArg returns a new UploadSessionStartBatchArg instance
5031+
func NewUploadSessionStartBatchArg(NumSessions uint64) *UploadSessionStartBatchArg {
5032+
s := new(UploadSessionStartBatchArg)
5033+
s.NumSessions = NumSessions
5034+
return s
5035+
}
5036+
5037+
// UploadSessionStartBatchResult : has no documentation (yet)
5038+
type UploadSessionStartBatchResult struct {
5039+
// SessionIds : A List of unique identifiers for the upload session. Pass
5040+
// each session_id to `uploadSessionAppend` and `uploadSessionFinish`.
5041+
SessionIds []string `json:"session_ids"`
5042+
}
5043+
5044+
// NewUploadSessionStartBatchResult returns a new UploadSessionStartBatchResult instance
5045+
func NewUploadSessionStartBatchResult(SessionIds []string) *UploadSessionStartBatchResult {
5046+
s := new(UploadSessionStartBatchResult)
5047+
s.SessionIds = SessionIds
5048+
return s
5049+
}
5050+
50155051
// UploadSessionStartError : has no documentation (yet)
50165052
type UploadSessionStartError struct {
50175053
dropbox.Tagged

v6/dropbox/openid/client.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright (c) Dropbox, Inc.
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
package openid
22+
23+
import (
24+
"encoding/json"
25+
"io"
26+
27+
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox"
28+
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/auth"
29+
)
30+
31+
// Client interface describes all routes in this namespace
32+
type Client interface {
33+
// Userinfo : This route is used for refreshing the info that is found in
34+
// the id_token during the OIDC flow. This route doesn't require any
35+
// arguments and will use the scopes approved for the given access token.
36+
Userinfo(arg *UserInfoArgs) (res *UserInfoResult, err error)
37+
}
38+
39+
type apiImpl dropbox.Context
40+
41+
//UserinfoAPIError is an error-wrapper for the userinfo route
42+
type UserinfoAPIError struct {
43+
dropbox.APIError
44+
EndpointError *UserInfoError `json:"error"`
45+
}
46+
47+
func (dbx *apiImpl) Userinfo(arg *UserInfoArgs) (res *UserInfoResult, err error) {
48+
req := dropbox.Request{
49+
Host: "api",
50+
Namespace: "openid",
51+
Route: "userinfo",
52+
Auth: "user",
53+
Style: "rpc",
54+
Arg: arg,
55+
ExtraHeaders: nil,
56+
}
57+
58+
var resp []byte
59+
var respBody io.ReadCloser
60+
resp, respBody, err = (*dropbox.Context)(dbx).Execute(req, nil)
61+
if err != nil {
62+
var appErr UserinfoAPIError
63+
err = auth.ParseError(err, &appErr)
64+
if err == &appErr {
65+
err = appErr
66+
}
67+
return
68+
}
69+
70+
err = json.Unmarshal(resp, &res)
71+
if err != nil {
72+
return
73+
}
74+
75+
_ = respBody
76+
return
77+
}
78+
79+
// New returns a Client implementation for this namespace
80+
func New(c dropbox.Config) Client {
81+
ctx := apiImpl(dropbox.NewContext(c))
82+
return &ctx
83+
}

0 commit comments

Comments
 (0)