Documentation
¶
Index ¶
- func HintForHTTPStatus(statusCode int) string
- func HintForItemError(code string) string
- func HintForMessage(msg string) string
- func HintForPublishStatus(statusCode string) string
- func ParseAPIError(body []byte) string
- func ResolveHint(errorCode string, httpStatus int, message string) string
- type APIError
- type APIErrorBody
- type APIErrorDetail
- type CWSError
- type CancelResponse
- type Client
- func (c *Client) CancelSubmission(ctx context.Context, extensionID string) (*CancelResponse, error)
- func (c *Client) FetchStatus(ctx context.Context, extensionID string) (*StatusResponse, []byte, error)
- func (c *Client) Publish(ctx context.Context, extensionID string, staged bool) (*PublishResponse, error)
- func (c *Client) SetDeployPercentage(ctx context.Context, extensionID string, percentage int) (*DeployPercentageResponse, error)
- func (c *Client) Upload(ctx context.Context, extensionID string, zipData []byte) (*UploadResponse, error)
- type DeployPercentageRequest
- type DeployPercentageResponse
- type DistributionChannel
- type ErrorDetail
- type FieldViolation
- type ItemError
- type ItemRevisionStatus
- type ParsedAPIError
- type PublishRequest
- type PublishResponse
- type StatusResponse
- type UploadResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HintForHTTPStatus ¶ added in v1.1.0
HintForHTTPStatus returns an actionable hint for a known HTTP status code.
func HintForItemError ¶ added in v1.1.0
HintForItemError returns an actionable hint for a known ItemError error_code.
func HintForMessage ¶ added in v1.1.0
HintForMessage returns an actionable hint by pattern-matching against the error message. This is used as a fallback for vague API errors that lack structured error codes.
func HintForPublishStatus ¶ added in v1.1.0
HintForPublishStatus returns an actionable hint for a known publish status code.
func ParseAPIError ¶
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 CWSError ¶ added in v1.1.0
type CWSError struct {
Operation string // "upload", "publish", "status", "rollout", "cancel"
HTTPStatus int // HTTP status code from the API response
Message string // original API error message, preserved verbatim
Code string // primary error code (e.g., "PKG_INVALID_VERSION_NUMBER")
Hint string // actionable suggestion for the user
Details []ErrorDetail // all errors when multiple ItemErrors are present
}
CWSError is a structured error returned by Chrome Web Store API operations. It preserves the original API message and attaches an actionable hint when possible.
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 ¶
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.
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 ErrorDetail ¶ added in v1.1.0
ErrorDetail represents a single error entry from an ItemError array.
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 ParsedAPIError ¶ added in v1.1.0
type ParsedAPIError struct {
Message string // top-level error message
StatusCode int // HTTP-like code from the error body
Status string // status string (e.g., "INVALID_ARGUMENT")
Reasons []string // reason codes from field violations (e.g., "PKG_INVALID_VERSION_NUMBER")
Description string // most specific description found
}
ParsedAPIError holds structured information extracted from a Google API error response.
func ParseAPIErrorDetail ¶ added in v1.1.0
func ParseAPIErrorDetail(body []byte) *ParsedAPIError
ParseAPIErrorDetail extracts structured error information from a Google API error response. Returns nil if the body is not a recognized error format.
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.