Documentation ¶
Index ¶
- func Bool(v bool) *bool
- func CheckResponse(r *http.Response) error
- func DoRequest(ctx context.Context, req *http.Request) (*http.Response, error)
- func DoRequestWithClient(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)
- func Int(v int) *int
- func StreamToString(stream io.Reader) string
- func String(v string) *string
- type Client
- type ClientOpt
- type Config
- type ErrorResponse
- type ListOptions
- type PoolDataset
- type PoolDatasetCreate
- type PoolDatasets
- type PoolDatasetsOp
- func (s *PoolDatasetsOp) Create(ctx context.Context, body PoolDatasetCreate) (*PoolDataset, *http.Response, error)
- func (s *PoolDatasetsOp) Delete(ctx context.Context, id string) (*http.Response, error)
- func (s *PoolDatasetsOp) Get(ctx context.Context, id string) (*PoolDataset, *http.Response, error)
- func (s *PoolDatasetsOp) List(ctx context.Context, opt *ListOptions) (*[]PoolDataset, *http.Response, error)
- type RequestCompletionCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
func DoRequestWithClient ¶
func DoRequestWithClient( ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)
DoRequestWithClient submits an HTTP request using the specified client.
func Int ¶
Int is a helper routine that allocates a new int32 value to store v and returns a pointer to it, but unlike Int32 its argument value is an int.
func StreamToString ¶
StreamToString converts a reader to a string
Types ¶
type Client ¶
type Client struct { // Config for the client such as the TrueNAS hostname and credentials Config *Config // Base URL for API requests. BaseURL *url.URL // User agent for client UserAgent string // Services used for communicating with the API PoolDatasets PoolDatasets // contains filtered or unexported fields }
Client manages communication with TrueNAS V2 API.
func NewClient ¶
NewClient returns a new TrueNAS API client, using the given http.Client to perform all requests.
Users who wish to pass their own http.Client should use this method. If you're in need of further customization, the gotruenas.New method allows more options, such as setting a custom URL or a custom user agent string.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error)
NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included in as the request body.
func (*Client) OnRequestCompleted ¶
func (c *Client) OnRequestCompleted(rc RequestCompletionCallback)
OnRequestCompleted sets the TrueNAS API request completion callback
type ClientOpt ¶
ClientOpt are options for New.
func SetBaseURL ¶
SetBaseURL is a client option for setting the base URL.
func SetRequestHeaders ¶
SetRequestHeaders sets optional HTTP headers on the client that are sent on each HTTP request.
func SetUserAgent ¶
SetUserAgent is a client option for setting the user agent.
type ErrorResponse ¶
type ErrorResponse struct { // HTTP response that caused this error Response *http.Response // Error message Message string `json:"message"` // RequestID returned from the API, useful to contact support. RequestID string `json:"request_id"` }
An ErrorResponse reports the error caused by an API request
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type ListOptions ¶
type ListOptions struct { Count bool `url:"count,omitempty"` Limit int `url:"limit,omitempty"` Offset int `url:"offset,omitempty"` Sort string `url:"count,omitempty"` }
ListOptions specifies the optional parameters to various List methods that support pagination.
type PoolDataset ¶
type PoolDataset struct { ID *string `json:"id"` Type *string `json:"type"` Children *[]PoolDataset `json:"children"` Name *string `json:"name"` Pool *string `json:"pool"` Encryption *bool `json:"encryption"` EncryptionRoot *bool `json:"encryption_root"` KeyLoaded *bool `json:"key_loaded"` Mountpoint *string `json:"mountpoint"` Deduplication *value `json:"deduplication"` ACLMode *value `json:"aclmode"` ACLType *value `json:"acltype"` Xattr *value `json:"xattr"` Atime *value `json:"atime"` CaseSensitivity *value `json:"casesensitivity"` Exec *value `json:"exec"` Sync *value `json:"sync"` Compression *value `json:"compression"` CompressRatio *value `json:"compressratio"` Origin *value `json:"origin"` Quota *value `json:"quota"` RefQuota *value `json:"refquota"` Reservation *value `json:"reservation"` RefReservation *value `json:"refreservation"` Copies *value `json:"copies"` SnapDir *value `json:"snapdir"` ReadOnly *value `json:"readonly"` RecordSize *value `json:"recordsize"` KeyFormat *value `json:"key_format"` EncryptionAlgorithm *value `json:"encryption_algorithm"` Used *value `json:"used"` Available *value `json:"available"` SpecialSmallBlockSize *value `json:"special_small_block_size"` Pbkdf2iters *value `json:"pbkdf2iters"` Locked *bool `json:"locked"` }
PoolDataset defines model for a pool dataset.
type PoolDatasetCreate ¶
type PoolDatasetCreate struct { Name *string `json:"name"` Type *string `json:"type"` VolSize *int `json:"volsize,omitempty"` VolBlockSize *int `json:"volblocksize,omitempty"` Sparse *bool `json:"sparse,omitempty"` ForceSize *bool `json:"force_size,omitempty"` Comments *string `json:"comments,omitempty"` Sync *string `json:"sync,omitempty"` Compression *string `json:"compression,omitempty"` ATime *string `json:"atime,omitempty"` Exec *string `json:"exec,omitempty"` ManagedBy *string `json:"managedby,omitempty"` Quota *int `json:"quota,omitempty"` QuotaWarning *int `json:"quota_warning,omitempty"` QuotaCritical *int `json:"quota_critical,omitempty"` RefQuota *int `json:"refquota,omitempty"` RefQuotaWarning *int `json:"refquota_warning,omitempty"` RefquotaCritical *int `json:"refquota_critical,omitempty"` Reservation *int `json:"reservation,omitempty"` RefReservation *int `json:"refreservation,omitempty"` SpecialSmallBlockSize *int `json:"special_small_block_size,omitempty"` Copies *int `json:"copies,omitempty"` SnapDir *string `json:"snapdir,omitempty"` Deduplication *string `json:"deduplication,omitempty"` ReadOnly *string `json:"readonly,omitempty"` RecordSize *string `json:"recordsize,omitempty"` CaseSensitivity *string `json:"casesensitivity,omitempty"` ACLMode *string `json:"aclmode,omitempty"` ACLType *string `json:"acltype,omitempty"` Xattr *string `json:"xattr,omitempty"` Encryption *bool `json:"encryption,omitempty"` InheritEncryption *bool `json:"inherit_encryption,omitempty"` EncryptionOptions struct { GenerateKey *bool `json:"generate_key,omitempty"` Pbkdf2iters *int `json:"pbkdf2iters,omitempty"` Algorithm *string `json:"algorithm,omitempty"` Passphrase *string `json:"passphrase,omitempty"` Key *string `json:"key,omitempty"` } `json:"encryption_options,omitempty"` }
PoolDatasetCreate defines model for creating a pool dataset.
type PoolDatasets ¶
type PoolDatasets interface { Create(ctx context.Context, body PoolDatasetCreate) (*PoolDataset, *http.Response, error) Delete(ctx context.Context, id string) (*http.Response, error) Get(ctx context.Context, id string) (*PoolDataset, *http.Response, error) List(ctx context.Context, opt *ListOptions) (*[]PoolDataset, *http.Response, error) }
PoolDatasets is an interface for interacting with Pool Datasets
type PoolDatasetsOp ¶
type PoolDatasetsOp struct {
// contains filtered or unexported fields
}
PoolDatasetsOp handles communication with the Pool Dataset related methods of the TrueNAS REST API
func (*PoolDatasetsOp) Create ¶
func (s *PoolDatasetsOp) Create(ctx context.Context, body PoolDatasetCreate) (*PoolDataset, *http.Response, error)
Create a new activation key
func (*PoolDatasetsOp) Get ¶
func (s *PoolDatasetsOp) Get(ctx context.Context, id string) (*PoolDataset, *http.Response, error)
Get a single pool dataset by its ID
func (*PoolDatasetsOp) List ¶
func (s *PoolDatasetsOp) List(ctx context.Context, opt *ListOptions) (*[]PoolDataset, *http.Response, error)
List all activation keys or a filtered list of activation keys