client

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrServerNotFound indicates the server was not found (404)
	ErrServerNotFound = errors.New("server not found")
)

Functions

This section is empty.

Types

type AgentRequest

type AgentRequest struct {
	Provisioned *bool `json:"provisioned,omitempty"`
}

AgentRequest represents the STACKIT agent configuration for a server

type BootVolumeRequest

type BootVolumeRequest struct {
	DeleteOnTermination *bool                    `json:"deleteOnTermination,omitempty"`
	PerformanceClass    string                   `json:"performanceClass,omitempty"`
	Size                int                      `json:"size,omitempty"`
	Source              *BootVolumeSourceRequest `json:"source,omitempty"`
}

BootVolumeRequest represents the boot volume configuration for a server

type BootVolumeSourceRequest

type BootVolumeSourceRequest struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

BootVolumeSourceRequest represents the source for creating a boot volume

type CreateServerRequest

type CreateServerRequest struct {
	Name                string                   `json:"name"`
	MachineType         string                   `json:"machineType"`
	ImageID             string                   `json:"imageId,omitempty"`
	Labels              map[string]string        `json:"labels,omitempty"`
	Networking          *ServerNetworkingRequest `json:"networking"` // Required in v2 API, no omitempty
	SecurityGroups      []string                 `json:"securityGroups,omitempty"`
	UserData            string                   `json:"userData,omitempty"`
	BootVolume          *BootVolumeRequest       `json:"bootVolume,omitempty"`
	Volumes             []string                 `json:"volumes,omitempty"`
	KeypairName         string                   `json:"keypairName,omitempty"`
	AvailabilityZone    string                   `json:"availabilityZone,omitempty"`
	AffinityGroup       string                   `json:"affinityGroup,omitempty"`
	ServiceAccountMails []string                 `json:"serviceAccountMails,omitempty"`
	Agent               *AgentRequest            `json:"agent,omitempty"`
	Metadata            map[string]any           `json:"metadata,omitempty"`
}

CreateServerRequest represents the request to create a server

type NIC

type NIC struct {
	ID               string   `json:"id"`
	NetworkID        string   `json:"networkId"`
	AllowedAddresses []string `json:"allowedAddresses,omitempty"`
	IPv4             string   `json:"ipv4,omitempty"`
	IPv6             string   `json:"ipv6,omitempty"`
}

NIC represents a STACKIT network interface

type SdkStackitClient

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

SdkStackitClient is an SDK implementation of StackitClient Each instance handles a single STACKIT project (single-tenant design) The IaaS client is created once and reused across all requests The SDK automatically handles token refresh and re-authentication

func NewStackitClient

func NewStackitClient(serviceAccountKey string) (*SdkStackitClient, error)

NewStackitClient creates a new SDK STACKIT client wrapper with the IaaS client The serviceAccountKey is used for authentication (ServiceAccount Key Flow) The client is created once and reused for all subsequent requests

func (*SdkStackitClient) CreateServer

func (c *SdkStackitClient) CreateServer(ctx context.Context, projectID, region string, req *CreateServerRequest) (*Server, error)

CreateServer creates a new server via STACKIT SDK

func (*SdkStackitClient) DeleteServer

func (c *SdkStackitClient) DeleteServer(ctx context.Context, projectID, region, serverID string) error

DeleteServer deletes a server by ID via STACKIT SDK

func (*SdkStackitClient) GetNICsForServer

func (c *SdkStackitClient) GetNICsForServer(ctx context.Context, projectID, region, serverID string) ([]*NIC, error)

func (*SdkStackitClient) GetServer

func (c *SdkStackitClient) GetServer(ctx context.Context, projectID, region, serverID string) (*Server, error)

GetServer retrieves a server by ID via STACKIT SDK

func (*SdkStackitClient) ListServers

func (c *SdkStackitClient) ListServers(ctx context.Context, projectID, region string, labelSelector map[string]string) ([]*Server, error)

ListServers lists all servers in a project via STACKIT SDK

func (*SdkStackitClient) UpdateNIC

func (c *SdkStackitClient) UpdateNIC(ctx context.Context, projectID, region, networkID, nicID string, allowedAddresses []string) (*NIC, error)

type Server

type Server struct {
	ID           string            `json:"id"`
	Name         string            `json:"name"`
	Status       string            `json:"status"`
	ErrorMessage string            `json:"errorMessage,omitempty"`
	Labels       map[string]string `json:"labels,omitempty"`
}

Server represents a STACKIT server response

type ServerNetworkingRequest

type ServerNetworkingRequest struct {
	NetworkID string   `json:"networkId,omitempty"`
	NICIDs    []string `json:"nicIds,omitempty"`
}

ServerNetworkingRequest represents the networking configuration for a server

Union type - use one of the following (mutually exclusive):

  • NetworkID: Auto-create a NIC in the specified network (takes precedence)
  • NICIDs: Attach pre-existing NICs to the server

If both are specified, NetworkID takes precedence and NICIDs is ignored.

type StackitClient

type StackitClient interface {
	// CreateServer creates a new server in STACKIT
	CreateServer(ctx context.Context, projectID, region string, req *CreateServerRequest) (*Server, error)
	// GetServer retrieves a server by ID from STACKIT
	GetServer(ctx context.Context, projectID, region, serverID string) (*Server, error)
	// DeleteServer deletes a server by ID from STACKIT
	DeleteServer(ctx context.Context, projectID, region, serverID string) error
	// ListServers lists all servers in a project
	ListServers(ctx context.Context, projectID, region string, labelSelector map[string]string) ([]*Server, error)
	// GetNICsForServer retrieves a network interfaces for a given server
	GetNICsForServer(ctx context.Context, projectID, region, serverID string) ([]*NIC, error)
	// UpdateNIC updates a network interface
	UpdateNIC(ctx context.Context, projectID, region, networkID, nicID string, allowedAddresses []string) (*NIC, error)
}

StackitClient is an interface for interacting with STACKIT IAAS API This allows us to mock the client in unit tests

Architecture: Single-tenant design - Each client instance is bound to one STACKIT project via serviceAccountKey - The serviceAccountKey is provided once during client creation (NewStackitClient) - The SDK automatically handles JWT token generation and refresh

Note: region parameter is required by STACKIT SDK v1.0.0+ It must be extracted from the Secret (e.g., "eu01-1", "eu01-2")

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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