Go SDK for interacting with TrueNAS APIs (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
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: v2.0
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen
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 truenas "github.com/terrycain/truenas-go-sdk/pkg/truenas"
To use a proxy, set the environment variable HTTP_PROXY
:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Default configuration comes with Servers
field that contains server objects as defined in the OpenAPI specification.
For using other server than the one defined on index 0 set context value truenas.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), truenas.ContextServerIndex, 1)
Templated server URL is formatted using default variables from configuration or from context value truenas.ContextServerVariables
of type map[string]string
.
ctx := context.WithValue(context.Background(), truenas.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
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 truenas.ContextOperationServerIndices
and truenas.ContextOperationServerVariables
context maps.
ctx := context.WithValue(context.Background(), truenas.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), truenas.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
All URIs are relative to http://localhost
Class | Method | HTTP request | Description |
---|---|---|---|
CronjobAPI | CreateCronJob | Post /cronjob | |
CronjobAPI | DeleteCronJob | Delete /cronjob/id/{id} | |
CronjobAPI | GetCronJob | Get /cronjob/id/{id} | |
CronjobAPI | UpdateCronJob | Put /cronjob/id/{id} | |
DatasetAPI | CreateDataset | Post /pool/dataset | |
DatasetAPI | DeleteDataset | Delete /pool/dataset/id/{id} | |
DatasetAPI | GetDataset | Get /pool/dataset/id/{id} | |
DatasetAPI | ListDatasets | Get /pool/dataset | |
DatasetAPI | UpdateDataset | Put /pool/dataset/id/{id} | |
GroupAPI | CreateGroup | Post /group | |
GroupAPI | DeleteGroup | Delete /group/id/{id} | |
GroupAPI | GetGroup | Get /group/id/{id} | |
GroupAPI | ListGroups | Get /group | |
GroupAPI | UpdateGroup | Put /group/id/{id} | |
IscsiExtentAPI | CreateISCSIExtent | Post /iscsi/extent | |
IscsiExtentAPI | DeleteISCSIExtent | Delete /iscsi/extent/id/{id} | |
IscsiExtentAPI | GetISCSIExtent | Get /iscsi/extent/id/{id} | |
IscsiExtentAPI | ListISCSIExtent | Get /iscsi/extent | |
IscsiGlobalAPI | GetISCSIGlobalConfiguration | Get /iscsi/global | |
IscsiInitiatorAPI | CreateISCSIInitiator | Post /iscsi/initiator | |
IscsiInitiatorAPI | DeleteISCSIInitiator | Delete /iscsi/initiator/id/{id} | |
IscsiInitiatorAPI | GetISCSIInitiator | Get /iscsi/initiator/id/{id} | |
IscsiInitiatorAPI | ListISCSIInitiator | Get /iscsi/initiator | |
IscsiPortalAPI | GetISCSIPortal | Get /iscsi/portal/id/{id} | |
IscsiPortalAPI | ListISCSIPortal | Get /iscsi/portal | |
IscsiTargetAPI | CreateISCSITarget | Post /iscsi/target | |
IscsiTargetAPI | DeleteISCSITarget | Delete /iscsi/target/id/{id} | |
IscsiTargetAPI | GetISCSITarget | Get /iscsi/target/id/{id} | |
IscsiTargetAPI | ListISCSITarget | Get /iscsi/target | |
IscsiTargetextentAPI | CreateISCSITargetExtent | Post /iscsi/targetextent | |
IscsiTargetextentAPI | DeleteISCSITargetExtent | Delete /iscsi/targetextent/id/{id} | |
IscsiTargetextentAPI | GetISCSITargetExtent | Get /iscsi/targetextent/id/{id} | |
IscsiTargetextentAPI | ListISCSITargetExtent | Get /iscsi/targetextent | |
NetworkAPI | GetNetworkConfiguration | Get /network/configuration | |
NetworkAPI | GetNetworkSummary | Get /network/general/summary | |
PoolAPI | ListPools | Get /pool | |
ServiceAPI | GetService | Get /service/id/{id} | |
SharingAPI | CreateShareNFS | Post /sharing/nfs | |
SharingAPI | CreateShareSMB | Post /sharing/smb | |
SharingAPI | GetShareNFS | Get /sharing/nfs/id/{id} | |
SharingAPI | GetShareSMB | Get /sharing/smb/id/{id} | |
SharingAPI | ListSharesNFS | Get /sharing/nfs | |
SharingAPI | ListSharesSMB | Get /sharing/smb | |
SharingAPI | RemoveShareNFS | Delete /sharing/nfs/id/{id} | |
SharingAPI | RemoveShareSMB | Delete /sharing/smb/id/{id} | |
SharingAPI | UpdateShareNFS | Put /sharing/nfs/id/{id} | |
SharingAPI | UpdateShareSMB | Put /sharing/smb/id/{id} | |
UserAPI | CreateUser | Post /user | |
UserAPI | DeleteUser | Delete /user/id/{id} | |
UserAPI | GetUser | Get /user/id/{id} | |
UserAPI | GetUserShellChoices | Post /user/shell_choices | |
UserAPI | ListUsers | Get /user | |
UserAPI | UpdateUser | Put /user/id/{id} | |
VmAPI | GetVM | Get /vm/id/{id} | |
VmAPI | ListVMS | Get /vm |
- CompositeValue
- CreateCronjobParams
- CreateDatasetParams
- CreateDatasetParamsEncryptionOptions
- CreateGroupParams
- CreateISCSIExtentParams
- CreateISCSIInitiatorParams
- CreateISCSITargetExtentParams
- CreateISCSITargetParams
- CreateISCSITargetParamsGroupsInner
- CreateShareNFSParams
- CreateShareSMBParams
- CreateUserParams
- CronJob
- CronJobSchedule
- Dataset
- DeleteGroupParams
- DeleteISCSIExtentParams
- DeleteUserParams
- Group
- ISCSIExtent
- ISCSIGlobalConfiguration
- ISCSIInitiator
- ISCSIPortal
- ISCSIPortalListenInner
- ISCSITarget
- ISCSITargetExtent
- ISCSITargetGroupsInner
- NetworkConfig
- NetworkConfigServiceAnnouncement
- NetworkSummary
- NetworkSummaryIpsValue
- Pool
- Service
- ShareNFS
- ShareSMB
- UpdateDatasetParams
- UpdateUserParams
- User
- UserGroup
- VM
- VMDevicesInner
- VMStatus
Authentication schemes defined for the API:
- Type: HTTP Bearer token authentication
Example
auth := context.WithValue(context.Background(), truenas.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)
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