api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultURL      = "https://api.central.sophos.com"
	AuthTokenURL    = "https://id.sophos.com/api/v2/oauth2/token" //nolint:gosec
	DefaultTimeout  = 5
	DefaultPageSize = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	ID string `json:"id"`
	// Alert categories.
	//
	// The following values are allowed:
	// azure, adSync, applicationControl, appReputation, blockListed, connectivity, cwg, denc, downloadReputation,
	// endpointFirewall, fenc, forensicSnapshot, general, iaas, iaasAzure, isolation, malware, mtr, mobiles, policy,
	// protection, pua, runtimeDetections, security, smc, systemHealth, uav, uncategorized, updating, utm, virt,
	// wireless, xgEmail
	Category     string            `json:"category"`
	Description  string            `json:"description"`
	GroupKey     string            `json:"groupKey"`
	ManagedAgent AlertManagedAgent `json:"managedAgent"`
	// Product types.
	//
	// The following values are allowed:
	// other, endpoint, server, mobile, encryption, emailGateway, webGateway, phishThreat, wireless, iaas, firewall
	Product string `json:"product"`
	// When the alert was triggered.
	RaisedAt time.Time `json:"raisedAt"`
	// Severity levels for alerts.
	//
	// The following values are allowed:
	// high, medium, low
	Severity string `json:"severity"`
	// Alert type.
	Type string `json:"type"`
}

func (*Alert) String added in v0.3.0

func (a *Alert) String() string

type AlertManagedAgent added in v0.2.0

type AlertManagedAgent struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

type Client

type Client struct {
	AuthConfig *clientcredentials.Config
	HttpClient *http.Client
	BaseURL    string
	DataURL    string
	UserInfo   *UserInfo
	TenantID   string
	PageSize   uint32
}

func NewClient

func NewClient(id, secret string) (c *Client)

func (*Client) Do added in v0.2.0

func (c *Client) Do(req *http.Request) (res *http.Response, err error)

func (*Client) GetAlerts

func (c *Client) GetAlerts() (alerts []*Alert, err error)

func (*Client) GetEndpoints

func (c *Client) GetEndpoints() (endpoints []*Endpoint, err error)

func (*Client) GetResults

func (c *Client) GetResults(request *http.Request) (items []json.RawMessage, err error)

nolint: funlen

func (*Client) NewDataRequest

func (c *Client) NewDataRequest(method, url string, body io.Reader) (req *http.Request, err error)

func (*Client) NewRequest added in v0.2.0

func (c *Client) NewRequest(method, url string, body io.Reader) (req *http.Request, err error)

func (*Client) WhoAmI

func (c *Client) WhoAmI() (err error)

type Endpoint

type Endpoint struct {
	// The hostname of the endpoint.
	Hostname string `json:"hostname"`
	// The unique ID for the endpoint.
	ID string `json:"id"`
	// Products assigned to the endpoint.
	AssignedProducts []json.RawMessage `json:"assignedProducts"`
	// The health status of the endpoint.
	Health EndpointHealth `json:"health"`
	// The endpoint type.
	//
	// The following values are allowed:
	// computer, server, securityVm
	Type string `json:"type"`
}

func (*Endpoint) String added in v0.3.0

func (e *Endpoint) String() string

type EndpointHealth

type EndpointHealth struct {
	// Health status of the endpoint or a service running on the endpoint.
	//
	// The following values are allowed:
	// good, suspicious, bad, unknown
	Overall string `json:"overall"`
	// Status of services on the endpoint.
	Services json.RawMessage `json:"services"`
	// Threats on the endpoint.
	Threats json.RawMessage `json:"threats"`
}

type LoggingRoundTripper added in v0.2.0

type LoggingRoundTripper struct {
	Base http.RoundTripper
}

func (LoggingRoundTripper) RoundTrip added in v0.2.0

func (r LoggingRoundTripper) RoundTrip(req *http.Request) (res *http.Response, err error)

type PageInfo

type PageInfo struct {
	// The key of the first item in the returned page.
	FromKey string `json:"fromKey"`
	// (Optional) The total number of items on all the pages, if pageTotal=true was passed into the request.
	Items int `json:"items"`
	// The maximum page size that can be requested.
	MaxSize int `json:"maxSize"`
	// The key to use when fetching the next page.
	NextKey string `json:"nextKey"`
	// The size of the page being returned.
	Size int `json:"size"`
	// (Optional) The total number of pages that exist, if pageTotal=true in the request.
	Total int `json:"total"`
}

type ResponseBody

type ResponseBody struct {
	Items []json.RawMessage `json:"items"`
	Pages PageInfo          `json:"pages"`
}

type UserInfo

type UserInfo struct {
	ID       string            `json:"id"`
	IDType   string            `json:"idType"`
	ApiHosts map[string]string `json:"apiHosts"`
}

Jump to

Keyboard shortcuts

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