scale

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBaseURL   = "http://localhost/api/v2.0/"
	DefaultUserAgent = "truenas-scale-acme/0.1"
)
View Source
const CertificateCreateImported = "CERTIFICATE_CREATE_IMPORTED"

Variables

View Source
var ErrStatus = errors.New("status code error")

ErrStatus respresents a non success status code error.

Functions

This section is empty.

Types

type Certificate

type Certificate struct {
	ID                 int      `json:"id,omitempty"`
	Type               int      `json:"type,omitempty"`
	Name               string   `json:"name,omitempty"`
	Certificate        string   `json:"certificate,omitempty"`
	Privatekey         string   `json:"privatekey,omitempty"`
	RootPath           string   `json:"root_path,omitempty"`
	CertificatePath    string   `json:"certificate_path,omitempty"`
	PrivatekeyPath     string   `json:"privatekey_path,omitempty"`
	CSRPath            string   `json:"csr_path,omitempty"`
	CertType           string   `json:"cert_type,omitempty"`
	Revoked            bool     `json:"revoked,omitempty"`
	CanBeRevoked       bool     `json:"can_be_revoked,omitempty"`
	Internal           string   `json:"internal,omitempty"`
	CATypeExisting     bool     `json:"CA_type_existing,omitempty"`
	CATypeInternal     bool     `json:"CA_type_internal,omitempty"`
	CATypeIntermediate bool     `json:"CA_type_intermediate,omitempty"`
	CertTypeExisting   bool     `json:"cert_type_existing,omitempty"`
	CertTypeInternal   bool     `json:"cert_type_internal,omitempty"`
	CertTypeCSR        bool     `json:"cert_type_CSR,omitempty"`
	Issuer             string   `json:"issuer,omitempty"`
	ChainList          []string `json:"chain_list,omitempty"`
	KeyLength          int      `json:"key_length,omitempty"`
	KeyType            string   `json:"key_type,omitempty"`
	Country            string   `json:"country,omitempty"`
	State              string   `json:"state,omitempty"`
	City               string   `json:"city,omitempty"`
	Organization       string   `json:"organization,omitempty"`
	Common             string   `json:"common,omitempty"`
	SAN                []string `json:"san,omitempty"`
	Email              string   `json:"email,omitempty"`
	DN                 string   `json:"DN,omitempty"`
	SubjectNameHash    int64    `json:"subject_name_hash,omitempty"`
	DigestAlgorithm    string   `json:"digest_algorithm,omitempty"`
	Lifetime           int      `json:"lifetime,omitempty"`
	From               Time     `json:"from,omitempty"`
	Until              Time     `json:"until,omitempty"`
	Serial             *big.Int `json:"serial,omitempty"`
	Chain              bool     `json:"chain,omitempty"`
	Fingerprint        string   `json:"fingerprint,omitempty"`
	Expired            bool     `json:"expired,omitempty"`
	Parsed             bool     `json:"parsed,omitempty"`
}

func (*Certificate) TLSCertificate

func (c *Certificate) TLSCertificate() (tls.Certificate, error)

type CertificateCreate

type CertificateCreate string

type CertificateImport

type CertificateImport struct {
	Name        string            `json:"name"`
	CreateType  CertificateCreate `json:"create_type"`
	Certificate string            `json:"certificate"`
	Privatekey  string            `json:"privatekey"`
}

type Client

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

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new API client for TrueNAS Scale.

func (*Client) Certificate

func (c *Client) Certificate(ctx context.Context, id int) (*Certificate, error)

Certificates returns a list of certificates.

func (*Client) CertificateDelete

func (c *Client) CertificateDelete(ctx context.Context, id int) error

CertificateDelete deletes a certificate.

func (*Client) CertificateImport

func (c *Client) CertificateImport(ctx context.Context, name string, cert tls.Certificate) (*Certificate, error)

CertificateImport imports a certificate.

func (*Client) Certificates

func (c *Client) Certificates(ctx context.Context) ([]Certificate, error)

Certificates returns a list of certificates.

func (*Client) CoreGetJob

func (c *Client) CoreGetJob(ctx context.Context, id int) (*Job, error)

CoreGetJob returns a Job.

func (*Client) CoreGetJobs

func (c *Client) CoreGetJobs(ctx context.Context, params JobsParams) ([]Job, error)

