This commit is contained in:
bel
2020-01-13 03:37:51 +00:00
commit c8eb52f9ba
2023 changed files with 702080 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
Copyright (c) 2009-2016 Dropbox Inc., http://www.dropbox.com/
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.

View File

@@ -0,0 +1,160 @@
// 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 async : has no documentation (yet)
package async
import (
"encoding/json"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
)
// LaunchResultBase : Result returned by methods that launch an asynchronous
// job. A method who may either launch an asynchronous job, or complete the
// request synchronously, can use this union by extending it, and adding a
// 'complete' field with the type of the synchronous response. See
// `LaunchEmptyResult` for an example.
type LaunchResultBase struct {
dropbox.Tagged
// AsyncJobId : This response indicates that the processing is asynchronous.
// The string is an id that can be used to obtain the status of the
// asynchronous job.
AsyncJobId string `json:"async_job_id,omitempty"`
}
// Valid tag values for LaunchResultBase
const (
LaunchResultBaseAsyncJobId = "async_job_id"
)
// UnmarshalJSON deserializes into a LaunchResultBase instance
func (u *LaunchResultBase) 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 "async_job_id":
err = json.Unmarshal(body, &u.AsyncJobId)
if err != nil {
return err
}
}
return nil
}
// LaunchEmptyResult : Result returned by methods that may either launch an
// asynchronous job or complete synchronously. Upon synchronous completion of
// the job, no additional information is returned.
type LaunchEmptyResult struct {
dropbox.Tagged
// AsyncJobId : This response indicates that the processing is asynchronous.
// The string is an id that can be used to obtain the status of the
// asynchronous job.
AsyncJobId string `json:"async_job_id,omitempty"`
}
// Valid tag values for LaunchEmptyResult
const (
LaunchEmptyResultAsyncJobId = "async_job_id"
LaunchEmptyResultComplete = "complete"
)
// UnmarshalJSON deserializes into a LaunchEmptyResult instance
func (u *LaunchEmptyResult) 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 "async_job_id":
err = json.Unmarshal(body, &u.AsyncJobId)
if err != nil {
return err
}
}
return nil
}
// PollArg : Arguments for methods that poll the status of an asynchronous job.
type PollArg struct {
// AsyncJobId : Id of the asynchronous job. This is the value of a response
// returned from the method that launched the job.
AsyncJobId string `json:"async_job_id"`
}
// NewPollArg returns a new PollArg instance
func NewPollArg(AsyncJobId string) *PollArg {
s := new(PollArg)
s.AsyncJobId = AsyncJobId
return s
}
// PollResultBase : Result returned by methods that poll for the status of an
// asynchronous job. Unions that extend this union should add a 'complete' field
// with a type of the information returned upon job completion. See
// `PollEmptyResult` for an example.
type PollResultBase struct {
dropbox.Tagged
}
// Valid tag values for PollResultBase
const (
PollResultBaseInProgress = "in_progress"
)
// PollEmptyResult : Result returned by methods that poll for the status of an
// asynchronous job. Upon completion of the job, no additional information is
// returned.
type PollEmptyResult struct {
dropbox.Tagged
}
// Valid tag values for PollEmptyResult
const (
PollEmptyResultInProgress = "in_progress"
PollEmptyResultComplete = "complete"
)
// PollError : Error returned by methods for polling the status of asynchronous
// job.
type PollError struct {
dropbox.Tagged
}
// Valid tag values for PollError
const (
PollErrorInvalidAsyncJobId = "invalid_async_job_id"
PollErrorInternalError = "internal_error"
PollErrorOther = "other"
)

View File

