cli: add `entire api` authenticated passthrough (core + cell) · Entire

cli: add entire api authenticated passthrough (core + cell)

a7e9795→main· Soph·2w ago·4 files·+579 added/-0 removed

A gh api-style escape hatch: make an authenticated request to an Entire API and print the JSON response, with the CLI attaching the right bearer and dialing the right host.

API Commands

Sessions

e7709d561284View transcript

Changes

4


148 unmodified lines

return c.do(ctx, http.MethodDelete, path, nil, nil)
}

// Request sends an authenticated request with an explicit method, optional
// extra headers, and an optional raw body. It’s the general-purpose escape
// hatch behind `entire api`; prefer the typed verbs (Get/Post/…) for normal
// use. The bearer, User-Agent, and default Accept are still attached by the
// transport; a body still gets Content-Type: application/json.
func (c *Client) Request(ctx context.Context, method, path string, headers http.Header, body io.Reader) (*http.Response, error) {
return c.do(ctx, method, path, body, headers)
}

func (c *Client) do(ctx context.Context, method, path string, body io.Reader, headers http.Header) (*http.Response, error) {
endpoint, err := ResolveURLFromBase(c.baseURL, path)
if err != nil {

Additional Code

package cli

import (
    "bytes"
    "context"
    "encoding/json"
    "errors"
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
    "sort"
    "strconv"
    "strings"

"github.com/spf13/cobra"
    "github.com/entireio/cli/cmd/entire/cli/api"
    "github.com/entireio/cli/cmd/entire/cli/auth"
    "github.com/entireio/cli/cmd/entire/cli/gitremote"
    "github.com/entireio/cli/internal/coreapi"
)

// Function Definitions
// ...

const apiMaxResponseBytes = 32 << 20 // 32 MiB cap on a printed response body.

// Functions related to API handling, Context resolution, and request handling
// ...

// Test functions
// ...