legacy

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package legacy is a hand-written client for the Runpod REST v1 host and the GraphQL endpoint, used only by the Terraform provider's deprecated compatibility shims. Nothing in it is generated, and it is not wired onto the root client: v2 API work goes through runpod.New and the packages under lib/.

It exists because REST v2 has no route yet for what those shims carry. On GraphQL: the machine resource and data sources, and the registry usernames. On REST v1: the account user read, the three billing reads, and the pod, template and serverless-endpoint fields the 1.x provider carried over. Nothing belongs here that is not a 1.x behaviour REST v2 has no field for.

Every field name in the typed routes is the v1 wire name observed from the 1.x provider's REST v1 requests (runpod/terraform-provider-runpod v1.0.8), and each struct holds only the fields a 2.0.0 shim needs rather than the whole v1 object: everything else comes from the v2 SDK.

Deprecated: each route here is removed as REST v2 carries the same fields, and the package goes with the last of them.

Index

Constants

View Source
const (
	// DefaultGraphQLURL is the production GraphQL endpoint.
	DefaultGraphQLURL = "https://api.runpod.io/graphql"
	// DefaultRestV1URL is the production REST v1 base URL; paths are appended to it.
	DefaultRestV1URL = "https://rest.runpod.io/v1"

	// DefaultUserAgent identifies this package in the legacy hosts' access
	// logs, following the v2 SDK's own scheme.
	DefaultUserAgent = "runpod-go-sdk/v2 legacy"
)

Variables

This section is empty.

Functions

func IsDecodeFailure

func IsDecodeFailure(err error) bool

IsDecodeFailure reports whether err is, or wraps, an unreadable response body.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err is, or wraps, a 404.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the legacy GraphQL and REST v1 APIs with a bearer key.

func New

func New(cfg Config) (*Client, error)

New builds a Client from cfg. An empty APIKey is an error rather than a deferred 401, matching runpod.New in the v2 SDK.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, params map[string]string) (map[string]any, error)

Get issues a REST v1 GET against path (relative to the configured base URL) and returns the decoded object. A `{"data": {...}}` envelope is unwrapped, matching how the 1.x provider read these routes; a bare object is returned as-is.

Only an object-valued `data` is unwrapped here, where unwrapInto — the typed path — unwraps any `data`, because a bare array is what the billing routes answer and no map can hold one. Unwrapping keeps the envelope's `data` and nothing else, so a real v1 object carrying its own object-valued `data` member would lose every sibling field; no route this package calls returns one, and the 1.x provider read them the same way.

func (*Client) GetEndpointV1

func (c *Client) GetEndpointV1(ctx context.Context, id string) (*EndpointV1, error)

GetEndpointV1 reads the v1 serverless-endpoint fields for id. The route leaves workers out unless includeWorkers=true is on the query string, so the parameter is always sent.

func (*Client) GetPodV1

func (c *Client) GetPodV1(ctx context.Context, id string) (*PodV1, error)

GetPodV1 reads the v1 pod fields for id. A pod the v1 route does not know, such as a CPU or cluster pod, comes back as *NotFoundError.

func (*Client) GetTemplateV1

func (c *Client) GetTemplateV1(ctx context.Context, id string) (*TemplateV1, error)

GetTemplateV1 reads the v1 template fields for id.

func (*Client) GraphQLURL

func (c *Client) GraphQLURL() string

GraphQLURL reports the resolved GraphQL endpoint, for error messages that need to say which host was called.

func (*Client) ListEndpointBillingV1

func (c *Client) ListEndpointBillingV1(ctx context.Context, query EndpointBillingQueryV1) ([]EndpointBillingRecordV1, error)

ListEndpointBillingV1 reads serverless-endpoint billing buckets.

func (*Client) ListNetworkVolumeBillingV1

func (c *Client) ListNetworkVolumeBillingV1(ctx context.Context, query NetworkVolumeBillingQueryV1) ([]NetworkVolumeBillingRecordV1, error)

ListNetworkVolumeBillingV1 reads network-volume billing buckets.

func (*Client) ListPodBillingV1

func (c *Client) ListPodBillingV1(ctx context.Context, query PodBillingQueryV1) ([]PodBillingRecordV1, error)

ListPodBillingV1 reads pod billing buckets. The route answers with a bare JSON array, which is why these go through getInto rather than Get.

func (*Client) PatchEndpointV1

func (c *Client) PatchEndpointV1(ctx context.Context, id string, patch EndpointPatchV1) (*EndpointV1, error)

PatchEndpointV1 writes the two v1-only endpoint inputs and returns the route's read-back. An empty patch is an error rather than an empty request. The v1 spec gives this route no includeWorkers parameter, so the read-back is not relied on for workers; GetEndpointV1 asks for them.

func (*Client) PatchTemplateV1

func (c *Client) PatchTemplateV1(ctx context.Context, id string, patch TemplatePatchV1) (*TemplateV1, error)

PatchTemplateV1 writes the two v1-only template inputs and returns the route's read-back. An empty patch is an error rather than an empty request.

func (*Client) Query