@@ -0,0 +1,238 @@
// 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 common : has no documentation (yet)
package common
import (
"encoding/json"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
)
// PathRoot : has no documentation (yet)
type PathRoot struct {
dropbox.Tagged
// Root : Paths are relative to the authenticating user's root namespace
// (This results in `PathRootError.invalid_root` if the user's root
// namespace has changed.).
Root string `json:"root,omitempty"`
// NamespaceId : Paths are relative to given namespace id (This results in
// `PathRootError.no_permission` if you don't have access to this
// namespace.).
NamespaceId string `json:"namespace_id,omitempty"`
}
// Valid tag values for PathRoot
const (
PathRootHome = "home"
PathRootRoot = "root"
PathRootNamespaceId = "namespace_id"
PathRootOther = "other"
)
// UnmarshalJSON deserializes into a PathRoot instance
func (u *PathRoot) 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 "root":
err = json.Unmarshal(body, &u.Root)
if err != nil {
return err
}
case "namespace_id":
err = json.Unmarshal(body, &u.NamespaceId)
if err != nil {
return err
}
}
return nil
}
// PathRootError : has no documentation (yet)
type PathRootError struct {
dropbox.Tagged
// InvalidRoot : The root namespace id in Dropbox-API-Path-Root header is
// not valid. The value of this error is use's latest root info.
InvalidRoot IsRootInfo `json:"invalid_root,omitempty"`
}
// Valid tag values for PathRootError
const (
PathRootErrorInvalidRoot = "invalid_root"
PathRootErrorNoPermission = "no_permission"
PathRootErrorOther = "other"
)
// UnmarshalJSON deserializes into a PathRootError instance
func (u *PathRootError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// InvalidRoot : The root namespace id in Dropbox-API-Path-Root header
// is not valid. The value of this error is use's latest root info.
InvalidRoot json.RawMessage `json:"invalid_root,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 "invalid_root":
u.InvalidRoot, err = IsRootInfoFromJSON(body)
if err != nil {
return err
}
}
return nil
}
// RootInfo : Information about current user's root.
type RootInfo struct {
// RootNamespaceId : The namespace ID for user's root namespace. It will be
// the namespace ID of the shared team root if the user is member of a team
// with a separate team root. Otherwise it will be same as
// `RootInfo.home_namespace_id`.
RootNamespaceId string `json:"root_namespace_id"`
// HomeNamespaceId : The namespace ID for user's home namespace.
HomeNamespaceId string `json:"home_namespace_id"`
}
// NewRootInfo returns a new RootInfo instance
func NewRootInfo(RootNamespaceId string, HomeNamespaceId string) *RootInfo {
s := new(RootInfo)
s.RootNamespaceId = RootNamespaceId
s.HomeNamespaceId = HomeNamespaceId
return s
}
// IsRootInfo is the interface type for RootInfo and its subtypes
type IsRootInfo interface {
IsRootInfo()
}
// IsRootInfo implements the IsRootInfo interface
func (u *RootInfo) IsRootInfo() {}
type rootInfoUnion struct {
dropbox.Tagged
// Team : has no documentation (yet)
Team *TeamRootInfo `json:"team,omitempty"`
// User : has no documentation (yet)
User *UserRootInfo `json:"user,omitempty"`
}
// Valid tag values for RootInfo
const (
RootInfoTeam = "team"
RootInfoUser = "user"
)
// UnmarshalJSON deserializes into a rootInfoUnion instance
func (u *rootInfoUnion) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Team : has no documentation (yet)
Team json.RawMessage `json:"team,omitempty"`
// User : has no documentation (yet)
User json.RawMessage `json:"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 "team":
err = json.Unmarshal(body, &u.Team)
if err != nil {
return err
}
case "user":
err = json.Unmarshal(body, &u.User)
if err != nil {
return err
}
}
return nil
}
// IsRootInfoFromJSON converts JSON to a concrete IsRootInfo instance
func IsRootInfoFromJSON(data []byte) (IsRootInfo, error) {
var t rootInfoUnion
if err := json.Unmarshal(data, &t); err != nil {
return nil, err
}
switch t.Tag {
case "team":
return t.Team, nil
case "user":
return t.User, nil
}
return nil, nil
}
// TeamRootInfo : Root info when user is member of a team with a separate root
// namespace ID.
type TeamRootInfo struct {
RootInfo
// HomePath : The path for user's home directory under the shared team root.
HomePath string `json:"home_path"`
}
// NewTeamRootInfo returns a new TeamRootInfo instance
func NewTeamRootInfo(RootNamespaceId string, HomeNamespaceId string, HomePath string) *TeamRootInfo {
s := new(TeamRootInfo)
s.RootNamespaceId = RootNamespaceId
s.HomeNamespaceId = HomeNamespaceId
s.HomePath = HomePath
return s
}
// UserRootInfo : Root info when user is not member of a team or the user is a
// member of a team and the team does not have a separate root namespace.
type UserRootInfo struct {
RootInfo
}
// NewUserRootInfo returns a new UserRootInfo instance
func NewUserRootInfo(RootNamespaceId string, HomeNamespaceId string) *UserRootInfo {
s := new(UserRootInfo)
s.RootNamespaceId = RootNamespaceId
s.HomeNamespaceId = HomeNamespaceId
return s
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,213 @@
// 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 dropbox
import (
"fmt"
"io"
"log"
"net/http"
"golang.org/x/net/context"
"golang.org/x/oauth2"
)
const (
apiVersion = 2
defaultDomain = ".dropboxapi.com"
hostAPI = "api"
hostContent = "content"
hostNotify = "notify"
sdkVersion = "4.2.0"
specVersion = "222ba8c"
)
// Version returns the current SDK version and API Spec version
func Version() (string, string) {
return sdkVersion, specVersion
}
// Config contains parameters for configuring the SDK.
type Config struct {
// OAuth2 access token
Token string
// Logging level for SDK generated logs
LogLevel LogLevel
// Logging target for verbose SDK logging
Logger *log.Logger
// Used with APIs that support operations as another user
AsMemberID string
// No need to set -- for testing only
Domain string
// No need to set -- for testing only
Client *http.Client
// No need to set -- for testing only
HeaderGenerator func(hostType string, style string, namespace string, route string) map[string]string
// No need to set -- for testing only
URLGenerator func(hostType string, style string, namespace string, route string) string
}
// LogLevel defines a type that can set the desired level of logging the SDK will generate.
type LogLevel uint
const (
// LogOff will disable all SDK logging. This is the default log level
LogOff LogLevel = iota * (1 << 8)
// LogDebug will enable detailed SDK debug logs. It will log requests (including arguments),
// response and body contents.
LogDebug
// LogInfo will log SDK request (not including arguments) and responses.
LogInfo
)
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) {
return
}
if c.Logger != nil {
c.Logger.Printf(format, v...)
} else {
log.Printf(format, v...)
}
}
// LogDebug emits a debug level SDK log if config's log level is at least LogDebug
func (c *Config) LogDebug(format string, v ...interface{}) {
c.doLog(LogDebug, format, v...)
}
// LogInfo emits an info level SDK log if config's log level is at least LogInfo
func (c *Config) LogInfo(format string, v ...interface{}) {
c.doLog(LogInfo, format, v...)
}
// Context is the base client context used to implement per-namespace clients.
type Context struct {
Config Config
Client *http.Client
HeaderGenerator func(hostType string, style string, namespace string, route string) map[string]string
URLGenerator func(hostType string, style string, namespace string, route string) string
}
// NewRequest returns an appropriate Request object for the given namespace/route.
func (c *Context) NewRequest(
hostType string,
style string,
authed bool,
namespace string,
route string,
headers map[string]string,
body io.Reader,
) (*http.Request, error) {
url := c.URLGenerator(hostType, style, namespace, route)
req, err := http.NewRequest("POST", url, body)
if err != nil {
return nil, err
}
for k, v := range headers {
req.Header.Add(k, v)
}
for k, v := range c.HeaderGenerator(hostType, style, namespace, route) {
req.Header.Add(k, v)
}
if req.Header.Get("Host") != "" {
req.Host = req.Header.Get("Host")
}
if !authed {
req.Header.Del("Authorization")
}
return req, nil
}
// NewContext returns a new Context with the given Config.
func NewContext(c Config) Context {
domain := c.Domain
if domain == "" {
domain = defaultDomain
}
client := c.Client
if client == nil {
var conf = &oauth2.Config{Endpoint: OAuthEndpoint(domain)}
tok := &oauth2.Token{AccessToken: c.Token}
client = conf.Client(context.Background(), tok)
}
headerGenerator := c.HeaderGenerator
if headerGenerator == nil {
headerGenerator = func(hostType string, style string, namespace string, route string) map[string]string {
return map[string]string{}
}
}
urlGenerator := c.URLGenerator
if urlGenerator == nil {
hostMap := map[string]string{
hostAPI: hostAPI + domain,
hostContent: hostContent + domain,
hostNotify: hostNotify + domain,
}
urlGenerator = func(hostType string, style string, namespace string, route string) string {
fqHost := hostMap[hostType]
return fmt.Sprintf("https://%s/%d/%s/%s", fqHost, apiVersion, namespace, route)
}
}
return Context{c, client, headerGenerator, urlGenerator}
}
// OAuthEndpoint constructs an `oauth2.Endpoint` for the given domain
func OAuthEndpoint(domain string) oauth2.Endpoint {
if domain == "" {
domain = defaultDomain
}
authURL := fmt.Sprintf("https://meta%s/1/oauth2/authorize", domain)
tokenURL := fmt.Sprintf("https://api%s/1/oauth2/token", domain)
if domain == defaultDomain {
authURL = "https://www.dropbox.com/1/oauth2/authorize"
}
return oauth2.Endpoint{AuthURL: authURL, TokenURL: tokenURL}
}
// Tagged is used for tagged unions.
type Tagged struct {
Tag string `json:".tag"`
}
// APIError is the base type for endpoint-specific errors.
type APIError struct {
ErrorSummary string `json:"error_summary"`
}
func (e APIError) Error() string {
return e.ErrorSummary
}
func init() {
// These are not registered in the oauth library by default
oauth2.RegisterBrokenAuthHeaderProvider("https://api.dropboxapi.com")
oauth2.RegisterBrokenAuthHeaderProvider("https://api-dbdev.dev.corp.dropbox.com")
}

