newapi

package
v0.0.0-...-7303733 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package newapi provides a Go SDK for the New API documentation surface.

In addition to the typed helper methods in this package, the client also exposes generated operation trees that mirror the official API reference.

Index

Constants

This section is empty.

Variables

View Source
var (
	WithHTTPClient    = core.WithHTTPClient
	WithTimeout       = core.WithTimeout
	WithAdminAuth     = core.WithAdminAuth
	WithDefaultAuth   = core.WithDefaultAuth
	WithBearerToken   = core.WithBearerToken
	WithSessionCookie = core.WithSessionCookie
	WithDefaultUserID = core.WithDefaultUserID
	WithUserAgent     = core.WithUserAgent
)
View Source
var ErrNotFound = core.ErrNotFound

Functions

This section is empty.

Types

type APIError

type APIError = core.APIError

type Auth

type Auth = core.Auth

type CallConfig

type CallConfig = core.CallConfig

type Client

type Client struct {
	*core.Client

	AIModel    *aimodel.Service
	Management *management.Service
}

func New

func New(baseURL string, opts ...Option) (*Client, error)

func NewApiClient

func NewApiClient(baseURL string, opts ...Option) (*Client, error)

func NewClient

func NewClient(baseURL, rootToken string, rootUserID, timeoutSec int) *Client

func (*Client) AdminCreateRedemptions

func (c *Client) AdminCreateRedemptions(name string, quota int, count int, expiredTime int64) ([]string, error)

func (*Client) AdminCreateRedemptionsContext

func (c *Client) AdminCreateRedemptionsContext(ctx context.Context, input CreateRedemptionsRequest) ([]string, error)

func (*Client) AdminCreateUser

func (c *Client) AdminCreateUser(username, password, displayName string) error

func (*Client) AdminCreateUserAndGet

func (c *Client) AdminCreateUserAndGet(username, password, displayName string) (*User, error)

func (*Client) AdminCreateUserAndGetContext

func (c *Client) AdminCreateUserAndGetContext(ctx context.Context, username, password, displayName string) (*User, error)

func (*Client) AdminCreateUserContext

func (c *Client) AdminCreateUserContext(ctx context.Context, input CreateUserRequest) error

func (*Client) AdminGetLogs

func (c *Client) AdminGetLogs(params url.Values) (*LogPageInfo, error)

func (*Client) AdminGetLogsContext

func (c *Client) AdminGetLogsContext(ctx context.Context, params url.Values) (*LogPageInfo, error)

func (*Client) AdminGetUser

func (c *Client) AdminGetUser(userID int) (*User, error)

func (*Client) AdminGetUserContext

func (c *Client) AdminGetUserContext(ctx context.Context, userID int) (*User, error)

func (*Client) AdminManageUser

func (c *Client) AdminManageUser(userID int, action string) error

func (*Client) AdminManageUserContext

func (c *Client) AdminManageUserContext(ctx context.Context, userID int, action string) error

func (*Client) AdminSearchUser

func (c *Client) AdminSearchUser(keyword string) (*User, error)

func (*Client) AdminSearchUserContext

func (c *Client) AdminSearchUserContext(ctx context.Context, keyword string) (*User, error)

func (*Client) AdminUpdateUser

func (c *Client) AdminUpdateUser(userID int, username, displayName, group, remark string, quota int) error

func (*Client) AdminUpdateUserContext

func (c *Client) AdminUpdateUserContext(ctx context.Context, input UpdateUserRequest) error

func (*Client) CreateTokenWithToken

func (c *Client) CreateTokenWithToken(rawToken string, userID int, name string, unlimitedQuota bool) error

func (*Client) CreateTokenWithTokenContext

func (c *Client) CreateTokenWithTokenContext(ctx context.Context, rawToken string, userID int, name string, unlimitedQuota bool) (*Token, error)

func (*Client) GetUserWithToken

func (c *Client) GetUserWithToken(rawToken string, userID int) (*User, error)

func (*Client) GetUserWithTokenContext

func (c *Client) GetUserWithTokenContext(ctx context.Context, rawToken string, userID int) (*User, error)

func (*Client) ListTokensWithToken

func (c *Client) ListTokensWithToken(rawToken string, userID, page, pageSize int) ([]Token, error)

func (*Client) ListTokensWithTokenContext

func (c *Client) ListTokensWithTokenContext(ctx context.Context, rawToken string, userID, page, pageSize int) ([]Token, error)

func (*Client) UserCreateToken

func (c *Client) UserCreateToken(accessToken string, userID int, name string, unlimitedQuota bool) (*Token, error)

func (*Client) UserCreateTokenContext

func (c *Client) UserCreateTokenContext(ctx context.Context, accessToken string, userID int, input CreateTokenRequest) (*Token, error)

func (*Client) UserDeleteToken

func (c *Client) UserDeleteToken(accessToken string, userID int, tokenID int) error

func (*Client) UserDeleteTokenContext

func (c *Client) UserDeleteTokenContext(ctx context.Context, accessToken string, userID int, tokenID int) error

func (*Client) UserGenerateAccessToken

func (c *Client) UserGenerateAccessToken(sessionCookie string, userID int) (string, error)

