vendor: update all dependencies to latest versions

This commit is contained in:
Nick Craig-Wood
2018-01-16 13:20:59 +00:00
parent 8e83fb6fb9
commit 7d3a17725d
4878 changed files with 1974213 additions and 201199 deletions
@@ -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:-"4.0.0"}
sdk_version=${1:-"4.2.0"}
pushd ${spec_dir}
spec_version=$(git rev-parse --short HEAD)
popd
@@ -12,6 +12,7 @@ from stone.ir import (
unwrap_nullable,
is_composite_type,
is_list_type,
is_primitive_type,
is_struct_type,
Void,
)
@@ -68,10 +69,14 @@ def _rename_if_reserved(s):
return s
def fmt_type(data_type, namespace=None, use_interface=False):
def fmt_type(data_type, namespace=None, use_interface=False, raw=False):
data_type, nullable = unwrap_nullable(data_type)
if is_list_type(data_type):
return '[]%s' % fmt_type(data_type.data_type, namespace, use_interface)
if raw and is_primitive_type(data_type.data_type):
return "json.RawMessage"
return '[]%s' % fmt_type(data_type.data_type, namespace, use_interface, raw)
if raw:
return "json.RawMessage"
type_name = data_type.name
if use_interface and _needs_base_type(data_type):
type_name = 'Is' + type_name
@@ -1,109 +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 files
import "encoding/json"
type listFolderResult struct {
Entries []json.RawMessage `json:"entries"`
Cursor string `json:"cursor"`
HasMore bool `json:"has_more"`
}
// UnmarshalJSON deserializes into a ListFolderResult instance
func (r *ListFolderResult) UnmarshalJSON(b []byte) error {
var l listFolderResult
if err := json.Unmarshal(b, &l); err != nil {
return err
}
r.Cursor = l.Cursor
r.HasMore = l.HasMore
r.Entries = make([]IsMetadata, len(l.Entries))
for i, e := range l.Entries {
metadata, err := IsMetadataFromJSON(e)
if err != nil {
return err
}
r.Entries[i] = metadata
}
return nil
}
type searchMatch struct {
MatchType *SearchMatchType `json:"match_type"`
Metadata json.RawMessage `json:"metadata"`
}
// UnmarshalJSON deserializes into a SearchMatch instance
func (s *SearchMatch) UnmarshalJSON(b []byte) error {
var m searchMatch
if err := json.Unmarshal(b, &m); err != nil {
return err
}
s.MatchType = m.MatchType
metadata, err := IsMetadataFromJSON(m.Metadata)
if err != nil {
return err
}
s.Metadata = metadata
return nil
}
type deleteResult struct {
FileOpsResult
Metadata json.RawMessage `json:"metadata"`
}
// 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
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
}
@@ -21,6 +21,7 @@
package dropbox
import (
"context"
"fmt"
"io"
"log"
@@ -77,12 +78,12 @@ const (
LogInfo
)
func (l LogLevel) ShouldLog(v LogLevel) bool {
return l > v || l & v == v
func (l LogLevel) shouldLog(v LogLevel) bool {
return l > v || l&v == v
}
func (c *Config) doLog(l LogLevel, format string, v ...interface{}) {
if !c.LogLevel.ShouldLog(l) {
if !c.LogLevel.shouldLog(l) {
return
}
@@ -152,7 +153,7 @@ func NewContext(c Config) Context {
if client == nil {
var conf = &oauth2.Config{Endpoint: OAuthEndpoint(domain)}
tok := &oauth2.Token{AccessToken: c.Token}
client = conf.Client(oauth2.NoContext, tok)
client = conf.Client(context.Background(), tok)
}
headerGenerator := c.HeaderGenerator
@@ -1,49 +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 sharing
import "encoding/json"
type listSharedLinksResult struct {
Links []sharedLinkMetadataUnion `json:"links"`
HasMore bool `json:"has_more"`
Cursor string `json:"cursor,omitempty"`
}
// UnmarshalJSON deserializes into a ListSharedLinksResult instance
func (r *ListSharedLinksResult) UnmarshalJSON(b []byte) error {
var l listSharedLinksResult
if err := json.Unmarshal(b, &l); err != nil {
return err
}
r.Cursor = l.Cursor
r.HasMore = l.HasMore
r.Links = make([]IsSharedLinkMetadata, len(l.Links))
for i, e := range l.Links {
switch e.Tag {
case "file":
r.Links[i] = e.File
case "folder":
r.Links[i] = e.Folder
}
}
return nil
}
@@ -4,6 +4,7 @@ import shutil
from stone.backend import CodeBackend
from stone.ir import (
is_boolean_type,
is_list_type,
is_nullable_type,
is_primitive_type,
is_struct_type,
@@ -16,6 +17,8 @@ from go_helpers import (
fmt_type,
fmt_var,
generate_doc,
needs_base_type,
_needs_base_type
)
@@ -26,10 +29,6 @@ class GoTypesBackend(CodeBackend):
self.target_folder_path)
for namespace in api.namespaces.values():
self._generate_namespace(namespace)
if namespace.name == 'files' or namespace.name == 'sharing':
self.logger.info('Copying metadata.go to files')
shutil.copy(os.path.join(rsrc_folder, namespace.name, 'metadata.go'),
os.path.join(self.target_folder_path, namespace.name))
def _generate_namespace(self, namespace):
file_name = os.path.join(self.target_folder_path, namespace.name,
@@ -90,6 +89,39 @@ class GoTypesBackend(CodeBackend):
self.emit('// ExtraHeaders can be used to pass Range, If-None-Match headers')
self.emit('ExtraHeaders map[string]string `json:"-"`')
self._generate_struct_builder(struct)
self.emit()
if needs_base_type(struct):
self.emit('// UnmarshalJSON deserializes into a %s instance' % struct.name)
with self.block('func (u *%s) UnmarshalJSON(b []byte) error' % struct.name):
with self.block('type wrap struct'):
for field in struct.all_fields:
self._generate_field(field, namespace=struct.namespace,
raw=_needs_base_type(field.data_type))
self.emit('var w wrap')
with self.block('if err := json.Unmarshal(b, &w); err != nil'):
self.emit('return err')
for field in struct.all_fields:
dt = field.data_type
fn = fmt_var(field.name)
tn = fmt_type(dt, namespace=struct.namespace, use_interface=True)
if _needs_base_type(dt):
if is_list_type(dt):
self.emit("u.{0} = make({1}, len(w.{0}))".format(fn, tn))
# Grab the underlying type to get the correct Is...FromJSON method
tn = fmt_type(dt.data_type, namespace=struct.namespace, use_interface=True)
with self.block("for i, e := range w.{0}".format(fn)):
self.emit("v, err := {1}FromJSON(e)".format(fn, tn))
with self.block('if err != nil'):
self.emit('return err')
self.emit("u.{0}[i] = v".format(fn))
else:
self.emit("{0}, err := {1}FromJSON(w.{0})".format(fn, tn))
with self.block('if err != nil'):
self.emit('return err')
self.emit("u.{0} = {0}".format(fn))
else:
self.emit("u.{0} = w.{0}".format(fn))
self.emit('return nil')
def _generate_struct_builder(self, struct):
fields = ["%s %s" % (fmt_var(field.name),
@@ -122,14 +154,11 @@ class GoTypesBackend(CodeBackend):
def _generate_field(self, field, union_field=False, namespace=None, raw=False):
generate_doc(self, field)
field_name = fmt_var(field.name)
type_name = fmt_type(field.data_type, namespace, use_interface=True)
type_name = fmt_type(field.data_type, namespace, use_interface=True, raw=raw)
json_tag = '`json:"%s"`' % field.name
if is_nullable_type(field.data_type) or union_field:
json_tag = '`json:"%s,omitempty"`' % field.name
if raw:
self.emit('%s json.RawMessage %s' % (field_name, json_tag))
else:
self.emit('%s %s %s' % (field_name, type_name, json_tag))
self.emit('%s %s %s' % (field_name, type_name, json_tag))
def _generate_union(self, union):
self._generate_union_helper(union)
@@ -187,8 +216,7 @@ class GoTypesBackend(CodeBackend):
if is_union_type(field.data_type):
self.emit('err = json.Unmarshal(w.{0}, &u.{0})'
.format(field_name))
elif is_struct_type(field.data_type) and \
field.data_type.has_enumerated_subtypes():
elif _needs_base_type(field.data_type):
self.emit("u.{0}, err = Is{1}FromJSON(body)"
.format(field_name, field.data_type.name))
else: