dashboard

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultDashboardURL = "https://dashboard.algolia.com"
	DefaultAPIURL       = "https://api.dashboard.algolia.com"
	DefaultOAuthScope   = "public applications:manage keys:manage"
)

Production defaults; overridable via ldflags or ALGOLIA_DASHBOARD_URL / ALGOLIA_API_URL / ALGOLIA_OAUTH_SCOPE env vars.

View Source
var ErrSessionExpired = errors.New("session expired")

ErrSessionExpired is returned when an API call gets a 401 Unauthorized.

View Source
var WriteACL = []string{
	"search", "browse", "seeUnretrievableAttributes", "listIndexes",
	"analytics", "logs", "addObject", "deleteObject", "deleteIndex",
	"settings", "editSettings", "recommendation",
}

WriteACL is the set of permissions for API keys created by the CLI.

Functions

This section is empty.

Types

type APIKeyAttributes

type APIKeyAttributes struct {
	Value string `json:"value"`
}

APIKeyAttributes contains the actual API key fields.

type APIKeyResource

type APIKeyResource struct {
	ID         string           `json:"id"`
	Type       string           `json:"type"`
	Attributes APIKeyAttributes `json:"attributes"`
}

APIKeyResource is a JSON:API resource wrapper for an API key.

type Application

type Application struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	APIKey string `json:"api_key,omitempty"`
}

Application is a flattened view of an Algolia application for CLI consumption.

type ApplicationAttributes

type ApplicationAttributes struct {
	Name          string `json:"name"`
	ApplicationID string `json:"application_id"`
	APIKey        string `json:"api_key"`
}

ApplicationAttributes contains the actual application fields.

type ApplicationResource

type ApplicationResource struct {
	ID         string                `json:"id"`
	Type       string                `json:"type"`
	Attributes ApplicationAttributes `json:"attributes"`
}

ApplicationResource is a JSON:API resource wrapper for an application.

type ApplicationsResponse

type ApplicationsResponse struct {
	Data  []ApplicationResource `json:"data"`
	Meta  PaginationMeta        `json:"meta"`
	Links PaginationLinks       `json:"links"`
}

ApplicationsResponse is the JSON:API response from GET /1/applications.

type Client

type Client struct {
	DashboardURL string
	APIURL       string
	OAuthScope   string
	ClientID     string
	// contains filtered or unexported fields
}

Client interacts with the Algolia Dashboard OAuth endpoint and the Public API.

func NewClient

func NewClient(clientID string) *Client

NewClient creates a new dashboard client with the given OAuth client ID. Respects ALGOLIA_DASHBOARD_URL, ALGOLIA_API_URL, and ALGOLIA_OAUTH_SCOPE environment variables, falling back to the compiled-in defaults (set via ldflags).

func NewClientWithHTTPClient

func NewClientWithHTTPClient(clientID string, httpClient *http.Client) *Client

NewClientWithHTTPClient creates a new dashboard client with a custom HTTP client. Used primarily in tests; callers must set DashboardURL and APIURL explicitly.

func (*Client) AuthorizationCodeGrant

func (c *Client) AuthorizationCodeGrant(code, codeVerifier, redirectURI string) (*OAuthTokenResponse, error)

AuthorizationCodeGrant exchanges an authorization code + PKCE code_verifier for an access token. The redirectURI must match the one used in the authorize URL.

func (*Client) AuthorizeURL

func (c *Client) AuthorizeURL(codeChallenge, redirectURI string) string

AuthorizeURL builds the OAuth 2.0 authorization URL for the browser-based sign-in flow.

func (*Client) CreateAPIKey

func (c *Client) CreateAPIKey(accessToken, appID string, acl []string, description string) (string, error)

CreateAPIKey creates a new API key with the given ACL for the specified application.

func (*Client) CreateApplication

func (c *Client) CreateApplication(accessToken, region, name string) (*Application, error)

CreateApplication creates a new application for the authenticated user.

func (*Client) GetApplication

func (c *Client) GetApplication(accessToken, appID string) (*Application, error)

GetApplication returns a single application by its ID.

func (*Client) GetCrawlerUser added in v1.8.3

func (c *Client) GetCrawlerUser(accessToken string) (*DashboardCrawlerUserData, error)

GetCrawlerUser gets the crawler API user data for the current authenticated user

func (*Client) ListApplications

func (c *Client) ListApplications(accessToken string) ([]Application, error)

