api

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAPIError

func ParseAPIError(body []byte) string

ParseAPIError attempts to extract a human-readable error from a Google API error response. Returns an empty string if the body is not a recognized error format.

Types

type APIError

type APIError struct {
	Error *APIErrorBody `json:"error,omitempty"`
}

APIError represents a Google API error response.

type APIErrorBody

type APIErrorBody struct {
	Code    int              `json:"code"`
	Message string           `json:"message"`
	Status  string           `json:"status"`
	Details []APIErrorDetail `json:"details,omitempty"`
}

APIErrorBody represents the body of a Google API error.

type APIErrorDetail

type APIErrorDetail struct {
	Type            string           `json:"@type"`
	Reason          string           `json:"reason,omitempty"`
	FieldViolations []FieldViolation `json:"fieldViolations,omitempty"`
}

APIErrorDetail represents a detail entry in a Google API error.

type CancelResponse

type CancelResponse struct {
	Status string `json:"status,omitempty"`
}

CancelResponse represents the response from cancelSubmission.

type Client

type Client struct {
	BaseURL string // override for testing; empty uses default
	// contains filtered or unexported fields
}

Client is the Chrome Web Store API V2 client.

func NewClient

func NewClient(authenticator auth.Authenticator, publisherID string) *Client

NewClient creates a new API client.

func (*Client) CancelSubmission

func (c *Client) CancelSubmission(ctx context.Context, extensionID string) (*CancelResponse, error)

CancelSubmission cancels a pending submission.

func (*Client) FetchStatus

func (c *Client) FetchStatus(ctx context.Context, extensionID string) (*StatusResponse, []byte, error)

FetchStatus retrieves the current status of an extension.

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, extensionID string, staged bool) (*PublishResponse, error)

Publish publishes the most recently uploaded version.

func (*Client) SetDeployPercentage

func (c *Client) SetDeployPercentage(ctx context.Context, extensionID string, percentage int) (*DeployPercentageResponse, error)

SetDeployPercentage sets the deploy percentage for a published extension.

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, extensionID string, zipData []byte) (*UploadResponse, error)

Upload uploads a zip file to the Chrome Web Store.

type DeployPercentageRequest

type DeployPercentageRequest struct {
	DeployPercentage int `json:"deployPercentage"`
}

DeployPercentageRequest represents the request body for setPublishedDeployPercentage.

type DeployPercentageResponse

type DeployPercentageResponse struct {
	DeployPercentage int    `json:"deployPercentage"`
	Status           string `json:"status,omitempty"`
}

DeployPercentageResponse represents the response from setPublishedDeployPercentage.

type DistributionChannel

type DistributionChannel struct {
	DeployPercentage int    `json:"deployPercentage"`
	CrxVersion       string `json:"crxVersion"`
}

DistributionChannel represents a distribution channel for a published extension.

type FieldViolation

type FieldViolation struct {
	Field       string `json:"field"`
	Description string `json:"description"`
	Reason      string `json:"reason,omitempty"`
}

FieldViolation represents a field-level error.

type ItemError

type ItemError struct {
	ErrorCode   string `json:"error_code"`
	ErrorDetail string `json:"error_detail"`
}

ItemError represents an error returned by the API.

type ItemRevisionStatus

type ItemRevisionStatus struct {
	State                string                `json:"state"`
	CrxVersion           string                `json:"crxVersion,omitempty"`
	DistributionChannels []DistributionChannel `json:"distributionChannels,omitempty"`
}

ItemRevisionStatus represents the status of an item revision (published, in-review, or draft).

type PublishRequest

type PublishRequest struct {
	PublishType string `json:"publishType,omitempty"`
}

PublishRequest represents the request body for the publish endpoint.

type PublishResponse

type PublishResponse struct {
	Status     []string `json:"status"`
	StatusCode string   `json:"statusCode,omitempty"`
}

PublishResponse represents the response from the publish endpoint.

type StatusResponse

type StatusResponse struct {
	Name                        string              `json:"name"`
	ItemID                      string              `json:"itemId"`
	PublishedItemRevisionStatus *ItemRevisionStatus `json:"publishedItemRevisionStatus,omitempty"`
	SubmittedItemRevisionStatus *ItemRevisionStatus `json:"submittedItemRevisionStatus,omitempty"`
	LastAsyncUploadState        string              `json:"lastAsyncUploadState,omitempty"`
	ItemError                   []ItemError         `json:"itemError,omitempty"`
}

StatusResponse represents the response from the fetchStatus endpoint (V2 API).

type UploadResponse

type UploadResponse struct {
	ID          string      `json:"id"`
	UploadState string      `json:"uploadState"`
	ItemError   []ItemError `json:"itemError,omitempty"`
}

UploadResponse represents the response from the upload endpoint.

Jump to

Keyboard shortcuts

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