func (c *Client) Query(ctx context.Context, query string, variables map[string]any) (map[string]any, error)

Query posts a GraphQL document and returns its top-level "data" object. GraphQL reports field errors with HTTP 200 and an "errors" array, so those come back as a Go error too — a caller never has to inspect the envelope.

func (*Client) RestV1URL

func (c *Client) RestV1URL() string

RestV1URL reports the resolved REST v1 base URL, for error messages that need to say which host was called.

type Config

type Config struct {
	APIKey     string
	GraphQLURL string
	RestV1URL  string
	HTTPClient *http.Client

	// UserAgent overrides DefaultUserAgent. A consumer that has its own
	// attribution on the API side passes it here — the Terraform provider
	// sends the value its 1.x releases sent followed by its v2 requests'
	// value, so filters on the 1.x value still match and the shim requests
	// are attributed to the same client as the v2 ones.
	UserAgent string
}

Config is the client's input. Empty URLs fall back to the production defaults; a nil HTTPClient gets the same retrying client shape the v2 SDK builds (see transport.Retry: idempotent requests retry on 429 and 5xx, POST only on 429).

type DecodeError

type DecodeError struct {
	Err error
}

DecodeError is a response the host answered successfully and this client could not read: a body that is not the expected JSON shape. It is a distinct type because on a write it says the opposite of a failure — the host accepted the change and only the read-back is unusable, so the caller can report it as a warning with null read-backs instead of failing an apply that landed. v1.0.8 read every one of these fields with a checked type assertion and skipped what did not match rather than failing the call.

func (*DecodeError) Error

func (e *DecodeError) Error() string

func (*DecodeError) Unwrap

func (e *DecodeError) Unwrap() error

type EndpointBillingQueryV1

type EndpointBillingQueryV1 struct {
	BucketSize string
	EndTime    string
	EndpointID string
}

EndpointBillingQueryV1 filters the endpoint billing read behind the deprecated runpod_billing_endpoint data source.

type EndpointBillingRecordV1

type EndpointBillingRecordV1 struct {
	Amount       *float64 `json:"amount"`
	EndpointID   *string  `json:"endpointId"`
	Time         *string  `json:"time"`
	TimeBilledMs *float64 `json:"timeBilledMs"`
}

EndpointBillingRecordV1 is one bucket of the /billing/endpoints array; the pointers and float64s are there for the reasons PodBillingRecordV1 gives.

type EndpointPatchV1

type EndpointPatchV1 struct {
	CpuFlavorPriority *string `json:"cpuFlavorPriority,omitempty"`
	GpuTypePriority   *string `json:"gpuTypePriority,omitempty"`
}

EndpointPatchV1 carries the two create-and-update inputs REST v2 has no field for. A nil field is not sent. computeType is not one of them: REST v2 fixes the compute family through the GPU or CPU block, so sending it here could change nothing and could only fail the apply.

v1.0.8 PATCHed /endpoints/{id} with the whole configuration (templateId, name, workersMin, scalerType, env and the rest), so a body carrying only these two keys is a shape that release never sent: this shim relies on the route merging a partial body. The live route is not guaranteed to, so treat a failure here as a warning on those two attributes rather than a failed write; the rest of the endpoint is written through REST v2.

func (EndpointPatchV1) IsEmpty

func (p EndpointPatchV1) IsEmpty() bool

IsEmpty reports whether the patch would send nothing, so a caller can skip the request entirely.

type EndpointV1

type EndpointV1 struct {
	TemplateVersion *int
	// UserID is not a pointer: every /endpoints/{id} response carries userId,
	// so there is no absent case to distinguish.
	UserID  string
	Version *int
	Workers []EndpointWorkerV1
}

EndpointV1 is the /endpoints/{id} subset behind runpod_serverless_endpoint's template_version, users, version and workers. computeType is not read: the provider derives compute_type from the GPU or CPU block REST v2 reports and never lets the legacy value contradict it.

type EndpointWorkerV1

type EndpointWorkerV1 struct {
	ID         *string  `json:"id"`
	PodID      *string  `json:"podId"`
	Status     *string  `json:"status"`
	UptimeMs   *float64 `json:"uptimeMs"`
	LastBusyMs *float64 `json:"lastBusyMs"`
	StartTime  *string  `json:"startTime"`
}

EndpointWorkerV1 is one element of the v1 workers array.

Every field is a pointer because v1.0.8 set each worker attribute only for a field the response carried and left it null otherwise. The two millisecond counters are float64 for the same reason restv1_billing.go gives: v1.0.8 read them as JSON numbers and truncated (`workerMap["uptimeMs"].(float64)`), so a fractional value is data to round rather than a decode error that would fail an apply whose write already landed. The mapping layer truncates.

type NetworkVolumeBillingQueryV1

type NetworkVolumeBillingQueryV1 struct {
	BucketSize      string
	EndTime         string
	NetworkVolumeID string
}

NetworkVolumeBillingQueryV1 filters the network-volume billing read behind the deprecated runpod_billing_network_volume data source.

type NetworkVolumeBillingRecordV1

