dropbox

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseURL  = "https://api.dropboxapi.com"
	AuthURL  = "https://dropbox.com/oauth2/authorize"
	TokenURL = BaseURL + "/oauth2/token"
)
View Source
const (
	// users.
	ListUsersURL         = BaseURL + "/2/team/members/list_v2"
	ListUsersContinueURL = BaseURL + "/2/team/members/list/continue_v2"

	// roles.
	SetRoleURL = BaseURL + "/2/team/members/set_admin_permissions_v2"

	// groups.
	ListGroupsURL               = BaseURL + "/2/team/groups/list"
	ListGroupsContinueURL       = BaseURL + "/2/team/groups/list/continue"
	ListGroupMembersURL         = BaseURL + "/2/team/groups/members/list"
	ListGroupMembersContinueURL = BaseURL + "/2/team/groups/members/list/continue"
	AddUserToGroupURL           = BaseURL + "/2/team/groups/members/add"
	RemoveUserFromGroupURL      = BaseURL + "/2/team/groups/members/remove"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddToGroupMembers

type AddToGroupMembers struct {
	AccessLevel string   `json:"access_type"`
	User        EmailTag `json:"user"`
}

type AddUserToGroupBody

type AddUserToGroupBody struct {
	Group         GroupIdTag          `json:"group"`
	Members       []AddToGroupMembers `json:"members"`
	ReturnMembers bool                `json:"return_members"`
}

type Client

type Client struct {
	uhttp.BaseHttpClient
	Config
	TokenSource oauth2.TokenSource
}

func NewClient

func NewClient(ctx context.Context, config Config) (*Client, error)

func (*Client) AddRoleToUser

func (c *Client) AddRoleToUser(ctx context.Context, roleId, email string) (*v2.RateLimitDescription, error)

func (*Client) AddUserToGroup

func (c *Client) AddUserToGroup(ctx context.Context, groupId, email, accessType string) (*v2.RateLimitDescription, error)

func (*Client) Authorize

func (c *Client) Authorize(ctx context.Context, appKey, appSecret string) (string, error)

func (*Client) ClearRoles

func (c *Client) ClearRoles(ctx context.Context, email string) (*v2.RateLimitDescription, error)

endpoint only allows removing all roles, not specific roles also removing them all leaves the user with the member role by default https://www.dropbox.com/developers/documentation/http/teams#team-members-set_admin_permissions

func (*Client) GetTeamMemberID

func (c *Client) GetTeamMemberID(ctx context.Context, groupId, userId string) (string, error)

func (*Client) ListGroupMembers

func (c *Client) ListGroupMembers(ctx context.Context, groupId string, limit int) (*ListGroupMembersPayload, *v2.RateLimitDescription, error)

func (*Client) ListGroupMembersContinue

func (c *Client) ListGroupMembersContinue(ctx context.Context, cursor string) (*ListGroupMembersPayload, *v2.RateLimitDescription, error)

func (*Client) ListGroupsContinue

func (c *Client) ListGroupsContinue(ctx context.Context, cursor string) (*ListGroupsPayload, *v2.RateLimitDescription, error)

func (*Client) ListUsers

func (c *Client) ListUsers(ctx context.Context, limit int) (*ListUsersPayload, *v2.RateLimitDescription, error)

func (*Client) ListUsersContinue

func (c *Client) ListUsersContinue(ctx context.Context, cursor string) (*ListUsersPayload, *v2.RateLimitDescription, error)

func (*Client) RemoveUserFromGroup

func (c *Client) RemoveUserFromGroup(ctx context.Context, groupId, email string) (*v2.RateLimitDescription, error)

func (*Client) RequestAccessToken

func (c *Client) RequestAccessToken(ctx context.Context, code string) (string, *time.Time, string, error)

func (*Client) RequestAccessTokenUsingRefreshToken

func (c *Client) RequestAccessTokenUsingRefreshToken(ctx context.Context) (string, *time.Time, error)

returns access token and expiry time

curl https://api.dropbox.com/oauth2/token \
    -d grant_type=refresh_token \
    -d refresh_token=<refresh_token> \
    -d client_id=<app_key> \
    -d client_secret=<app_secret>

type Config

type Config struct {
	AppKey       string
	AppSecret    string
	RefreshToken string
}

type EmailTag

type EmailTag struct {
	Tag   string `json:".tag"`
	Email string `json:"email"`
}

type Group

type Group struct {
	GroupID             string `json:"group_id"`
	Name                string `json:"group_name"`
	GroupManagementType Tag    `json:"group_management_type"`
	MemberCount         int    `json:"member_count"`
}

type GroupIdTag

type GroupIdTag struct {
	GroupID string `json:"group_id"`
	Tag     string `json:".tag"`
}

type ListGroupMembersBody

type ListGroupMembersBody struct {
	Group GroupIdTag `json:"group"`
	Limit int        `json:"limit"`
}

func DefaultGroupMembersBody

func DefaultGroupMembersBody() ListGroupMembersBody

type ListGroupMembersPayload

type ListGroupMembersPayload struct {
	Cursor  string           `json:"cursor"`
	HasMore bool             `json:"has_more"`
	Members []MembersPayload `json:"members"`
}

type ListGroupsBody

type ListGroupsBody struct {
	Limit int `json:"limit"`
}

func DefaultListGroupsBody

func DefaultListGroupsBody() ListGroupsBody

type ListGroupsPayload

type ListGroupsPayload struct {
	Cursor  string  `json:"cursor"`
	HasMore bool    `json:"has_more"`
	Groups  []Group `json:"groups"`
}

type ListUserBody

type ListUserBody struct {
	Limit          int  `json:"limit"`
	IncludeRemoved bool `json:"include_removed"`
}

func DefaultListUserBody

func DefaultListUserBody() ListUserBody

type ListUsersPayload

type ListUsersPayload struct {
	Cursor  string        `json:"cursor"`
	HasMore bool          `json:"has_more"`
	Members []UserPayload `json:"members"`
}

type MembersPayload

type MembersPayload struct {
	Profile MembersProfile `json:"profile"`

	// owner or member of the group
	AccessType Tag `json:"access_type"`
}

type MembersProfile

type MembersProfile struct {
	Profile
	TeamMemberID string `json:"team_member_id"`
}

type Name

type Name struct {
	DisplayName string `json:"display_name"`
	GivenName   string `json:"given_name"`
	Surname     string `json:"surname"`
}

type Profile

type Profile struct {
	AccountID    string   `json:"account_id"`
	TeamMemberID string   `json:"team_member_id"`
	Name         Name     `json:"name"`
	Email        string   `json:"email"`
	Groups       []string `json:"groups"`
}

type RemoveUserFromGroupBody

type RemoveUserFromGroupBody struct {
	Group         GroupIdTag `json:"group"`
	Users         []EmailTag `json:"users"`
	ReturnMembers bool       `json:"return_members"`
}

type Role

type Role struct {
	Description string `json:"description"`
	Name        string `json:"name"`
	RoleID      string `json:"role_id"`
}

type Tag

type Tag struct {
	Tag string `json:".tag"`
}

type UserPayload

type UserPayload struct {
	Profile Profile `json:"profile"`
	Roles   []Role  `json:"roles"`
}

func (UserPayload) HasRole

func (u UserPayload) HasRole(roleID string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL