box

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestAccessToken

func RequestAccessToken(ctx context.Context, clientID string, clientSecret string, enterpriseId string, baseURL string) (string, error)

RequestAccessToken creates bearer token needed to use the Box API.

Types

type APIError added in v0.0.4

type APIError struct {
	Message string
	Code    string
	Status  int
}

APIError carries a structured Box API error so callers can check error codes with errors.As.

func (*APIError) Error added in v0.0.4

func (e *APIError) Error() string

type BaseType

type BaseType struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client, token string, baseURL string) (*Client, error)

func (*Client) ActivateUser added in v0.0.4

func (c *Client) ActivateUser(ctx context.Context, userID string) error

ActivateUser sets a Box user's status back to active.

func (*Client) CheckAdminAccess added in v0.0.5

func (c *Client) CheckAdminAccess(ctx context.Context) error

CheckAdminAccess verifies the token has manage-users admin scope by requesting a single user entry. Box CCG Service Accounts are not assigned a role designation, so validating via the role field is incorrect; a 403 here means insufficient scope.

func (*Client) CreateUser added in v0.0.4

func (c *Client) CreateUser(ctx context.Context, input CreateUserInput) (*User, error)

CreateUser creates a new managed Box user via POST /2.0/users.

func (*Client) DeactivateUser added in v0.0.4

func (c *Client) DeactivateUser(ctx context.Context, userID string) error

DeactivateUser sets a Box user's status to inactive (reversible).

func (*Client) DeleteUser added in v0.0.4

func (c *Client) DeleteUser(ctx context.Context, userID string) error

DeleteUser permanently deletes a Box user via DELETE /2.0/users/{id}. force=true removes the user even when they still have content. notify=false suppresses the email notification sent to the user.

func (*Client) GetCurrentUserWithEnterprise

func (c *Client) GetCurrentUserWithEnterprise(ctx context.Context) (User, error)

GetCurrentUserWithEnterprise returns current user with enterprise data.

func (*Client) GetGroup

func (c *Client) GetGroup(ctx context.Context, groupId string) (Group, error)

GetGroup returns Box group details.

func (*Client) GetGroupMemberships

func (c *Client) GetGroupMemberships(ctx context.Context, groupId string, marker string) ([]GroupMembership, string, annotations.Annotations, error)

GetGroupMemberships returns one page of memberships for the given group.

func (*Client) GetGroups

func (c *Client) GetGroups(ctx context.Context, marker string) ([]Group, string, annotations.Annotations, error)

GetGroups returns one page of groups from the Box enterprise.

func (*Client) GetUser added in v0.0.5

func (c *Client) GetUser(ctx context.Context, userID string) (*User, error)

GetUser fetches a single Box user by ID.

func (*Client) GetUserByLogin added in v0.0.4

func (c *Client) GetUserByLogin(ctx context.Context, login string) (*User, error)

GetUserByLogin fetches a single user by exact login (email) match via GET /2.0/users?filter_term=. Returns nil, nil when no user with that login exists.

func (*Client) GetUsers

func (c *Client) GetUsers(ctx context.Context, marker string) ([]User, string, annotations.Annotations, error)

GetUsers returns one page of users from the Box enterprise.

func (*Client) UpdateUser added in v0.0.4

func (c *Client) UpdateUser(ctx context.Context, userID string, updates map[string]interface{}) (*User, error)

UpdateUser updates a Box user's properties via PUT /2.0/users/{user_id}.

type CreateUserInput added in v0.0.4

type CreateUserInput struct {
	Login  string `json:"login"`
	Name   string `json:"name"`
	Role   string `json:"role,omitempty"`
	Status string `json:"status,omitempty"`
}

CreateUserInput holds the fields sent to POST /2.0/users.

type Enterprise

type Enterprise struct {
	BaseType
	Name string `json:"name"`
}

type Group

type Group struct {
	BaseType
	InvitabilityLevel      string `json:"invitability_level"`
	MemberViewabilityLevel string `json:"member_viewability_level"`
	Name                   string `json:"name"`
}

type GroupMembership

type GroupMembership struct {
	BaseType
	Role  string `json:"role"`
	User  User   `json:"user"`
	Group Group  `json:"group"`
}

type User

type User struct {
	BaseType
	Enterprise Enterprise `json:"enterprise"`
	Login      string     `json:"login"`
	Name       string     `json:"name"`
	Phone      string     `json:"phone"`
	Role       string     `json:"role"`
	Status     string     `json:"status"`
}

Jump to

Keyboard shortcuts

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