Categorygithub.com/DirkTheDaring/px-api-client-go
repositorypackage
1.0.12
Repository: https://github.com/dirkthedaring/px-api-client-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Go API client for pxapiflat

ProxMox VE API

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 8.0
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import pxapiflat "github.com/DirkTheDaring/px-api-client-go"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value pxapiflat.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), pxapiflat.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value pxapiflat.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), pxapiflat.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using pxapiflat.ContextOperationServerIndices and pxapiflat.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), pxapiflat.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), pxapiflat.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://127.0.0.1:8006/api2/json

ClassMethodHTTP requestDescription
AccessAPICreateAccessTicketPost /access/ticketcreateAccessTicket
AccessAPIGetAccessTicketGet /access/ticketgetAccessTicket
ClusterAPIGetClusterConfigNodesGet /cluster/config/nodesgetClusterConfigNodes
ClusterAPIGetClusterNextidGet /cluster/nextidgetClusterNextid
ClusterAPIGetClusterResourcesGet /cluster/resourcesgetClusterResources
NodesAPICreateContainerPost /nodes/{node}/lxccreateContainer
NodesAPICreateContainerSnapshotPost /nodes/{node}/lxc/{vmid}/snapshotcreateContainerSnapshot
NodesAPICreateNodesSingleStorageSingleContentPost /nodes/{node}/storage/{storage}/contentcreateNodesSingleStorageSingleContent
NodesAPICreateVMPost /nodes/{node}/qemucreateVM
NodesAPICreateVMSnapshotPost /nodes/{node}/qemu/{vmid}/snapshotcreateVMSnapshot
NodesAPIDeleteContainerDelete /nodes/{node}/lxc/{vmid}deleteContainer
NodesAPIDeleteContainerSnapshotDelete /nodes/{node}/lxc/{vmid}/snapshot/{snapname}deleteContainerSnapshot
NodesAPIDeleteVMDelete /nodes/{node}/qemu/{vmid}deleteVM
NodesAPIDeleteVMSnapshotDelete /nodes/{node}/qemu/{vmid}/snapshot/{snapname}deleteVMSnapshot
NodesAPIGetContainerGet /nodes/{node}/lxc/{vmid}getContainer
NodesAPIGetContainerConfigGet /nodes/{node}/lxc/{vmid}/configgetContainerConfig
NodesAPIGetContainerConfigPendingGet /nodes/{node}/lxc/{vmid}/pendinggetContainerConfigPending
NodesAPIGetContainerSnapshotGet /nodes/{node}/lxc/{vmid}/snapshot/{snapname}getContainerSnapshot
NodesAPIGetContainerSnapshotConfigGet /nodes/{node}/lxc/{vmid}/snapshot/{snapname}/configgetContainerSnapshotConfig
NodesAPIGetContainerSnapshotsGet /nodes/{node}/lxc/{vmid}/snapshotgetContainerSnapshots
NodesAPIGetContainerStatusGet /nodes/{node}/lxc/{vmid}/statusgetContainerStatus
NodesAPIGetContainersGet /nodes/{node}/lxcgetContainers
NodesAPIGetCurrentContainerStatusGet /nodes/{node}/lxc/{vmid}/status/currentgetCurrentContainerStatus
NodesAPIGetCurrentVMStatusGet /nodes/{node}/qemu/{vmid}/status/currentgetCurrentVMStatus
NodesAPIGetNodeTaskGet /nodes/{node}/tasks/{upid}getNodeTask
NodesAPIGetNodeTaskLogGet /nodes/{node}/tasks/{upid}/loggetNodeTaskLog
NodesAPIGetNodeTaskStatusGet /nodes/{node}/tasks/{upid}/statusgetNodeTaskStatus
NodesAPIGetNodeTasksGet /nodes/{node}/tasksgetNodeTasks
NodesAPIGetStorageContentGet /nodes/{node}/storage/{storage}/contentgetStorageContent
NodesAPIGetStoragesGet /nodes/{node}/storagegetStorages
NodesAPIGetVMGet /nodes/{node}/qemu/{vmid}getVM
NodesAPIGetVMConfigGet /nodes/{node}/qemu/{vmid}/configgetVMConfig
NodesAPIGetVMConfigPendingGet /nodes/{node}/qemu/{vmid}/pendinggetVMConfigPending
NodesAPIGetVMSnapshotGet /nodes/{node}/qemu/{vmid}/snapshot/{snapname}getVMSnapshot
NodesAPIGetVMSnapshotConfigGet /nodes/{node}/qemu/{vmid}/snapshot/{snapname}/configgetVMSnapshotConfig
NodesAPIGetVMSnapshotsGet /nodes/{node}/qemu/{vmid}/snapshotgetVMSnapshots
NodesAPIGetVMsGet /nodes/{node}/qemugetVMs
NodesAPIRebootContainerPost /nodes/{node}/lxc/{vmid}/status/rebootrebootContainer
NodesAPIRebootVMPost /nodes/{node}/qemu/{vmid}/status/rebootrebootVM
NodesAPIResizeContainerDiskPut /nodes/{node}/lxc/{vmid}/resizeresizeContainerDisk
NodesAPIResizeVMDiskPut /nodes/{node}/qemu/{vmid}/resizeresizeVMDisk
NodesAPIResumeContainerPost /nodes/{node}/lxc/{vmid}/status/resumeresumeContainer
NodesAPIResumeVMPost /nodes/{node}/qemu/{vmid}/status/resumeresumeVM
NodesAPIRollbackContainerSnapshotPost /nodes/{node}/lxc/{vmid}/snapshot/{snapname}/rollbackrollbackContainerSnapshot
NodesAPIRollbackVMSnapshotPost /nodes/{node}/qemu/{vmid}/snapshot/{snapname}/rollbackrollbackVMSnapshot
NodesAPIShutdownContainerPost /nodes/{node}/lxc/{vmid}/status/shutdownshutdownContainer
NodesAPIShutdownVMPost /nodes/{node}/qemu/{vmid}/status/shutdownshutdownVM
NodesAPIStartContainerPost /nodes/{node}/lxc/{vmid}/status/startstartContainer
NodesAPIStartVMPost /nodes/{node}/qemu/{vmid}/status/startstartVM
NodesAPIStopContainerPost /nodes/{node}/lxc/{vmid}/status/stopstopContainer
NodesAPIStopNodeTaskDelete /nodes/{node}/tasks/{upid}stopNodeTask
NodesAPIStopVMPost /nodes/{node}/qemu/{vmid}/status/stopstopVM
NodesAPISuspendContainerPost /nodes/{node}/lxc/{vmid}/status/suspendsuspendContainer
NodesAPISuspendVMPost /nodes/{node}/qemu/{vmid}/status/suspendsuspendVM
NodesAPIUpdateContainerConfigSyncPut /nodes/{node}/lxc/{vmid}/configupdateContainerConfigSync
NodesAPIUpdateContainerSnapshotConfigPut /nodes/{node}/lxc/{vmid}/snapshot/{snapname}/configupdateContainerSnapshotConfig
NodesAPIUpdateVMConfigPost /nodes/{node}/qemu/{vmid}/configupdateVMConfig
NodesAPIUpdateVMConfigSyncPut /nodes/{node}/qemu/{vmid}/configupdateVMConfigSync
NodesAPIUpdateVMSnapshotConfigPut /nodes/{node}/qemu/{vmid}/snapshot/{snapname}/configupdateVMSnapshotConfig
NodesAPIUploadFilePost /nodes/{node}/storage/{storage}/uploaduploadFile
StorageAPICreateStoragePost /storagecreateStorage
StorageAPIGetStorageGet /storagegetStorage

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

cookie

  • Type: API key
  • API key parameter name: Cookie
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: Cookie and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		pxapiflat.ContextAPIKeys,
		map[string]pxapiflat.APIKey{
			"Cookie": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

token

  • Type: API key
  • API key parameter name: CSRFPreventionToken
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: CSRFPreventionToken and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		pxapiflat.ContextAPIKeys,
		map[string]pxapiflat.APIKey{
			"CSRFPreventionToken": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

[email protected]