censys

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	GlobalDataClient
	CollectionsClient
	ThreatHuntingClient
	HasOrgID() bool
}

func NewCensysSDK

func NewCensysSDK(
	ctx context.Context,
	ds store.Store,
	httpRequestTimeout time.Duration,
	retryStrategy config.RetryStrategy,
) (Client, error)

type ClientError

type ClientError interface {
	cenclierrors.CencliError
	Status() string
	StatusCode() mo.Option[int64]
}

func NewClientError

func NewClientError(err error) ClientError

type ClientGenericError

type ClientGenericError interface {
	ClientError
}

func NewCensysClientGenericError

func NewCensysClientGenericError(err *sdkerrors.SDKError) ClientGenericError

type ClientNotConfiguredError

type ClientNotConfiguredError interface {
	cenclierrors.CencliError
}

CensysClientNotConfiguredError isn't really a client error, since it will be used before an API call is made.

func NewCensysClientNotConfiguredError

func NewCensysClientNotConfiguredError() ClientNotConfiguredError

type ClientStructuredError

type ClientStructuredError interface {
	ClientError
}

func NewCensysClientStructuredError

func NewCensysClientStructuredError(err *sdkerrors.ErrorModel) ClientStructuredError

type ClientUnauthorizedError

type ClientUnauthorizedError interface {
	ClientError
}

type CollectionsClient

type CollectionsClient interface {
	// https://github.com/censys/censys-sdk-go/tree/main/docs/sdks/collections#search
	SearchCollection(
		ctx context.Context,
		collectionID string,
		orgID mo.Option[string],
		query string,
		fields []string,
		pageSize mo.Option[int64],
		pageToken mo.Option[string],
	) (Result[components.SearchQueryResponse], ClientError)
	// https://github.com/censys/censys-sdk-go/tree/main/docs/sdks/collections#aggregate
	AggregateCollection(
		ctx context.Context,
		collectionID string,
		orgID mo.Option[string],
		query string,
		field string,
		numBuckets int64,
		countByLevel mo.Option[string],
		filterByQuery mo.Option[bool],
	) (Result[components.SearchAggregateResponse], ClientError)
}

type GlobalDataClient

type GlobalDataClient interface {
	// https://github.com/censys/censys-sdk-go/tree/main/docs/sdks/globaldata#gethosts
	GetHosts(
		ctx context.Context,
		orgID mo.Option[string],
		hostIDs []string,
		atTime mo.Option[time.Time],
	) (Result[[]components.Host], ClientError)
	// https://github.com/censys/censys-sdk-go/tree/main/docs/sdks/globaldata#getcertificates
	GetCertificates(
		ctx context.Context,
		orgID mo.Option[string],
		certificateIDs []string,
	) (Result[[]components.Certificate], ClientError)
	// https://github.com/censys/censys-sdk-go/tree/main/docs/sdks/globaldata#getwebproperties
	GetWebProperties(
		ctx context.Context,
		orgID mo.Option[string],
		webPropertyIDs []string,
		atTime mo.Option[time.Time],
	) (Result[[]components.Webproperty], ClientError)
	// https://github.com/censys/censys-sdk-go/tree/main/docs/sdks/globaldata#search
	Search(
		ctx context.Context,
		orgID mo.Option[string],
		query string,
		fields []string,
		pageSize mo.Option[int64],
		pageToken mo.Option[string],
	) (Result[components.SearchQueryResponse], ClientError)
	// https://github.com/censys/censys-sdk-go/tree/main/docs/sdks/globaldata#aggregate
	Aggregate(
		ctx context.Context,
		orgID mo.Option[string],
		query string,
		field string,
		numBuckets int64,
		countByLevel mo.Option[string],
		filterByQuery mo.Option[bool],
	) (Result[components.SearchAggregateResponse], ClientError)
	// https://github.com/censys/censys-sdk-go/blob/v0.22.2/models/operations/v3globaldataassethosttimeline.go
	// Note: the SDK client has the parameters backwards; fromTime is the end time and toTime is the start time. This is a mistake, but we need to keep it to not break existing API usage, so we abstract this miscommunication through this function's parameters.
	HostTimeline(
		ctx context.Context,
		orgID mo.Option[string],
		hostID string,
		fromTime time.Time,
		toTime time.Time,
	) (Result[components.HostTimeline], ClientError)
}

type Metadata

type Metadata struct {
	Request  *http.Request
	Response *http.Response
	Latency  time.Duration
	Attempts uint64
}

type Result

type Result[T any] struct {
	Metadata Metadata
	Data     *T
}

Jump to

Keyboard shortcuts

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