You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.asciidoc
+21-13Lines changed: 21 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,15 +18,18 @@ WARNING: This SDK is **NOT yet official**. What does this mean?
18
18
19
19
[source,sh]
20
20
----
21
-
$ go get github.com/dropbox/dropbox-sdk-go-unofficial
21
+
$ go get github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/...
22
22
----
23
23
24
-
Note that while the import path ends in `dropbox-sdk-go-unofficial`, it actually exports the package `dropbox`. There are additional subpackages, one for each namespace in the https://www.dropbox.com/developers/documentation/http/documentation[API]:
24
+
For most applications, you should just import the relevant namespace(s) only. The SDK exports the following sub-packages:
api := dropbox.Client(token, dropbox.Options{Verbose: true}) // second argument enables verbose logging in the SDK
48
+
config := dropbox.Config{Token: token, Verbose: true} // second arg enables verbose logging in the SDK
49
+
dbx := users.New(config)
46
50
// start making API calls
47
51
}
48
52
----
@@ -66,7 +70,7 @@ Here's an example:
66
70
[source, go]
67
71
----
68
72
arg := users.NewGetAccountArg()
69
-
if resp, err := api.GetAccount(arg); err != nil {
73
+
if resp, err := dbx.GetAccount(arg); err != nil {
70
74
return err
71
75
}
72
76
fmt.Printf("Name: %v", resp.Name)
@@ -78,12 +82,16 @@ As described in the https://www.dropbox.com/developers/documentation/http/docume
78
82
79
83
== Note on using the Teams API
80
84
81
-
All features of the Team API are supported except https://www.dropbox.com/developers/documentation/http/teams#teams-member-file-access[acting on behalf of team members]. This should be available soon.
82
-
83
-
Note that to use the Team API, you will need to create a Dropbox Business App. The OAuth token from this app will _only_ work for the Team API.
85
+
To use the Team API, you will need to create a Dropbox Business App. The OAuth token from this app will _only_ work for the Team API.
84
86
85
87
Please read the https://www.dropbox.com/developers/documentation/http/teams[API docs] carefully to appropriate secure your apps and tokens when using the Team API.
86
88
89
+
== Code Generation
90
+
91
+
This SDK is automatically generated using the public https://github.com/dropbox/dropbox-api-spec[Dropbox API spec]
92
+
and https://github.com/dropbox/stone[Stone]. See this https://github.com/dropbox/dropbox-sdk-go-unofficial/blob/master/generator/README.asciidoc[README]
93
+
for more details on how code is generated.
94
+
87
95
== Caveats
88
96
89
97
* To re-iterate, this is an **UNOFFICIAL** SDK and thus has no official support from Dropbox
Copy file name to clipboardExpand all lines: generator/README.asciidoc
+13-16Lines changed: 13 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,25 @@
1
1
= Dropbox Go SDK Generator
2
2
3
-
This repository is used to generate the (currently private) https://github.com/dropbox/dropbox-sdk-go[Dropbox Go SDK]. It does not contain any auto-generated code.
3
+
This directory contains the https://github.com/dropbox/stone[Stone] code generators
4
+
used to programmatically generate the https://github.com/dropbox/dropbox-sdk-go[Dropbox Go SDK].
4
5
5
6
== Requirements
6
7
7
8
* While not a hard requirement, this repo currently assumes `python3` in the path.
9
+
* Assumes you have already installed https://github.com/dropbox/stone[Stone]
8
10
* Requires https://godoc.org/golang.org/x/tools/cmd/goimports[goimports] to fix up imports in the auto-generated code
9
-
11
+
10
12
== Basic Setup
11
13
12
14
. Clone this repo
13
15
. Run `git submodule init` followed by `git submodule update`
14
-
. Run `./codegen.sh` to generate code under `$GOPATH/src/github.com/dropbox/dropbox-sdk-go`
16
+
. Run `./generate-sdk.sh` to generate code under `../dropbox`
15
17
16
18
== Generated Code
17
19
18
20
=== Structs
19
21
20
-
Babel https://github.com/braincore/babel-docs/blob/master/doc/lang_ref.rst#struct[structs] are represented as Go https://gobyexample.com/structs[structs] in a relatively straigh-forward manner.
22
+
Stone https://github.com/dropbox/stone/blob/master/doc/lang_ref.rst#struct[structs] are represented as Go https://gobyexample.com/structs[structs] in a relatively straight-forward manner.
21
23
22
24
----
23
25
struct Account <1>
@@ -29,11 +31,6 @@ struct Account <1>
29
31
name Name <5>
30
32
"Details of a user's name."
31
33
----
32
-
<1> A struct is defined as a Go struct
33
-
<2> The documentation shows up before the struct definition
34
-
<3> Each struct member is exported and also gets assigned the correct json tag. The latter is used for serializing requests and deserializing responses.
35
-
<4> Member documentation appears above the member definition
36
-
<5> Non-primitive types are represented as pointers to the corresponding type
37
34
38
35
[source,go]
39
36
----
@@ -46,10 +43,15 @@ type Account struct { // <1>
46
43
Name *Name `json:"name"` // <5>
47
44
}
48
45
----
46
+
<1> A struct is defined as a Go struct
47
+
<2> The documentation shows up before the struct definition
48
+
<3> Each struct member is exported and also gets assigned the correct json tag. The latter is used for serializing requests and deserializing responses.
49
+
<4> Member documentation appears above the member definition
50
+
<5> Non-primitive types are represented as pointers to the corresponding type
49
51
50
52
=== Unions
51
53
52
-
Babel https://github.com/braincore/babel-docs/blob/master/doc/lang_ref.rst#union[unions] are bit more complex as Go doesn't have native support for union types (tagged or otherwise). We declare a union as a Go struct with all the possible fields as pointer types, and then use the tag value to populate the correct field during deserialization. This necessitates the use of an intermedia wrapper struct for the deserialization to work correctly, see below for a concrete example.
54
+
Stone https://github.com/dropbox/stone/blob/master/doc/lang_ref.rst#union[unions] are bit more complex as Go doesn't have native support for union types (tagged or otherwise). We declare a union as a Go struct with all the possible fields as pointer types, and then use the tag value to populate the correct field during deserialization. This necessitates the use of an intermedia wrapper struct for the deserialization to work correctly, see below for a concrete example.
Per the https://github.com/braincore/babel-docs/blob/master/doc/lang_ref.rst#struct-with-enumerated-subtypes[spec], structs with enumerated subtypes are a mechanism of inheritance:
118
+
Per the https://github.com/dropbox/stone/blob/master/doc/lang_ref.rst#struct-polymorphism[spec], structs with enumerated subtypes are a mechanism of inheritance:
117
119
118
120
> If a struct enumerates its subtypes, an instance of any subtype will satisfy the type constraint.
119
121
@@ -163,8 +165,3 @@ type FileMetadata struct {
163
165
<1> Subtype is represented like we represent unions as described above
164
166
<2> Common fields are duplicated in subtypes
165
167
<3> Subtype specific fields are included as usual in structs
0 commit comments