Skip to content

Commit 64af361

Browse files
author
Diwaker Gupta
committed
Update READMEs
1 parent 91a02b4 commit 64af361

File tree

2 files changed

+34
-29
lines changed

2 files changed

+34
-29
lines changed

README.asciidoc

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ WARNING: This SDK is **NOT yet official**. What does this mean?
1818

1919
[source,sh]
2020
----
21-
$ go get github.com/dropbox/dropbox-sdk-go-unofficial
21+
$ go get github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/...
2222
----
2323

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:
2525

26-
* `github.com/dropbox/dropbox-sdk-go-unofficial/users`
27-
* `github.com/dropbox/dropbox-sdk-go-unofficial/files`
28-
* `github.com/dropbox/dropbox-sdk-go-unofficial/sharing`
29-
* `github.com/dropbox/dropbox-sdk-go-unofficial/team`
26+
* `github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/auth`
27+
* `github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files`
28+
* `github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/sharing`
29+
* `github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/team`
30+
* `github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users`
31+
32+
Additionally, the base `github.com/dropbox/dropbox-sdk-go-unofficial/dropbox` package exports some configuration and helper methods.
3033

3134
== Usage
3235

@@ -38,11 +41,12 @@ Once you've created an app, you can get an access token from the app's console.
3841

3942
[source,go]
4043
----
41-
// NOTE: this imports package `dropbox`
42-
import "github.com/dropbox/dropbox-sdk-go-unofficial"
44+
import "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
45+
import "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users"
4346
4447
func main() {
45-
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)
4650
// start making API calls
4751
}
4852
----
@@ -66,7 +70,7 @@ Here's an example:
6670
[source, go]
6771
----
6872
arg := users.NewGetAccountArg()
69-
if resp, err := api.GetAccount(arg); err != nil {
73+
if resp, err := dbx.GetAccount(arg); err != nil {
7074
return err
7175
}
7276
fmt.Printf("Name: %v", resp.Name)
@@ -78,12 +82,16 @@ As described in the https://www.dropbox.com/developers/documentation/http/docume
7882

7983
== Note on using the Teams API
8084

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.
8486

8587
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.
8688

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+
8795
== Caveats
8896

8997
* To re-iterate, this is an **UNOFFICIAL** SDK and thus has no official support from Dropbox

generator/README.asciidoc

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
= Dropbox Go SDK Generator
22

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].
45

56
== Requirements
67

78
* 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]
810
* Requires https://godoc.org/golang.org/x/tools/cmd/goimports[goimports] to fix up imports in the auto-generated code
9-
11+
1012
== Basic Setup
1113

1214
. Clone this repo
1315
. 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`
1517

1618
== Generated Code
1719

1820
=== Structs
1921

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.
2123

2224
----
2325
struct Account <1>
@@ -29,11 +31,6 @@ struct Account <1>
2931
name Name <5>
3032
"Details of a user's name."
3133
----
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
3734

3835
[source,go]
3936
----
@@ -46,10 +43,15 @@ type Account struct { // <1>
4643
Name *Name `json:"name"` // <5>
4744
}
4845
----
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
4951

5052
=== Unions
5153

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.
5355

5456
----
5557
union SpaceAllocation
@@ -113,7 +115,7 @@ func (u *SpaceAllocation) UnmarshalJSON(body []byte) error { // <4>
113115

114116
=== Struct with Enumerated Subtypes
115117

116-
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:
117119

118120
> If a struct enumerates its subtypes, an instance of any subtype will satisfy the type constraint.
119121

@@ -163,8 +165,3 @@ type FileMetadata struct {
163165
<1> Subtype is represented like we represent unions as described above
164166
<2> Common fields are duplicated in subtypes
165167
<3> Subtype specific fields are included as usual in structs
166-
167-
== Known Issues
168-
169-
* Wildcard unions not supported
170-
* Min/max constraints on strings are not enforced

0 commit comments

Comments
 (0)