func (*Client) UserGenerateAccessTokenContext

func (c *Client) UserGenerateAccessTokenContext(ctx context.Context, sessionCookie string, userID int) (string, error)

func (*Client) UserGetSelf

func (c *Client) UserGetSelf(accessToken string, userID int) (*User, error)

func (*Client) UserGetSelfContext

func (c *Client) UserGetSelfContext(ctx context.Context, accessToken string, userID int) (*User, error)

func (*Client) UserListModels

func (c *Client) UserListModels(accessToken string, userID int) ([]Model, error)

func (*Client) UserListModelsContext

func (c *Client) UserListModelsContext(ctx context.Context, accessToken string, userID int) ([]Model, error)

func (*Client) UserListTokens

func (c *Client) UserListTokens(accessToken string, userID int, page, pageSize int) ([]Token, error)

func (*Client) UserListTokensPage

func (c *Client) UserListTokensPage(accessToken string, userID int, page, pageSize int) (*TokenPageInfo, error)

func (*Client) UserListTokensPageContext

func (c *Client) UserListTokensPageContext(ctx context.Context, accessToken string, userID int, page, pageSize int) (*TokenPageInfo, error)

func (*Client) UserLogin

func (c *Client) UserLogin(username, password string) (string, error)

func (*Client) UserLoginContext

func (c *Client) UserLoginContext(ctx context.Context, username, password string) (string, error)

func (*Client) UserRedeemRedemption

func (c *Client) UserRedeemRedemption(accessToken string, userID int, key string) (int, error)

func (*Client) UserRedeemRedemptionContext

func (c *Client) UserRedeemRedemptionContext(ctx context.Context, accessToken string, userID int, key string) (int, error)

type CreateRedemptionsRequest

type CreateRedemptionsRequest struct {
	Name        string `json:"name"`
	Quota       int    `json:"quota"`
	Count       int    `json:"count"`
	ExpiredTime int64  `json:"expired_time"`
}

type CreateTokenRequest

type CreateTokenRequest struct {
	Name           string `json:"name"`
	RemainQuota    int    `json:"remain_quota"`
	UnlimitedQuota bool   `json:"unlimited_quota"`
}

type CreateUserRequest

type CreateUserRequest struct {
	Username    string `json:"username"`
	Password    string `json:"password"`
	DisplayName string `json:"display_name"`
}

type Log

type Log struct {
	ID               int    `json:"id"`
	CreatedAt        int64  `json:"created_at"`
	Type             int    `json:"type"`
	Content          string `json:"content"`
	Username         string `json:"username"`
	TokenName        string `json:"token_name"`
	ModelName        string `json:"model_name"`
	Quota            int    `json:"quota"`
	PromptTokens     int    `json:"prompt_tokens"`
	CompletionTokens int    `json:"completion_tokens"`
	UseTime          int    `json:"use_time"`
	IsStream         bool   `json:"is_stream"`
	ChannelID        int    `json:"channel"`
	TokenID          int    `json:"token_id"`
	Group            string `json:"group"`
	RequestID        string `json:"request_id,omitempty"`
}

type LogPageInfo

type LogPageInfo struct {
	Items    []Log `json:"items"`
	Total    int   `json:"total"`
	Page     int   `json:"page"`
	PageSize int   `json:"page_size"`
}

type Model

type Model struct {
	ID      string `json:"id"`
	Object  string `json:"object,omitempty"`
	OwnedBy string `json:"owned_by,omitempty"`
	Name    string `json:"name,omitempty"`
	Group   string `json:"group,omitempty"`
}

type Operation

type Operation = core.Operation

type Option

type Option = core.Option

type RawResponse

type RawResponse = core.RawResponse

type Session

type Session struct {
	Cookie string
}

type Token

type Token struct {
	ID             int    `json:"id"`
	Name           string `json:"name"`
	Key            string `json:"key"`
	UnlimitedQuota bool   `json:"unlimited_quota"`
}

type TokenPageInfo

type TokenPageInfo struct {
	Items    []Token `json:"items"`
	Total    int64   `json:"total"`
	Page     int     `json:"page"`
	PageSize int     `json:"page_size"`
}

type UpdateUserRequest

type UpdateUserRequest struct {
	ID          int    `json:"id"`
	Username    string `json:"username"`
	DisplayName string `json:"display_name"`
	Group       string `json:"group"`
	Remark      string `json:"remark"`
	Quota       int    `json:"quota"`
}

type User

type User struct {
	ID          int    `json:"id"`
	Username    string `json:"username"`
	DisplayName string `json:"display_name"`
	AccessToken string `json:"access_token"`
	Quota       int    `json:"quota"`
	UsedQuota   int    `json:"used_quota"`
	Group       string `json:"group"`
	Status      int    `json:"status"`
	Remark      string `json:"remark,omitempty"`
}

Directories

Path Synopsis
Code generated by go run ./tools/generate-operations; DO NOT EDIT.
Code generated by go run ./tools/generate-operations; DO NOT EDIT.
Code generated by go run ./tools/generate-operations; DO NOT EDIT.
Code generated by go run ./tools/generate-operations; DO NOT EDIT.

Jump to

Keyboard shortcuts

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