Documentation
¶
Index ¶
- Constants
- Variables
- func RequestWasMade() bool
- func SetRequestWasMade(made bool) bool
- func WrapMutationError(method string, err error) error
- type Context
- func (c *Context) ForConsole() (sdkclient.Client, error)
- func (c *Context) ForConsoleWithOrganization(organizationID string) (sdkclient.Client, error)
- func (c *Context) ForProject(projectID string) (sdkclient.Client, error)
- func (c *Context) ForSessionProject(projectID, projectEndpoint string) (sdkclient.Client, error)
- type UnknownMutationOutcome
Constants ¶
const ( EnvProjectID = "APPWRITE_PROJECT_ID" EnvOrganizationID = "APPWRITE_ORGANIZATION_ID" EnvEndpoint = "APPWRITE_ENDPOINT" )
Environment variables that override the configured context.
A CI job sets these expecting them to beat a checked-in appwrite.config.json, so they are consulted first.
These live outside sdk.go because that file is emitted as a stub in the conformance build -- generated commands call mock services there, so nothing constructs a client -- and the CLI still needs these names in both builds. `client --debug` reads them to report the effective project, and referencing them from the conditional half broke the conformance build with "undefined: sdk.EnvProjectID" while every ordinary build kept compiling.
Variables ¶
var ErrNotLoggedIn = errors.New("no active session. Run `appwrite login` to sign in")
ErrNotLoggedIn is returned when a command needs a session and none is stored.
var ErrProjectNotSet = errors.New("project is not set. Run `appwrite init project` or pass --project-id")
ErrProjectNotSet is returned when a project-scoped command runs outside a project directory and no project is configured.
var LastResponse = &responseRecorder{}
LastResponse holds the most recent JSON response body.
Last-wins is deliberate. A chunked upload makes one request per chunk and the command renders the file the final chunk returns, so the final body is the one to keep.
Functions ¶
func RequestWasMade ¶
func RequestWasMade() bool
RequestWasMade reports whether any request has been sent.
It answers whether --verbose has anything to say. That flag prints the status code, the unwrap chain and the captured response body, all of which come from a request; a command that fails before it sends one -- a missing argument, an unsupported -l value, a config file with no tables in it -- has none of them, so advising the user to re-run with it promised detail that did not exist.
Set before the round trip rather than after, so a connection that never completed still counts. `dial tcp: connection refused` is a request the user made, and the chain that wraps it is worth printing.
func SetRequestWasMade ¶
SetRequestWasMade overrides the flag, and exists for tests: the difference between a failure that reached the API and one that did not is what decides whether the CLI advises --verbose, and nothing in a test sends a request.
Returns the previous value, so a caller can restore it.
func WrapMutationError ¶
WrapMutationError marks a timeout from an unsafe HTTP method as an unknown outcome. Read-only requests and ordinary failures keep their original error.
Types ¶
type Context ¶
Context carries what every client needs.
func (*Context) ForConsole ¶
ForConsole builds a client against the console project.
func (*Context) ForConsoleWithOrganization ¶
ForConsoleWithOrganization builds a console client scoped to an organization.
The `/organization` endpoints carry no organization ID in their path and act on whichever organization the header names, so it is resolved from the project config unless the caller passes one.
func (*Context) ForProject ¶
ForProject builds a client against the project in the working directory's config.
func (*Context) ForSessionProject ¶
ForSessionProject builds a project client from the active login and the endpoint returned by project discovery.
Resource discovery must not consult appwrite.config.json: a user can list projects while standing in a repository for another endpoint. The discovered endpoint is still checked against the session before credentials are sent; regional Cloud endpoints normalize to the same login endpoint.
type UnknownMutationOutcome ¶
type UnknownMutationOutcome struct {
// contains filtered or unexported fields
}
UnknownMutationOutcome is a timeout returned after a mutating request may already have reached the server. Retrying it as an ordinary failure can duplicate a create or repeat another side effect.
func (*UnknownMutationOutcome) Error ¶
func (e *UnknownMutationOutcome) Error() string
func (*UnknownMutationOutcome) Unwrap ¶
func (e *UnknownMutationOutcome) Unwrap() error
Unwrap keeps the transport error available to --verbose and errors.Is/As.