client

package module
v0.0.0-...-f78addd Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

README

Go API client for JupyterHub

The REST API for JupyterHub

Overview

  • API version: 4.0.0b2
  • Package version: 1.0.0

Installation

go get -u "github.com/black-06/jupyterhub-client"

Usage

In jupyterhub_config.py

c.JupyterHub.services = [
    {
        "name": "my-service",
        "api_token": "tokentokentoekntokentokentoekn",
        "admin": True,
    }
]

In golang client

ctx := context.WithValue(context.Background(), ContextAccessToken, "tokentokentoekntokentokentoekn")

apiClient := NewAPIClient(&Configuration{
    BasePath:      "/hub/api",
    Host:          "127.0.0.1:8000",
    Scheme:        "http",
    DefaultHeader: make(map[string]string),
})

users, _, err := apiClient.UsersGet(ctx, &DefaultApiUsersGetOpts{})

Documentation for API Endpoints

All URIs are relative to /hub/api

authorizations.go
Method HTTP request Description
RequestNewAPIToken Post /authorizations/token Request a new API token
IdentifyUserOrServiceFromAPIToken Get /authorizations/token/{token} Identify a user or service from an API token
IdentifyUserFromCookie Get /authorizations/cookie/{cookie_name}/{cookie_value} Identify a user from a cookie
groups.go
Method HTTP request Description
ListGroups Get /groups List groups
DeleteGroup Delete /groups/{name} Delete a group
GetGroupByName Get /groups/{name} Get a group by name
CreateGroup Post /groups/{name} Create a group
SetGroupProperties Put /groups/{name}/properties Set the group properties. Added in JupyterHub 3.2.
RemoveUsersFromGroup Delete /groups/{name}/users Remove users from a group
AddUsersToGroup Post /groups/{name}/users Add users to a group
oauth2.go
Method HTTP request Description
OAuth2Authorize Get /oauth2/authorize OAuth 2.0 authorize endpoint
RequestOauth2Token Post /oauth2/token Request an OAuth2 token
platform.go
Method HTTP request Description
GetVersion Get / Get JupyterHub version
GetDetailedInfo Get /info Get detailed info about JupyterHub
Shutdown Post /shutdown Shutdown the Hub
proxy.go
Method HTTP request Description
GetProxy Get /proxy Get the proxy's routing table
SyncProxy Post /proxy Force the Hub to sync with the proxy
NotifyProxy Patch /proxy Notify the Hub about a new proxy
services.go
Method HTTP request Description
ListServices Get /services List services
GetServiceByName Get /services/{name} Get a service by name
user_server.go
Method HTTP request Description
StartUserServer Post /users/{name}/server Start a user's single-user notebook server
StopUserServer Delete /users/{name}/server Stop a user's server
StartUserNamedServer Post /users/{name}/servers/{server_name} Start a user's single-user named-server notebook server
StopUserNamedServer Delete /users/{name}/servers/{server_name} Stop a user's named server
user_token.go
Method HTTP request Description
ListUserTokens Get /users/{name}/tokens List tokens for the user
CreateUserToken Post /users/{name}/tokens Create a new token for the user
DeleteUserToken Deltete "/users/{name}/tokens/{token_id}" Delete (revoke) a token by id
GetUserTokenByID Get /users/{name}/tokens/{token_id} Get the model for a token by id
users.go
Method HTTP request Description
GetAuthenticatedUser Get /user Return authenticated user's model
ListUsers Get /users List users
CreateUsers Post /users Create multiple users
GetUserByName Get /users/{name} Get a user by name
CreateUser Post /users/{name} Create a single user
DeleteUser Delete /users/{name} Delete a user
UpdateUser Patch /users/{name} Modify a user
UpdateUserActivity Post /users/{name}/activity Notify Hub of activity for a given user.

Documentation

Overview

Package client is The REST API for JupyterHub API version: 4.0.0b2

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

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

APIClient manages communication with the JupyterHub API v4.0.0b2 In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) AddUsersToGroup

func (c *APIClient) AddUsersToGroup(ctx context.Context, groupName string, userNames []string) (Group, *http.Response, error)

AddUsersToGroup Add users to a group. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param body The users to add to the group @param name group name @return Group

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

ChangeBasePath changes base path to allow switching to mocks