View File

@@ -0,0 +1,38 @@
// 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 seen_state : has no documentation (yet)
package seen_state
import "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
// PlatformType : Possible platforms on which a user may view content.
type PlatformType struct {
dropbox.Tagged
}
// Valid tag values for PlatformType
const (
PlatformTypeWeb = "web"
PlatformTypeMobile = "mobile"
PlatformTypeDesktop = "desktop"
PlatformTypeUnknown = "unknown"
PlatformTypeOther = "other"
)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,104 @@
// 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 team_common : has no documentation (yet)
package team_common
import (
"time"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
)
// GroupManagementType : The group type determines how a group is managed.
type GroupManagementType struct {
dropbox.Tagged
}
// Valid tag values for GroupManagementType
const (
GroupManagementTypeUserManaged = "user_managed"
GroupManagementTypeCompanyManaged = "company_managed"
GroupManagementTypeSystemManaged = "system_managed"
GroupManagementTypeOther = "other"
)
// GroupSummary : Information about a group.
type GroupSummary struct {
// GroupName : has no documentation (yet)
GroupName string `json:"group_name"`
// GroupId : has no documentation (yet)
GroupId string `json:"group_id"`
// GroupExternalId : External ID of group. This is an arbitrary ID that an
// admin can attach to a group.
GroupExternalId string `json:"group_external_id,omitempty"`
// MemberCount : The number of members in the group.
MemberCount uint32 `json:"member_count,omitempty"`
// GroupManagementType : Who is allowed to manage the group.
GroupManagementType *GroupManagementType `json:"group_management_type"`
}
// NewGroupSummary returns a new GroupSummary instance
func NewGroupSummary(GroupName string, GroupId string, GroupManagementType *GroupManagementType) *GroupSummary {
s := new(GroupSummary)
s.GroupName = GroupName
s.GroupId = GroupId
s.GroupManagementType = GroupManagementType
return s
}
// GroupType : The group type determines how a group is created and managed.
type GroupType struct {
dropbox.Tagged
}
// Valid tag values for GroupType
const (
GroupTypeTeam = "team"
GroupTypeUserManaged = "user_managed"
GroupTypeOther = "other"
)
// MemberSpaceLimitType : The type of the space limit imposed on a team member.
type MemberSpaceLimitType struct {
dropbox.Tagged
}
// Valid tag values for MemberSpaceLimitType
const (
MemberSpaceLimitTypeOff = "off"
MemberSpaceLimitTypeAlertOnly = "alert_only"
MemberSpaceLimitTypeStopSync = "stop_sync"
MemberSpaceLimitTypeOther = "other"
)
// TimeRange : Time range.
type TimeRange struct {
// StartTime : Optional starting time (inclusive).
StartTime time.Time `json:"start_time,omitempty"`
// EndTime : Optional ending time (exclusive).
EndTime time.Time `json:"end_time,omitempty"`
}
// NewTimeRange returns a new TimeRange instance
func NewTimeRange() *TimeRange {
s := new(TimeRange)
return s
}