ListApplications returns all applications for the authenticated user, following pagination to fetch every page.

func (*Client) ListRegions

func (c *Client) ListRegions(accessToken string) ([]Region, error)

ListRegions returns the allowed hosting regions for application creation.

func (*Client) RefreshToken

func (c *Client) RefreshToken(refreshToken string) (*OAuthTokenResponse, error)

RefreshToken uses a refresh token to obtain a new access token.

func (*Client) RevokeToken

func (c *Client) RevokeToken(token string) error

RevokeToken revokes an OAuth access or refresh token via POST /2/oauth/revoke.

func (*Client) SignupAuthorizeURL

func (c *Client) SignupAuthorizeURL(codeChallenge, redirectURI string) string

SignupAuthorizeURL builds an OAuth 2.0 authorization URL that opens the sign-up page instead of the default sign-in page.

type CreateAPIKeyRequest

type CreateAPIKeyRequest struct {
	ACL         []string `json:"acl"`
	Description string   `json:"description"`
}

CreateAPIKeyRequest is the payload for POST /1/applications/{application_id}/api-keys.

type CreateAPIKeyResponse

type CreateAPIKeyResponse struct {
	Data APIKeyResource `json:"data"`
}

CreateAPIKeyResponse is the JSON:API response from POST /1/applications/{application_id}/api-keys.

type CreateApplicationRequest

type CreateApplicationRequest struct {
	RegionCode string `json:"region_code"`
	Name       string `json:"name"`
}

CreateApplicationRequest is the payload for POST /1/applications.

type DashboardCrawlerError added in v1.8.3

type DashboardCrawlerError struct {
	Status string  `json:"status"`
	Title  string  `json:"title"`
	Detail *string `json:"detail"`
}

type DashboardCrawlerErrorResponse added in v1.8.3

type DashboardCrawlerErrorResponse struct {
	Errors []DashboardCrawlerError `json:"errors"`
}

type DashboardCrawlerUserData added in v1.8.3

type DashboardCrawlerUserData struct {
	ID     string `json:"id"`
	Email  string `json:"email"`
	Name   string `json:"name"`
	APIKey string `json:"apiKey"`
}

DashboardCrawlerUserData contains the user information from the crawler API

type DashboardCrawlerUserResponse added in v1.8.3

type DashboardCrawlerUserResponse struct {
	Data DashboardCrawlerUserData `json:"data"`
}

DashboardCrawlerUserResponse is the JSON:API response from GET /1/crawler/user

type ErrClusterUnavailable

type ErrClusterUnavailable struct {
	Region  string
	Message string
}

ErrClusterUnavailable is returned when a region has no available cluster.

func (*ErrClusterUnavailable) Error

func (e *ErrClusterUnavailable) Error() string

type OAuthErrorResponse

type OAuthErrorResponse struct {
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

OAuthErrorResponse is the error format from the OAuth endpoints.

type OAuthTokenResponse

type OAuthTokenResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	Scope        string `json:"scope"`
	CreatedAt    int64  `json:"created_at"`
	User         *User  `json:"user,omitempty"`
}

OAuthTokenResponse is the response from POST /2/oauth/token.

type PaginationLinks struct {
	First string `json:"first"`
	Last  string `json:"last"`
	Prev  string `json:"prev"`
	Next  string `json:"next"`
}

PaginationLinks contains pagination URLs.

type PaginationMeta added in v1.8.1

type PaginationMeta struct {
	TotalCount  int `json:"total_count"`
	PerPage     int `json:"per_page"`
	CurrentPage int `json:"current_page"`
	TotalPages  int `json:"total_pages"`
}

PaginationMeta contains page-based pagination metadata.

type Region

type Region struct {
	Code string `json:"code"`
	Name string `json:"name"`
}

Region represents a hosting region from GET /1/hosting/regions.

type RegionsResponse

type RegionsResponse struct {
	RegionCodes []Region `json:"region_codes"`
}

RegionsResponse is the response from GET /1/hosting/regions.

type SingleApplicationResponse

type SingleApplicationResponse struct {
	Data ApplicationResource `json:"data"`
}

SingleApplicationResponse is the JSON:API response from GET /1/application/:id.

type User

type User struct {
	ID        int    `json:"id"`
	Email     string `json:"email"`
	Name      string `json:"name"`
	AvatarURL string `json:"avatar_url"`
}

User represents the authenticated user from the OAuth token response.

Jump to

Keyboard shortcuts

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