func (*APIClient) CreateGroup

func (c *APIClient) CreateGroup(ctx context.Context, name string) (Group, *http.Response, error)

CreateGroup Create a group. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name group name @return Group

func (*APIClient) CreateUser

func (c *APIClient) CreateUser(ctx context.Context, name string) (User, *http.Response, error)

CreateUser Create a single user. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name username @return User

func (*APIClient) CreateUserToken

func (c *APIClient) CreateUserToken(ctx context.Context, name string, tokenOpts *TokenOpts) (Token, *http.Response, error)

CreateUserToken Create a new token for the user @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name username @param optional TokenOpts @return Token

func (*APIClient) CreateUsers

func (c *APIClient) CreateUsers(ctx context.Context, body CreateUsersRequest) ([]User, *http.Response, error)

CreateUsers Create multiple users @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param body @return []User

func (*APIClient) DeleteGroup

func (c *APIClient) DeleteGroup(ctx context.Context, name string) (*http.Response, error)

DeleteGroup Delete a group. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name group name

func (*APIClient) DeleteUser

func (c *APIClient) DeleteUser(ctx context.Context, name string) (*http.Response, error)

DeleteUser Delete a user @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name username

func (*APIClient) DeleteUserToken

func (c *APIClient) DeleteUserToken(ctx context.Context, name string, tokenId string) (*http.Response, error)

DeleteUserToken Delete (revoke) a token by id @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name username @param tokenId

func (*APIClient) GetAuthenticatedUser

func (c *APIClient) GetAuthenticatedUser(ctx context.Context) (RequestIdentity, *http.Response, error)

GetAuthenticatedUser Return authenticated user's model @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return RequestIdentity

func (*APIClient) GetDetailedInfo

func (c *APIClient) GetDetailedInfo(ctx context.Context) (DetailedInfo, *http.Response, error)

GetDetailedInfo Get detailed info about JupyterHub. Detailed JupyterHub information, including Python version, JupyterHub's version and executable path, and which Authenticator and Spawner are active. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return DetailedInfo

func (*APIClient) GetGroupByName

func (c *APIClient) GetGroupByName(ctx context.Context, name string) (Group, *http.Response, error)

GetGroupByName Get a group by name. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name group name @return Group

func (*APIClient) GetProxy

func (c *APIClient) GetProxy(ctx context.Context, offset, limit *int) (interface{}, *http.Response, error)

GetProxy Get the proxy's routing table A convenience alias for getting the routing table directly from the proxy @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param offset - Return a number of routes starting at the given offset. Can be used with limit to paginate. If unspecified, return all routes. @param limit - Return a finite number of routes. Can be used with offset to paginate. If unspecified, use api_page_default_limit @return interface{}

func (*APIClient) GetServiceByName

func (c *APIClient) GetServiceByName(ctx context.Context, name string) (Service, *http.Response, error)

GetServiceByName Get a service by name @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name service name @return Service

func (*APIClient) GetUserByName

func (c *APIClient) GetUserByName(ctx context.Context, name string) (User, *http.Response, error)

GetUserByName Get a user by name @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name username @return User

func (*APIClient) GetUserTokenByID

func (c *APIClient) GetUserTokenByID(ctx context.Context, name string, tokenId string) (Token, *http.Response, error)

GetUserTokenByID Get the model for a token by id @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name username @param tokenId @return Token

func (*APIClient) GetVersion

func (c *APIClient) GetVersion(ctx context.Context) (VersionResponse, *http.Response, error)

GetVersion Get JupyterHub version. This endpoint is not authenticated for the purpose of clients and user to identify the JupyterHub version before setting up authentication. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return VersionResponse

func (*APIClient) IdentifyUserFromCookie

func (c *APIClient) IdentifyUserFromCookie(ctx context.Context, cookieName string, cookieValue string) (User, *http.Response, error)

IdentifyUserFromCookie identify a user from a cookie. Used by single-user notebook servers to hand off cookie authentication to the Hub @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param cookieName @param cookieValue @return User

func (*APIClient) IdentifyUserOrServiceFromAPIToken

func (c *APIClient) IdentifyUserOrServiceFromAPIToken(ctx context.Context, token string) (*http.Response, error)

IdentifyUserOrServiceFromAPIToken Identify a user or service from an API token. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param token

