Documentation
¶
Index ¶
- Constants
- Variables
- func BaseURL() string
- func CheckResponse(resp *http.Response) error
- func DecodeJSON(resp *http.Response, dest any) error
- func RequireSecureURL(baseURL string) error
- func ResolveURL(path string) (string, error)
- func ResolveURLFromBase(baseURL, path string) (string, error)
- type Client
- func (c *Client) Delete(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) Get(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) Patch(ctx context.Context, path string, body any) (*http.Response, error)
- func (c *Client) Post(ctx context.Context, path string, body any) (*http.Response, error)
- func (c *Client) Put(ctx context.Context, path string, body any) (*http.Response, error)
- type ErrorResponse
- type TrailCreateRequest
- type TrailCreateResponse
- type TrailDetailResponse
- type TrailListResponse
- type TrailResource
- type TrailUpdateRequest
- type TrailUpdateResponse
Constants ¶
const ( // DefaultBaseURL is the production Entire API origin. DefaultBaseURL = "https://entire.io" // BaseURLEnvVar overrides the Entire API origin for local development. BaseURLEnvVar = "ENTIRE_API_BASE_URL" )
Variables ¶
var ErrInsecureHTTP = errors.New("refusing to use insecure http:// base URL for authentication (use --insecure-http-auth to override)")
ErrInsecureHTTP is returned when the base URL uses HTTP without an explicit opt-in.
Functions ¶
func BaseURL ¶
func BaseURL() string
BaseURL returns the effective Entire API base URL. ENTIRE_API_BASE_URL takes precedence over the production default.
func CheckResponse ¶ added in v0.5.2
CheckResponse returns an error if the response status code indicates failure. For non-2xx responses, it reads and parses the error message from the body. The caller is responsible for closing resp.Body.
func DecodeJSON ¶ added in v0.5.2
DecodeJSON reads the response body and decodes it into dest. It limits the body size to protect against unbounded reads. The caller is responsible for closing resp.Body.
func RequireSecureURL ¶
RequireSecureURL returns ErrInsecureHTTP if the base URL uses the http scheme. Call this before making authenticated requests unless --insecure-http-auth is set.
func ResolveURL ¶
ResolveURL joins an API-relative path against the effective base URL.
func ResolveURLFromBase ¶
ResolveURLFromBase joins an API-relative path against an explicit base URL. Only http and https schemes are accepted.
Types ¶
type Client ¶ added in v0.5.2
type Client struct {
// contains filtered or unexported fields
}
Client is an authenticated HTTP client for the Entire API. It attaches the bearer token to all outgoing requests via the Authorization header.
func NewClient ¶ added in v0.5.2
NewClient creates a new authenticated API client with an explicit bearer token.
func (*Client) Delete ¶ added in v0.5.2
Delete sends an authenticated DELETE request to the given API-relative path.
func (*Client) Get ¶ added in v0.5.2
Get sends an authenticated GET request to the given API-relative path.
func (*Client) Patch ¶ added in v0.5.2
Patch sends an authenticated PATCH request with a JSON body to the given API-relative path.
type ErrorResponse ¶ added in v0.5.2
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse represents a standard API error response.
type TrailCreateRequest ¶ added in v0.5.2
type TrailCreateRequest struct {
Title string `json:"title"`
Body string `json:"body,omitempty"`
BranchName string `json:"branch_name"`
Base string `json:"base,omitempty"`
Status string `json:"status,omitempty"`
Assignees []string `json:"assignees,omitempty"`
Labels []string `json:"labels,omitempty"`
Priority string `json:"priority,omitempty"`
Type string `json:"type,omitempty"`
}
TrailCreateRequest is the body for POST /api/v1/trails/:host/:owner/:repo.
type TrailCreateResponse ¶ added in v0.5.2
type TrailCreateResponse struct {
Trail TrailResource `json:"trail"`
BranchCreated bool `json:"branch_created"`
}
TrailCreateResponse is the response from POST /api/v1/trails/:org/:repo.
type TrailDetailResponse ¶ added in v0.5.2
type TrailDetailResponse struct {
Trail TrailResource `json:"trail"`
Discussion trail.Discussion `json:"discussion"`
Checkpoints trail.Checkpoints `json:"checkpoints"`
}
TrailDetailResponse is the response from GET /api/v1/trails/:org/:repo/:trailId.
type TrailListResponse ¶ added in v0.5.2
type TrailListResponse struct {
Trails []TrailResource `json:"trails"`
RepoFullName string `json:"repo_full_name"`
DefaultBranch string `json:"default_branch"`
UpdatedAt time.Time `json:"updated_at"`
}
TrailListResponse is the response from GET /api/v1/trails/:org/:repo.
type TrailResource ¶ added in v0.5.2
type TrailResource struct {
TrailID string `json:"trail_id"`
Branch string `json:"branch"`
Base string `json:"base"`
Title string `json:"title"`
Body string `json:"body"`
Status string `json:"status"`
Author string `json:"author"`
Assignees []string `json:"assignees"`
Labels []string `json:"labels"`
Priority string `json:"priority,omitempty"`
Type string `json:"type,omitempty"`
Reviewers []trail.Reviewer `json:"reviewers,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
MergedAt *time.Time `json:"merged_at,omitempty"`
CommentCount int `json:"comment_count,omitempty"`
UnresolvedCount int `json:"unresolved_count,omitempty"`
CheckpointCount int `json:"checkpoint_count,omitempty"`
CommitsAhead int `json:"commits_ahead,omitempty"`
}
TrailResource represents a single trail from the API.
func (*TrailResource) ToMetadata ¶ added in v0.5.2
func (r *TrailResource) ToMetadata() *trail.Metadata
ToMetadata converts a TrailResource to a trail.Metadata for display.
type TrailUpdateRequest ¶ added in v0.5.2
type TrailUpdateRequest struct {
Branch *string `json:"branch,omitempty"`
Base *string `json:"base,omitempty"`
Status *string `json:"status,omitempty"`
Title *string `json:"title,omitempty"`
Body *string `json:"body,omitempty"`
Assignees *[]string `json:"assignees,omitempty"`
Labels *[]string `json:"labels,omitempty"`
Priority *string `json:"priority,omitempty"`
Type *string `json:"type,omitempty"`
}
TrailUpdateRequest is the body for PATCH /api/v1/trails/:host/:owner/:repo/:trailId. Pointer fields distinguish "not provided" (nil) from "set to value". For slices, *[]string is used so nil means "no change" while &[]string{} means "clear".
type TrailUpdateResponse ¶ added in v0.5.2
type TrailUpdateResponse struct {
Trail TrailResource `json:"trail"`
}
TrailUpdateResponse is the response from PATCH /api/v1/trails/:org/:repo/:trailId.