api

package
v0.0.0-...-d3d9421 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2025 Pextra Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2025 Pextra Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2025 Pextra Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2025 Pextra Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2025 Pextra Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2025 Pextra Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2025 Pextra Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2025 Pextra Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2025 Pextra Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2025 Pextra Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2025 Pextra Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNodeById

func GetNodeById(ctx context.Context, c *Client, arg *GetNodeByIdArg) (*GetNodeByIdResponse, *APIError)

Types

type APIError

type APIError struct {
	Err     error  `json:"-"` // not serialized
	Status  int    `json:"code"`
	Message string `json:"message"`
}

API error struct.

func NewAPIError

func NewAPIError(status int, message string) *APIError

Creates a new APIError with status and message.

func WrapAPIError

func WrapAPIError(err error, status int, message string) *APIError

Wraps an existing error into an APIError with status and message.

func (*APIError) Error

func (e *APIError) Error() string

Implements the error interface.

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

Returns the underlying error for use with errors.Is / errors.As.

type Client

type Client struct {
	HTTP      *http.Client
	BaseURL   *url.URL
	APIPrefix string
	Headers   http.Header
}

func NewClient

func NewClient(baseURL string, insecureSkipVerify bool, timeout time.Duration, caCertPath string, customHeaders http.Header) (*Client, error)

Construct a new Client.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string, query url.Values, out any) *APIError

func (*Client) Do

func (c *Client) Do(req *http.Request, out any) *APIError

Do executes the request and decodes JSON into out if provided. On non-2xx responses it tries to parse an APIError from the body.

func (*Client) ExpandPath

func (c *Client) ExpandPath(pathTemplate string, params map[string]string) string

ExpandPath replaces placeholders in the form {name} with the corresponding values from params. Values are url.PathEscaped. Example:

p := client.ExpandPath("/nodes/{node_id}/images", map[string]string{"node_id": id})
client.Get(ctx, p, nil, out)

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, query url.Values, out any) *APIError

Get convenience helper to perform a GET and decode JSON response into out.

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, query url.Values, body io.Reader, out any) *APIError

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, query url.Values, body io.Reader, out any) *APIError

type ClusterList

type ClusterList struct {
	Id             string `json:"id"`
	OrganizationId string `json:"organization_id"`
	DatacenterId   string `json:"datacenter_id"`
	Name           string `json:"name"`
	Creation       string `json:"creation"`
	Description    string `json:"description"`
	NodeCount      int    `json:"node_count"`
	FaultTolerance int    `json:"fault_tolerance"`
	Standalone     bool   `json:"standalone"`
	LeaderId       string `json:"leader_id"`
	HasLeader      bool   `json:"has_leader"`
}

type CreateOrganizationArg

type CreateOrganizationArg struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

type CreateOrganizationResponse

type CreateOrganizationResponse = struct {
	Id string `json:"id"`
}

type DatacenterList

type DatacenterList struct {
	Id             string `json:"id"`
	OrganizationId string `json:"organization_id"`
	Name           string `json:"name"`
	Location       struct {
		Latitude  float64 `json:"latitude"`
		Longitude float64 `json:"longitude"`
	} `json:"location"`
	Creation    string `json:"creation"`
	Description string `json:"description"`
}

type DeleteOrganizationByIdArg

type DeleteOrganizationByIdArg struct {
	OrganizationId string
}

type DeleteOrganizationByIdResponse

type DeleteOrganizationByIdResponse = struct{}

type DeleteUserByIdArg

type DeleteUserByIdArg struct {
	UserId string
}

type DeleteUserByIdResponse

type DeleteUserByIdResponse struct{}

type GetClusterHardwareByIdArg

type GetClusterHardwareByIdArg struct {
	ClusterId string
}

type GetClusterHardwareByIdResponse

type GetClusterHardwareByIdResponse struct {
	Partial   bool `json:"partial"`
	Vcpus     int  `json:"vcpus"`
	MemoryGB  int  `json:"memory_gb"`
	StorageGB int  `json:"storage_gb"`
}

type GetClusterLicensingByIdArg

type GetClusterLicensingByIdArg struct {
	ClusterId string
}

type GetClusterLicensingByIdResponse

type GetClusterLicensingByIdResponse struct {
	Cluster struct {
		Status     string `json:"status"`
		NextExpiry string `json:"next_expiry"`
	}
	// `node_id` -> { ok: bool, expiry: string }
	Nodes map[string]struct {
		Ok     bool   `json:"ok"`
		Expiry string `json:"expiry"`
	}
}

type GetInstancesByIdArg

type GetInstancesByIdArg struct {
	// Either `NodeId` or `ClusterId` must be provided
	NodeId    string
	ClusterId string
}