func (*APIClient) ListGroups

func (c *APIClient) ListGroups(ctx context.Context, offset, limit *int) ([]Group, *http.Response, error)

ListGroups List groups. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param offset - Return a number of groups starting at the specified offset. Can be used with limit to paginate. If unspecified, return all groups. @param limit - Return a finite number of groups. Can be used with offset to paginate. If unspecified, use api_page_default_limit. @return []Group

func (*APIClient) ListServices

func (c *APIClient) ListServices(ctx context.Context) ([]Service, *http.Response, error)

ListServices List services @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return []Service

func (*APIClient) ListUserTokens

func (c *APIClient) ListUserTokens(ctx context.Context, name string) ([]Token, *http.Response, error)

ListUserTokens List tokens for the user @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name username @return []Token

func (*APIClient) ListUsers

func (c *APIClient) ListUsers(ctx context.Context, listUsersOpts *ListUsersOpts) ([]User, *http.Response, error)

ListUsers List users @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param optional nil or *ListUsersOpts - Optional Parameters. @return []User

func (*APIClient) NotifyProxy

func (c *APIClient) NotifyProxy(ctx context.Context, request ProxyRequest) (*http.Response, error)

NotifyProxy Notify the Hub about a new proxy Notifies the Hub of a new proxy to use. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param body Any values that have changed for the new proxy. All keys are optional.

func (*APIClient) OAuth2Authorize

func (c *APIClient) OAuth2Authorize(ctx context.Context, clientId, responseType, state, redirectUri string) (*http.Response, error)

OAuth2Authorize OAuth 2.0 authorize endpoint Redirect users to this URL to begin the OAuth process. It is not an API endpoint. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param clientId The client id @param responseType The response type (always 'code') @param optional state string @param redirectUri The redirect url

func (*APIClient) RemoveUsersFromGroup

func (c *APIClient) RemoveUsersFromGroup(ctx context.Context, groupName string, userNames []string) (*http.Response, error)

RemoveUsersFromGroup Remove users from a group. Body should be a JSON dictionary where `users` is a list of usernames to remove from the groups.

{
	"users": ["name1", "name2"]
}

@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name group name

func (*APIClient) RequestNewAPIToken

func (c *APIClient) RequestNewAPIToken(ctx context.Context, auth *BasicAuth) (string, *http.Response, error)

RequestNewAPIToken Request a new API token. Request a new API token to use with the JupyterHub REST API. If not already authenticated, username and password can be sent in the JSON request body. Logging in via this method is only available when the active Authenticator accepts passwords (e.g. not OAuth). @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param optional BasicAuth - optional. @return token value.

func (*APIClient) RequestOauth2Token

func (c *APIClient) RequestOauth2Token(ctx context.Context, clientId string, clientSecret string, grantType string, code string, redirectUri string) (OAuth2TokenResponse, *http.Response, error)

RequestOauth2Token Request an OAuth2 token Request an OAuth2 token from an authorization code. This request completes the OAuth process. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param clientId @param clientSecret @param grantType @param code @param redirectUri @return OAuth2TokenResponse

func (*APIClient) SetGroupProperties

func (c *APIClient) SetGroupProperties(ctx context.Context, body map[string]interface{}, name string) (Group, *http.Response, error)

SetGroupProperties Set the group properties. Added in JupyterHub 3.2. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param body The new group properties, as a JSON dict. @param name group name @return Group

func (*APIClient) Shutdown

func (c *APIClient) Shutdown(ctx context.Context, request *ShutdownRequest) (*http.Response, error)

Shutdown the Hub. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param optional nil or *ShutdownOpts - Optional Parameters.

func (*APIClient) StartUserNamedServer

func (c *APIClient) StartUserNamedServer(ctx context.Context, name string, serverName string, spawnOpts interface{}) (*http.Response, error)

StartUserNamedServer Start a user's single-user named-server notebook server @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name username @param serverName name given to a named-server. Note that depending on your JupyterHub infrastructure there are chracterter size limitation to `server_name`. Default spawner with K8s pod will not allow Jupyter Notebooks to be spawned with a name that contains more than 253 characters (keep in mind that the pod will be spawned with extra characters to identify the user and hub). @param spawnOpts - Optional Spawn options can be passed as a JSON body

