client

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package client implements a small Airlock Digital REST API client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolInt

func BoolInt(v bool) string

func IntString

func IntString(v int64) string

func Values

func Values(kv ...string) url.Values

Types

type APIError

type APIError struct {
	StatusCode int
	Path       string
	AirlockErr string
}

APIError is returned for non-successful Airlock API calls. Response bodies are not included because they may contain environment data.

func (*APIError) Error

func (e *APIError) Error() string

type Agent added in v0.1.2

type Agent struct {
	AgentID       string `json:"agentid"`
	ClientVersion string `json:"clientversion"`
	Domain        string `json:"domain"`
	FreeSpace     string `json:"freespace"`
	GroupID       string `json:"groupid"`
	Hostname      string `json:"hostname"`
	IP            string `json:"ip"`
	LocalIP       string `json:"localip"`
	LastCheckin   string `json:"lastcheckin"`
	OS            string `json:"os"`
	PolicyVersion string `json:"policyversion"`
	Status        any    `json:"status"`
	Username      string `json:"username"`
}

func (Agent) Named added in v0.1.2

func (a Agent) Named() Named

type Client

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

Client talks to the Airlock Digital REST API.

func New

func New(cfg Config) (*Client, error)

New returns a configured API client.

func (*Client) AddApplicationHash

func (c *Client) AddApplicationHash(ctx context.Context, applicationID string, hashes []string) error

func (*Client) AddBaselineHash

func (c *Client) AddBaselineHash(ctx context.Context, baselineID string, hashes []string) error

func (*Client) AddBlocklistHash

func (c *Client) AddBlocklistHash(ctx context.Context, blocklistID string, hashes []string) error

func (*Client) AddGroupPath

func (c *Client) AddGroupPath(ctx context.Context, groupID, path, comment string) error

func (*Client) AddGroupProcess

func (c *Client) AddGroupProcess(ctx context.Context, groupID, process, typ, comment string) error

func (*Client) AddGroupPublisher

func (c *Client) AddGroupPublisher(ctx context.Context, groupID, publisher, comment string) error

func (*Client) AddRepositoryHashes added in v0.1.0

func (c *Client) AddRepositoryHashes(ctx context.Context, hashes []map[string]string) error

func (*Client) CreateApplication

func (c *Client) CreateApplication(ctx context.Context, name, version, categoryID string) (string, error)

func (*Client) CreateApplicationCategory

func (c *Client) CreateApplicationCategory(ctx context.Context, name, parentID string) (string, error)

func (*Client) CreateApplicationMetarule added in v0.1.0

func (c *Client) CreateApplicationMetarule(ctx context.Context, body map[string]any) (string, error)

func (*Client) CreateBaseline

func (c *Client) CreateBaseline(ctx context.Context, name string) (string, error)

func (*Client) CreateBlocklist

func (c *Client) CreateBlocklist(ctx context.Context, name string) (string, error)

func (*Client) CreateBlocklistMetarule added in v0.1.0

func (c *Client) CreateBlocklistMetarule(ctx context.Context, body map[string]any) (string, error)

func (*Client) CreateGroup

func (c *Client) CreateGroup(ctx context.Context, name, parent string, hidden bool) (string, error)

func (*Client) DeleteApplication

func (c *Client) DeleteApplication(ctx context.Context, id string) error

func (*Client) DeleteApplicationCategory

func (c *Client) DeleteApplicationCategory(ctx context.Context, id string) error

func (*Client) DeleteApplicationMetarule added in v0.1.0

func (c *Client) DeleteApplicationMetarule(ctx context.Context, id string) error

func (*Client) DeleteBaseline

func (c *Client) DeleteBaseline(ctx context.Context, id string) error

func (*Client) DeleteBlocklist

func (c *Client) DeleteBlocklist(ctx context.Context, id string) error

func (*Client) DeleteBlocklistMetarule added in v0.1.0

func (c *Client) DeleteBlocklistMetarule(ctx context.Context, id string) error

func (*Client) DeleteGroup

func (c *Client) DeleteGroup(ctx context.Context, id string) error

func (*Client) ExportApplication added in v0.1.1

func (c *Client) ExportApplication(ctx context.Context, applicationID string) ([]byte, error)

func (*Client) ExportBaseline added in v0.1.1

func (c *Client) ExportBaseline(ctx context.Context, baselineID string) ([]byte, error)

func (*Client) ExportBlocklist added in v0.1.1

func (c *Client) ExportBlocklist(ctx context.Context, blocklistID string) ([]byte, error)

func (*Client) FindAgents added in v0.1.2

func (c *Client) FindAgents(ctx context.Context, params url.Values) ([]Agent, error)

func (*Client) GetAgent added in v0.1.2

func (c *Client) GetAgent(ctx context.Context, agentID string) (Agent, bool, error)

func (*Client) GetGroupPolicy

func (c *Client) GetGroupPolicy(ctx context.Context, groupID string) (*Policy, error)

func (*Client) GetGroupPolicyRaw added in v0.1.0

func (c *Client) GetGroupPolicyRaw(ctx context.Context, groupID string) (map[string]any, error)

func (*Client) ImportReferenceBaseline added in v0.1.0

func (c *Client) ImportReferenceBaseline(ctx context.Context, name string) error

func (*Client) ListAgents

func (c *Client) ListAgents(ctx context.Context) ([]Named, error)

func (*Client) ListApplicationCategories