type GetInstancesByIdResponse

type GetInstancesByIdResponse = []InstanceList

type GetNodeByIdArg

type GetNodeByIdArg struct {
	NodeId string
}

type GetNodeByIdResponse

type GetNodeByIdResponse struct {
	Node      NodeDetail     `json:"node"`
	Instances []InstanceList `json:"instances"`
	Hostname  string         `json:"hostname"`
	Os        struct {
		Kernel       string `json:"kernel"`
		Architecture string `json:"architecture"`
		Uefi         bool   `json:"uefi"`
	} `json:"os"`
	Time struct {
		Time     int64  `json:"time"`
		Timezone string `json:"timezone"`
		Uptime   int64  `json:"uptime"`
	} `json:"time"`
	PceVersion string `json:"pce_version"`
}

type GetNodeHardwareByIdArg

type GetNodeHardwareByIdArg struct {
	NodeId string
}

type GetNodeHardwareByIdResponse

type GetNodeHardwareByIdResponse struct {
	Vcpus  int                  `json:"vcpus"`
	CPU    NodeHardwareCpu      `json:"cpu"`
	Memory []NodeHardwareMemory `json:"memory"`
	Disks  []NodeHardwareDisk   `json:"disks"`
	Usb    []NodeHardwareUsb    `json:"usb"`
}

type GetNodeLicenseByIdArg

type GetNodeLicenseByIdArg struct {
	NodeId string
}

type GetNodeLicenseByIdResponse

type GetNodeLicenseByIdResponse struct {
	Key    string `json:"key"`
	Expiry string `json:"expiry"`
	Valid  bool   `json:"valid"`
}

type GetNodePciDevicesByIdArg

type GetNodePciDevicesByIdArg struct {
	NodeId string
}

type GetNodePciDevicesByIdResponse

type GetNodePciDevicesByIdResponse = []NodePciDevice

type GetNodeStoragePoolsByIdArg

type GetNodeStoragePoolsByIdArg struct {
	NodeId string
}

type GetNodeStoragePoolsByIdResponse

type GetNodeStoragePoolsByIdResponse = []StoragePoolDetail

type GetOrganizationByIdArg

type GetOrganizationByIdArg struct {
	OrganizationId string
}

type GetOrganizationByIdResponse

type GetOrganizationByIdResponse = OrganizationDetail

type ImageList

type ImageList struct {
	Name          string                `json:"name"`
	SizeMB        int64                 `json:"size"`
	Creation      string                `json:"creation"`
	Type          enum.InstanceTypeEnum `json:"type"`
	StoragePoolId string                `json:"storage_pool_id"`
}

type InstanceList

type InstanceList struct {
	Id     string `json:"id"`
	NodeId string `json:"node_id"`
	Type   int    `json:"type"`
	Name   string `json:"name"`
	Cpu    struct {
		Sockets int `json:"sockets"`
		Cores   int `json:"cores"`
		Threads int `json:"threads"`
	} `json:"cpu"`
	Vcpus     int    `json:"vcpus"`
	Memory    int    `json:"memory"`
	Creation  string `json:"creation"`
	Autostart bool   `json:"autostart"`
	BootOrder int    `json:"boot_order"`
}

type InvalidateUserSessionsByIdArg

type InvalidateUserSessionsByIdArg struct {
	UserId            string
	InvalidateCurrent bool
}

type InvalidateUserSessionsByIdResponse

type InvalidateUserSessionsByIdResponse struct{}

type ListImagesByNodeArg

type ListImagesByNodeArg struct {
	NodeId string
}

type ListImagesByNodeResponse

type ListImagesByNodeResponse = []ImageList

type ListOrganizationsArg

type ListOrganizationsArg struct{}

type ListOrganizationsResponse

type ListOrganizationsResponse = []OrganizationDetail

type ListUsersInOrganizationByIdArg

type ListUsersInOrganizationByIdArg struct {
	OrganizationId string
}

type ListUsersInOrganizationByIdResponse

type ListUsersInOrganizationByIdResponse = []UserList

type NodeDetail

type NodeDetail struct {
	NodeList
	SshKey     string `json:"ssh_key"`
	ClientCert string `json:"client_cert"`
}

type NodeHardwareCpu

type NodeHardwareCpu struct {
	Manufacturer string `json:"manufacturer"`
	Brand        string `json:"brand"`
	Speed        struct {
		CurrentGHz float64 `json:"current"`
	} `json:"speed"`
	Governor string `json:"governor"`
	Cores    struct {
		Physical    int `json:"physical"`
		Performance int `json:"performance"`
		Efficiency  int `json:"efficiency"`
	} `json:"cores"`
	Processors            int      `json:"processors"`
	Sockets               int      `json:"sockets"`
	Flags                 []string `json:"flags"`
	VirtualizationSupport bool     `json:"virtualization"`
}