when spawning via the API instead of spawn form. The structure of the options will depend on the Spawner's configuration.

func (*APIClient) StartUserServer

func (c *APIClient) StartUserServer(ctx context.Context, name string, spawnOpts interface{}) (*http.Response, error)

StartUserServer Start a user's single-user notebook server @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name username @param spawnOpts - Optional Spawn options can be passed as a JSON body

when spawning via the API instead of spawn form. The structure of the options will depend on the Spawner's configuration. The body itself will be available as `user_options` for the Spawner.

func (*APIClient) StopUserNamedServer

func (c *APIClient) StopUserNamedServer(ctx context.Context, name string, serverName string) (*http.Response, error)

StopUserNamedServer Stop a user's named server To remove the named server in addition to deleting it, the body may be a JSON dictionary with a boolean `remove` field: ```json {\"remove\": true} ``` @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name username @param serverName name given to a named-server

func (*APIClient) StopUserServer

func (c *APIClient) StopUserServer(ctx context.Context, name string) (*http.Response, error)

StopUserServer Stop a user's server @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param name username

func (*APIClient) SyncProxy

func (c *APIClient) SyncProxy(ctx context.Context) (*http.Response, error)

SyncProxy Force the Hub to sync with the proxy @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().

func (*APIClient) UpdateUser

func (c *APIClient) UpdateUser(ctx context.Context, body UpdateUserRequest, name string) (User, *http.Response, error)

UpdateUser Modify a user. Change a user's name or admin status @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param body Updated user info. At least one key to be updated (name or admin) is required. @param name username @return User

func (*APIClient) UpdateUserActivity

func (c *APIClient) UpdateUserActivity(ctx context.Context, name string, localVarOptionals *UpdateUserActivityRequest) (*http.Response, error)

UpdateUserActivity Notify Hub of activity for a given user. Notify the Hub of activity by the user, e.g. accessing a service or (more likely) actively using a server. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param name username * @param optional nil or *UpdateUserActivityOpts - Optional Parameters.

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the swagger operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

type Authenticator