View File

@@ -0,0 +1,268 @@
// 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 team_policies : has no documentation (yet)
package team_policies
import "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
// EmmState : has no documentation (yet)
type EmmState struct {
dropbox.Tagged
}
// Valid tag values for EmmState
const (
EmmStateDisabled = "disabled"
EmmStateOptional = "optional"
EmmStateRequired = "required"
EmmStateOther = "other"
)
// GroupCreation : has no documentation (yet)
type GroupCreation struct {
dropbox.Tagged
}
// Valid tag values for GroupCreation
const (
GroupCreationAdminsAndMembers = "admins_and_members"
GroupCreationAdminsOnly = "admins_only"
)
// OfficeAddInPolicy : has no documentation (yet)
type OfficeAddInPolicy struct {
dropbox.Tagged
}
// Valid tag values for OfficeAddInPolicy
const (
OfficeAddInPolicyDisabled = "disabled"
OfficeAddInPolicyEnabled = "enabled"
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 {
dropbox.Tagged
}
// Valid tag values for SharedFolderJoinPolicy
const (
SharedFolderJoinPolicyFromTeamOnly = "from_team_only"
SharedFolderJoinPolicyFromAnyone = "from_anyone"
SharedFolderJoinPolicyOther = "other"
)
// SharedFolderMemberPolicy : Policy governing who can be a member of a folder
// shared by a team member.
type SharedFolderMemberPolicy struct {
dropbox.Tagged
}
// Valid tag values for SharedFolderMemberPolicy
const (
SharedFolderMemberPolicyTeam = "team"
SharedFolderMemberPolicyAnyone = "anyone"
SharedFolderMemberPolicyOther = "other"
)
// SharedLinkCreatePolicy : Policy governing the visibility of shared links.
// This policy can apply to newly created shared links, or all shared links.
type SharedLinkCreatePolicy struct {
dropbox.Tagged
}
// Valid tag values for SharedLinkCreatePolicy
const (
SharedLinkCreatePolicyDefaultPublic = "default_public"
SharedLinkCreatePolicyDefaultTeamOnly = "default_team_only"
SharedLinkCreatePolicyTeamOnly = "team_only"
SharedLinkCreatePolicyOther = "other"
)
// ShowcaseDownloadPolicy : has no documentation (yet)
type ShowcaseDownloadPolicy struct {
dropbox.Tagged
}
// Valid tag values for ShowcaseDownloadPolicy
const (
ShowcaseDownloadPolicyDisabled = "disabled"
ShowcaseDownloadPolicyEnabled = "enabled"
ShowcaseDownloadPolicyOther = "other"
)
// ShowcaseEnabledPolicy : has no documentation (yet)
type ShowcaseEnabledPolicy struct {
dropbox.Tagged
}
// Valid tag values for ShowcaseEnabledPolicy
const (
ShowcaseEnabledPolicyDisabled = "disabled"
ShowcaseEnabledPolicyEnabled = "enabled"
ShowcaseEnabledPolicyOther = "other"
)
// ShowcaseExternalSharingPolicy : has no documentation (yet)
type ShowcaseExternalSharingPolicy struct {
dropbox.Tagged
}
// Valid tag values for ShowcaseExternalSharingPolicy
const (
ShowcaseExternalSharingPolicyDisabled = "disabled"
ShowcaseExternalSharingPolicyEnabled = "enabled"
ShowcaseExternalSharingPolicyOther = "other"
)
// SmartSyncPolicy : has no documentation (yet)
type SmartSyncPolicy struct {
dropbox.Tagged
}
// Valid tag values for SmartSyncPolicy
const (
SmartSyncPolicyLocal = "local"
SmartSyncPolicyOnDemand = "on_demand"
SmartSyncPolicyOther = "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.
Sharing *TeamSharingPolicies `json:"sharing"`
// EmmState : This describes the Enterprise Mobility Management (EMM) state
// for this team. This information can be used to understand if an
// organization is integrating with a third-party EMM vendor to further
// manage and apply restrictions upon the team's Dropbox usage on mobile
// devices. This is a new feature and in the future we'll be adding more new
// fields and additional documentation.
EmmState *EmmState `json:"emm_state"`
// OfficeAddin : The admin policy around the Dropbox Office Add-In for this
// team.
OfficeAddin *OfficeAddInPolicy `json:"office_addin"`
}
// NewTeamMemberPolicies returns a new TeamMemberPolicies instance
func NewTeamMemberPolicies(Sharing *TeamSharingPolicies, EmmState *EmmState, OfficeAddin *OfficeAddInPolicy) *TeamMemberPolicies {
s := new(TeamMemberPolicies)
s.Sharing = Sharing
s.EmmState = EmmState
s.OfficeAddin = OfficeAddin
return s
}
// TeamSharingPolicies : Policies governing sharing within and outside of the
// team.
type TeamSharingPolicies struct {
// SharedFolderMemberPolicy : Who can join folders shared by team members.
SharedFolderMemberPolicy *SharedFolderMemberPolicy `json:"shared_folder_member_policy"`
// SharedFolderJoinPolicy : Which shared folders team members can join.
SharedFolderJoinPolicy *SharedFolderJoinPolicy `json:"shared_folder_join_policy"`
// SharedLinkCreatePolicy : Who can view shared links owned by team members.
SharedLinkCreatePolicy *SharedLinkCreatePolicy `json:"shared_link_create_policy"`
}
// NewTeamSharingPolicies returns a new TeamSharingPolicies instance
func NewTeamSharingPolicies(SharedFolderMemberPolicy *SharedFolderMemberPolicy, SharedFolderJoinPolicy *SharedFolderJoinPolicy, SharedLinkCreatePolicy *SharedLinkCreatePolicy) *TeamSharingPolicies {
s := new(TeamSharingPolicies)
s.SharedFolderMemberPolicy = SharedFolderMemberPolicy
s.SharedFolderJoinPolicy = SharedFolderJoinPolicy
s.SharedLinkCreatePolicy = SharedLinkCreatePolicy
return s
}
// TwoStepVerificationPolicy : has no documentation (yet)
type TwoStepVerificationPolicy struct {
dropbox.Tagged
}
// Valid tag values for TwoStepVerificationPolicy
const (
TwoStepVerificationPolicyRequireTfaEnable = "require_tfa_enable"
TwoStepVerificationPolicyRequireTfaDisable = "require_tfa_disable"
TwoStepVerificationPolicyOther = "other"
)

View File

@@ -0,0 +1,324 @@
// 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 users
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 {
// GetAccount : Get information about a user's account.
GetAccount(arg *GetAccountArg) (res *BasicAccount, err error)
// GetAccountBatch : Get information about multiple user accounts. At most
// 300 accounts may be queried per request.
GetAccountBatch(arg *GetAccountBatchArg) (res []*BasicAccount, err error)
// GetCurrentAccount : Get information about the current user's account.
GetCurrentAccount() (res *FullAccount, err error)
// GetSpaceUsage : Get the space usage information for the current user's
// account.
GetSpaceUsage() (res *SpaceUsage, err error)
}
type apiImpl dropbox.Context
//GetAccountAPIError is an error-wrapper for the get_account route
type GetAccountAPIError struct {
dropbox.APIError
EndpointError *GetAccountError `json:"error"`
}
func (dbx *apiImpl) GetAccount(arg *GetAccountArg) (res *BasicAccount, err error) {
cli := dbx.Client
dbx.Config.LogDebug("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, "users", "get_account", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.LogInfo("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.LogInfo("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.LogDebug("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 GetAccountAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//GetAccountBatchAPIError is an error-wrapper for the get_account_batch route
type GetAccountBatchAPIError struct {
dropbox.APIError
EndpointError *GetAccountBatchError `json:"error"`
}
func (dbx *apiImpl) GetAccountBatch(arg *GetAccountBatchArg) (res []*BasicAccount, err error) {
cli := dbx.Client
dbx.Config.LogDebug("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, "users", "get_account_batch", headers, bytes.NewReader(b))
if err != nil {
return
}
dbx.Config.LogInfo("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.LogInfo("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.LogDebug("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 GetAccountBatchAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//GetCurrentAccountAPIError is an error-wrapper for the get_current_account route
type GetCurrentAccountAPIError struct {
dropbox.APIError
EndpointError struct{} `json:"error"`
}
func (dbx *apiImpl) GetCurrentAccount() (res *FullAccount, 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, "users", "get_current_account", headers, nil)
if err != nil {
return
}
dbx.Config.LogInfo("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.LogInfo("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.LogDebug("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 GetCurrentAccountAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//GetSpaceUsageAPIError is an error-wrapper for the get_space_usage route
type GetSpaceUsageAPIError struct {
dropbox.APIError
EndpointError struct{} `json:"error"`
}
func (dbx *apiImpl) GetSpaceUsage() (res *SpaceUsage, 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, "users", "get_space_usage", headers, nil)
if err != nil {
return
}
dbx.Config.LogInfo("req: %v", req)
resp, err := cli.Do(req)
if err != nil {
return
}
dbx.Config.LogInfo("resp: %v", resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
dbx.Config.LogDebug("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 GetSpaceUsageAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest || resp.StatusCode == http.StatusInternalServerError {
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) Client {
ctx := apiImpl(dropbox.NewContext(c))
return &ctx
}

View File

@@ -0,0 +1,443 @@
// 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 users : This namespace contains endpoints and data types for user
// management.
package users
import (
"encoding/json"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/common"
"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_common"
)
// Account : The amount of detail revealed about an account depends on the user
// being queried and the user making the query.
type Account struct {
// AccountId : The user's unique Dropbox ID.
AccountId string `json:"account_id"`
// Name : Details of a user's name.
Name *Name `json:"name"`
// Email : The user's e-mail address. Do not rely on this without checking
// the `email_verified` field. Even then, it's possible that the user has
// since lost access to their e-mail.
Email string `json:"email"`
// EmailVerified : Whether the user has verified their e-mail address.
EmailVerified bool `json:"email_verified"`
// ProfilePhotoUrl : URL for the photo representing the user, if one is set.
ProfilePhotoUrl string `json:"profile_photo_url,omitempty"`
// Disabled : Whether the user has been disabled.
Disabled bool `json:"disabled"`
}
// NewAccount returns a new Account instance
func NewAccount(AccountId string, Name *Name, Email string, EmailVerified bool, Disabled bool) *Account {
s := new(Account)
s.AccountId = AccountId
s.Name = Name
s.Email = Email
s.EmailVerified = EmailVerified
s.Disabled = Disabled
return s
}
// BasicAccount : Basic information about any account.
type BasicAccount struct {
Account
// IsTeammate : Whether this user is a teammate of the current user. If this
// account is the current user's account, then this will be true.
IsTeammate bool `json:"is_teammate"`
// TeamMemberId : The user's unique team member id. This field will only be
// present if the user is part of a team and `is_teammate` is true.
TeamMemberId string `json:"team_member_id,omitempty"`
}
// NewBasicAccount returns a new BasicAccount instance
func NewBasicAccount(AccountId string, Name *Name, Email string, EmailVerified bool, Disabled bool, IsTeammate bool) *BasicAccount {
s := new(BasicAccount)
s.AccountId = AccountId
s.Name = Name
s.Email = Email
s.EmailVerified = EmailVerified
s.Disabled = Disabled
s.IsTeammate = IsTeammate
return s
}
// FullAccount : Detailed information about the current user's account.
type FullAccount struct {
Account
// Country : The user's two-letter country code, if available. Country codes
// are based on `ISO 3166-1` <http://en.wikipedia.org/wiki/ISO_3166-1>.
Country string `json:"country,omitempty"`
// Locale : The language that the user specified. Locale tags will be `IETF
// language tags` <http://en.wikipedia.org/wiki/IETF_language_tag>.
Locale string `json:"locale"`
// ReferralLink : The user's `referral link`
// <https://www.dropbox.com/referrals>.
ReferralLink string `json:"referral_link"`
// Team : If this account is a member of a team, information about that
// team.
Team *FullTeam `json:"team,omitempty"`
// TeamMemberId : This account's unique team member id. This field will only
// be present if `team` is present.
TeamMemberId string `json:"team_member_id,omitempty"`
// IsPaired : Whether the user has a personal and work account. If the
// current account is personal, then `team` will always be nil, but
// `is_paired` will indicate if a work account is linked.
IsPaired bool `json:"is_paired"`
// AccountType : What type of account this user has.
AccountType *users_common.AccountType `json:"account_type"`
// RootInfo : The root info for this account.
RootInfo common.IsRootInfo `json:"root_info"`
}
// NewFullAccount returns a new FullAccount instance
func NewFullAccount(AccountId string, Name *Name, Email string, EmailVerified bool, Disabled bool, Locale string, ReferralLink string, IsPaired bool, AccountType *users_common.AccountType, RootInfo common.IsRootInfo) *FullAccount {
s := new(FullAccount)
s.AccountId = AccountId
s.Name = Name
s.Email = Email
s.EmailVerified = EmailVerified
s.Disabled = Disabled
s.Locale = Locale
s.ReferralLink = ReferralLink
s.IsPaired = IsPaired
s.AccountType = AccountType
s.RootInfo = RootInfo
return s
}
// UnmarshalJSON deserializes into a FullAccount instance
func (u *FullAccount) UnmarshalJSON(b []byte) error {
type wrap struct {
// AccountId : The user's unique Dropbox ID.
AccountId string `json:"account_id"`
// Name : Details of a user's name.
Name *Name `json:"name"`
// Email : The user's e-mail address. Do not rely on this without
// checking the `email_verified` field. Even then, it's possible that
// the user has since lost access to their e-mail.
Email string `json:"email"`
// EmailVerified : Whether the user has verified their e-mail address.
EmailVerified bool `json:"email_verified"`
// Disabled : Whether the user has been disabled.
Disabled bool `json:"disabled"`
// Locale : The language that the user specified. Locale tags will be
// `IETF language tags`
// <http://en.wikipedia.org/wiki/IETF_language_tag>.
Locale string `json:"locale"`
// ReferralLink : The user's `referral link`
// <https://www.dropbox.com/referrals>.
ReferralLink string `json:"referral_link"`
// IsPaired : Whether the user has a personal and work account. If the
// current account is personal, then `team` will always be nil, but
// `is_paired` will indicate if a work account is linked.
IsPaired bool `json:"is_paired"`
// AccountType : What type of account this user has.
AccountType *users_common.AccountType `json:"account_type"`
// RootInfo : The root info for this account.
RootInfo json.RawMessage `json:"root_info"`
// ProfilePhotoUrl : URL for the photo representing the user, if one is
// set.
ProfilePhotoUrl string `json:"profile_photo_url,omitempty"`
// Country : The user's two-letter country code, if available. Country
// codes are based on `ISO 3166-1`
// <http://en.wikipedia.org/wiki/ISO_3166-1>.
Country string `json:"country,omitempty"`
// Team : If this account is a member of a team, information about that
// team.
Team *FullTeam `json:"team,omitempty"`
// TeamMemberId : This account's unique team member id. This field will
// only be present if `team` is present.
TeamMemberId string `json:"team_member_id,omitempty"`
}
var w wrap
if err := json.Unmarshal(b, &w); err != nil {
return err
}
u.AccountId = w.AccountId
u.Name = w.Name
u.Email = w.Email
u.EmailVerified = w.EmailVerified
u.Disabled = w.Disabled
u.Locale = w.Locale
u.ReferralLink = w.ReferralLink
u.IsPaired = w.IsPaired
u.AccountType = w.AccountType
RootInfo, err := common.IsRootInfoFromJSON(w.RootInfo)
if err != nil {
return err
}
u.RootInfo = RootInfo
u.ProfilePhotoUrl = w.ProfilePhotoUrl
u.Country = w.Country
u.Team = w.Team
u.TeamMemberId = w.TeamMemberId
return nil
}
// Team : Information about a team.
type Team struct {
// Id : The team's unique ID.
Id string `json:"id"`
// Name : The name of the team.
Name string `json:"name"`
}
// NewTeam returns a new Team instance
func NewTeam(Id string, Name string) *Team {
s := new(Team)
s.Id = Id
s.Name = Name
return s
}
// FullTeam : Detailed information about a team.
type FullTeam struct {
Team
// SharingPolicies : Team policies governing sharing.
SharingPolicies *team_policies.TeamSharingPolicies `json:"sharing_policies"`
// OfficeAddinPolicy : Team policy governing the use of the Office Add-In.
OfficeAddinPolicy *team_policies.OfficeAddInPolicy `json:"office_addin_policy"`
}
// NewFullTeam returns a new FullTeam instance
func NewFullTeam(Id string, Name string, SharingPolicies *team_policies.TeamSharingPolicies, OfficeAddinPolicy *team_policies.OfficeAddInPolicy) *FullTeam {
s := new(FullTeam)
s.Id = Id
s.Name = Name
s.SharingPolicies = SharingPolicies
s.OfficeAddinPolicy = OfficeAddinPolicy
return s
}
// GetAccountArg : has no documentation (yet)
type GetAccountArg struct {
// AccountId : A user's account identifier.
AccountId string `json:"account_id"`
}
// NewGetAccountArg returns a new GetAccountArg instance
func NewGetAccountArg(AccountId string) *GetAccountArg {
s := new(GetAccountArg)
s.AccountId = AccountId
return s
}
// GetAccountBatchArg : has no documentation (yet)
type GetAccountBatchArg struct {
// AccountIds : List of user account identifiers. Should not contain any
// duplicate account IDs.
AccountIds []string `json:"account_ids"`
}
// NewGetAccountBatchArg returns a new GetAccountBatchArg instance
func NewGetAccountBatchArg(AccountIds []string) *GetAccountBatchArg {
s := new(GetAccountBatchArg)
s.AccountIds = AccountIds
return s
}
// GetAccountBatchError : has no documentation (yet)
type GetAccountBatchError struct {
dropbox.Tagged
// NoAccount : The value is an account ID specified in
// `GetAccountBatchArg.account_ids` that does not exist.
NoAccount string `json:"no_account,omitempty"`
}
// Valid tag values for GetAccountBatchError
const (
GetAccountBatchErrorNoAccount = "no_account"
GetAccountBatchErrorOther = "other"
)
// UnmarshalJSON deserializes into a GetAccountBatchError instance
func (u *GetAccountBatchError) 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 "no_account":
err = json.Unmarshal(body, &u.NoAccount)
if err != nil {
return err
}
}
return nil
}
// GetAccountError : has no documentation (yet)
type GetAccountError struct {
dropbox.Tagged
}
// Valid tag values for GetAccountError
const (
GetAccountErrorNoAccount = "no_account"
GetAccountErrorOther = "other"
)
// IndividualSpaceAllocation : has no documentation (yet)
type IndividualSpaceAllocation struct {
// Allocated : The total space allocated to the user's account (bytes).
Allocated uint64 `json:"allocated"`
}
// NewIndividualSpaceAllocation returns a new IndividualSpaceAllocation instance
func NewIndividualSpaceAllocation(Allocated uint64) *IndividualSpaceAllocation {
s := new(IndividualSpaceAllocation)
s.Allocated = Allocated
return s
}
// Name : Representations for a person's name to assist with
// internationalization.
type Name struct {
// GivenName : Also known as a first name.
GivenName string `json:"given_name"`
// Surname : Also known as a last name or family name.
Surname string `json:"surname"`
// FamiliarName : Locale-dependent name. In the US, a person's familiar name
// is their `given_name`, but elsewhere, it could be any combination of a
// person's `given_name` and `surname`.
FamiliarName string `json:"familiar_name"`
// DisplayName : A name that can be used directly to represent the name of a
// user's Dropbox account.
DisplayName string `json:"display_name"`
// AbbreviatedName : An abbreviated form of the person's name. Their
// initials in most locales.
AbbreviatedName string `json:"abbreviated_name"`
}
// NewName returns a new Name instance
func NewName(GivenName string, Surname string, FamiliarName string, DisplayName string, AbbreviatedName string) *Name {
s := new(Name)
s.GivenName = GivenName
s.Surname = Surname
s.FamiliarName = FamiliarName
s.DisplayName = DisplayName
s.AbbreviatedName = AbbreviatedName
return s
}
// SpaceAllocation : Space is allocated differently based on the type of
// account.
type SpaceAllocation struct {
dropbox.Tagged
// Individual : The user's space allocation applies only to their individual
// account.
Individual *IndividualSpaceAllocation `json:"individual,omitempty"`
// Team : The user shares space with other members of their team.
Team *TeamSpaceAllocation `json:"team,omitempty"`
}
// Valid tag values for SpaceAllocation
const (
SpaceAllocationIndividual = "individual"
SpaceAllocationTeam = "team"
SpaceAllocationOther = "other"
)
// UnmarshalJSON deserializes into a SpaceAllocation instance
func (u *SpaceAllocation) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Individual : The user's space allocation applies only to their
// individual account.
Individual json.RawMessage `json:"individual,omitempty"`
// Team : The user shares space with other members of their team.
Team json.RawMessage `json:"team,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 "individual":
err = json.Unmarshal(body, &u.Individual)
if err != nil {
return err
}
case "team":
err = json.Unmarshal(body, &u.Team)
if err != nil {
return err
}
}
return nil
}
// SpaceUsage : Information about a user's space usage and quota.
type SpaceUsage struct {
// Used : The user's total space usage (bytes).
Used uint64 `json:"used"`
// Allocation : The user's space allocation.
Allocation *SpaceAllocation `json:"allocation"`
}
// NewSpaceUsage returns a new SpaceUsage instance
func NewSpaceUsage(Used uint64, Allocation *SpaceAllocation) *SpaceUsage {
s := new(SpaceUsage)
s.Used = Used
s.Allocation = Allocation
return s
}
// TeamSpaceAllocation : has no documentation (yet)
type TeamSpaceAllocation struct {
// Used : The total space currently used by the user's team (bytes).
Used uint64 `json:"used"`
// Allocated : The total space allocated to the user's team (bytes).
Allocated uint64 `json:"allocated"`
// UserWithinTeamSpaceAllocated : The total space allocated to the user
// within its team allocated space (0 means that no restriction is imposed
// on the user's quota within its team).
UserWithinTeamSpaceAllocated uint64 `json:"user_within_team_space_allocated"`
// UserWithinTeamSpaceLimitType : The type of the space limit imposed on the
// team member (off, alert_only, stop_sync).
UserWithinTeamSpaceLimitType *team_common.MemberSpaceLimitType `json:"user_within_team_space_limit_type"`
}
// NewTeamSpaceAllocation returns a new TeamSpaceAllocation instance
func NewTeamSpaceAllocation(Used uint64, Allocated uint64, UserWithinTeamSpaceAllocated uint64, UserWithinTeamSpaceLimitType *team_common.MemberSpaceLimitType) *TeamSpaceAllocation {
s := new(TeamSpaceAllocation)
s.Used = Used
s.Allocated = Allocated
s.UserWithinTeamSpaceAllocated = UserWithinTeamSpaceAllocated
s.UserWithinTeamSpaceLimitType = UserWithinTeamSpaceLimitType
return s
}

View File

@@ -0,0 +1,37 @@
// 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 users_common : This namespace contains common data types used within
// the users namespace.
package users_common
import "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
// AccountType : What type of account this user has.
type AccountType struct {
dropbox.Tagged
}
// Valid tag values for AccountType
const (
AccountTypeBasic = "basic"
AccountTypePro = "pro"
AccountTypeBusiness = "business"
)