CoreGetJobs returns a list of Jobs.

func (*Client) CoreJobWait

func (c *Client) CoreJobWait(ctx context.Context, id int) (*Job, error)

CoreJobWait waits for a job to finish.

func (*Client) SystemGeneral

func (c *Client) SystemGeneral(ctx context.Context) (*SystemGeneral, error)

SystemGeneral returns general system config.

func (*Client) SystemGeneralCheckIn

func (c *Client) SystemGeneralCheckIn(ctx context.Context) error

func (*Client) SystemGeneralUpdate

func (c *Client) SystemGeneralUpdate(ctx context.Context, params SystemGeneralUpdateParams) error

SystemGeneralUpdate updates general system config.

type Date

type Date struct {
	Date Timestamp `json:"$date,omitempty"`
}

type Job

type Job struct {
	ID           int      `json:"id,omitempty"`
	Method       string   `json:"method,omitempty"`
	Transient    bool     `json:"transient,omitempty"`
	Abortable    bool     `json:"abortable,omitempty"`
	LogsPath     any      `json:"logs_path,omitempty"`
	LogsExcerpt  any      `json:"logs_excerpt,omitempty"`
	Progress     Progress `json:"progress,omitempty"`
	Result       any      `json:"result,omitempty"`
	Error        string   `json:"error,omitempty"`
	Exception    string   `json:"exception,omitempty"`
	State        string   `json:"state,omitempty"`
	TimeStarted  Date     `json:"time_started,omitempty"`
	TimeFinished Date     `json:"time_finished,omitempty"`
}

type JobsParams

type JobsParams struct {
	ID    int `url:"id,omitempty"`
	Limit int `url:"limit,omitempty"`
}

type Option

type Option func(*Client)

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey defines the API key to be used.

func WithBaseURL

func WithBaseURL(u *url.URL) Option

WithBaseURL defines the API's base url.

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient allows to replace the http client.

func WithUserAgent

func WithUserAgent(userAgent string) Option

WithUserAgent allows to change the user agent.

type Progress

type Progress struct {
	Percent     uint8  `json:"percent,omitempty"`
	Description string `json:"description,omitempty"`
	Extra       any    `json:"extra,omitempty"`
}

type SystemGeneral

type SystemGeneral struct {
	ID                   int         `json:"id,omitempty"`
	Language             string      `json:"language,omitempty"`
	KDBMap               string      `json:"kbdmap,omitempty"`
	Birthday             Date        `json:"birthday,omitempty"`
	Timezone             string      `json:"timezone,omitempty"`
	Wizardshown          bool        `json:"wizardshown,omitempty"`
	CrashReporting       bool        `json:"crash_reporting,omitempty"`
	UsageCollection      bool        `json:"usage_collection,omitempty"`
	DSAuth               bool        `json:"ds_auth,omitempty"`
	UIAddress            []string    `json:"ui_address,omitempty"`
	UIV6Address          []string    `json:"ui_v6address,omitempty"`
	UIAllowlist          []any       `json:"ui_allowlist,omitempty"`
	UIPort               int         `json:"ui_port,omitempty"`
	UIHttpsport          int         `json:"ui_httpsport,omitempty"`
	UIHttpsredirect      bool        `json:"ui_httpsredirect,omitempty"`
	UIHttpsprotocols     []string    `json:"ui_httpsprotocols,omitempty"`
	UIXFrameOptions      string      `json:"ui_x_frame_options,omitempty"`
	UIConsolemsg         bool        `json:"ui_consolemsg,omitempty"`
	UICertificate        Certificate `json:"ui_certificate,omitempty"`
	CrashReportingIsSet  bool        `json:"crash_reporting_is_set,omitempty"`
	UsageCollectionIsSet bool        `json:"usage_collection_is_set,omitempty"`
}

type SystemGeneralUpdateParams

type SystemGeneralUpdateParams struct {
	UICertificate   int `json:"ui_certificate,omitempty"`
	UIRestartDelay  int `json:"ui_restart_delay,omitempty"`
	RollbackTimeout int `json:"rollback_timeout,omitempty"`
}

type Time

type Time struct {
	time.Time
}

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

type Timestamp

type Timestamp struct {
	time.Time
}

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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