vendor: add github.com/ncw/dropbox-sdk-go-unofficial and remove github.com/stacktic/dropbox

In due course this will become github.com/dropbox/dropbox-sdk-go-unofficial
when the fate of https://github.com/dropbox/dropbox-sdk-go-unofficial/pull/14
has been decided.
This commit is contained in:
Nick Craig-Wood
2017-05-30 15:49:29 +01:00
parent 9d335eb5cb
commit 178ff62d6a
51 changed files with 36327 additions and 4288 deletions
+132
View File
@@ -0,0 +1,132 @@
// 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/ncw/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
}
// Valid tag values for LaunchEmptyResult
const (
LaunchEmptyResultComplete = "complete"
)
// 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 (
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"
)
+193
View File
@@ -0,0 +1,193 @@
// 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 auth
import (
"bytes"
"encoding/json"
"io/ioutil"
"log"
"net/http"
"github.com/ncw/dropbox-sdk-go-unofficial/dropbox"
)
// Client interface describes all routes in this namespace
type Client interface {
// TokenFromOauth1 : Creates an OAuth 2.0 access token from the supplied
// OAuth 1.0 access token.
TokenFromOauth1(arg *TokenFromOAuth1Arg) (res *TokenFromOAuth1Result, err error)
// TokenRevoke : Disables the access token used to authenticate the call.
TokenRevoke() (err error)
}
type apiImpl dropbox.Context
//TokenFromOauth1APIError is an error-wrapper for the token/from_oauth1 route
type TokenFromOauth1APIError struct {
dropbox.APIError
EndpointError *TokenFromOAuth1Error `json:"error"`
}
func (dbx *apiImpl) TokenFromOauth1(arg *TokenFromOAuth1Arg) (res *TokenFromOAuth1Result, err error) {
cli := dbx.Client
if dbx.Config.Verbose {
log.Printf("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, "auth", "token/from_oauth1", headers, bytes.NewReader(b))
if err != nil {
return
}
if dbx.Config.Verbose {
log.Printf("req: %v", req)
}
resp, err := cli.Do(req)
if dbx.Config.Verbose {
log.Printf("resp: %v", resp)
}
if err != nil {
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
if dbx.Config.Verbose {
log.Printf("body: %s", body)
}
if resp.StatusCode == http.StatusOK {
err = json.Unmarshal(body, &res)
if err != nil {
return
}
return
}
if resp.StatusCode == http.StatusConflict {
var apiError TokenFromOauth1APIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//TokenRevokeAPIError is an error-wrapper for the token/revoke route
type TokenRevokeAPIError struct {
dropbox.APIError
EndpointError struct{} `json:"error"`
}
func (dbx *apiImpl) TokenRevoke() (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, "auth", "token/revoke", headers, nil)
if err != nil {
return
}
if dbx.Config.Verbose {
log.Printf("req: %v", req)
}
resp, err := cli.Do(req)
if dbx.Config.Verbose {
log.Printf("resp: %v", resp)
}
if err != nil {
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
if dbx.Config.Verbose {
log.Printf("body: %s", body)
}
if resp.StatusCode == http.StatusOK {
return
}
if resp.StatusCode == http.StatusConflict {
var apiError TokenRevokeAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
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) *apiImpl {
ctx := apiImpl(dropbox.NewContext(c))
return &ctx
}
+187
View File
@@ -0,0 +1,187 @@
// 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 auth : has no documentation (yet)
package auth
import (
"encoding/json"
"github.com/ncw/dropbox-sdk-go-unofficial/dropbox"
)
// AccessError : Error occurred because the account doesn't have permission to
// access the resource.
type AccessError struct {
dropbox.Tagged
// InvalidAccountType : Current account type cannot access the resource.
InvalidAccountType *InvalidAccountTypeError `json:"invalid_account_type,omitempty"`
// PaperAccessDenied : Current account cannot access Paper.
PaperAccessDenied *PaperAccessError `json:"paper_access_denied,omitempty"`
}
// Valid tag values for AccessError
const (
AccessErrorInvalidAccountType = "invalid_account_type"
AccessErrorPaperAccessDenied = "paper_access_denied"
AccessErrorOther = "other"
)
// UnmarshalJSON deserializes into a AccessError instance
func (u *AccessError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// InvalidAccountType : Current account type cannot access the resource.
InvalidAccountType json.RawMessage `json:"invalid_account_type,omitempty"`
// PaperAccessDenied : Current account cannot access Paper.
PaperAccessDenied json.RawMessage `json:"paper_access_denied,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_account_type":
err = json.Unmarshal(w.InvalidAccountType, &u.InvalidAccountType)
if err != nil {
return err
}
case "paper_access_denied":
err = json.Unmarshal(w.PaperAccessDenied, &u.PaperAccessDenied)
if err != nil {
return err
}
}
return nil
}
// AuthError : Errors occurred during authentication.
type AuthError struct {
dropbox.Tagged
}
// Valid tag values for AuthError
const (
AuthErrorInvalidAccessToken = "invalid_access_token"
AuthErrorInvalidSelectUser = "invalid_select_user"
AuthErrorInvalidSelectAdmin = "invalid_select_admin"
AuthErrorUserSuspended = "user_suspended"
AuthErrorOther = "other"
)
// InvalidAccountTypeError : has no documentation (yet)
type InvalidAccountTypeError struct {
dropbox.Tagged
}
// Valid tag values for InvalidAccountTypeError
const (
InvalidAccountTypeErrorEndpoint = "endpoint"
InvalidAccountTypeErrorFeature = "feature"
InvalidAccountTypeErrorOther = "other"
)
// PaperAccessError : has no documentation (yet)
type PaperAccessError struct {
dropbox.Tagged
}
// Valid tag values for PaperAccessError
const (
PaperAccessErrorPaperDisabled = "paper_disabled"
PaperAccessErrorNotPaperUser = "not_paper_user"
PaperAccessErrorOther = "other"
)
// RateLimitError : Error occurred because the app is being rate limited.
type RateLimitError struct {
// Reason : The reason why the app is being rate limited.
Reason *RateLimitReason `json:"reason"`
// RetryAfter : The number of seconds that the app should wait before making
// another request.
RetryAfter uint64 `json:"retry_after"`
}
// NewRateLimitError returns a new RateLimitError instance
func NewRateLimitError(Reason *RateLimitReason) *RateLimitError {
s := new(RateLimitError)
s.Reason = Reason
s.RetryAfter = 1
return s
}
// RateLimitReason : has no documentation (yet)
type RateLimitReason struct {
dropbox.Tagged
}
// Valid tag values for RateLimitReason
const (
RateLimitReasonTooManyRequests = "too_many_requests"
RateLimitReasonTooManyWriteOperations = "too_many_write_operations"
RateLimitReasonOther = "other"
)
// TokenFromOAuth1Arg : has no documentation (yet)
type TokenFromOAuth1Arg struct {
// Oauth1Token : The supplied OAuth 1.0 access token.
Oauth1Token string `json:"oauth1_token"`
// Oauth1TokenSecret : The token secret associated with the supplied access
// token.
Oauth1TokenSecret string `json:"oauth1_token_secret"`
}
// NewTokenFromOAuth1Arg returns a new TokenFromOAuth1Arg instance
func NewTokenFromOAuth1Arg(Oauth1Token string, Oauth1TokenSecret string) *TokenFromOAuth1Arg {
s := new(TokenFromOAuth1Arg)
s.Oauth1Token = Oauth1Token
s.Oauth1TokenSecret = Oauth1TokenSecret
return s
}
// TokenFromOAuth1Error : has no documentation (yet)
type TokenFromOAuth1Error struct {
dropbox.Tagged
}
// Valid tag values for TokenFromOAuth1Error
const (
TokenFromOAuth1ErrorInvalidOauth1TokenInfo = "invalid_oauth1_token_info"
TokenFromOAuth1ErrorAppIdMismatch = "app_id_mismatch"
TokenFromOAuth1ErrorOther = "other"
)
// TokenFromOAuth1Result : has no documentation (yet)
type TokenFromOAuth1Result struct {
// Oauth2Token : The OAuth 2.0 token generated from the supplied OAuth 1.0
// token.
Oauth2Token string `json:"oauth2_token"`
}
// NewTokenFromOAuth1Result returns a new TokenFromOAuth1Result instance
func NewTokenFromOAuth1Result(Oauth2Token string) *TokenFromOAuth1Result {
s := new(TokenFromOAuth1Result)
s.Oauth2Token = Oauth2Token
return s
}
+132
View File
@@ -0,0 +1,132 @@
// 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/ncw/dropbox-sdk-go-unofficial/dropbox"
)
// InvalidPathRootError : has no documentation (yet)
type InvalidPathRootError struct {
// PathRoot : The latest path root id for user's team if the user is still
// in a team.
PathRoot string `json:"path_root,omitempty"`
}
// NewInvalidPathRootError returns a new InvalidPathRootError instance
func NewInvalidPathRootError() *InvalidPathRootError {
s := new(InvalidPathRootError)
return s
}
// PathRoot : has no documentation (yet)
type PathRoot struct {
dropbox.Tagged
// Team : Paths are relative to the given team directory. (This results in
// `PathRootError.invalid` if the user is not a member of the team
// associated with that path root id.)
Team string `json:"team,omitempty"`
// SharedFolder : Paths are relative to given shared folder id (This results
// in `PathRootError.no_permission` if you don't have access to this shared
// folder.)
SharedFolder string `json:"shared_folder,omitempty"`
}
// Valid tag values for PathRoot
const (
PathRootHome = "home"
PathRootMemberHome = "member_home"
PathRootTeam = "team"
PathRootUserHome = "user_home"
PathRootSharedFolder = "shared_folder"
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 "team":
err = json.Unmarshal(body, &u.Team)
if err != nil {
return err
}
case "shared_folder":
err = json.Unmarshal(body, &u.SharedFolder)
if err != nil {
return err
}
}
return nil
}
// PathRootError : has no documentation (yet)
type PathRootError struct {
dropbox.Tagged
// Invalid : The path root id value in Dropbox-API-Path-Root header is no
// longer valid.
Invalid *InvalidPathRootError `json:"invalid,omitempty"`
}
// Valid tag values for PathRootError
const (
PathRootErrorInvalid = "invalid"
PathRootErrorNoPermission = "no_permission"
PathRootErrorOther = "other"
)
// UnmarshalJSON deserializes into a PathRootError instance
func (u *PathRootError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// Invalid : The path root id value in Dropbox-API-Path-Root header is
// no longer valid.
Invalid json.RawMessage `json:"invalid,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":
err = json.Unmarshal(body, &u.Invalid)
if err != nil {
return err
}
}
return nil
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,75 @@
// 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 []metadataUnion `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 {
switch e.Tag {
case "file":
r.Entries[i] = e.File
case "folder":
r.Entries[i] = e.Folder
case "deleted":
r.Entries[i] = e.Deleted
}
}
return nil
}
type searchMatch struct {
MatchType *SearchMatchType `json:"match_type"`
Metadata metadataUnion `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
e := m.Metadata
switch e.Tag {
case "file":
s.Metadata = e.File
case "folder":
s.Metadata = e.Folder
case "deleted":
s.Metadata = e.Deleted
}
return nil
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+729
View File
@@ -0,0 +1,729 @@
// 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 paper : This namespace contains endpoints and data types for managing
// docs and folders in Dropbox Paper.
package paper
import (
"encoding/json"
"time"
"github.com/ncw/dropbox-sdk-go-unofficial/dropbox"
"github.com/ncw/dropbox-sdk-go-unofficial/dropbox/sharing"
)
// AddMember : has no documentation (yet)
type AddMember struct {
// PermissionLevel : Permission for the user.
PermissionLevel *PaperDocPermissionLevel `json:"permission_level"`
// Member : User which should be added to the Paper doc. Specify only email
// address or Dropbox account ID.
Member *sharing.MemberSelector `json:"member"`
}
// NewAddMember returns a new AddMember instance
func NewAddMember(Member *sharing.MemberSelector) *AddMember {
s := new(AddMember)
s.Member = Member
s.PermissionLevel = &PaperDocPermissionLevel{Tagged: dropbox.Tagged{"edit"}}
return s
}
// RefPaperDoc : has no documentation (yet)
type RefPaperDoc struct {
// DocId : The Paper doc ID.
DocId string `json:"doc_id"`
}
// NewRefPaperDoc returns a new RefPaperDoc instance
func NewRefPaperDoc(DocId string) *RefPaperDoc {
s := new(RefPaperDoc)
s.DocId = DocId
return s
}
// AddPaperDocUser : has no documentation (yet)
type AddPaperDocUser struct {
RefPaperDoc
// Members : User which should be added to the Paper doc. Specify only email
// address or Dropbox account ID.
Members []*AddMember `json:"members"`
// CustomMessage : A personal message that will be emailed to each
// successfully added member.
CustomMessage string `json:"custom_message,omitempty"`
// Quiet : Clients should set this to true if no email message shall be sent
// to added users.
Quiet bool `json:"quiet"`
}
// NewAddPaperDocUser returns a new AddPaperDocUser instance
func NewAddPaperDocUser(DocId string, Members []*AddMember) *AddPaperDocUser {
s := new(AddPaperDocUser)
s.DocId = DocId
s.Members = Members
s.Quiet = false
return s
}
// AddPaperDocUserMemberResult : Per-member result for `docsUsersAdd`.
type AddPaperDocUserMemberResult struct {
// Member : One of specified input members.
Member *sharing.MemberSelector `json:"member"`
// Result : The outcome of the action on this member.
Result *AddPaperDocUserResult `json:"result"`
}
// NewAddPaperDocUserMemberResult returns a new AddPaperDocUserMemberResult instance
func NewAddPaperDocUserMemberResult(Member *sharing.MemberSelector, Result *AddPaperDocUserResult) *AddPaperDocUserMemberResult {
s := new(AddPaperDocUserMemberResult)
s.Member = Member
s.Result = Result
return s
}
// AddPaperDocUserResult : has no documentation (yet)
type AddPaperDocUserResult struct {
dropbox.Tagged
}
// Valid tag values for AddPaperDocUserResult
const (
AddPaperDocUserResultSuccess = "success"
AddPaperDocUserResultUnknownError = "unknown_error"
AddPaperDocUserResultSharingOutsideTeamDisabled = "sharing_outside_team_disabled"
AddPaperDocUserResultDailyLimitReached = "daily_limit_reached"
AddPaperDocUserResultUserIsOwner = "user_is_owner"
AddPaperDocUserResultFailedUserDataRetrieval = "failed_user_data_retrieval"
AddPaperDocUserResultPermissionAlreadyGranted = "permission_already_granted"
AddPaperDocUserResultOther = "other"
)
// Cursor : has no documentation (yet)
type Cursor struct {
// Value : The actual cursor value.
Value string `json:"value"`
// Expiration : Expiration time of `value`. Some cursors might have
// expiration time assigned. This is a UTC value after which the cursor is
// no longer valid and the API starts returning an error. If cursor expires
// a new one needs to be obtained and pagination needs to be restarted. Some
// cursors might be short-lived some cursors might be long-lived. This
// really depends on the sorting type and order, e.g.: 1. on one hand,
// listing docs created by the user, sorted by the created time ascending
// will have undefinite expiration because the results cannot change while
// the iteration is happening. This cursor would be suitable for long term
// polling. 2. on the other hand, listing docs sorted by the last modified
// time will have a very short expiration as docs do get modified very often
// and the modified time can be changed while the iteration is happening
// thus altering the results.
Expiration time.Time `json:"expiration,omitempty"`
}
// NewCursor returns a new Cursor instance
func NewCursor(Value string) *Cursor {
s := new(Cursor)
s.Value = Value
return s
}
// PaperApiBaseError : has no documentation (yet)
type PaperApiBaseError struct {
dropbox.Tagged
}
// Valid tag values for PaperApiBaseError
const (
PaperApiBaseErrorInsufficientPermissions = "insufficient_permissions"
PaperApiBaseErrorOther = "other"
)
// DocLookupError : has no documentation (yet)
type DocLookupError struct {
dropbox.Tagged
}
// Valid tag values for DocLookupError
const (
DocLookupErrorDocNotFound = "doc_not_found"
)
// DocSubscriptionLevel : The subscription level of a Paper doc.
type DocSubscriptionLevel struct {
dropbox.Tagged
}
// Valid tag values for DocSubscriptionLevel
const (
DocSubscriptionLevelDefault = "default"
DocSubscriptionLevelIgnore = "ignore"
DocSubscriptionLevelEvery = "every"
DocSubscriptionLevelNoEmail = "no_email"
)
// ExportFormat : The desired export format of the Paper doc.
type ExportFormat struct {
dropbox.Tagged
}
// Valid tag values for ExportFormat
const (
ExportFormatHtml = "html"
ExportFormatMarkdown = "markdown"
ExportFormatOther = "other"
)
// Folder : Data structure representing a Paper folder.
type Folder struct {
// Id : Paper folder ID. This ID uniquely identifies the folder.
Id string `json:"id"`
// Name : Paper folder name.
Name string `json:"name"`
}
// NewFolder returns a new Folder instance
func NewFolder(Id string, Name string) *Folder {
s := new(Folder)
s.Id = Id
s.Name = Name
return s
}
// FolderSharingPolicyType : The sharing policy of a Paper folder. Note: The
// sharing policy of subfolders is inherited from the root folder.
type FolderSharingPolicyType struct {
dropbox.Tagged
}
// Valid tag values for FolderSharingPolicyType
const (
FolderSharingPolicyTypeTeam = "team"
FolderSharingPolicyTypeInviteOnly = "invite_only"
)
// FolderSubscriptionLevel : The subscription level of a Paper folder.
type FolderSubscriptionLevel struct {
dropbox.Tagged
}
// Valid tag values for FolderSubscriptionLevel
const (
FolderSubscriptionLevelNone = "none"
FolderSubscriptionLevelActivityOnly = "activity_only"
FolderSubscriptionLevelDailyEmails = "daily_emails"
FolderSubscriptionLevelWeeklyEmails = "weekly_emails"
)
// FoldersContainingPaperDoc : Metadata about Paper folders containing the
// specififed Paper doc.
type FoldersContainingPaperDoc struct {
// FolderSharingPolicyType : The sharing policy of the folder containing the
// Paper doc.
FolderSharingPolicyType *FolderSharingPolicyType `json:"folder_sharing_policy_type,omitempty"`
// Folders : The folder path. If present the first folder is the root
// folder.
Folders []*Folder `json:"folders,omitempty"`
}
// NewFoldersContainingPaperDoc returns a new FoldersContainingPaperDoc instance
func NewFoldersContainingPaperDoc() *FoldersContainingPaperDoc {
s := new(FoldersContainingPaperDoc)
return s
}
// InviteeInfoWithPermissionLevel : has no documentation (yet)
type InviteeInfoWithPermissionLevel struct {
// Invitee : Email address invited to the Paper doc.
Invitee *sharing.InviteeInfo `json:"invitee"`
// PermissionLevel : Permission level for the invitee.
PermissionLevel *PaperDocPermissionLevel `json:"permission_level"`
}
// NewInviteeInfoWithPermissionLevel returns a new InviteeInfoWithPermissionLevel instance
func NewInviteeInfoWithPermissionLevel(Invitee *sharing.InviteeInfo, PermissionLevel *PaperDocPermissionLevel) *InviteeInfoWithPermissionLevel {
s := new(InviteeInfoWithPermissionLevel)
s.Invitee = Invitee
s.PermissionLevel = PermissionLevel
return s
}
// ListDocsCursorError : has no documentation (yet)
type ListDocsCursorError struct {
dropbox.Tagged
// CursorError : has no documentation (yet)
CursorError *PaperApiCursorError `json:"cursor_error,omitempty"`
}
// Valid tag values for ListDocsCursorError
const (
ListDocsCursorErrorCursorError = "cursor_error"
ListDocsCursorErrorOther = "other"
)
// UnmarshalJSON deserializes into a ListDocsCursorError instance
func (u *ListDocsCursorError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// CursorError : has no documentation (yet)
CursorError json.RawMessage `json:"cursor_error,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 "cursor_error":
err = json.Unmarshal(w.CursorError, &u.CursorError)
if err != nil {
return err
}
}
return nil
}
// ListPaperDocsArgs : has no documentation (yet)
type ListPaperDocsArgs struct {
// FilterBy : Allows user to specify how the Paper docs should be filtered.
FilterBy *ListPaperDocsFilterBy `json:"filter_by"`
// SortBy : Allows user to specify how the Paper docs should be sorted.
SortBy *ListPaperDocsSortBy `json:"sort_by"`
// SortOrder : Allows user to specify the sort order of the result.
SortOrder *ListPaperDocsSortOrder `json:"sort_order"`
// Limit : Size limit per batch. The maximum number of docs that can be
// retrieved per batch is 1000. Higher value results in invalid arguments
// error.
Limit int32 `json:"limit"`
}
// NewListPaperDocsArgs returns a new ListPaperDocsArgs instance
func NewListPaperDocsArgs() *ListPaperDocsArgs {
s := new(ListPaperDocsArgs)
s.FilterBy = &ListPaperDocsFilterBy{Tagged: dropbox.Tagged{"docs_accessed"}}
s.SortBy = &ListPaperDocsSortBy{Tagged: dropbox.Tagged{"accessed"}}
s.SortOrder = &ListPaperDocsSortOrder{Tagged: dropbox.Tagged{"ascending"}}
s.Limit = 1000
return s
}
// ListPaperDocsContinueArgs : has no documentation (yet)
type ListPaperDocsContinueArgs struct {
// Cursor : The cursor obtained from `docsList` or `docsListContinue`.
// Allows for pagination.
Cursor string `json:"cursor"`
}
// NewListPaperDocsContinueArgs returns a new ListPaperDocsContinueArgs instance
func NewListPaperDocsContinueArgs(Cursor string) *ListPaperDocsContinueArgs {
s := new(ListPaperDocsContinueArgs)
s.Cursor = Cursor
return s
}
// ListPaperDocsFilterBy : has no documentation (yet)
type ListPaperDocsFilterBy struct {
dropbox.Tagged
}
// Valid tag values for ListPaperDocsFilterBy
const (
ListPaperDocsFilterByDocsAccessed = "docs_accessed"
ListPaperDocsFilterByDocsCreated = "docs_created"
ListPaperDocsFilterByOther = "other"
)
// ListPaperDocsResponse : has no documentation (yet)
type ListPaperDocsResponse struct {
// DocIds : The list of Paper doc IDs that can be used to access the given
// Paper docs or supplied to other API methods. The list is sorted in the
// order specified by the initial call to `docsList`.
DocIds []string `json:"doc_ids"`
// Cursor : Pass the cursor into `docsListContinue` to paginate through all
// files. The cursor preserves all properties as specified in the original
// call to `docsList`.
Cursor *Cursor `json:"cursor"`
// HasMore : Will be set to True if a subsequent call with the provided
// cursor to `docsListContinue` returns immediately with some results. If
// set to False please allow some delay before making another call to
// `docsListContinue`.
HasMore bool `json:"has_more"`
}
// NewListPaperDocsResponse returns a new ListPaperDocsResponse instance
func NewListPaperDocsResponse(DocIds []string, Cursor *Cursor, HasMore bool) *ListPaperDocsResponse {
s := new(ListPaperDocsResponse)
s.DocIds = DocIds
s.Cursor = Cursor
s.HasMore = HasMore
return s
}
// ListPaperDocsSortBy : has no documentation (yet)
type ListPaperDocsSortBy struct {
dropbox.Tagged
}
// Valid tag values for ListPaperDocsSortBy
const (
ListPaperDocsSortByAccessed = "accessed"
ListPaperDocsSortByModified = "modified"
ListPaperDocsSortByCreated = "created"
ListPaperDocsSortByOther = "other"
)
// ListPaperDocsSortOrder : has no documentation (yet)
type ListPaperDocsSortOrder struct {
dropbox.Tagged
}
// Valid tag values for ListPaperDocsSortOrder
const (
ListPaperDocsSortOrderAscending = "ascending"
ListPaperDocsSortOrderDescending = "descending"
ListPaperDocsSortOrderOther = "other"
)
// ListUsersCursorError : has no documentation (yet)
type ListUsersCursorError struct {
dropbox.Tagged
// CursorError : has no documentation (yet)
CursorError *PaperApiCursorError `json:"cursor_error,omitempty"`
}
// Valid tag values for ListUsersCursorError
const (
ListUsersCursorErrorDocNotFound = "doc_not_found"
ListUsersCursorErrorCursorError = "cursor_error"
)
// UnmarshalJSON deserializes into a ListUsersCursorError instance
func (u *ListUsersCursorError) UnmarshalJSON(body []byte) error {
type wrap struct {
dropbox.Tagged
// CursorError : has no documentation (yet)
CursorError json.RawMessage `json:"cursor_error,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 "cursor_error":
err = json.Unmarshal(w.CursorError, &u.CursorError)
if err != nil {
return err
}
}
return nil
}
// ListUsersOnFolderArgs : has no documentation (yet)
type ListUsersOnFolderArgs struct {
RefPaperDoc
// Limit : Size limit per batch. The maximum number of users that can be
// retrieved per batch is 1000. Higher value results in invalid arguments
// error.
Limit int32 `json:"limit"`
}
// NewListUsersOnFolderArgs returns a new ListUsersOnFolderArgs instance
func NewListUsersOnFolderArgs(DocId string) *ListUsersOnFolderArgs {
s := new(ListUsersOnFolderArgs)
s.DocId = DocId
s.Limit = 1000
return s
}
// ListUsersOnFolderContinueArgs : has no documentation (yet)
type ListUsersOnFolderContinueArgs struct {
RefPaperDoc
// Cursor : The cursor obtained from `docsFolderUsersList` or
// `docsFolderUsersListContinue`. Allows for pagination.
Cursor string `json:"cursor"`
}
// NewListUsersOnFolderContinueArgs returns a new ListUsersOnFolderContinueArgs instance
func NewListUsersOnFolderContinueArgs(DocId string, Cursor string) *ListUsersOnFolderContinueArgs {
s := new(ListUsersOnFolderContinueArgs)
s.DocId = DocId
s.Cursor = Cursor
return s
}
// ListUsersOnFolderResponse : has no documentation (yet)
type ListUsersOnFolderResponse struct {
// Invitees : List of email addresses that are invited on the Paper folder.
Invitees []*sharing.InviteeInfo `json:"invitees"`
// Users : List of users that are invited on the Paper folder.
Users []*sharing.UserInfo `json:"users"`
// Cursor : Pass the cursor into `docsFolderUsersListContinue` to paginate
// through all users. The cursor preserves all properties as specified in
// the original call to `docsFolderUsersList`.
Cursor *Cursor `json:"cursor"`
// HasMore : Will be set to True if a subsequent call with the provided
// cursor to `docsFolderUsersListContinue` returns immediately with some
// results. If set to False please allow some delay before making another
// call to `docsFolderUsersListContinue`.
HasMore bool `json:"has_more"`
}
// NewListUsersOnFolderResponse returns a new ListUsersOnFolderResponse instance
func NewListUsersOnFolderResponse(Invitees []*sharing.InviteeInfo, Users []*sharing.UserInfo, Cursor *Cursor, HasMore bool) *ListUsersOnFolderResponse {
s := new(ListUsersOnFolderResponse)
s.Invitees = Invitees
s.Users = Users
s.Cursor = Cursor
s.HasMore = HasMore
return s
}
// ListUsersOnPaperDocArgs : has no documentation (yet)
type ListUsersOnPaperDocArgs struct {
RefPaperDoc
// Limit : Size limit per batch. The maximum number of users that can be
// retrieved per batch is 1000. Higher value results in invalid arguments
// error.
Limit int32 `json:"limit"`
// FilterBy : Specify this attribute if you want to obtain users that have
// already accessed the Paper doc.
FilterBy *UserOnPaperDocFilter `json:"filter_by"`
}
// NewListUsersOnPaperDocArgs returns a new ListUsersOnPaperDocArgs instance
func NewListUsersOnPaperDocArgs(DocId string) *ListUsersOnPaperDocArgs {
s := new(ListUsersOnPaperDocArgs)
s.DocId = DocId
s.Limit = 1000
s.FilterBy = &UserOnPaperDocFilter{Tagged: dropbox.Tagged{"shared"}}
return s
}
// ListUsersOnPaperDocContinueArgs : has no documentation (yet)
type ListUsersOnPaperDocContinueArgs struct {
RefPaperDoc
// Cursor : The cursor obtained from `docsUsersList` or
// `docsUsersListContinue`. Allows for pagination.
Cursor string `json:"cursor"`
}
// NewListUsersOnPaperDocContinueArgs returns a new ListUsersOnPaperDocContinueArgs instance
func NewListUsersOnPaperDocContinueArgs(DocId string, Cursor string) *ListUsersOnPaperDocContinueArgs {
s := new(ListUsersOnPaperDocContinueArgs)
s.DocId = DocId
s.Cursor = Cursor
return s
}
// ListUsersOnPaperDocResponse : has no documentation (yet)
type ListUsersOnPaperDocResponse struct {
// Invitees : List of email addresses with their respective permission
// levels that are invited on the Paper doc.
Invitees []*InviteeInfoWithPermissionLevel `json:"invitees"`
// Users : List of users with their respective permission levels that are
// invited on the Paper folder.
Users []*UserInfoWithPermissionLevel `json:"users"`
// DocOwner : The Paper doc owner. This field is populated on every single
// response.
DocOwner *sharing.UserInfo `json:"doc_owner"`
// Cursor : Pass the cursor into `docsUsersListContinue` to paginate through
// all users. The cursor preserves all properties as specified in the
// original call to `docsUsersList`.
Cursor *Cursor `json:"cursor"`
// HasMore : Will be set to True if a subsequent call with the provided
// cursor to `docsUsersListContinue` returns immediately with some results.
// If set to False please allow some delay before making another call to
// `docsUsersListContinue`.
HasMore bool `json:"has_more"`
}
// NewListUsersOnPaperDocResponse returns a new ListUsersOnPaperDocResponse instance
func NewListUsersOnPaperDocResponse(Invitees []*InviteeInfoWithPermissionLevel, Users []*UserInfoWithPermissionLevel, DocOwner *sharing.UserInfo, Cursor *Cursor, HasMore bool) *ListUsersOnPaperDocResponse {
s := new(ListUsersOnPaperDocResponse)
s.Invitees = Invitees
s.Users = Users
s.DocOwner = DocOwner
s.Cursor = Cursor
s.HasMore = HasMore
return s
}
// PaperApiCursorError : has no documentation (yet)
type PaperApiCursorError struct {
dropbox.Tagged
}
// Valid tag values for PaperApiCursorError
const (
PaperApiCursorErrorExpiredCursor = "expired_cursor"
PaperApiCursorErrorInvalidCursor = "invalid_cursor"
PaperApiCursorErrorWrongUserInCursor = "wrong_user_in_cursor"
PaperApiCursorErrorReset = "reset"
PaperApiCursorErrorOther = "other"
)
// PaperDocExport : has no documentation (yet)
type PaperDocExport struct {
RefPaperDoc
// ExportFormat : has no documentation (yet)
ExportFormat *ExportFormat `json:"export_format"`
}
// NewPaperDocExport returns a new PaperDocExport instance
func NewPaperDocExport(DocId string, ExportFormat *ExportFormat) *PaperDocExport {
s := new(PaperDocExport)
s.DocId = DocId
s.ExportFormat = ExportFormat
return s
}
// PaperDocExportResult : has no documentation (yet)
type PaperDocExportResult struct {
// Owner : The Paper doc owner's email address.
Owner string `json:"owner"`
// Title : The Paper doc title.
Title string `json:"title"`
// Revision : The Paper doc revision. Simply an ever increasing number.
Revision int64 `json:"revision"`
// MimeType : MIME type of the export. This corresponds to `ExportFormat`
// specified in the request.
MimeType string `json:"mime_type"`
}
// NewPaperDocExportResult returns a new PaperDocExportResult instance
func NewPaperDocExportResult(Owner string, Title string, Revision int64, MimeType string) *PaperDocExportResult {
s := new(PaperDocExportResult)
s.Owner = Owner
s.Title = Title
s.Revision = Revision
s.MimeType = MimeType
return s
}
// PaperDocPermissionLevel : has no documentation (yet)
type PaperDocPermissionLevel struct {
dropbox.Tagged
}
// Valid tag values for PaperDocPermissionLevel
const (
PaperDocPermissionLevelEdit = "edit"
PaperDocPermissionLevelViewAndComment = "view_and_comment"
PaperDocPermissionLevelOther = "other"
)
// PaperDocSharingPolicy : has no documentation (yet)
type PaperDocSharingPolicy struct {
RefPaperDoc
// SharingPolicy : The default sharing policy to be set for the Paper doc.
SharingPolicy *SharingPolicy `json:"sharing_policy"`
}
// NewPaperDocSharingPolicy returns a new PaperDocSharingPolicy instance
func NewPaperDocSharingPolicy(DocId string, SharingPolicy *SharingPolicy) *PaperDocSharingPolicy {
s := new(PaperDocSharingPolicy)
s.DocId = DocId
s.SharingPolicy = SharingPolicy
return s
}
// RemovePaperDocUser : has no documentation (yet)
type RemovePaperDocUser struct {
RefPaperDoc
// Member : User which should be removed from the Paper doc. Specify only
// email address or Dropbox account ID.
Member *sharing.MemberSelector `json:"member"`
}
// NewRemovePaperDocUser returns a new RemovePaperDocUser instance
func NewRemovePaperDocUser(DocId string, Member *sharing.MemberSelector) *RemovePaperDocUser {
s := new(RemovePaperDocUser)
s.DocId = DocId
s.Member = Member
return s
}
// SharingPolicy : Sharing policy of Paper doc.
type SharingPolicy struct {
// PublicSharingPolicy : This value applies to the non-team members.
PublicSharingPolicy *SharingPublicPolicyType `json:"public_sharing_policy,omitempty"`
// TeamSharingPolicy : This value applies to the team members only. The
// value is null for all personal accounts.
TeamSharingPolicy *SharingTeamPolicyType `json:"team_sharing_policy,omitempty"`
}
// NewSharingPolicy returns a new SharingPolicy instance
func NewSharingPolicy() *SharingPolicy {
s := new(SharingPolicy)
return s
}
// SharingTeamPolicyType : The sharing policy type of the Paper doc.
type SharingTeamPolicyType struct {
dropbox.Tagged
}
// Valid tag values for SharingTeamPolicyType
const (
SharingTeamPolicyTypePeopleWithLinkCanEdit = "people_with_link_can_edit"
SharingTeamPolicyTypePeopleWithLinkCanViewAndComment = "people_with_link_can_view_and_comment"
SharingTeamPolicyTypeInviteOnly = "invite_only"
)
// SharingPublicPolicyType : has no documentation (yet)
type SharingPublicPolicyType struct {
dropbox.Tagged
}
// Valid tag values for SharingPublicPolicyType
const (
SharingPublicPolicyTypeDisabled = "disabled"
)
// UserInfoWithPermissionLevel : has no documentation (yet)
type UserInfoWithPermissionLevel struct {
// User : User shared on the Paper doc.
User *sharing.UserInfo `json:"user"`
// PermissionLevel : Permission level for the user.
PermissionLevel *PaperDocPermissionLevel `json:"permission_level"`
}
// NewUserInfoWithPermissionLevel returns a new UserInfoWithPermissionLevel instance
func NewUserInfoWithPermissionLevel(User *sharing.UserInfo, PermissionLevel *PaperDocPermissionLevel) *UserInfoWithPermissionLevel {
s := new(UserInfoWithPermissionLevel)
s.User = User
s.PermissionLevel = PermissionLevel
return s
}
// UserOnPaperDocFilter : has no documentation (yet)
type UserOnPaperDocFilter struct {
dropbox.Tagged
}
// Valid tag values for UserOnPaperDocFilter
const (
UserOnPaperDocFilterVisited = "visited"
UserOnPaperDocFilterShared = "shared"
UserOnPaperDocFilterOther = "other"
)
@@ -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 properties : This namespace contains helper entities for property and
// property/template endpoints.
package properties
import (
"encoding/json"
"github.com/ncw/dropbox-sdk-go-unofficial/dropbox"
)
// GetPropertyTemplateArg : has no documentation (yet)
type GetPropertyTemplateArg struct {
// TemplateId : An identifier for property template added by route
// properties/template/add.
TemplateId string `json:"template_id"`
}
// NewGetPropertyTemplateArg returns a new GetPropertyTemplateArg instance
func NewGetPropertyTemplateArg(TemplateId string) *GetPropertyTemplateArg {
s := new(GetPropertyTemplateArg)
s.TemplateId = TemplateId
return s
}
// PropertyGroupTemplate : Describes property templates that can be filled and
// associated with a file.
type PropertyGroupTemplate struct {
// Name : A display name for the property template. Property template names
// can be up to 256 bytes.
Name string `json:"name"`
// Description : Description for new property template. Property template
// descriptions can be up to 1024 bytes.
Description string `json:"description"`
// Fields : This is a list of custom properties associated with a property
// template. There can be up to 64 properties in a single property template.
Fields []*PropertyFieldTemplate `json:"fields"`
}
// NewPropertyGroupTemplate returns a new PropertyGroupTemplate instance
func NewPropertyGroupTemplate(Name string, Description string, Fields []*PropertyFieldTemplate) *PropertyGroupTemplate {
s := new(PropertyGroupTemplate)
s.Name = Name
s.Description = Description
s.Fields = Fields
return s
}
// GetPropertyTemplateResult : The Property template for the specified template.
type GetPropertyTemplateResult struct {
PropertyGroupTemplate
}
// NewGetPropertyTemplateResult returns a new GetPropertyTemplateResult instance
func NewGetPropertyTemplateResult(Name string, Description string, Fields []*PropertyFieldTemplate) *GetPropertyTemplateResult {
s := new(GetPropertyTemplateResult)
s.Name = Name
s.Description = Description
s.Fields = Fields
return s
}
// ListPropertyTemplateIds : has no documentation (yet)
type ListPropertyTemplateIds struct {
// TemplateIds : List of identifiers for templates added by route
// properties/template/add.
TemplateIds []string `json:"template_ids"`
}
// NewListPropertyTemplateIds returns a new ListPropertyTemplateIds instance
func NewListPropertyTemplateIds(TemplateIds []string) *ListPropertyTemplateIds {
s := new(ListPropertyTemplateIds)
s.TemplateIds = TemplateIds
return s
}
// PropertyTemplateError : has no documentation (yet)
type PropertyTemplateError struct {
dropbox.Tagged
// TemplateNotFound : Property template does not exist for given identifier.
TemplateNotFound string `json:"template_not_found,omitempty"`
}
// Valid tag values for PropertyTemplateError
const (
PropertyTemplateErrorTemplateNotFound = "template_not_found"
PropertyTemplateErrorRestrictedContent = "restricted_content"
PropertyTemplateErrorOther = "other"
)
// UnmarshalJSON deserializes into a PropertyTemplateError instance
func (u *PropertyTemplateError) 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 "template_not_found":
err = json.Unmarshal(body, &u.TemplateNotFound)
if err != nil {
return err
}
}
return nil
}
// ModifyPropertyTemplateError : has no documentation (yet)
type ModifyPropertyTemplateError struct {
dropbox.Tagged
}
// Valid tag values for ModifyPropertyTemplateError
const (
ModifyPropertyTemplateErrorConflictingPropertyNames = "conflicting_property_names"
ModifyPropertyTemplateErrorTooManyProperties = "too_many_properties"
ModifyPropertyTemplateErrorTooManyTemplates = "too_many_templates"
ModifyPropertyTemplateErrorTemplateAttributeTooLarge = "template_attribute_too_large"
)
// PropertyField : has no documentation (yet)
type PropertyField struct {
// Name : This is the name or key of a custom property in a property
// template. File property names can be up to 256 bytes.
Name string `json:"name"`
// Value : Value of a custom property attached to a file. Values can be up
// to 1024 bytes.
Value string `json:"value"`
}
// NewPropertyField returns a new PropertyField instance
func NewPropertyField(Name string, Value string) *PropertyField {
s := new(PropertyField)
s.Name = Name
s.Value = Value
return s
}
// PropertyFieldTemplate : Describe a single property field type which that can
// be part of a property template.
type PropertyFieldTemplate struct {
// Name : This is the name or key of a custom property in a property
// template. File property names can be up to 256 bytes.
Name string `json:"name"`
// Description : This is the description for a custom property in a property
// template. File property description can be up to 1024 bytes.
Description string `json:"description"`
// Type : This is the data type of the value of this property. This type
// will be enforced upon property creation and modifications.
Type *PropertyType `json:"type"`
}
// NewPropertyFieldTemplate returns a new PropertyFieldTemplate instance
func NewPropertyFieldTemplate(Name string, Description string, Type *PropertyType) *PropertyFieldTemplate {
s := new(PropertyFieldTemplate)
s.Name = Name
s.Description = Description
s.Type = Type
return s
}
// PropertyGroup : Collection of custom properties in filled property templates.
type PropertyGroup struct {
// TemplateId : A unique identifier for a property template type.
TemplateId string `json:"template_id"`
// Fields : This is a list of custom properties associated with a file.
// There can be up to 32 properties for a template.
Fields []*PropertyField `json:"fields"`
}
// NewPropertyGroup returns a new PropertyGroup instance
func NewPropertyGroup(TemplateId string, Fields []*PropertyField) *PropertyGroup {
s := new(PropertyGroup)
s.TemplateId = TemplateId
s.Fields = Fields
return s
}
// PropertyType : Data type of the given property added. This endpoint is in
// beta and only properties of type strings is supported.
type PropertyType struct {
dropbox.Tagged
}
// Valid tag values for PropertyType
const (
PropertyTypeString = "string"
PropertyTypeOther = "other"
)
+170
View File
@@ -0,0 +1,170 @@
// 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"
"net/http"
"golang.org/x/oauth2"
)
const (
apiVersion = 2
defaultDomain = ".dropboxapi.com"
hostAPI = "api"
hostContent = "content"
hostNotify = "notify"
sdkVersion = "1.0.0-beta"
specVersion = "8c790b1"
)
// 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
// Enable verbose logging in SDK
Verbose bool
// 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
}
// 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(oauth2.NoContext, 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")
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,49 @@
// 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
}
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
@@ -0,0 +1,91 @@
// 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/ncw/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"
)
// 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
}
@@ -0,0 +1,202 @@
// 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_log
import (
"bytes"
"encoding/json"
"io/ioutil"
"log"
"net/http"
"github.com/ncw/dropbox-sdk-go-unofficial/dropbox"
)
// Client interface describes all routes in this namespace
type Client interface {
// GetEvents : Retrieves team events. Permission : Team Auditing.
GetEvents(arg *GetTeamEventsArg) (res *GetTeamEventsResult, err error)
// GetEventsContinue : Once a cursor has been retrieved from `getEvents`,
// use this to paginate through all events. Permission : Team Auditing.
GetEventsContinue(arg *GetTeamEventsContinueArg) (res *GetTeamEventsResult, err error)
}
type apiImpl dropbox.Context
//GetEventsAPIError is an error-wrapper for the get_events route
type GetEventsAPIError struct {
dropbox.APIError
EndpointError *GetTeamEventsError `json:"error"`
}
func (dbx *apiImpl) GetEvents(arg *GetTeamEventsArg) (res *GetTeamEventsResult, err error) {
cli := dbx.Client
if dbx.Config.Verbose {
log.Printf("arg: %v", arg)
}
b, err := json.Marshal(arg)
if err != nil {
return
}
headers := map[string]string{
"Content-Type": "application/json",
}
req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "team_log", "get_events", headers, bytes.NewReader(b))
if err != nil {
return
}
if dbx.Config.Verbose {
log.Printf("req: %v", req)
}
resp, err := cli.Do(req)
if dbx.Config.Verbose {
log.Printf("resp: %v", resp)
}
if err != nil {
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
if dbx.Config.Verbose {
log.Printf("body: %s", body)
}
if resp.StatusCode == http.StatusOK {
err = json.Unmarshal(body, &res)
if err != nil {
return
}
return
}
if resp.StatusCode == http.StatusConflict {
var apiError GetEventsAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
apiError.ErrorSummary = string(body)
err = apiError
return
}
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
//GetEventsContinueAPIError is an error-wrapper for the get_events/continue route
type GetEventsContinueAPIError struct {
dropbox.APIError
EndpointError *GetTeamEventsContinueError `json:"error"`
}
func (dbx *apiImpl) GetEventsContinue(arg *GetTeamEventsContinueArg) (res *GetTeamEventsResult, err error) {
cli := dbx.Client
if dbx.Config.Verbose {
log.Printf("arg: %v", arg)
}
b, err := json.Marshal(arg)
if err != nil {
return
}
headers := map[string]string{
"Content-Type": "application/json",
}
req, err := (*dropbox.Context)(dbx).NewRequest("api", "rpc", true, "team_log", "get_events/continue", headers, bytes.NewReader(b))
if err != nil {
return
}
if dbx.Config.Verbose {
log.Printf("req: %v", req)
}
resp, err := cli.Do(req)
if dbx.Config.Verbose {
log.Printf("resp: %v", resp)
}
if err != nil {
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
if dbx.Config.Verbose {
log.Printf("body: %s", body)
}
if resp.StatusCode == http.StatusOK {
err = json.Unmarshal(body, &res)
if err != nil {
return
}
return
}
if resp.StatusCode == http.StatusConflict {
var apiError GetEventsContinueAPIError
err = json.Unmarshal(body, &apiError)
if err != nil {
return
}
err = apiError
return
}
var apiError dropbox.APIError
if resp.StatusCode == http.StatusBadRequest {
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) *apiImpl {
ctx := apiImpl(dropbox.NewContext(c))
return &ctx
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,118 @@
// 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/ncw/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"
)
// 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"
)
// 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"`
}
// NewTeamMemberPolicies returns a new TeamMemberPolicies instance
func NewTeamMemberPolicies(Sharing *TeamSharingPolicies, EmmState *EmmState) *TeamMemberPolicies {
s := new(TeamMemberPolicies)
s.Sharing = Sharing
s.EmmState = EmmState
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
}
+353
View File
@@ -0,0 +1,353 @@
// 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"
"log"
"net/http"
"github.com/ncw/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
if dbx.Config.Verbose {
log.Printf("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
}
if dbx.Config.Verbose {
log.Printf("req: %v", req)
}
resp, err := cli.Do(req)
if dbx.Config.Verbose {
log.Printf("resp: %v", resp)
}
if err != nil {
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
if dbx.Config.Verbose {
log.Printf("body: %s", 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 {
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
if dbx.Config.Verbose {
log.Printf("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
}
if dbx.Config.Verbose {
log.Printf("req: %v", req)
}
resp, err := cli.Do(req)
if dbx.Config.Verbose {
log.Printf("resp: %v", resp)
}
if err != nil {
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
if dbx.Config.Verbose {
log.Printf("body: %s", 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 {
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
}
if dbx.Config.Verbose {
log.Printf("req: %v", req)
}
resp, err := cli.Do(req)
if dbx.Config.Verbose {
log.Printf("resp: %v", resp)
}
if err != nil {
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
if dbx.Config.Verbose {
log.Printf("body: %s", 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 {
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
}
if dbx.Config.Verbose {
log.Printf("req: %v", req)
}
resp, err := cli.Do(req)
if dbx.Config.Verbose {
log.Printf("resp: %v", resp)
}
if err != nil {
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
if dbx.Config.Verbose {
log.Printf("body: %s", 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 {
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) *apiImpl {
ctx := apiImpl(dropbox.NewContext(c))
return &ctx
}
+357
View File
@@ -0,0 +1,357 @@
// 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/ncw/dropbox-sdk-go-unofficial/dropbox"
"github.com/ncw/dropbox-sdk-go-unofficial/dropbox/team_policies"
"github.com/ncw/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"`
}
// 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) *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
return s
}
// 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"`
}
// NewFullTeam returns a new FullTeam instance
func NewFullTeam(Id string, Name string, SharingPolicies *team_policies.TeamSharingPolicies) *FullTeam {
s := new(FullTeam)
s.Id = Id
s.Name = Name
s.SharingPolicies = SharingPolicies
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"`
}
// NewTeamSpaceAllocation returns a new TeamSpaceAllocation instance
func NewTeamSpaceAllocation(Used uint64, Allocated uint64) *TeamSpaceAllocation {
s := new(TeamSpaceAllocation)
s.Used = Used
s.Allocated = Allocated
return s
}
@@ -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/ncw/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"
)