type Authenticator struct {
	// The Python class currently active for JupyterHub Authentication
	Class string `json:"class,omitempty"`
	// The version of the currently active Authenticator
	Version string `json:"version,omitempty"`
}

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`   // Host is "ip:port"
	Scheme        string            `json:"scheme,omitempty"` // Scheme is http or https
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	HTTPClient    *http.Client
}

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

type CreateUsersRequest

type CreateUsersRequest struct {
	// list of usernames to create on the Hub
	Usernames []string `json:"usernames,omitempty"`
	// whether the created users should be admins
	Admin bool `json:"admin,omitempty"`
}

type DetailedInfo

type DetailedInfo struct {
	// The version of JupyterHub itself
	Version string `json:"version,omitempty"`
	// The Python version, as returned by sys.version
	Python string `json:"python,omitempty"`
	// The path to sys.executable running JupyterHub
	SysExecutable string         `json:"sys_executable,omitempty"`
	Authenticator *Authenticator `json:"authenticator,omitempty"`
	Spawner       *Spawner       `json:"spawner,omitempty"`
}

type GenericError

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

GenericError Provides access to the body, error and model on returned errors.

func (GenericError) Body

func (e GenericError) Body() []byte

Body returns the raw bytes of the response

func (GenericError) Error

func (e GenericError) Error() string

Error returns non-empty string if there was an error.

func (GenericError) Model

func (e GenericError) Model() interface{}

Model returns the unpacked model of the error

type Group

type Group struct {
	// The group's name
	Name string `json:"name,omitempty"`
	// The names of users who are members of this group
	Users []string `json:"users,omitempty"`
	// Group properties (a dictionary).  Unused by JupyterHub itself, but an extension point to store information about groups.  Added in JupyterHub 3.2.
	Properties *interface{} `json:"properties,omitempty"`
	// The names of roles this group has
	Roles []string `json:"roles,omitempty"`
}

type ListUsersOpts

type ListUsersOpts struct {
	// State Return only users who have servers in the given state. If unspecified, return all users.  active: all users with any active servers (ready OR pending) ready: all users who have any ready servers (running, not pending) inactive: all users who have *no* active servers (complement of active)  Added in JupyterHub 1.3
	State *string
	// Offset Return a number users starting at the given offset. Can be used with limit to paginate. If unspecified, return all users.
	Offset *int
	// Limit Return a finite number of users. Can be used with offset to paginate. If unspecified, use api_page_default_limit.
	Limit *int
	// IncludeStoppedServers Include stopped servers in user model(s). Added in JupyterHub 3.0. Allows retrieval of information about stopped servers, such as activity and state fields.
	IncludeStoppedServers *byte
}

type OAuth2TokenResponse

type OAuth2TokenResponse struct {
	// The new API token for the user
	AccessToken string `json:"access_token,omitempty"`
	// Will always be 'Bearer'
	TokenType string `json:"token_type,omitempty"`
}

type ProxyRequest

type ProxyRequest struct {
	// IP address of the new proxy
	Ip string `json:"ip,omitempty"`
	// Port of the new proxy
	Port string `json:"port,omitempty"`
	// Protocol of new proxy, if changed
	Protocol string `json:"protocol,omitempty"`
	// CONFIGPROXY_AUTH_TOKEN for the new proxy
	AuthToken string `json:"auth_token,omitempty"`
}

type RequestIdentity

type RequestIdentity struct {
	// The session id associated with the request's OAuth token, if any. null, if the request token not associated with a session id.  Added in 2.0.
	SessionId string `json:"session_id,omitempty"`
	// The list of all expanded scopes the request credentials have access to.  Added in 2.0.
	Scopes []string `json:"scopes,omitempty"`
}

RequestIdentity is the model for the entity making the request. Extends User or Service model to add information about the specific credentials (e.g. session or token-authorised scopes).

type Server

type Server struct {
	// The server's name. The user's default server has an empty name (”)
	Name string `json:"name,omitempty"`
	// Whether the server is ready for traffic. Will always be false when any transition is pending.
	Ready bool `json:"ready,omitempty"`
	// Whether the server is stopped. Added in JupyterHub 3.0, and only useful when using the `?include_stopped_servers` request parameter. Now that stopped servers may be included (since JupyterHub 3.0), this is the simplest way to select stopped servers. Always equivalent to `not (ready or pending)`.
	Stopped bool `json:"stopped,omitempty"`
	// The currently pending action, if any. A server is not ready if an action is pending.
	Pending string `json:"pending,omitempty"`
	// The URL where the server can be accessed (typically /user/:name/:server.name/).
	Url string `json:"url,omitempty"`
	// The URL for an event-stream to retrieve events during a spawn.
	ProgressUrl string `json:"progress_url,omitempty"`
	// UTC timestamp when the server was last started.
	Started time.Time `json:"started,omitempty"`
	// UTC timestamp last-seen activity on this server.
	LastActivity time.Time `json:"last_activity,omitempty"`
	// Arbitrary internal state from this server's spawner. Only available on the hub's users list or get-user-by-name method, and only with admin:users:server_state scope. None otherwise.
	State *interface{} `json:"state,omitempty"`
	// User specified options for the user's spawned instance of a single-user server.
	UserOptions *interface{} `json:"user_options,omitempty"`
}

type ServerActivity

type ServerActivity struct {
	// Timestamp of last-seen activity on this server.
	LastActivity time.Time `json:"last_activity"`
}

ServerActivity is activity for a single server.

type Service

type Service struct {
	// The service's name
	Name string `json:"name,omitempty"`
	// Whether the service is an admin
	Admin bool `json:"admin,omitempty"`
	// The names of roles this service has
	Roles []string `json:"roles,omitempty"`
	// The internal url where the service is running
	Url string `json:"url,omitempty"`
	// The proxied URL prefix to the service's url
	Prefix string `json:"prefix,omitempty"`
	// The PID of the service process (if managed)
	Pid float64 `json:"pid,omitempty"`
	// The command used to start the service (if managed)
	Command []string `json:"command,omitempty"`
	// Additional information a deployment can attach to a service. JupyterHub does not use this field.
	Info *interface{} `json:"info,omitempty"`
}

type ShutdownRequest

type ShutdownRequest struct {
	// Whether the proxy should be shutdown as well (default from Hub config)
	Proxy bool `json:"proxy,omitempty"`
	// Whether users' notebook servers should be shutdown as well (default from Hub config)
	Servers bool `json:"servers,omitempty"`
}

type Spawner

type Spawner struct {
	// The Python class currently active for spawning single-user notebook servers
	Class string `json:"class,omitempty"`
	// The version of the currently active Spawner
	Version string `json:"version,omitempty"`
}

type Token

type Token struct {
	// The token itself. Only present in responses to requests for a new token.
	Token string `json:"token,omitempty"`
	// The id of the API token. Used for modifying or deleting the token.
	Id string `json:"id,omitempty"`
	// The user that owns a token (undefined if owned by a service)
	User string `json:"user,omitempty"`
	// The service that owns the token (undefined of owned by a user)
	Service string `json:"service,omitempty"`
	// Deprecated in JupyterHub 3, always an empty list. Tokens have 'scopes' starting from JupyterHub 3.
	Roles []string `json:"roles,omitempty"`
	// List of scopes this token has been assigned. New in JupyterHub 3. In JupyterHub 2.x, tokens were assigned 'roles' insead of scopes.
	Scopes []string `json:"scopes,omitempty"`
	// A note about the token, typically describing what it was created for.
	Note string `json:"note,omitempty"`
	// Timestamp when this token was created
	Created time.Time `json:"created,omitempty"`
	// Timestamp when this token expires. Null if there is no expiry.
	ExpiresAt time.Time `json:"expires_at,omitempty"`
	// Timestamp of last-seen activity using this token. Can be null if token has never been used.
	LastActivity time.Time `json:"last_activity,omitempty"`
	// The session id associated with the token, if any. Only used for tokens set during oauth flows.  Added in 2.0.
	SessionId string `json:"session_id,omitempty"`
}

type TokenOpts

type TokenOpts struct {
	// lifetime (in seconds) after which the requested token will expire.
	ExpiresIn float64 `json:"expires_in,omitempty"`
	// A note attached to the token for future bookkeeping
	Note string `json:"note,omitempty"`
	// A list of role names from which to derive scopes. This is a shortcut for assigning collections of scopes; Tokens do not retain role assignment. (Changed in 3.0: roles are immediately resolved to scopes instead of stored on roles.)
	Roles []string `json:"roles,omitempty"`
	// A list of scopes that the token should have. (new in JupyterHub 3.0).
	Scopes []string `json:"scopes,omitempty"`
}

type UpdateUserActivityRequest

type UpdateUserActivityRequest struct {
	// LastActivity is timestamp of last-seen activity for this user. Only needed if this is not activity associated with using a given server.
	LastActivity time.Time `json:"last_activity,omitempty"`
	// Servers register activity for specific servers by name. The keys of this dict are the names of servers. The default server has an empty name (”).
	Servers map[string]ServerActivity `json:"servers,omitempty"`
}

type UpdateUserRequest

type UpdateUserRequest struct {
	// the new name (optional, if another key is updated i.e. admin)
	Name string `json:"name,omitempty"`
	// update admin (optional, if another key is updated i.e. name)
	Admin bool `json:"admin,omitempty"`
}

type User

type User struct {
	// The user's name
	Name string `json:"name,omitempty"`
	// Whether the user is an admin
	Admin bool `json:"admin,omitempty"`
	// The names of roles this user has
	Roles []string `json:"roles,omitempty"`
	// The names of groups where this user is a member
	Groups []string `json:"groups,omitempty"`
	// The user's notebook server's base URL, if running; null if not.
	Server string `json:"server,omitempty"`
	// The currently pending action, if any
	Pending string `json:"pending,omitempty"`
	// Timestamp of last-seen activity from the user
	LastActivity time.Time `json:"last_activity,omitempty"`
	// The servers for this user. By default: only includes _active_ servers. Changed in 3.0: if `?include_stopped_servers` parameter is specified, stopped servers will be included as well.
	Servers []Server `json:"servers,omitempty"`
	// Authentication state of the user. Only available with admin:users:auth_state scope. None otherwise.
	AuthState *interface{} `json:"auth_state,omitempty"`
}

type UserNames

type UserNames struct {
	// Users are list of usernames to add/remove to the group
	Users []string `json:"users,omitempty"`
}

type VersionResponse

type VersionResponse struct {
	// The version of JupyterHub itself
	Version string `json:"version,omitempty"`
}

Jump to

Keyboard shortcuts

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