Documentation
¶
Index ¶
- Variables
- func NewTransferHTTPClient() *http.Client
- func RequestAccessToken(ctx context.Context, clientID string, clientSecret string, enterpriseId string, ...) (string, error)
- type APIError
- type BaseType
- type Client
- func (c *Client) ActivateUser(ctx context.Context, userID string) error
- func (c *Client) CheckAdminAccess(ctx context.Context) error
- func (c *Client) CreateUser(ctx context.Context, input CreateUserInput) (*User, error)
- func (c *Client) DeactivateUser(ctx context.Context, userID string) error
- func (c *Client) DeleteUser(ctx context.Context, userID string, force bool) error
- func (c *Client) GetCurrentUserWithEnterprise(ctx context.Context) (User, error)
- func (c *Client) GetGroup(ctx context.Context, groupId string) (Group, error)
- func (c *Client) GetGroupMemberships(ctx context.Context, groupId string, marker string) ([]GroupMembership, string, annotations.Annotations, error)
- func (c *Client) GetGroups(ctx context.Context, marker string) ([]Group, string, annotations.Annotations, error)
- func (c *Client) GetUser(ctx context.Context, userID string) (*User, error)
- func (c *Client) GetUserByLogin(ctx context.Context, login string) (*User, error)
- func (c *Client) GetUsers(ctx context.Context, marker string) ([]User, string, annotations.Annotations, error)
- func (c *Client) TransferOwnedItems(ctx context.Context, sourceUserID, destUserID string, notify bool) (*Folder, error)
- func (c *Client) UpdateUser(ctx context.Context, userID string, updates map[string]interface{}) (*User, error)
- type ClientOption
- type CreateUserInput
- type Enterprise
- type Folder
- type Group
- type GroupMembership
- type User
Constants ¶
This section is empty.
Variables ¶
var ErrTransferNoAnswer = errors.New("box received the transfer request but did not answer in time")
ErrTransferNoAnswer reports that Box received the whole transfer request but no answer from Box arrived before the client stopped waiting: the wait timed out, or Box's gateway gave up with a 504. Box documents that a transfer keeps running after a gateway timeout; that it also keeps running when we stop waiting and close the connection is assumed, not documented. Either way the caller reports the transfer as still in progress.
Functions ¶
func NewTransferHTTPClient ¶ added in v0.1.1
NewTransferHTTPClient returns an HTTP client for the transfer request. The client from uhttp.NewClient stops waiting for response headers after 60 seconds, while Box holds the transfer request open until it finishes (up to 10 minutes). This client has no header timeout, so the caller's context alone bounds the wait. It keeps the proxy and HTTP/2 keepalive settings of the uhttp transport, and opens a new connection per request so a connection left idle across a Lambda freeze is never reused. It sends the same baton-sdk User-Agent as uhttp, but unlike the uhttp transport it does not retry a request that was never sent (a dial or proxy-connect failure) and does not log requests.
Types ¶
type APIError ¶ added in v0.0.4
APIError carries a structured Box API error so callers can check error codes with errors.As.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ActivateUser ¶ added in v0.0.4
ActivateUser sets a Box user's status back to active.
func (*Client) CheckAdminAccess ¶ added in v0.0.5
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
CreateUser creates a new managed Box user via POST /2.0/users.
func (*Client) DeactivateUser ¶ added in v0.0.4
DeactivateUser sets a Box user's status to inactive (reversible).
func (*Client) DeleteUser ¶ added in v0.0.4
DeleteUser permanently deletes a Box user via DELETE /2.0/users/{id}. With force=true Box removes the user even when they still own content, and deletes that content; with force=false Box refuses to delete a user who still owns content. notify=false suppresses the email notification sent to the user.
func (*Client) GetCurrentUserWithEnterprise ¶
GetCurrentUserWithEnterprise returns current user with enterprise data.
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
GetUser fetches a single Box user by ID. It skips uhttp's GET cache: actions use it to check a user's current status, which an earlier action in the same process may have just changed.
func (*Client) GetUserByLogin ¶ added in v0.0.4
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) TransferOwnedItems ¶ added in v0.1.1
func (c *Client) TransferOwnedItems(ctx context.Context, sourceUserID, destUserID string, notify bool) (*Folder, error)
TransferOwnedItems moves every item owned by sourceUserID into a new folder in destUserID's account via PUT /2.0/users/{id}/folders/0, and returns that folder. Box names it "{login} - {name}'s Files and Folders" after the source user, with a suffix such as " (1)" when that name is taken. Box holds the request open while it moves content; only a transfer that runs past 10 minutes keeps going after Box answers, and Box offers no endpoint to check completion.
When Box has received the whole request but the wait ends first (the context deadline, a response-header timeout, or a 504 from Box's gateway), the error wraps ErrTransferNoAnswer. A connection that closes or resets after the request was sent is deliberately a plain error: it may come from a proxy that never forwarded the request, and reporting a transfer that never started as in progress invites a deprovision that deletes the content.
type ClientOption ¶ added in v0.1.1
type ClientOption func(*Client)
ClientOption configures a Client.
func WithTransferHTTPClient ¶ added in v0.1.1
func WithTransferHTTPClient(httpClient *http.Client) ClientOption
WithTransferHTTPClient sets the HTTP client used for the transfer request. Without it, the transfer request uses the client passed to NewClient.
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 Folder ¶ added in v0.1.1
Folder is the subset of a Box folder returned by the transfer owned folders endpoint.