api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	BaseURL string // BaseURL is the base endpoint for WriftAI's API.
	// contains filtered or unexported fields
}

API represents the struct used to interact with WriftAI's API v1.

func NewAPI

func NewAPI(baseURL string, client *http.Client) *API

NewAPI creates a new instance of the API client.

baseURL is the base endpoint for WriftAI's API. client is an instance of http.Client, which handles HTTP communication.

Returns a pointer to an API struct that can be used to interact with WriftAI's API.

func (*API) CreateVersion

func (api *API) CreateVersion(token, modelOwner, modelName, containerImageDigest, releaseNotes string,
	schemas map[string]any) (*Version, error)

CreateVersion creates a new model version.

token is a string representing the authorization access token used to authenticate the request. modelOwner is a string representing the username of the owner of the model. modelName is a string representing the name of the model. containerImageDigest is the sha256 hash digest of the version's Docker container image in WriftAI's registry. schemas is the schemas of the version. releaseNotes is a string representing the release notes for the new version.

This function sends an HTTP POST request to the "/models/{model_owner}/{model_name}/versions" endpoint of WriftAI's API. The token is included in the Authorization header as a Bearer token.

If successful, CreateVersion returns a pointer to a Version struct containing the version's details. If an error occurs, it returns a nil version and an error describing the failure.

func (*API) GetModel

func (api *API) GetModel(token string, owner string, name string) (*Model, error)

GetModel retrieves a model from WriftAI's API.

token is a string representing the authorization access token used to authenticate the request. owner is a string representing the username of the owner of the model. name is a string representing the name of the model.

This function sends an HTTP GET request to the "/models/{model_owner}/{model_name}" endpoint of WriftAI's API. The token is included in the Authorization header as a Bearer token.

If successful, GetModel returns a pointer to a Model struct containing the model's details. If an error occurs, it returns a nil model and an error describing the failure.

func (*API) GetUser

func (api *API) GetUser(token string) (*User, error)

GetUser retrieves a user from WriftAI's API using the provided token.

token is a string representing the authorization access token used to authenticate the request.

This function sends an HTTP GET request to the "/user" endpoint of WriftAI's API. The token is included in the Authorization header as a Bearer token.

If successful, GetUser returns a pointer to a User struct containing the user's details. If an error occurs, it returns a nil user and an error describing the failure.

type Model

type Model struct {
	ID    string `json:"id"`    // ID is the unique identifier of the model.
	Owner User   `json:"owner"` // Owner is the object containing details of the model owner.
}

Model represents a model object returned by WriftAI's API.

type User

type User struct {
	ID       string `json:"id"`       // ID is the unique identifier of the user.
	Username string `json:"username"` // Username is the display name of the user.
}

User represents a user object returned by WriftAI's API.

type Version

type Version struct {
	ID string `json:"id"` // ID is the unique identifier of the model version.
}

Version represents a model version object returned by WriftAI's API.

Jump to

Keyboard shortcuts

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