type NetworkVolumeBillingRecordV1 struct {
	Amount            *float64 `json:"amount"`
	DiskSpaceBilledGb *float64 `json:"diskSpaceBilledGb"`
	NetworkVolumeID   *string  `json:"networkVolumeId"`
	Time              *string  `json:"time"`
	TimeBilledMs      *float64 `json:"timeBilledMs"`
}

NetworkVolumeBillingRecordV1 is one bucket of the /billing/networkvolumes array; the pointers and float64s are there for the reasons PodBillingRecordV1 gives. The sources disagree on the name of the bucket's timestamp: the public v1 spec's NetworkVolumeBillingRecords, runpodctl and the 1.x provider all read time, while a backend-shaped fixture from review carries startDate. The handler source is not available to settle it, so Time decodes from startDate when present and from time otherwise.

func (*NetworkVolumeBillingRecordV1) UnmarshalJSON

func (r *NetworkVolumeBillingRecordV1) UnmarshalJSON(data []byte) error

UnmarshalJSON fills Time from startDate, falling back to time.

type NotFoundError

type NotFoundError struct {
	Path   string
	Detail string
}

NotFoundError is a 404 from the legacy API.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type PodBillingQueryV1

type PodBillingQueryV1 struct {
	BucketSize string
	EndTime    string
	GPUTypeID  string
	PodID      string
}

PodBillingQueryV1 filters the pod billing read behind the deprecated runpod_billing_pod data source.

The query parameters are exactly the ones v1.0.8 sent (bucketSize, endTime and the one id filter per route; it never sent a start time), and an unset filter is left off the query string rather than sent empty.

type PodBillingRecordV1

type PodBillingRecordV1 struct {
	Amount            *float64 `json:"amount"`
	DiskSpaceBilledGb *float64 `json:"diskSpaceBilledGb"`
	EndpointID        *string  `json:"endpointId"`
	GPUTypeID         *string  `json:"gpuTypeId"`
	PodID             *string  `json:"podId"`
	Time              *string  `json:"time"`
	TimeBilledMs      *float64 `json:"timeBilledMs"`
}

PodBillingRecordV1 is one bucket of the /billing/pods array.

Every field is a pointer so a missing one becomes a null attribute: v1.0.8 read amount and time with unchecked type assertions that panicked when either was absent. diskSpaceBilledGb and timeBilledMs are float64 because that is what JSON gives and v1.0.8 truncated with int64(val). The data sources truncate the same way, and a fractional value would fail an int64 decode outright.

type PodV1

type PodV1 struct {
	MachineID        *string  `json:"machineId"`
	DockerEntrypoint []string `json:"dockerEntrypoint"`
	DockerStartCmd   []string `json:"dockerStartCmd"`
	VolumeEncrypted  *bool    `json:"volumeEncrypted"`
}

PodV1 is the GET /pods/{id} subset behind runpod_pod's machine_id, docker_entrypoint, docker_start_cmd and volume_encrypted. None of them was ever a create input in v1.0.8 (the create body never carried them), so they are read-back only. The other two v1 fields the 1.x provider read, costPerHr and memoryInGb, come from REST v2 as cost and memory_in_gb and are not read here.

The scalars are pointers so an absent field stays distinguishable from a reported empty one: v1.0.8 set machine_id only for a present, non-empty machineId and volume_encrypted only for a present volumeEncrypted, leaving the attribute null otherwise, and a CPU or cluster pod carries neither.

type TemplatePatchV1

type TemplatePatchV1 struct {
	DockerEntrypoint *[]string `json:"dockerEntrypoint,omitempty"`
	Readme           *string   `json:"readme,omitempty"`
}

TemplatePatchV1 carries the two template inputs REST v2 has no field for. A nil field is not sent; a non-nil empty slice or string is, so a caller can clear either one.

As with EndpointPatchV1: v1.0.8 PATCHed /templates/{id} with the whole configuration (name, imageName, category, containerDiskInGb, env, ports and the rest), so the two-key body here relies on the route merging a partial one, which the live route does not guarantee.

func (TemplatePatchV1) IsEmpty

func (p TemplatePatchV1) IsEmpty() bool

IsEmpty reports whether the patch would send nothing, so a caller can skip the request entirely.

type TemplateV1

type TemplateV1 struct {
	DockerEntrypoint []string `json:"dockerEntrypoint"`
	Readme           *string  `json:"readme"`
	Earned           *float64 `json:"earned"`
	IsRunpod         *bool    `json:"isRunpod"`
	RuntimeInMin     *float64 `json:"runtimeInMin"`
}

TemplateV1 is the /templates/{id} subset behind runpod_template's docker_entrypoint, readme, earned, is_runpod and runtime_in_min.

Every field is a pointer, or a nil slice, so a caller can tell a field the response omitted from one it reported empty or zero: a PATCH answering with a partial body, or with no body at all, must leave the value alone rather than reporting a configured readme as cleared or a template's earnings as zero. runtimeInMin is float64 because v1.0.8 read it as a JSON number and truncated (`result["runtimeInMin"].(float64)`); the mapping layer truncates.

Jump to

Keyboard shortcuts

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