type NodeHardwareDisk

type NodeHardwareDisk struct {
	Device      string  `json:"device"`
	Name        string  `json:"name"`
	SizeGB      float64 `json:"size"`
	Serial      string  `json:"serial"`
	Interface   string  `json:"interface"`
	SmartStatus string  `json:"smart_status"`
	Vendor      string  `json:"vendor"`
	Temperature int     `json:"temperature"`
}

type NodeHardwareMemory

type NodeHardwareMemory struct {
	Bank  int  `json:"bank"`
	Empty bool `json:"empty"`
	Data  struct {
		Size    int    `json:"size"`
		Type    string `json:"type"`
		ECC     bool   `json:"ecc"`
		Voltage struct {
			Current float64 `json:"current"`
			Min     float64 `json:"min"`
			Max     float64 `json:"max"`
		} `json:"voltage"`
	} `json:"data"`
}

type NodeHardwareUsb

type NodeHardwareUsb struct {
	Bus       int    `json:"bus"`
	Device    int    `json:"device"`
	VendorId  string `json:"vendor_id"`
	ProductId string `json:"product_id"`
	Vendor    string `json:"vendor"`
	Name      string `json:"name"`
	Type      string `json:"type"`
	Removable bool   `json:"removable"`
	MaxPower  int    `json:"max_power"`
}

type NodeList

type NodeList struct {
	Id             string `json:"id"`
	OrganizationId string `json:"organization_id"`
	ClusterId      string `json:"cluster_id"`
	Name           string `json:"name"`
	Description    string `json:"description"`
	IpAddress      string `json:"ip_address"`
	WolMac         string `json:"wol_mac"`
	Creation       string `json:"creation"`
	Alive          bool   `json:"alive"`
	LastSeen       string `json:"last_seen"`
	Joining        bool   `json:"joining"`
}

type NodePciDevice

type NodePciDevice struct {
	Slot                 string `json:"slot"`
	Class                string `json:"class"`
	Vendor               string `json:"vendor"`
	Device               string `json:"device"`
	Revision             string `json:"revision"`
	ProgrammingInterface string `json:"prog_if"`
	IOMMUGroup           string `json:"iommu_group"`
	MarkedForPassthrough bool   `json:"marked_for_passthrough"`
}

type OrganizationDetail

type OrganizationDetail struct {
	Organization struct {
		Id          string `json:"id"`
		Name        string `json:"name"`
		Creation    string `json:"creation"`
		Description string `json:"description"`
	} `json:"organization"`
	Datacenters []DatacenterList `json:"datacenters"`
	Clusters    []ClusterList    `json:"clusters"`
	Nodes       []NodeList       `json:"nodes"`
}

type PowerInstanceArg

type PowerInstanceArg struct {
	InstanceId string
	NodeId     string
	Action     enum.InstancePowerAction
}

type PowerInstanceResponse

type PowerInstanceResponse struct {
	TaskId string `json:"task_id"`
}

type RunHealthcheckArg

type RunHealthcheckArg struct{}

type RunHealthcheckResponse

type RunHealthcheckResponse struct {
	Id            string `json:"id"`
	ClusterIdHash string `json:"cluster_id_hash"`
	Healthy       bool   `json:"healthy"`
	Time          int64  `json:"time"`
}

type StoragePoolDetail

type StoragePoolDetail struct {
	Id            string                   `json:"id"`
	Type          enum.StoragePoolTypeEnum `json:"type"`
	Name          string                   `json:"name"`
	Initialized   bool                     `json:"initialized"`
	Available     bool                     `json:"available"`
	CanHoldImages bool                     `json:"can_hold_images"`
	Usage         struct {
		CapacityGB  float64 `json:"capacity"`
		AllocatedGB float64 `json:"allocated"`
		AvailableGB float64 `json:"available"`
		PercentUsed float64 `json:"percent_used"`
	} `json:"usage"`
	VolumeCount int `json:"volume_count"`
}

type UserList

type UserList struct {
	Id             string `json:"id"`
	OrganizationId string `json:"organization_id"`
	Username       string `json:"username"`
	Enabled        bool   `json:"enabled"`
	Locked         bool   `json:"locked"`
	Expiry         string `json:"expiry"`
	Expired        bool   `json:"expired"`
	MfaEnabled     bool   `json:"mfa_enabled"`
	IsRoot         bool   `json:"is_root"`
	LinuxUser      string `json:"linux_user"`
	Description    string `json:"description"`
	Creation       string `json:"creation"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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