func (c *Client) ListApplicationCategories(ctx context.Context) ([]Named, error)

func (*Client) ListApplicationMetarules added in v0.1.0

func (c *Client) ListApplicationMetarules(ctx context.Context, applicationID string, includeCriteria bool) ([]Metarule, error)

func (*Client) ListApplications

func (c *Client) ListApplications(ctx context.Context) ([]Named, error)

func (*Client) ListBaselines

func (c *Client) ListBaselines(ctx context.Context) ([]Named, error)

func (*Client) ListBlocklistMetarules added in v0.1.0

func (c *Client) ListBlocklistMetarules(ctx context.Context, blocklistID string, includeCriteria bool) ([]Metarule, error)

func (*Client) ListBlocklists

func (c *Client) ListBlocklists(ctx context.Context) ([]Named, error)

func (*Client) ListCommunicationLists added in v0.1.0

func (c *Client) ListCommunicationLists(ctx context.Context) (json.RawMessage, error)

func (*Client) ListDomainGroups added in v0.1.0

func (c *Client) ListDomainGroups(ctx context.Context) ([]string, error)

func (*Client) ListGroupAgentsRaw added in v0.1.0

func (c *Client) ListGroupAgentsRaw(ctx context.Context, groupID string) (json.RawMessage, error)

func (*Client) ListGroups

func (c *Client) ListGroups(ctx context.Context) ([]Named, error)

func (*Client) ListReferenceBaselines added in v0.1.0

func (c *Client) ListReferenceBaselines(ctx context.Context) ([]Named, error)

func (*Client) MoveAgent added in v0.1.2

func (c *Client) MoveAgent(ctx context.Context, agentID, groupID string) error

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, params url.Values, body any, out any) error

Post sends Airlock's POST-style API request. Parameters are encoded as query parameters unless body is non-nil.

func (*Client) PostRaw added in v0.1.1

func (c *Client) PostRaw(ctx context.Context, path string, params url.Values, body any) ([]byte, error)

PostRaw sends an Airlock POST request and returns the raw response body. Use this for documented non-JSON endpoints such as XML exports.

func (*Client) QueryHashes added in v0.1.0

func (c *Client) QueryHashes(ctx context.Context, hashes []string) ([]HashQueryResult, error)

func (*Client) RemoveApplicationHash

func (c *Client) RemoveApplicationHash(ctx context.Context, applicationID string, hashes []string) error

func (*Client) RemoveBaselineHash

func (c *Client) RemoveBaselineHash(ctx context.Context, baselineID string, hashes []string) error

func (*Client) RemoveBlocklistHash

func (c *Client) RemoveBlocklistHash(ctx context.Context, blocklistID string, hashes []string) error

func (*Client) RemoveGroupPath

func (c *Client) RemoveGroupPath(ctx context.Context, groupID, path string) error

func (*Client) RemoveGroupProcess

func (c *Client) RemoveGroupProcess(ctx context.Context, groupID, process, typ string) error

func (*Client) RemoveGroupPublisher

func (c *Client) RemoveGroupPublisher(ctx context.Context, groupID, publisher string) error

func (*Client) SetGroupApplication

func (c *Client) SetGroupApplication(ctx context.Context, groupID, applicationID string, approved bool) error

func (*Client) SetGroupBaseline

func (c *Client) SetGroupBaseline(ctx context.Context, groupID, baselineID string, approved bool) error

func (*Client) SetGroupBlocklist

func (c *Client) SetGroupBlocklist(ctx context.Context, groupID, blocklistID string, approved bool, audit bool) error

func (*Client) UpdateApplicationMetaruleName added in v0.1.0

func (c *Client) UpdateApplicationMetaruleName(ctx context.Context, id, name string) error

func (*Client) UpdateBlocklistMetaruleName added in v0.1.0

func (c *Client) UpdateBlocklistMetaruleName(ctx context.Context, id, name string) error

func (*Client) UpdateGroupSettings added in v0.1.0

func (c *Client) UpdateGroupSettings(ctx context.Context, settings map[string]any) error

type Config

type Config struct {
	URL       string
	APIKey    string
	Insecure  bool
	UserAgent string
	Timeout   time.Duration
}

Config holds Airlock client configuration.

type HashQueryResult added in v0.1.0

type HashQueryResult struct {
	Hash string `json:"hash"`
	Data struct {
		Applications []application `json:"applications"`
		Baselines    []baseline    `json:"baselines"`
		Blocklists   []blocklist   `json:"blocklists"`
	} `json:"data"`
}

type Metarule added in v0.1.0

type Metarule struct {
	ID       string          `json:"metaruleid"`
	Name     string          `json:"name"`
	OS       string          `json:"os"`
	Criteria json.RawMessage `json:"criteria,omitempty"`
	Settings json.RawMessage `json:"settings,omitempty"`
}

type Named

type Named struct {
	ID    string            `json:"id"`
	Name  string            `json:"name"`
	Attrs map[string]string `json:"attrs,omitempty"`
}

Named is the common list shape used by provider resources and data sources.

func FindByID

func FindByID(items []Named, id string) (Named, bool)

func FindByName

func FindByName(items []Named, name string) (Named, bool)

type Policy

type Policy struct {
	GroupID      string
	Applications []Named
	Baselines    []Named
	Blocklists   []Named
	Paths        []Named
	Processes    []Named
	Publishers   []Named
}

Jump to

Keyboard shortcuts

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